author | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
---|---|---|
committer | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
commit | 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (unidiff) | |
tree | 96e66fdc18dca4d4ab8611133e072f57dea224b9 /noncore/apps | |
parent | 279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff) | |
download | opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.zip opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.gz opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.bz2 |
new opie-reader sources with support for ArriereGo, Reb input and flite output plugins
94 files changed, 4999 insertions, 1437 deletions
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp index 353996c..37dcc99 100644 --- a/noncore/apps/opie-reader/Aportis.cpp +++ b/noncore/apps/opie-reader/Aportis.cpp | |||
@@ -45,24 +45,25 @@ CList<Bkmk>* Aportis::getbkmklist() | |||
45 | t->push_back(Bkmk(tname, NULL, lcn)); | 45 | t->push_back(Bkmk(tname, NULL, lcn)); |
46 | } | 46 | } |
47 | return t; | 47 | return t; |
48 | } | 48 | } |
49 | else | 49 | else |
50 | { | 50 | { |
51 | return NULL; | 51 | return NULL; |
52 | } | 52 | } |
53 | } | 53 | } |
54 | */ | 54 | */ |
55 | if (bCompressed != 4) return NULL; | 55 | if (bCompressed != 4) return NULL; |
56 | CList<Bkmk>* t = new CList<Bkmk>; | 56 | CList<Bkmk>* t = new CList<Bkmk>; |
57 | unsuspend(); | ||
57 | size_t cur = ftell(fin); | 58 | size_t cur = ftell(fin); |
58 | for (int i = 0; i < nRecs2; i++) | 59 | for (int i = 0; i < nRecs2; i++) |
59 | { | 60 | { |
60 | DWORD dwPos; | 61 | DWORD dwPos; |
61 | fseek(fin, 0x56 + 8*i, SEEK_SET); | 62 | fseek(fin, 0x56 + 8*i, SEEK_SET); |
62 | fread(&dwPos, 4, 1, fin); | 63 | fread(&dwPos, 4, 1, fin); |
63 | dwPos = SwapLong(dwPos); | 64 | dwPos = SwapLong(dwPos); |
64 | fseek(fin,dwPos,SEEK_SET); | 65 | fseek(fin,dwPos,SEEK_SET); |
65 | unsigned char ch; | 66 | unsigned char ch; |
66 | fread(&ch,1,1,fin); | 67 | fread(&ch,1,1,fin); |
67 | if (ch != 241) | 68 | if (ch != 241) |
68 | { | 69 | { |
@@ -237,41 +238,43 @@ int Aportis::OpenFile(const char *src) | |||
237 | 238 | ||
238 | qDebug("Number of records:[%u,%u]", nRecs, nRecs2); | 239 | qDebug("Number of records:[%u,%u]", nRecs, nRecs2); |
239 | return ret; | 240 | return ret; |
240 | } | 241 | } |
241 | 242 | ||
242 | int Aportis::getch() | 243 | int Aportis::getch() |
243 | { | 244 | { |
244 | if (bCompressed == 1) | 245 | if (bCompressed == 1) |
245 | { | 246 | { |
246 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; | 247 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; |
247 | else | 248 | else |
248 | { | 249 | { |
250 | unsuspend(); | ||
249 | int c = getc(fin); | 251 | int c = getc(fin); |
250 | dePeanut(c); | 252 | dePeanut(c); |
251 | dwRecLen--; | 253 | dwRecLen--; |
252 | currentpos++; | 254 | currentpos++; |
253 | return c; | 255 | return c; |
254 | } | 256 | } |
255 | } | 257 | } |
256 | if (outptr != cbptr) | 258 | if (outptr != cbptr) |
257 | { | 259 | { |
258 | currentpos++; | 260 | currentpos++; |
259 | return (circbuf[outptr = (outptr + 1) % 2048]); | 261 | return (circbuf[outptr = (outptr + 1) % 2048]); |
260 | } | 262 | } |
261 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; | 263 | if ((dwRecLen == 0) && !refreshbuffer()) return EOF; |
262 | currentpos++; | 264 | currentpos++; |
263 | int c; | 265 | int c; |
264 | 266 | ||
265 | // take a char from the input buffer | 267 | // take a char from the input buffer |
268 | unsuspend(); | ||
266 | c = getc(fin); | 269 | c = getc(fin); |
267 | dePeanut(c); | 270 | dePeanut(c); |
268 | dwRecLen--; | 271 | dwRecLen--; |
269 | // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF | 272 | // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF |
270 | 273 | ||
271 | // codes 1...8 mean copy that many chars; for accented chars & binary | 274 | // codes 1...8 mean copy that many chars; for accented chars & binary |
272 | if (c == 0) | 275 | if (c == 0) |
273 | { | 276 | { |
274 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; | 277 | circbuf[outptr = cbptr = (cbptr+1)%2048] = c; |
275 | return c; | 278 | return c; |
276 | } | 279 | } |
277 | else if (c >= 0x09 && c <= 0x7F) | 280 | else if (c >= 0x09 && c <= 0x7F) |
@@ -311,47 +314,48 @@ int Aportis::getch() | |||
311 | else if (c >= 0xC0 && c <= 0xFF) | 314 | else if (c >= 0xC0 && c <= 0xFF) |
312 | { | 315 | { |
313 | circbuf[cbptr = (cbptr+1)%2048] = ' '; | 316 | circbuf[cbptr = (cbptr+1)%2048] = ' '; |
314 | circbuf[cbptr = (cbptr+1)%2048] = c^0x80; | 317 | circbuf[cbptr = (cbptr+1)%2048] = c^0x80; |
315 | return circbuf[outptr = (outptr+1)%2048]; | 318 | return circbuf[outptr = (outptr+1)%2048]; |
316 | } | 319 | } |
317 | } | 320 | } |
318 | 321 | ||
319 | unsigned int Aportis::GetBS(unsigned int bn) | 322 | unsigned int Aportis::GetBS(unsigned int bn) |
320 | { | 323 | { |
321 | DWORD dwPos; | 324 | DWORD dwPos; |
322 | WORD fs; | 325 | WORD fs; |
323 | 326 | unsuspend(); | |
324 | fseek(fin, 0x56 + 8*bn, SEEK_SET); | 327 | fseek(fin, 0x56 + 8*bn, SEEK_SET); |
325 | fread(&dwPos, 4, 1, fin); | 328 | fread(&dwPos, 4, 1, fin); |
326 | dwPos = SwapLong(dwPos); | 329 | dwPos = SwapLong(dwPos); |
327 | fseek(fin,dwPos,SEEK_SET); | 330 | fseek(fin,dwPos,SEEK_SET); |
328 | 331 | ||
329 | // gotorecordnumber(bn+1); | 332 | // gotorecordnumber(bn+1); |
330 | unsigned char ch; | 333 | unsigned char ch; |
331 | fread(&ch,1,1,fin); | 334 | fread(&ch,1,1,fin); |
332 | if (ch == 241) | 335 | if (ch == 241) |
333 | { | 336 | { |
334 | fread(&fs,sizeof(fs),1,fin); | 337 | fread(&fs,sizeof(fs),1,fin); |
335 | fs = SwapWord(fs); | 338 | fs = SwapWord(fs); |
336 | } | 339 | } |
337 | else | 340 | else |
338 | fs = 0; | 341 | fs = 0; |
339 | return fs; | 342 | return fs; |
340 | } | 343 | } |
341 | 344 | ||
342 | unsigned int Aportis::locate() | 345 | unsigned int Aportis::locate() |
343 | { | 346 | { |
344 | if (bCompressed == 4) | 347 | if (bCompressed == 4) |
345 | { | 348 | { |
349 | unsuspend(); | ||
346 | size_t cur = ftell(fin); | 350 | size_t cur = ftell(fin); |
347 | unsigned int clen = 0; | 351 | unsigned int clen = 0; |
348 | for (unsigned int i = 0; i < currentrec-1; i++) | 352 | for (unsigned int i = 0; i < currentrec-1; i++) |
349 | { | 353 | { |
350 | unsigned int bs = GetBS(i); | 354 | unsigned int bs = GetBS(i); |
351 | if (bs == 0) break; | 355 | if (bs == 0) break; |
352 | clen += bs; | 356 | clen += bs; |
353 | } | 357 | } |
354 | fseek(fin,cur,SEEK_SET); | 358 | fseek(fin,cur,SEEK_SET); |
355 | return clen+currentpos; | 359 | return clen+currentpos; |
356 | } | 360 | } |
357 | else | 361 | else |
@@ -392,24 +396,25 @@ void Aportis::locate(unsigned int n) | |||
392 | while (currentpos < offset && getch() != EOF); | 396 | while (currentpos < offset && getch() != EOF); |
393 | } | 397 | } |
394 | 398 | ||
395 | bool Aportis::refreshbuffer() | 399 | bool Aportis::refreshbuffer() |
396 | { | 400 | { |
397 | if (currentrec < nRecs) | 401 | if (currentrec < nRecs) |
398 | { | 402 | { |
399 | dwRecLen = recordlength(currentrec+1); | 403 | dwRecLen = recordlength(currentrec+1); |
400 | gotorecordnumber(currentrec+1); | 404 | gotorecordnumber(currentrec+1); |
401 | if (bCompressed == 4) | 405 | if (bCompressed == 4) |
402 | { | 406 | { |
403 | unsigned char t[3]; | 407 | unsigned char t[3]; |
408 | unsuspend(); | ||
404 | fread(t,1,3,fin); | 409 | fread(t,1,3,fin); |
405 | if (t[0] != 241) | 410 | if (t[0] != 241) |
406 | { | 411 | { |
407 | printf("You shouldn't be here!\n"); | 412 | printf("You shouldn't be here!\n"); |
408 | return false; | 413 | return false; |
409 | } | 414 | } |
410 | dwRecLen -= 3; | 415 | dwRecLen -= 3; |
411 | } | 416 | } |
412 | /* | 417 | /* |
413 | int n = fread(t.buf, 1, dwRecLen, fin); | 418 | int n = fread(t.buf, 1, dwRecLen, fin); |
414 | t.len = n; | 419 | t.len = n; |
415 | // if(bCompressed) | 420 | // if(bCompressed) |
@@ -421,24 +426,25 @@ bool Aportis::refreshbuffer() | |||
421 | currentrec++; | 426 | currentrec++; |
422 | return true; | 427 | return true; |
423 | } | 428 | } |
424 | else { | 429 | else { |
425 | return false; | 430 | return false; |
426 | } | 431 | } |
427 | } | 432 | } |
428 | 433 | ||
429 | #include <qimage.h> | 434 | #include <qimage.h> |
430 | 435 | ||
431 | QImage* Aportis::getPicture(unsigned long tgt) | 436 | QImage* Aportis::getPicture(unsigned long tgt) |
432 | { | 437 | { |
438 | unsuspend(); | ||
433 | unsigned short tgtrec = tgt+mobiimagerec; | 439 | unsigned short tgtrec = tgt+mobiimagerec; |
434 | if (tgtrec > nRecs2) return NULL; | 440 | if (tgtrec > nRecs2) return NULL; |
435 | size_t cur = ftell(fin); | 441 | size_t cur = ftell(fin); |
436 | unsigned short reclen = recordlength(tgtrec); | 442 | unsigned short reclen = recordlength(tgtrec); |
437 | gotorecordnumber(tgtrec); | 443 | gotorecordnumber(tgtrec); |
438 | UInt8* imgbuffer = new UInt8[reclen]; | 444 | UInt8* imgbuffer = new UInt8[reclen]; |
439 | fread(imgbuffer, 1, reclen, fin); | 445 | fread(imgbuffer, 1, reclen, fin); |
440 | QByteArray arr; | 446 | QByteArray arr; |
441 | arr.assign((const char*)imgbuffer, reclen); | 447 | arr.assign((const char*)imgbuffer, reclen); |
442 | 448 | ||
443 | QImage* qimage = new QImage(arr); | 449 | QImage* qimage = new QImage(arr); |
444 | fseek(fin, cur, SEEK_SET); | 450 | fseek(fin, cur, SEEK_SET); |
diff --git a/noncore/apps/opie-reader/ArriereCodec/.cvsignore b/noncore/apps/opie-reader/ArriereCodec/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/ArriereCodec/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/ArriereCodec/ArriereCodec.pro b/noncore/apps/opie-reader/ArriereCodec/ArriereCodec.pro new file mode 100644 index 0000000..8d820d6 --- a/dev/null +++ b/noncore/apps/opie-reader/ArriereCodec/ArriereCodec.pro | |||
@@ -0,0 +1,16 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = arrierego.h | ||
6 | |||
7 | SOURCES = arrierego.cpp | ||
8 | |||
9 | INTERFACES= | ||
10 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | ||
11 | TARGET = ArriereGo | ||
12 | LIBS += -L$(OPIEDIR)/lib -lreader_pdb -lreader_pluckerbase -lreader_codec | ||
13 | |||
14 | INCLUDEPATH+= $(OPIEDIR)/include | ||
15 | DEPENDPATH += $(OPIEDIR)/include | ||
16 | DEFINES += USENEF | ||
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp index 1f0a524..355d14d 100644 --- a/noncore/apps/opie-reader/BuffDoc.cpp +++ b/noncore/apps/opie-reader/BuffDoc.cpp | |||
@@ -1,35 +1,35 @@ | |||
1 | #include "names.h" | 1 | #include "names.h" |
2 | 2 | ||
3 | #define NEWLINEBREAK | 3 | #define NEWLINEBREAK |
4 | #define INCREMENTALWIDTH | 4 | #define INCREMENTALWIDTH |
5 | 5 | ||
6 | #include "usenef.h" | ||
7 | #include "BuffDoc.h" | 6 | #include "BuffDoc.h" |
8 | #include "config.h" | 7 | #include "config.h" |
9 | #include "CDrawBuffer.h" | 8 | #include "CDrawBuffer.h" |
10 | #include "ZText.h" | 9 | #include "ZText.h" |
11 | #include "ebookcodec.h" | 10 | #include "ebookcodec.h" |
12 | 11 | ||
13 | #ifdef __STATIC | 12 | #ifdef __STATIC |
14 | #include "Aportis.h" | 13 | #include "Aportis.h" |
15 | #include "CHM.h" | 14 | #include "CHM.h" |
16 | #include "ppm_expander.h" | 15 | #include "ppm_expander.h" |
17 | #include "ztxt.h" | 16 | #include "ztxt.h" |
18 | #include "plucker.h" | 17 | #include "plucker.h" |
19 | #ifdef USENEF | 18 | #ifdef USENEF |
20 | #include "nef.h" | 19 | #include "nef.h" |
21 | #include "arrierego.h" | 20 | #include "arrierego.h" |
22 | #endif | 21 | #endif |
23 | #include "iSilo.h" | 22 | #include "iSilo.h" |
23 | #include "Reb.h" | ||
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | 26 | ||
27 | linkType BuffDoc::hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) | 27 | linkType BuffDoc::hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) |
28 | { | 28 | { |
29 | linkType bRet = eNone; | 29 | linkType bRet = eNone; |
30 | if (exp != NULL) | 30 | if (exp != NULL) |
31 | { | 31 | { |
32 | bRet = filt->hyperlink(n, noff, wrd, nm); | 32 | bRet = filt->hyperlink(n, noff, wrd, nm); |
33 | if ((bRet & eLink) != 0) | 33 | if ((bRet & eLink) != 0) |
34 | { | 34 | { |
35 | lastword.empty(); | 35 | lastword.empty(); |
@@ -51,24 +51,36 @@ void BuffDoc::locate(unsigned int n) | |||
51 | lastword.empty(); | 51 | lastword.empty(); |
52 | lastsizes[0] = laststartline = n; | 52 | lastsizes[0] = laststartline = n; |
53 | #ifdef NEWLINEBREAK | 53 | #ifdef NEWLINEBREAK |
54 | lastispara = false; | 54 | lastispara = false; |
55 | #else | 55 | #else |
56 | lastispara = false; | 56 | lastispara = false; |
57 | #endif | 57 | #endif |
58 | // tchar linebuf[1024]; | 58 | // tchar linebuf[1024]; |
59 | if (exp != NULL) filt->locate(n); | 59 | if (exp != NULL) filt->locate(n); |
60 | // //qDebug("BuffDoc:Located"); | 60 | // //qDebug("BuffDoc:Located"); |
61 | } | 61 | } |
62 | 62 | ||
63 | void BuffDoc::resetPos() | ||
64 | { | ||
65 | // //qDebug("BuffDoc:locating:%u",n); | ||
66 | lastword.empty(); | ||
67 | lastsizes[0] = laststartline = exp->locate(); | ||
68 | #ifdef NEWLINEBREAK | ||
69 | lastispara = false; | ||
70 | #else | ||
71 | lastispara = false; | ||
72 | #endif | ||
73 | } | ||
74 | |||
63 | static bool isletter(unsigned short c) | 75 | static bool isletter(unsigned short c) |
64 | { | 76 | { |
65 | if ('a' <= c && c <= 'z') return true; | 77 | if ('a' <= c && c <= 'z') return true; |
66 | if ('A' <= c && c <= 'Z') return true; | 78 | if ('A' <= c && c <= 'Z') return true; |
67 | // Cyrillic letters | 79 | // Cyrillic letters |
68 | if (0x400 <= c && c <= 0x52F) return true; | 80 | if (0x400 <= c && c <= 0x52F) return true; |
69 | return false; | 81 | return false; |
70 | } | 82 | } |
71 | 83 | ||
72 | static bool isvowel(unsigned short c) // Only want lower case vowels | 84 | static bool isvowel(unsigned short c) // Only want lower case vowels |
73 | { | 85 | { |
74 | switch (c) | 86 | switch (c) |
@@ -626,45 +638,62 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
626 | } | 638 | } |
627 | if (ret != 0) | 639 | if (ret != 0) |
628 | { | 640 | { |
629 | 641 | ||
630 | delete exp; | 642 | delete exp; |
631 | exp = new iSilo; | 643 | exp = new iSilo; |
632 | ret = exp->openfile(src); | 644 | ret = exp->openfile(src); |
633 | } | 645 | } |
634 | if (ret != 0) | 646 | if (ret != 0) |
635 | { | 647 | { |
636 | delete exp; | 648 | delete exp; |
637 | //qDebug("Trying ppms"); | 649 | //qDebug("Trying ppms"); |
650 | exp = new CReb; | ||
651 | ret = exp->openfile(src); | ||
652 | } | ||
653 | if (ret != 0) | ||
654 | { | ||
655 | delete exp; | ||
656 | //qDebug("Trying ppms"); | ||
638 | exp = new ppm_expander; | 657 | exp = new ppm_expander; |
639 | ret = exp->openfile(src); | 658 | ret = exp->openfile(src); |
640 | } | 659 | } |
641 | if (ret != 0) | 660 | if (ret != 0) |
642 | { | 661 | { |
643 | delete exp; | 662 | delete exp; |
644 | exp = new Text; | 663 | exp = new Text; |
645 | // //qDebug("Trying text"); | 664 | // //qDebug("Trying text"); |
646 | ret = exp->openfile(src); | 665 | ret = exp->openfile(src); |
647 | if (ret == 0) qDebug("Text format"); | 666 | if (ret == 0) qDebug("Text format"); |
648 | } | 667 | } |
649 | 668 | ||
650 | if (ret != 0) | 669 | if (ret != 0) |
651 | { | 670 | { |
652 | delete exp; | 671 | delete exp; |
653 | QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); | 672 | QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); |
654 | return ret; | 673 | return ret; |
655 | } | 674 | } |
656 | // //qDebug("Doing final open:%x:%x",exp,filt); | 675 | // //qDebug("Doing final open:%x:%x",exp,filt); |
657 | #else | 676 | #else |
658 | QString codecpath(QTReaderUtil::getPluginPath()); | 677 | #ifdef USEQPE |
678 | #ifdef OPIE | ||
679 | QString codecpath(getenv("OPIEDIR")); | ||
680 | #else | ||
681 | QString codecpath(getenv("QTDIR")); | ||
682 | #endif | ||
683 | codecpath += "/plugins/reader/codecs"; | ||
684 | #else | ||
685 | QString codecpath(getenv("READERDIR")); | ||
686 | codecpath += "/codecs"; | ||
687 | #endif | ||
659 | QDir d(codecpath, "*.so"); | 688 | QDir d(codecpath, "*.so"); |
660 | 689 | ||
661 | if (d.exists()) | 690 | if (d.exists()) |
662 | { | 691 | { |
663 | 692 | ||
664 | const QFileInfoList *list = d.entryInfoList(); | 693 | const QFileInfoList *list = d.entryInfoList(); |
665 | QFileInfoListIterator it( *list ); // create list iterator | 694 | QFileInfoListIterator it( *list ); // create list iterator |
666 | QFileInfo *fi; // pointer for traversing | 695 | QFileInfo *fi; // pointer for traversing |
667 | 696 | ||
668 | int ret = -1; | 697 | int ret = -1; |
669 | while ( ret != 0 && (fi=it.current()) ) | 698 | while ( ret != 0 && (fi=it.current()) ) |
670 | { // for each file... | 699 | { // for each file... |
@@ -697,12 +726,34 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
697 | lastispara = false; | 726 | lastispara = false; |
698 | #endif | 727 | #endif |
699 | exp->locate(exp->getHome()); | 728 | exp->locate(exp->getHome()); |
700 | filt->setsource(exp); | 729 | filt->setsource(exp); |
701 | qDebug("BuffDoc:file opened"); | 730 | qDebug("BuffDoc:file opened"); |
702 | return 0; | 731 | return 0; |
703 | } | 732 | } |
704 | 733 | ||
705 | QString BuffDoc::about() | 734 | QString BuffDoc::about() |
706 | { | 735 | { |
707 | return QString("Buffered Decompressor (c) Tim Wentford\nHyphenation algorithm (c) Tim Wentford\n (Cyrillic support by Konstantin Isakov\n")+filt->about(); | 736 | return QString("Buffered Decompressor (c) Tim Wentford\nHyphenation algorithm (c) Tim Wentford\n (Cyrillic support by Konstantin Isakov\n")+filt->about(); |
708 | } | 737 | } |
738 | |||
739 | int BuffDoc::getsentence(CBuffer& buff) | ||
740 | { | ||
741 | tchar ch; | ||
742 | int i = 0; | ||
743 | bool intext = false; | ||
744 | while ((ch = getch()) != 10 && ch != UEOF) | ||
745 | { | ||
746 | buff[i++] = ch; | ||
747 | if (ch == '"' || ch == '\'' || ch == 0x2018 || ch == 0x2019 || | ||
748 | ch == 0x201a || ch == 0x201b || ch == 0x201c || ch == 0x201d) | ||
749 | { | ||
750 | intext = !intext; | ||
751 | } | ||
752 | if (!intext && (ch == '.' || ch == '!' || ch == '?')) break; | ||
753 | } | ||
754 | |||
755 | buff[i] = '\0'; | ||
756 | if (i == 0 && ch == UEOF) i = -1; | ||
757 | laststartline = exp->locate(); | ||
758 | return i; | ||
759 | } | ||
diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h index 2b4fb57..d6bfd99 100644 --- a/noncore/apps/opie-reader/BuffDoc.h +++ b/noncore/apps/opie-reader/BuffDoc.h | |||
@@ -38,28 +38,26 @@ class BuffDoc | |||
38 | exp->setSaveData(data, len, src, srclen); | 38 | exp->setSaveData(data, len, src, srclen); |
39 | } | 39 | } |
40 | } | 40 | } |
41 | void putSaveData(unsigned char*& src, unsigned short& srclen) | 41 | void putSaveData(unsigned char*& src, unsigned short& srclen) |
42 | { | 42 | { |
43 | if (exp != NULL) | 43 | if (exp != NULL) |
44 | { | 44 | { |
45 | exp->putSaveData(src, srclen); | 45 | exp->putSaveData(src, srclen); |
46 | } | 46 | } |
47 | } | 47 | } |
48 | #ifdef USEQPE | 48 | #ifdef USEQPE |
49 | void suspend() { if (exp != NULL) exp->suspend(); } | 49 | void suspend() { if (exp != NULL) exp->suspend(); } |
50 | void unsuspend() { if (exp != NULL) exp->unsuspend(); } | ||
51 | #else | 50 | #else |
52 | void suspend() {} | 51 | void suspend() {} |
53 | void unsuspend() {} | ||
54 | #endif | 52 | #endif |
55 | ~BuffDoc() | 53 | ~BuffDoc() |
56 | { | 54 | { |
57 | delete filt; | 55 | delete filt; |
58 | delete exp; | 56 | delete exp; |
59 | } | 57 | } |
60 | BuffDoc() | 58 | BuffDoc() |
61 | { | 59 | { |
62 | exp = NULL; | 60 | exp = NULL; |
63 | filt = NULL; | 61 | filt = NULL; |
64 | lastword.empty(); | 62 | lastword.empty(); |
65 | // // qDebug("Buffdoc created"); | 63 | // // qDebug("Buffdoc created"); |
@@ -86,28 +84,40 @@ class BuffDoc | |||
86 | } | 84 | } |
87 | return ch; | 85 | return ch; |
88 | } | 86 | } |
89 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 87 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
90 | { | 88 | { |
91 | if (exp != NULL) | 89 | if (exp != NULL) |
92 | { | 90 | { |
93 | filt->getch(ch, sty, pos); | 91 | filt->getch(ch, sty, pos); |
94 | } | 92 | } |
95 | else | 93 | else |
96 | ch = UEOF; | 94 | ch = UEOF; |
97 | } | 95 | } |
96 | /* | ||
97 | void rawgetch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
98 | { | ||
99 | if (exp != NULL) | ||
100 | { | ||
101 | filt->rawgetch(ch, sty, pos); | ||
102 | } | ||
103 | else | ||
104 | ch = UEOF; | ||
105 | } | ||
106 | */ | ||
98 | void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } | 107 | void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } |
99 | QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } | 108 | QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } |
100 | unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } | 109 | unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } |
101 | unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } | 110 | unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } |
111 | void resetPos(); | ||
102 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } | 112 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } |
103 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } | 113 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } |
104 | void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } | 114 | void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } |
105 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } | 115 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } |
106 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); | 116 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); |
107 | size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } | 117 | size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } |
108 | void locate(unsigned int n); | 118 | void locate(unsigned int n); |
109 | bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht); | 119 | bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht); |
110 | bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht); | 120 | bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht); |
111 | void sizes(unsigned long& fs, unsigned long& ts) | 121 | void sizes(unsigned long& fs, unsigned long& ts) |
112 | { | 122 | { |
113 | if (exp != NULL) | 123 | if (exp != NULL) |
@@ -120,24 +130,29 @@ class BuffDoc | |||
120 | } | 130 | } |
121 | } | 131 | } |
122 | int getpara(CBuffer& buff) | 132 | int getpara(CBuffer& buff) |
123 | { | 133 | { |
124 | tchar ch; | 134 | tchar ch; |
125 | int i = 0; | 135 | int i = 0; |
126 | while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; | 136 | while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; |
127 | buff[i] = '\0'; | 137 | buff[i] = '\0'; |
128 | if (i == 0 && ch == UEOF) i = -1; | 138 | if (i == 0 && ch == UEOF) i = -1; |
129 | laststartline = exp->locate(); | 139 | laststartline = exp->locate(); |
130 | return i; | 140 | return i; |
131 | } | 141 | } |
142 | int getsentence(CBuffer& buff); | ||
132 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } | 143 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } |
133 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } | 144 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } |
134 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } | 145 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } |
135 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } | 146 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } |
136 | bool hasnavigation() { return filt->hasnavigation(); } | 147 | bool hasnavigation() { return (exp == NULL) ? false : filt->hasnavigation(); } |
137 | bool getFile(QString href) | 148 | bool getFile(const QString& href, QString& nm) |
149 | { | ||
150 | return (exp == NULL) ? false : exp->getFile(href, nm); | ||
151 | } | ||
152 | QString getTableAsHtml(unsigned long loc) | ||
138 | { | 153 | { |
139 | return (exp == NULL) ? false : exp->getFile(href); | 154 | return (exp != NULL) ? filt->getTableAsHtml(loc) : QString(""); |
140 | } | 155 | } |
141 | }; | 156 | }; |
142 | 157 | ||
143 | #endif | 158 | #endif |
diff --git a/noncore/apps/opie-reader/ButtonPrefs.cpp b/noncore/apps/opie-reader/ButtonPrefs.cpp index 50365a8..762de55 100644 --- a/noncore/apps/opie-reader/ButtonPrefs.cpp +++ b/noncore/apps/opie-reader/ButtonPrefs.cpp | |||
@@ -143,24 +143,28 @@ CButtonPrefs::CButtonPrefs( QMap<orKey, int>* _kmap, QWidget* parent, const cha | |||
143 | { | 143 | { |
144 | listmap[i.key()] = new MyQListViewItem(i.key(), lb, i.key().text(), action->text(i.data()), (i.key().isScroll()) ? "*":""); | 144 | listmap[i.key()] = new MyQListViewItem(i.key(), lb, i.key().text(), action->text(i.data()), (i.key().isScroll()) ? "*":""); |
145 | } | 145 | } |
146 | 146 | ||
147 | lo = new QHBoxLayout(); | 147 | lo = new QHBoxLayout(); |
148 | QLabel* TextLabel = new QLabel( this, "TextLabel1" ); | 148 | QLabel* TextLabel = new QLabel( this, "TextLabel1" ); |
149 | TextLabel->setText( tr( "Debounce" ) ); | 149 | TextLabel->setText( tr( "Debounce" ) ); |
150 | lo->addWidget(TextLabel); | 150 | lo->addWidget(TextLabel); |
151 | 151 | ||
152 | debounce = new QSpinBox( this, "Debounce" ); | 152 | debounce = new QSpinBox( this, "Debounce" ); |
153 | debounce->setRange(0,1000); | 153 | debounce->setRange(0,1000); |
154 | lo->addWidget(debounce); | 154 | lo->addWidget(debounce); |
155 | /* | ||
156 | QPushButton* assignClose = new QPushButton("Assign\nCancel", this); | ||
157 | lo->addWidget(assignClose); | ||
158 | */ | ||
155 | lo->addStretch(1); | 159 | lo->addStretch(1); |
156 | QPushButton* delButton = new QPushButton("Delete", this); | 160 | QPushButton* delButton = new QPushButton("Delete", this); |
157 | connect(delButton, SIGNAL( clicked() ), this, SLOT( erasemapping() )); | 161 | connect(delButton, SIGNAL( clicked() ), this, SLOT( erasemapping() )); |
158 | lo->addWidget(delButton); | 162 | lo->addWidget(delButton); |
159 | QPushButton* exitButton = new QPushButton("Close", this); | 163 | QPushButton* exitButton = new QPushButton("Close", this); |
160 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotClosed() ) ); | 164 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotClosed() ) ); |
161 | lo->addWidget(exitButton); | 165 | lo->addWidget(exitButton); |
162 | vo->addLayout(lo); | 166 | vo->addLayout(lo); |
163 | } | 167 | } |
164 | 168 | ||
165 | void CButtonPrefs::erasemapping() | 169 | void CButtonPrefs::erasemapping() |
166 | { | 170 | { |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index bfb3027..227f0f6 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -355,24 +355,25 @@ int CDrawBuffer::offset(int scwidth, unsigned short _lborder, unsigned short _rb | |||
355 | } | 355 | } |
356 | break; | 356 | break; |
357 | case m_AlignCentre: | 357 | case m_AlignCentre: |
358 | { | 358 | { |
359 | currentx = ( | 359 | currentx = ( |
360 | scwidth - _lborder -_rborder + | 360 | scwidth - _lborder -_rborder + |
361 | leftMargin() - rightMargin() | 361 | leftMargin() - rightMargin() |
362 | - width(availht))/2 + _lborder; | 362 | - width(availht))/2 + _lborder; |
363 | } | 363 | } |
364 | break; | 364 | break; |
365 | case m_AlignJustify: | 365 | case m_AlignJustify: |
366 | case m_AlignLeft: | 366 | case m_AlignLeft: |
367 | case m_AlignNone: | ||
367 | currentx = _lborder + leftMargin(); | 368 | currentx = _lborder + leftMargin(); |
368 | break; | 369 | break; |
369 | } | 370 | } |
370 | return currentx; | 371 | return currentx; |
371 | } | 372 | } |
372 | 373 | ||
373 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned short _lborder, unsigned short _rborder, const QColor& _bg, int availht) | 374 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned short _lborder, unsigned short _rborder, const QColor& _bg, int availht) |
374 | { | 375 | { |
375 | CList<textsegment>::iterator textstart = segs.begin(); | 376 | CList<textsegment>::iterator textstart = segs.begin(); |
376 | QColor paperColour = QColor(qRgb(textstart->style.pRed(), | 377 | QColor paperColour = QColor(qRgb(textstart->style.pRed(), |
377 | textstart->style.pGreen(), | 378 | textstart->style.pGreen(), |
378 | textstart->style.pBlue())); | 379 | textstart->style.pBlue())); |
@@ -475,25 +476,25 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
475 | currentstyle.bGreen(), | 476 | currentstyle.bGreen(), |
476 | currentstyle.bBlue())); | 477 | currentstyle.bBlue())); |
477 | drawBackground = !(bgColour == _bg); | 478 | drawBackground = !(bgColour == _bg); |
478 | 479 | ||
479 | // if (drawBackground) qDebug("Drawing background"); | 480 | // if (drawBackground) qDebug("Drawing background"); |
480 | 481 | ||
481 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 482 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
482 | //f.setUnderline(currentstyle.isUnderline()); | 483 | //f.setUnderline(currentstyle.isUnderline()); |
483 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); | 484 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); |
484 | _p->setFont(f); | 485 | _p->setFont(f); |
485 | QString str = text.mid(textstart->start, end-textstart->start); | 486 | QString str = text.mid(textstart->start, end-textstart->start); |
486 | #if defined(OPIE) || !defined(USEQPE) | 487 | #if defined(OPIE) || !defined(USEQPE) |
487 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); | 488 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10/*0*/)); |
488 | #else | 489 | #else |
489 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); | 490 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); |
490 | #endif | 491 | #endif |
491 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; | 492 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; |
492 | 493 | ||
493 | if (_bMono) | 494 | if (_bMono) |
494 | { | 495 | { |
495 | 496 | ||
496 | Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour); | 497 | Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour); |
497 | if (currentstyle.isUnderline()) | 498 | if (currentstyle.isUnderline()) |
498 | { | 499 | { |
499 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); | 500 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); |
@@ -649,25 +650,25 @@ void CDrawBuffer::Highlight(QPainter* _p, bool drawBackground, int _x, int _y, i | |||
649 | } | 650 | } |
650 | 651 | ||
651 | CStyle CDrawBuffer::laststyle() | 652 | CStyle CDrawBuffer::laststyle() |
652 | { | 653 | { |
653 | return segs.last().style; | 654 | return segs.last().style; |
654 | } | 655 | } |
655 | 656 | ||
656 | CStyle CDrawBuffer::firststyle() | 657 | CStyle CDrawBuffer::firststyle() |
657 | { | 658 | { |
658 | return segs.first().style; | 659 | return segs.first().style; |
659 | } | 660 | } |
660 | 661 | ||
661 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img) | 662 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img, size_t& tabletgt) |
662 | { | 663 | { |
663 | linkType ret = eNone; | 664 | linkType ret = eNone; |
664 | int end = 0; | 665 | int end = 0; |
665 | CStyle currentstyle; | 666 | CStyle currentstyle; |
666 | CList<textsegment>::iterator textstart = segs.begin(); | 667 | CList<textsegment>::iterator textstart = segs.begin(); |
667 | CList<textsegment>::iterator textend = textstart; | 668 | CList<textsegment>::iterator textend = textstart; |
668 | do | 669 | do |
669 | { | 670 | { |
670 | textend++; | 671 | textend++; |
671 | end = (textend != segs.end()) ? textend->start : len; | 672 | end = (textend != segs.end()) ? textend->start : len; |
672 | currentstyle = textstart->style; | 673 | currentstyle = textstart->style; |
673 | /* | 674 | /* |
@@ -681,24 +682,29 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, siz | |||
681 | img = currentstyle.getPicture(); | 682 | img = currentstyle.getPicture(); |
682 | if (currentstyle.getPictureLink()) | 683 | if (currentstyle.getPictureLink()) |
683 | { | 684 | { |
684 | pictgt = currentstyle.getPictureLinkData(); | 685 | pictgt = currentstyle.getPictureLinkData(); |
685 | ret |= ePicture; | 686 | ret |= ePicture; |
686 | } | 687 | } |
687 | if (currentstyle.getLink()) | 688 | if (currentstyle.getLink()) |
688 | { | 689 | { |
689 | tgt = currentstyle.getData(); | 690 | tgt = currentstyle.getData(); |
690 | offset = currentstyle.getOffset(); | 691 | offset = currentstyle.getOffset(); |
691 | ret |= eLink; | 692 | ret |= eLink; |
692 | } | 693 | } |
694 | if (currentstyle.isTable()) | ||
695 | { | ||
696 | tabletgt = currentstyle.getTable(); | ||
697 | ret |= eTable; | ||
698 | } | ||
693 | return ret; | 699 | return ret; |
694 | } | 700 | } |
695 | 701 | ||
696 | void CDrawBuffer::resize(int availht) | 702 | void CDrawBuffer::resize(int availht) |
697 | { | 703 | { |
698 | int gzoom = fc->gzoom(); | 704 | int gzoom = fc->gzoom(); |
699 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 705 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
700 | /* | 706 | /* |
701 | int t_ascent = 0; | 707 | int t_ascent = 0; |
702 | int t_descent = 0; | 708 | int t_descent = 0; |
703 | int t_lineExtraSpacing = 0; | 709 | int t_lineExtraSpacing = 0; |
704 | */ | 710 | */ |
@@ -707,25 +713,25 @@ void CDrawBuffer::resize(int availht) | |||
707 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) | 713 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) |
708 | { | 714 | { |
709 | CStyle _style = iter->style; | 715 | CStyle _style = iter->style; |
710 | if (!_style.isPicture()) | 716 | if (!_style.isPicture()) |
711 | { | 717 | { |
712 | m_hastext = true; | 718 | m_hastext = true; |
713 | break; | 719 | break; |
714 | } | 720 | } |
715 | iter++; | 721 | iter++; |
716 | } | 722 | } |
717 | if (m_hastext) | 723 | if (m_hastext) |
718 | { | 724 | { |
719 | 725 | int p_linespacing = 0; | |
720 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) | 726 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) |
721 | { | 727 | { |
722 | CList<textsegment>::iterator next = iter; | 728 | CList<textsegment>::iterator next = iter; |
723 | iter++; | 729 | iter++; |
724 | int st = next->start; | 730 | int st = next->start; |
725 | if (st < 0) st = 0; | 731 | if (st < 0) st = 0; |
726 | 732 | ||
727 | CStyle _style = next->style; | 733 | CStyle _style = next->style; |
728 | 734 | ||
729 | int linespacing, ascent, descent, extra; | 735 | int linespacing, ascent, descent, extra; |
730 | 736 | ||
731 | ascent = fc->ascent(_style); | 737 | ascent = fc->ascent(_style); |
@@ -747,41 +753,52 @@ void CDrawBuffer::resize(int availht) | |||
747 | bool willscale = false; | 753 | bool willscale = false; |
748 | if (ht > availht) | 754 | if (ht > availht) |
749 | { | 755 | { |
750 | wt = (wt*availht)/ht; | 756 | wt = (wt*availht)/ht; |
751 | ht = availht; | 757 | ht = availht; |
752 | willscale = true; | 758 | willscale = true; |
753 | } | 759 | } |
754 | if (willscale || _style.canScale()) | 760 | if (willscale || _style.canScale()) |
755 | { | 761 | { |
756 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; | 762 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; |
757 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; | 763 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; |
758 | } | 764 | } |
765 | else | ||
766 | { | ||
767 | descent = (_style.getPicture()->height()-ascent)/2; | ||
768 | ascent = (_style.getPicture()->height()+ascent)/2; | ||
769 | } | ||
770 | int lineSpacing = ascent+descent; | ||
771 | if (lineSpacing > p_linespacing) | ||
772 | { | ||
773 | p_linespacing = lineSpacing; | ||
774 | } | ||
775 | extra = 0; | ||
759 | } | 776 | } |
760 | 777 | ||
761 | /* | 778 | /* |
762 | else if (fc != NULL) | 779 | else if (fc != NULL) |
763 | { | 780 | { |
764 | ascent = fc->ascent(_style); | 781 | ascent = fc->ascent(_style); |
765 | descent = fc->descent(_style); | 782 | descent = fc->descent(_style); |
766 | linespacing = fc->lineSpacing(_style); | 783 | linespacing = fc->lineSpacing(_style); |
767 | extra = linespacing - ascent - descent; | 784 | extra = linespacing - ascent - descent; |
768 | } | 785 | } |
769 | */ | 786 | */ |
770 | if (ascent > m_ascent) m_ascent = ascent; | 787 | if (ascent > m_ascent) m_ascent = ascent; |
771 | if (descent > m_descent) m_descent = descent; | 788 | if (descent > m_descent) m_descent = descent; |
772 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; | 789 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; |
773 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; | 790 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; |
774 | } | 791 | } |
775 | m_showPartial = (m_lineSpacing > t_lineSpacing); | 792 | m_showPartial = (p_linespacing > t_lineSpacing); |
776 | int lead = fc->getlead(); | 793 | int lead = fc->getlead(); |
777 | if (lead != 0) | 794 | if (lead != 0) |
778 | { | 795 | { |
779 | int xt = (lead*t_lineSpacing+5)/10; | 796 | int xt = (lead*t_lineSpacing+5)/10; |
780 | m_lineExtraSpacing += xt; | 797 | m_lineExtraSpacing += xt; |
781 | m_lineSpacing += xt; | 798 | m_lineSpacing += xt; |
782 | } | 799 | } |
783 | if (m_bSop) | 800 | if (m_bSop) |
784 | { | 801 | { |
785 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; | 802 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; |
786 | //qDebug("ExtraSpace:%d", xt); | 803 | //qDebug("ExtraSpace:%d", xt); |
787 | m_ascent += xt; | 804 | m_ascent += xt; |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.h b/noncore/apps/opie-reader/CDrawBuffer.h index 2625a72..1782cf8 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.h +++ b/noncore/apps/opie-reader/CDrawBuffer.h | |||
@@ -69,19 +69,19 @@ class CDrawBuffer : public CBuffer | |||
69 | void empty(); | 69 | void empty(); |
70 | void addch(tchar ch, CStyle _style); | 70 | void addch(tchar ch, CStyle _style); |
71 | void truncate(int); | 71 | void truncate(int); |
72 | void setright(CDrawBuffer&, int); | 72 | void setright(CDrawBuffer&, int); |
73 | CStyle firststyle(); | 73 | CStyle firststyle(); |
74 | CStyle laststyle(); | 74 | CStyle laststyle(); |
75 | int ascent() { return m_ascent; } | 75 | int ascent() { return m_ascent; } |
76 | int descent() { return m_descent; } | 76 | int descent() { return m_descent; } |
77 | int lineSpacing() { return m_lineSpacing; } | 77 | int lineSpacing() { return m_lineSpacing; } |
78 | int lineExtraSpacing() { return m_lineExtraSpacing; } | 78 | int lineExtraSpacing() { return m_lineExtraSpacing; } |
79 | 79 | ||
80 | // void frig(); | 80 | // void frig(); |
81 | linkType getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*&); | 81 | linkType getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*&, size_t&); |
82 | void resize(int); | 82 | void resize(int); |
83 | bool showPartial() { return m_showPartial; } | 83 | bool showPartial() { return m_showPartial; } |
84 | CStyle* getNextLink(int&); | 84 | CStyle* getNextLink(int&); |
85 | int invertLink(int); | 85 | int invertLink(int); |
86 | }; | 86 | }; |
87 | #endif | 87 | #endif |
diff --git a/noncore/apps/opie-reader/CEncoding.h b/noncore/apps/opie-reader/CEncoding.h index 1dfd74d..76cbfae 100644 --- a/noncore/apps/opie-reader/CEncoding.h +++ b/noncore/apps/opie-reader/CEncoding.h | |||
@@ -3,40 +3,47 @@ | |||
3 | 3 | ||
4 | #include "CExpander.h" | 4 | #include "CExpander.h" |
5 | 5 | ||
6 | #define MAX_ENCODING 6 | 6 | #define MAX_ENCODING 6 |
7 | 7 | ||
8 | class CEncoding : public CCharacterSource | 8 | class CEncoding : public CCharacterSource |
9 | { | 9 | { |
10 | friend class CFilterChain; | 10 | friend class CFilterChain; |
11 | protected: | 11 | protected: |
12 | CExpander_Interface* parent; | 12 | CExpander_Interface* parent; |
13 | linkType hyperlink(unsigned int n, unsigned int noff, QString& t, QString& nm) { return parent->hyperlink(n, noff, t, nm); } | 13 | linkType hyperlink(unsigned int n, unsigned int noff, QString& t, QString& nm) { return parent->hyperlink(n, noff, t, nm); } |
14 | public: | 14 | public: |
15 | virtual QString getTableAsHtml(unsigned long loc) | ||
16 | { | ||
17 | qDebug("CEncoding::getTableAsHtml()"); | ||
18 | return parent->getTableAsHtml(loc); | ||
19 | } | ||
15 | CEncoding() : parent(NULL) {} | 20 | CEncoding() : parent(NULL) {} |
16 | void setparent(CExpander_Interface* p) { parent = p; } | 21 | void setparent(CExpander_Interface* p) { parent = p; } |
17 | virtual ~CEncoding() {}; | 22 | virtual ~CEncoding() {}; |
18 | void locate(unsigned int n) { parent->locate(n); } | 23 | void locate(unsigned int n) { parent->locate(n); } |
19 | bool findanchor(const QString& nm) { return false; } | 24 | bool findanchor(const QString& nm) |
25 | { | ||
26 | return parent->findanchor(nm); | ||
27 | } | ||
20 | void saveposn(const QString& f, size_t posn) { parent->saveposn(posn); } | 28 | void saveposn(const QString& f, size_t posn) { parent->saveposn(posn); } |
21 | void writeposn(const QString& f, size_t posn) { parent->writeposn(posn); } | 29 | void writeposn(const QString& f, size_t posn) { parent->writeposn(posn); } |
22 | linkType forward(QString& f, size_t& loc) { return parent->forward(loc); } | 30 | linkType forward(QString& f, size_t& loc) { return parent->forward(loc); } |
23 | linkType back(QString& f, size_t& loc) { return parent->back(loc); } | 31 | linkType back(QString& f, size_t& loc) { return parent->back(loc); } |
24 | bool hasnavigation() { return parent->hasnavigation(); } | 32 | bool hasnavigation() { return parent->hasnavigation(); } |
25 | virtual int getwidth() { return parent->getwidth(); } | 33 | virtual int getwidth() { return parent->getwidth(); } |
26 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } | 34 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } |
27 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } | 35 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } |
28 | bool getFile(const QString& href) { qDebug("Encoding Get File"); return parent->getFile(href);} | 36 | bool getFile(const QString& href, const QString& nm) { qDebug("Encoding Get File"); return parent->getFile(href, nm);} |
29 | 37 | unsigned long startSection() { return parent->startSection(); } | |
30 | |||
31 | }; | 38 | }; |
32 | 39 | ||
33 | class CUtf8 : public CEncoding | 40 | class CUtf8 : public CEncoding |
34 | { | 41 | { |
35 | public: | 42 | public: |
36 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 43 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
37 | QString about() { return QString("UTF8 decoder (c) Tim Wentford\n")+parent->about(); } | 44 | QString about() { return QString("UTF8 decoder (c) Tim Wentford\n")+parent->about(); } |
38 | }; | 45 | }; |
39 | 46 | ||
40 | class CUcs16be : public CEncoding | 47 | class CUcs16be : public CEncoding |
41 | { | 48 | { |
42 | public: | 49 | public: |
diff --git a/noncore/apps/opie-reader/CExpander.cpp b/noncore/apps/opie-reader/CExpander.cpp index e398d86..1158a7a 100644 --- a/noncore/apps/opie-reader/CExpander.cpp +++ b/noncore/apps/opie-reader/CExpander.cpp | |||
@@ -1,13 +1,16 @@ | |||
1 | #include "CExpander.h" | 1 | #include "CExpander.h" |
2 | #ifdef USEQPE | ||
3 | #include <qpe/global.h> | ||
4 | #endif | ||
2 | 5 | ||
3 | size_t CExpander::getHome() { return m_homepos; } | 6 | size_t CExpander::getHome() { return m_homepos; } |
4 | 7 | ||
5 | CExpander::CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {}; | 8 | CExpander::CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {}; |
6 | 9 | ||
7 | CExpander::~CExpander() { if (fname != NULL) delete [] fname; }; | 10 | CExpander::~CExpander() { if (fname != NULL) delete [] fname; }; |
8 | 11 | ||
9 | int CExpander::openfile(const char *src) | 12 | int CExpander::openfile(const char *src) |
10 | { | 13 | { |
11 | bSuspended = false; | 14 | bSuspended = false; |
12 | fname = strdup(src); | 15 | fname = strdup(src); |
13 | return OpenFile(src); | 16 | return OpenFile(src); |
@@ -61,28 +64,33 @@ void CExpander::suspend(FILE*& fin) | |||
61 | suspos = ftell(fin); | 64 | suspos = ftell(fin); |
62 | fclose(fin); | 65 | fclose(fin); |
63 | fin = NULL; | 66 | fin = NULL; |
64 | sustime = time(NULL); | 67 | sustime = time(NULL); |
65 | } | 68 | } |
66 | 69 | ||
67 | void CExpander::unsuspend(FILE*& fin) | 70 | void CExpander::unsuspend(FILE*& fin) |
68 | { | 71 | { |
69 | if (bSuspended) | 72 | if (bSuspended) |
70 | { | 73 | { |
71 | bSuspended = false; | 74 | bSuspended = false; |
72 | int delay = time(NULL) - sustime; | 75 | int delay = time(NULL) - sustime; |
73 | if (delay < 10) sleep(10-delay); | 76 | if (delay < 10) |
77 | { | ||
78 | Global::statusMessage("Stalling"); | ||
79 | sleep(10-delay); | ||
80 | } | ||
74 | fin = fopen(fname, "rb"); | 81 | fin = fopen(fname, "rb"); |
75 | for (int i = 0; fin == NULL && i < 5; i++) | 82 | for (int i = 0; fin == NULL && i < 5; i++) |
76 | { | 83 | { |
84 | Global::statusMessage("Stalling"); | ||
77 | sleep(5); | 85 | sleep(5); |
78 | fin = fopen(fname, "rb"); | 86 | fin = fopen(fname, "rb"); |
79 | } | 87 | } |
80 | if (fin == NULL) | 88 | if (fin == NULL) |
81 | { | 89 | { |
82 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 90 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
83 | exit(0); | 91 | exit(0); |
84 | } | 92 | } |
85 | suspos = fseek(fin, suspos, SEEK_SET); | 93 | suspos = fseek(fin, suspos, SEEK_SET); |
86 | } | 94 | } |
87 | } | 95 | } |
88 | #endif | 96 | #endif |
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index 7fa84f9..24c317d 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h | |||
@@ -15,38 +15,40 @@ | |||
15 | #include "linktype.h" | 15 | #include "linktype.h" |
16 | 16 | ||
17 | class QImage; | 17 | class QImage; |
18 | class Bkmk; | 18 | class Bkmk; |
19 | class QString; | 19 | class QString; |
20 | 20 | ||
21 | template<class T> | 21 | template<class T> |
22 | class CList; | 22 | class CList; |
23 | 23 | ||
24 | class CCharacterSource | 24 | class CCharacterSource |
25 | { | 25 | { |
26 | public: | 26 | public: |
27 | virtual QString getTableAsHtml(unsigned long loc) = 0; | ||
27 | virtual void getch(tchar&, CStyle&, unsigned long&) = 0; | 28 | virtual void getch(tchar&, CStyle&, unsigned long&) = 0; |
28 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0; | 29 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0; |
29 | virtual void locate(unsigned int n) = 0; | 30 | virtual void locate(unsigned int n) = 0; |
30 | virtual bool findanchor(const QString& nm) = 0; | 31 | virtual bool findanchor(const QString& nm) = 0; |
31 | virtual void saveposn(const QString& f, size_t posn) = 0; | 32 | virtual void saveposn(const QString& f, size_t posn) = 0; |
32 | virtual void writeposn(const QString& f, size_t posn) = 0; | 33 | virtual void writeposn(const QString& f, size_t posn) = 0; |
33 | virtual linkType forward(QString& f, size_t& loc) = 0; | 34 | virtual linkType forward(QString& f, size_t& loc) = 0; |
34 | virtual linkType back(QString& f, size_t& loc) = 0; | 35 | virtual linkType back(QString& f, size_t& loc) = 0; |
35 | virtual bool hasnavigation() = 0; | 36 | virtual bool hasnavigation() = 0; |
36 | virtual int getwidth() = 0; | 37 | virtual int getwidth() = 0; |
37 | virtual QImage* getPicture(unsigned long) = 0; | 38 | virtual QImage* getPicture(unsigned long) = 0; |
38 | virtual QImage* getPicture(const QString& href) = 0; | 39 | virtual QImage* getPicture(const QString& href) = 0; |
39 | virtual bool getFile(const QString& href) = 0; | 40 | virtual bool getFile(const QString& href, const QString& nm) = 0; |
40 | virtual QString about() = 0; | 41 | virtual QString about() = 0; |
42 | virtual unsigned long startSection() = 0; | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | class CExpander_Interface | 45 | class CExpander_Interface |
44 | { | 46 | { |
45 | public: | 47 | public: |
46 | #ifdef USEQPE | 48 | #ifdef USEQPE |
47 | virtual void suspend() = 0; | 49 | virtual void suspend() = 0; |
48 | virtual void unsuspend() = 0; | 50 | virtual void unsuspend() = 0; |
49 | #endif | 51 | #endif |
50 | virtual QString about() = 0; | 52 | virtual QString about() = 0; |
51 | virtual size_t getHome() = 0; | 53 | virtual size_t getHome() = 0; |
52 | //CExpander_Interface(); | 54 | //CExpander_Interface(); |
@@ -74,25 +76,27 @@ class CExpander_Interface | |||
74 | virtual void setContinuous(bool _b) = 0; | 76 | virtual void setContinuous(bool _b) = 0; |
75 | #ifdef USEQPE | 77 | #ifdef USEQPE |
76 | virtual void suspend(FILE*& fin) = 0; | 78 | virtual void suspend(FILE*& fin) = 0; |
77 | virtual void unsuspend(FILE*& fin) = 0; | 79 | virtual void unsuspend(FILE*& fin) = 0; |
78 | #endif | 80 | #endif |
79 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0; | 81 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0; |
80 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0; | 82 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0; |
81 | virtual void setwidth(int w) = 0; | 83 | virtual void setwidth(int w) = 0; |
82 | // bool findstring(const QString& info); | 84 | // bool findstring(const QString& info); |
83 | // int getpara(CBuffer& buff); | 85 | // int getpara(CBuffer& buff); |
84 | virtual int getwidth() = 0; | 86 | virtual int getwidth() = 0; |
85 | virtual QImage* getPicture(const QString& href) = 0; | 87 | virtual QImage* getPicture(const QString& href) = 0; |
86 | virtual bool getFile(const QString& href) = 0; | 88 | virtual bool getFile(const QString& href, const QString& nm) = 0; |
89 | virtual bool findanchor(const QString& nm) = 0; | ||
90 | virtual QString getTableAsHtml(unsigned long loc) { return QString(""); } | ||
87 | }; | 91 | }; |
88 | 92 | ||
89 | class CExpander : public CExpander_Interface | 93 | class CExpander : public CExpander_Interface |
90 | { | 94 | { |
91 | protected: | 95 | protected: |
92 | size_t m_homepos; | 96 | size_t m_homepos; |
93 | bool m_continuous; | 97 | bool m_continuous; |
94 | char* fname; | 98 | char* fname; |
95 | bool bSuspended; | 99 | bool bSuspended; |
96 | size_t suspos; | 100 | size_t suspos; |
97 | time_t sustime; | 101 | time_t sustime; |
98 | int m_scrWidth; | 102 | int m_scrWidth; |
@@ -134,15 +138,19 @@ class CExpander : public CExpander_Interface | |||
134 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen); | 138 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen); |
135 | void setwidth(int w) | 139 | void setwidth(int w) |
136 | { | 140 | { |
137 | m_scrWidth = w; | 141 | m_scrWidth = w; |
138 | } | 142 | } |
139 | int getwidth() | 143 | int getwidth() |
140 | { | 144 | { |
141 | return m_scrWidth; | 145 | return m_scrWidth; |
142 | } | 146 | } |
143 | // bool findstring(const QString& info); | 147 | // bool findstring(const QString& info); |
144 | // int getpara(CBuffer& buff); | 148 | // int getpara(CBuffer& buff); |
145 | virtual QImage* getPicture(const QString& href) { return NULL; } | 149 | virtual QImage* getPicture(const QString& href) { return NULL; } |
146 | virtual bool getFile(const QString& href) { return false; } | 150 | virtual bool getFile(const QString& href, const QString& nm) { return false; } |
151 | virtual bool findanchor(const QString& nm) | ||
152 | { | ||
153 | return false; | ||
154 | } | ||
147 | }; | 155 | }; |
148 | #endif | 156 | #endif |
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp index ab98829..25cdfae 100644 --- a/noncore/apps/opie-reader/CFilter.cpp +++ b/noncore/apps/opie-reader/CFilter.cpp | |||
@@ -1,23 +1,23 @@ | |||
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 | |||
5 | #ifdef USEQPE | 6 | #ifdef USEQPE |
6 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
7 | #endif | 8 | #endif |
8 | #include "CDrawBuffer.h" | 9 | #include "CDrawBuffer.h" |
9 | #include "CFilter.h" | 10 | #include "CFilter.h" |
10 | #include "hrule.h" | 11 | #include "hrule.h" |
11 | #include "util.h" | ||
12 | 12 | ||
13 | #include <qregexp.h> | 13 | #include <qregexp.h> |
14 | #include <qimage.h> | 14 | #include <qimage.h> |
15 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
16 | //#include <qprogressdialog.h> | 16 | //#include <qprogressdialog.h> |
17 | //#include <qapplication.h> | 17 | //#include <qapplication.h> |
18 | 18 | ||
19 | void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) | 19 | void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) |
20 | { | 20 | { |
21 | if (uselast) | 21 | if (uselast) |
22 | { | 22 | { |
23 | ch = lastchar; | 23 | ch = lastchar; |
@@ -656,26 +656,35 @@ class ErrorFilter : public CFilter | |||
656 | } | 656 | } |
657 | else | 657 | else |
658 | { | 658 | { |
659 | ch = error[currentpos++].unicode(); | 659 | ch = error[currentpos++].unicode(); |
660 | } | 660 | } |
661 | } | 661 | } |
662 | QString about() { return parent->about(); } | 662 | QString about() { return parent->about(); } |
663 | }; | 663 | }; |
664 | 664 | ||
665 | #ifndef __STATIC | 665 | #ifndef __STATIC |
666 | ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) | 666 | ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) |
667 | { | 667 | { |
668 | QString filterpath(QTReaderUtil::getPluginPath("filters")); | 668 | #ifdef USEQPE |
669 | filterpath += "/lib"; | 669 | #ifdef OPIE |
670 | QString filterpath(getenv("OPIEDIR")); | ||
671 | #else | ||
672 | QString filterpath(getenv("QTDIR")); | ||
673 | #endif | ||
674 | filterpath += "/plugins/reader/filters/lib"; | ||
675 | #else | ||
676 | QString filterpath(getenv("READERDIR")); | ||
677 | filterpath += "/filters/lib"; | ||
678 | #endif | ||
670 | filterpath += nm; | 679 | filterpath += nm; |
671 | filterpath += ".so"; | 680 | filterpath += ".so"; |
672 | if (QFile::exists(filterpath)) | 681 | if (QFile::exists(filterpath)) |
673 | { | 682 | { |
674 | qDebug("Filter:%s", (const char*)filterpath); | 683 | qDebug("Filter:%s", (const char*)filterpath); |
675 | handle = dlopen(filterpath, RTLD_LAZY); | 684 | handle = dlopen(filterpath, RTLD_LAZY); |
676 | if (handle == 0) | 685 | if (handle == 0) |
677 | { | 686 | { |
678 | qDebug("Can't find filter:%s", dlerror()); | 687 | qDebug("Can't find filter:%s", dlerror()); |
679 | // status = -10; | 688 | // status = -10; |
680 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); | 689 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); |
681 | return; | 690 | return; |
@@ -683,25 +692,25 @@ ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NU | |||
683 | CFilter* (*newfilter)(const QString&); | 692 | CFilter* (*newfilter)(const QString&); |
684 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); | 693 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); |
685 | if (newfilter == NULL) | 694 | if (newfilter == NULL) |
686 | { | 695 | { |
687 | qDebug("Can't find newfilter"); | 696 | qDebug("Can't find newfilter"); |
688 | filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); | 697 | filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); |
689 | return; | 698 | return; |
690 | } | 699 | } |
691 | filt = (*newfilter)(optional); | 700 | filt = (*newfilter)(optional); |
692 | } | 701 | } |
693 | else | 702 | else |
694 | { | 703 | { |
695 | qDebug("No filter path"); | 704 | qDebug("No filter path:%s", (const char*)filterpath); |
696 | filt = new ErrorFilter(QString("No filter plugins installed:")+nm); | 705 | filt = new ErrorFilter(QString("No filter plugins installed:")+nm); |
697 | } | 706 | } |
698 | if (filt == NULL) | 707 | if (filt == NULL) |
699 | { | 708 | { |
700 | qDebug("Can't do newfilter"); | 709 | qDebug("Can't do newfilter"); |
701 | filt = new ErrorFilter(QString("Filter creation failed:")+nm); | 710 | filt = new ErrorFilter(QString("Filter creation failed:")+nm); |
702 | return; | 711 | return; |
703 | } | 712 | } |
704 | } | 713 | } |
705 | #endif | 714 | #endif |
706 | 715 | ||
707 | void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 716 | void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
@@ -804,12 +813,49 @@ void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
804 | } | 813 | } |
805 | else | 814 | else |
806 | { | 815 | { |
807 | tch = ch; | 816 | tch = ch; |
808 | ch = ' '; | 817 | ch = ' '; |
809 | return; | 818 | return; |
810 | } | 819 | } |
811 | } | 820 | } |
812 | tch = ch; | 821 | tch = ch; |
813 | */ | 822 | */ |
814 | return; | 823 | return; |
815 | } | 824 | } |
825 | |||
826 | void tableLink::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
827 | { | ||
828 | if (offset >= (int)text.length()) | ||
829 | { | ||
830 | offset = -1; | ||
831 | sty.setColour(m_r, m_g, m_b); | ||
832 | do | ||
833 | { | ||
834 | parent->getch(ch, sty, pos); | ||
835 | } | ||
836 | while (sty.isTable()); | ||
837 | return; | ||
838 | } | ||
839 | if (offset >= 0) | ||
840 | { | ||
841 | ch = text[offset++].unicode(); | ||
842 | return; | ||
843 | } | ||
844 | parent->getch(ch, sty, pos); | ||
845 | if (sty.isTable()) | ||
846 | { | ||
847 | offset = 1; | ||
848 | ch = text[0].unicode(); | ||
849 | m_r = sty.Red(), m_g = sty.Green(), m_b = sty.Blue(); | ||
850 | sty.setColour(255, 0, 0); | ||
851 | } | ||
852 | return; | ||
853 | } | ||
854 | |||
855 | void underlineLink::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
856 | { | ||
857 | parent->getch(ch, sty, pos); | ||
858 | if (sty.getLink()) sty.setUnderline(); | ||
859 | //if (isLink && !sty.getLink()) sty.unsetUnderline(); | ||
860 | //isLink = sty.getLink(); | ||
861 | } | ||
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h index 174e6b4..594b606 100644 --- a/noncore/apps/opie-reader/CFilter.h +++ b/noncore/apps/opie-reader/CFilter.h | |||
@@ -10,56 +10,63 @@ class CFilter_IFace : public CCharacterSource | |||
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 | virtual unsigned long startSection() = 0; | ||
22 | }; | 23 | }; |
23 | 24 | ||
24 | class CFilter : public CFilter_IFace | 25 | class CFilter : public CFilter_IFace |
25 | { | 26 | { |
26 | protected: | 27 | protected: |
27 | CCharacterSource* parent; | 28 | CCharacterSource* parent; |
28 | public: | 29 | public: |
30 | virtual QString getTableAsHtml(unsigned long loc) | ||
31 | { | ||
32 | qDebug("CFilter::getTableAsHtml()"); | ||
33 | return parent->getTableAsHtml(loc); | ||
34 | } | ||
29 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) | 35 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) |
30 | { | 36 | { |
31 | return parent->hyperlink(n,noff,w,nm); | 37 | return parent->hyperlink(n,noff,w,nm); |
32 | } | 38 | } |
33 | CFilter() : parent(NULL) {} | 39 | CFilter() : parent(NULL) {} |
34 | void setparent(CCharacterSource* p) { parent = p; } | 40 | void setparent(CCharacterSource* p) { parent = p; } |
35 | CCharacterSource* getparent() { return parent; } | 41 | CCharacterSource* getparent() { return parent; } |
36 | virtual ~CFilter() {}; | 42 | virtual ~CFilter() {}; |
37 | virtual void locate(unsigned int n) | 43 | virtual void locate(unsigned int n) |
38 | { | 44 | { |
39 | parent->locate(n); | 45 | parent->locate(n); |
40 | } | 46 | } |
41 | virtual bool findanchor(const QString& nm) | 47 | virtual bool findanchor(const QString& nm) |
42 | { | 48 | { |
43 | return parent->findanchor(nm); | 49 | return parent->findanchor(nm); |
44 | } | 50 | } |
45 | virtual void saveposn(const QString& f, size_t posn) { parent->saveposn(f, posn); } | 51 | 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); } | 52 | 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); } | 53 | 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); } | 54 | virtual linkType back(QString& f, size_t& loc) { return parent->back(f, loc); } |
49 | virtual bool hasnavigation() { return parent->hasnavigation(); } | 55 | virtual bool hasnavigation() { return parent->hasnavigation(); } |
50 | virtual int getwidth() { return parent->getwidth(); } | 56 | virtual int getwidth() { return parent->getwidth(); } |
51 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } | 57 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } |
52 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } | 58 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } |
53 | bool getFile(const QString& href) { return parent->getFile(href); } | 59 | bool getFile(const QString& href, const QString& nm) { return parent->getFile(href, nm); } |
60 | virtual unsigned long startSection() { return parent->startSection(); } | ||
54 | }; | 61 | }; |
55 | 62 | ||
56 | class CFilterChain | 63 | class CFilterChain |
57 | { | 64 | { |
58 | CExpander_Interface* expander; | 65 | CExpander_Interface* expander; |
59 | CEncoding* encoder; | 66 | CEncoding* encoder; |
60 | CFilter_IFace* first; | 67 | CFilter_IFace* first; |
61 | CCharacterSource* front; | 68 | CCharacterSource* front; |
62 | public: | 69 | public: |
63 | CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; | 70 | CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; |
64 | ~CFilterChain() | 71 | ~CFilterChain() |
65 | { | 72 | { |
@@ -67,32 +74,42 @@ class CFilterChain | |||
67 | while (p != encoder) | 74 | while (p != encoder) |
68 | { | 75 | { |
69 | CFilter_IFace* pnext = (CFilter_IFace*)p; | 76 | CFilter_IFace* pnext = (CFilter_IFace*)p; |
70 | p = ((CFilter_IFace*)p)->getparent(); | 77 | p = ((CFilter_IFace*)p)->getparent(); |
71 | delete pnext; | 78 | delete pnext; |
72 | } | 79 | } |
73 | delete encoder; | 80 | delete encoder; |
74 | } | 81 | } |
75 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) | 82 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) |
76 | { | 83 | { |
77 | return front->hyperlink(n, noff, wrd, nm); | 84 | return front->hyperlink(n, noff, wrd, nm); |
78 | } | 85 | } |
86 | QString getTableAsHtml(unsigned long loc) | ||
87 | { | ||
88 | return front->getTableAsHtml(loc); | ||
89 | } | ||
79 | void locate(unsigned int n) | 90 | void locate(unsigned int n) |
80 | { | 91 | { |
81 | front->locate(n); | 92 | front->locate(n); |
82 | } | 93 | } |
83 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 94 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
84 | { | 95 | { |
85 | front->getch(ch, sty, pos); | 96 | front->getch(ch, sty, pos); |
86 | } | 97 | } |
98 | /* | ||
99 | void rawgetch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
100 | { | ||
101 | encoder->getch(ch, sty, pos); | ||
102 | } | ||
103 | */ | ||
87 | void addfilter(CFilter_IFace* p) | 104 | void addfilter(CFilter_IFace* p) |
88 | { | 105 | { |
89 | if (first == NULL) | 106 | if (first == NULL) |
90 | { | 107 | { |
91 | front = first = p; | 108 | front = first = p; |
92 | p->setparent(encoder); | 109 | p->setparent(encoder); |
93 | } | 110 | } |
94 | else | 111 | else |
95 | { | 112 | { |
96 | p->setparent(front); | 113 | p->setparent(front); |
97 | front = p; | 114 | front = p; |
98 | } | 115 | } |
@@ -394,46 +411,55 @@ class HighlightFilter : public CFilter | |||
394 | #ifndef __STATIC | 411 | #ifndef __STATIC |
395 | #include <dlfcn.h> | 412 | #include <dlfcn.h> |
396 | 413 | ||
397 | class ExternFilter : public CFilter_IFace | 414 | class ExternFilter : public CFilter_IFace |
398 | { | 415 | { |
399 | CFilter* filt; | 416 | CFilter* filt; |
400 | void *handle; | 417 | void *handle; |
401 | public: | 418 | public: |
402 | linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) | 419 | linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) |
403 | { | 420 | { |
404 | return filt->hyperlink(n, noff, w, nm); | 421 | return filt->hyperlink(n, noff, w, nm); |
405 | } | 422 | } |
423 | QString getTableAsHtml(unsigned long loc) | ||
424 | { | ||
425 | qDebug("ExternFilter::getTableAsHtml()"); | ||
426 | return filt->getTableAsHtml(loc); | ||
427 | } | ||
406 | void setparent(CCharacterSource* p) { filt->setparent(p); } | 428 | void setparent(CCharacterSource* p) { filt->setparent(p); } |
407 | ExternFilter(const QString& nm, const QString& optional); | 429 | ExternFilter(const QString& nm, const QString& optional); |
408 | ~ExternFilter() | 430 | ~ExternFilter() |
409 | { | 431 | { |
410 | if (filt != NULL) delete filt; | 432 | if (filt != NULL) delete filt; |
411 | if (handle != NULL) dlclose(handle); | 433 | if (handle != NULL) dlclose(handle); |
412 | } | 434 | } |
413 | void locate(unsigned int n) { filt->locate(n); } | 435 | void locate(unsigned int n) { filt->locate(n); } |
414 | bool findanchor(const QString& nm) { return filt->findanchor(nm); } | 436 | bool findanchor(const QString& nm) |
437 | { | ||
438 | return filt->findanchor(nm); | ||
439 | } | ||
415 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } | 440 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } |
416 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } | 441 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } |
417 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } | 442 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } |
418 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } | 443 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } |
419 | bool hasnavigation() { return filt->hasnavigation(); } | 444 | bool hasnavigation() { return filt->hasnavigation(); } |
420 | int getwidth() { return filt->getwidth(); } | 445 | int getwidth() { return filt->getwidth(); } |
421 | CCharacterSource* getparent() { return filt->getparent(); } | 446 | CCharacterSource* getparent() { return filt->getparent(); } |
422 | void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } | 447 | void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } |
423 | QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } | 448 | QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } |
424 | CFilter* filter() { return filt; } | 449 | CFilter* filter() { return filt; } |
425 | QImage* getPicture(const QString& href) { return filt->getPicture(href); } | 450 | QImage* getPicture(const QString& href) { return filt->getPicture(href); } |
426 | bool getFile(const QString& href) { return filt->getFile(href); } | 451 | bool getFile(const QString& href, const QString& nm) { return filt->getFile(href, nm); } |
427 | QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); } | 452 | QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); } |
453 | unsigned long startSection() { return filt->startSection(); } | ||
428 | }; | 454 | }; |
429 | #endif | 455 | #endif |
430 | 456 | ||
431 | class kern : public CFilter | 457 | class kern : public CFilter |
432 | { | 458 | { |
433 | tchar lastchar; | 459 | tchar lastchar; |
434 | bool uselast; | 460 | bool uselast; |
435 | CStyle laststy; | 461 | CStyle laststy; |
436 | public: | 462 | public: |
437 | kern() : lastchar(0), uselast(false) {} | 463 | kern() : lastchar(0), uselast(false) {} |
438 | ~kern() {} | 464 | ~kern() {} |
439 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 465 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
@@ -462,13 +488,36 @@ class setbg : public CFilter | |||
462 | QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } | 488 | QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } |
463 | }; | 489 | }; |
464 | 490 | ||
465 | class setfg : public CFilter | 491 | class setfg : public CFilter |
466 | { | 492 | { |
467 | int m_r, m_g, m_b; | 493 | int m_r, m_g, m_b; |
468 | public: | 494 | public: |
469 | setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} | 495 | setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} |
470 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 496 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
471 | QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } | 497 | QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } |
472 | }; | 498 | }; |
473 | 499 | ||
500 | class tableLink : public CFilter | ||
501 | { | ||
502 | QString text; | ||
503 | int offset; | ||
504 | int m_r, m_g, m_b; | ||
505 | public: | ||
506 | tableLink() : text( "See Table" ), offset(-1) | ||
507 | { | ||
508 | } | ||
509 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
510 | QString about() { return QString("Table link filter (c) Tim Wentford\n")+parent->about(); } | ||
511 | }; | ||
512 | |||
513 | class underlineLink : public CFilter | ||
514 | { | ||
515 | bool isLink; | ||
516 | public: | ||
517 | underlineLink() : isLink(false) {} | ||
518 | ~underlineLink() {} | ||
519 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
520 | QString about() { return QString("Link underlining filter (c) Tim Wentford\n")+parent->about(); } | ||
521 | }; | ||
522 | |||
474 | #endif | 523 | #endif |
diff --git a/noncore/apps/opie-reader/CHM.cpp b/noncore/apps/opie-reader/CHM.cpp index 88d53bf..ace5abc 100644 --- a/noncore/apps/opie-reader/CHM.cpp +++ b/noncore/apps/opie-reader/CHM.cpp | |||
@@ -1,19 +1,22 @@ | |||
1 | #include "CHM.h" | 1 | #include "CHM.h" |
2 | #include "chm_lib.h" | 2 | #include "chm_lib.h" |
3 | #include <qstring.h> | 3 | #include <qstring.h> |
4 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <qimage.h> | 6 | #include <qimage.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #ifdef USEQPE | ||
9 | #include <qpe/global.h> | ||
10 | #endif | ||
8 | 11 | ||
9 | #ifndef __STATIC | 12 | #ifndef __STATIC |
10 | extern "C" | 13 | extern "C" |
11 | { | 14 | { |
12 | CExpander* newcodec() { return new CHM; } | 15 | CExpander* newcodec() { return new CHM; } |
13 | } | 16 | } |
14 | #endif | 17 | #endif |
15 | 18 | ||
16 | static int _print_ui_index(struct chmFile *h, struct chmUnitInfo *ui, | 19 | static int _print_ui_index(struct chmFile *h, struct chmUnitInfo *ui, |
17 | void *context) | 20 | void *context) |
18 | { | 21 | { |
19 | CHM *chm = (CHM *)context; | 22 | CHM *chm = (CHM *)context; |
@@ -40,61 +43,66 @@ CHM::CHM() { | |||
40 | chmFile = NULL; | 43 | chmFile = NULL; |
41 | chmPath = ""; | 44 | chmPath = ""; |
42 | chmHHCPath = ""; | 45 | chmHHCPath = ""; |
43 | chmBuffer = ""; | 46 | chmBuffer = ""; |
44 | bufpos = 0; | 47 | bufpos = 0; |
45 | } | 48 | } |
46 | 49 | ||
47 | CHM::~CHM() { | 50 | CHM::~CHM() { |
48 | if (chmFile != NULL) | 51 | if (chmFile != NULL) |
49 | chm_close(chmFile); | 52 | chm_close(chmFile); |
50 | } | 53 | } |
51 | 54 | ||
52 | void CHM::suspend() { | 55 | void CHM::suspend() { |
53 | #ifdef USEQPE | 56 | #ifdef USEQPE |
54 | bSuspended = true; | 57 | bSuspended = true; |
55 | //suspos = gztell(file); | 58 | //suspos = gztell(file); |
56 | chm_close(chmFile); | 59 | chm_close(chmFile); |
57 | chmFile = NULL; | 60 | chmFile = NULL; |
58 | sustime = time(NULL); | 61 | sustime = time(NULL); |
59 | #endif | 62 | #endif |
60 | } | 63 | } |
61 | 64 | ||
62 | void CHM::unsuspend() { | 65 | void CHM::unsuspend() { |
63 | #ifdef USEQPE | 66 | #ifdef USEQPE |
64 | if (bSuspended) | 67 | if (bSuspended) |
65 | { | 68 | { |
66 | bSuspended = false; | 69 | bSuspended = false; |
67 | int delay = time(NULL) - sustime; | 70 | int delay = time(NULL) - sustime; |
68 | if (delay < 10) | 71 | if (delay < 10) |
69 | sleep(10-delay); | 72 | { |
73 | Global::statusMessage("Stalling"); | ||
74 | sleep(10-delay); | ||
75 | } | ||
70 | chmFile = chm_open(fname); | 76 | chmFile = chm_open(fname); |
71 | for (int i = 0; chmFile == NULL && i < 5; i++) { | 77 | for (int i = 0; chmFile == NULL && i < 5; i++) { |
78 | Global::statusMessage("Stalling"); | ||
72 | sleep(5); | 79 | sleep(5); |
73 | chmFile = chm_open(fname); | 80 | chmFile = chm_open(fname); |
74 | } | 81 | } |
75 | if (chmFile == NULL) { | 82 | if (chmFile == NULL) { |
76 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 83 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
77 | exit(0); | 84 | exit(0); |
78 | } | 85 | } |
79 | //suspos = gzseek(file, suspos, SEEK_SET); | 86 | //suspos = gzseek(file, suspos, SEEK_SET); |
80 | } | 87 | } |
81 | #endif | 88 | #endif |
82 | } | 89 | } |
83 | 90 | ||
84 | void CHM::addContent(QString content) { | 91 | void CHM::addContent(QString content) { |
85 | chmBuffer += content; | 92 | chmBuffer += content; |
86 | } | 93 | } |
87 | 94 | ||
88 | void CHM::FillHomeContent() { | 95 | void CHM::FillHomeContent() { |
96 | unsuspend(); | ||
89 | if (chmHHCPath != "") { | 97 | if (chmHHCPath != "") { |
90 | const char *ext; | 98 | const char *ext; |
91 | char buffer[65536]; | 99 | char buffer[65536]; |
92 | unsigned int swath, offset; | 100 | unsigned int swath, offset; |
93 | QString tmp=""; | 101 | QString tmp=""; |
94 | QString HTML=""; | 102 | QString HTML=""; |
95 | /* try to find the file */ | 103 | /* try to find the file */ |
96 | const char *filename = (const char *)chmHHCPath; | 104 | const char *filename = (const char *)chmHHCPath; |
97 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) | 105 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) |
98 | { | 106 | { |
99 | chmBuffer = "HELP"; | 107 | chmBuffer = "HELP"; |
100 | fsize = chmBuffer.length(); | 108 | fsize = chmBuffer.length(); |
@@ -153,24 +161,25 @@ void CHM::FillHomeContent() { | |||
153 | HTML +="</BODY>\r\n"; | 161 | HTML +="</BODY>\r\n"; |
154 | HTML +="</HTML>\r\n"; | 162 | HTML +="</HTML>\r\n"; |
155 | chmHomeBuffer = HTML; | 163 | chmHomeBuffer = HTML; |
156 | chmBuffer = HTML; | 164 | chmBuffer = HTML; |
157 | fsize = chmBuffer.length(); | 165 | fsize = chmBuffer.length(); |
158 | m_currentstart = m_ui.start; | 166 | m_currentstart = m_ui.start; |
159 | m_currentend = m_currentstart+chmBuffer.length(); | 167 | m_currentend = m_currentstart+chmBuffer.length(); |
160 | } | 168 | } |
161 | } | 169 | } |
162 | 170 | ||
163 | bool CHM::FillBuffer() | 171 | bool CHM::FillBuffer() |
164 | { | 172 | { |
173 | unsuspend(); | ||
165 | bool bRetVal = false; | 174 | bool bRetVal = false; |
166 | char buffer[65536]; | 175 | char buffer[65536]; |
167 | int swath, offset; | 176 | int swath, offset; |
168 | chmBuffer = ""; | 177 | chmBuffer = ""; |
169 | swath = 65536; | 178 | swath = 65536; |
170 | offset = 0; | 179 | offset = 0; |
171 | fsize = m_ui.length; | 180 | fsize = m_ui.length; |
172 | while (offset < m_ui.length) | 181 | while (offset < m_ui.length) |
173 | { | 182 | { |
174 | if ((m_ui.length - offset) < 65536) | 183 | if ((m_ui.length - offset) < 65536) |
175 | swath = m_ui.length - offset; | 184 | swath = m_ui.length - offset; |
176 | else | 185 | else |
@@ -187,24 +196,25 @@ bool CHM::FillBuffer() | |||
187 | chmBuffer = chmBuffer+"</HTML>"; | 196 | chmBuffer = chmBuffer+"</HTML>"; |
188 | } | 197 | } |
189 | fsize = chmBuffer.length(); | 198 | fsize = chmBuffer.length(); |
190 | 199 | ||
191 | bufpos = 0; | 200 | bufpos = 0; |
192 | bRetVal = true; | 201 | bRetVal = true; |
193 | m_currentstart = m_ui.start; | 202 | m_currentstart = m_ui.start; |
194 | m_currentend = m_currentstart+chmBuffer.length(); | 203 | m_currentend = m_currentstart+chmBuffer.length(); |
195 | return bRetVal; | 204 | return bRetVal; |
196 | } | 205 | } |
197 | 206 | ||
198 | bool CHM::FillContent() { | 207 | bool CHM::FillContent() { |
208 | unsuspend(); | ||
199 | bool bRetVal = false; | 209 | bool bRetVal = false; |
200 | if (chmPath != "") { | 210 | if (chmPath != "") { |
201 | /* try to find the file */ | 211 | /* try to find the file */ |
202 | const char *filename = (const char *)chmPath; | 212 | const char *filename = (const char *)chmPath; |
203 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) | 213 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) |
204 | { | 214 | { |
205 | fsize = chmBuffer.length(); | 215 | fsize = chmBuffer.length(); |
206 | return bRetVal; | 216 | return bRetVal; |
207 | } | 217 | } |
208 | 218 | ||
209 | char buffer[65536]; | 219 | char buffer[65536]; |
210 | int swath, offset; | 220 | int swath, offset; |
@@ -230,25 +240,26 @@ bool CHM::FillContent() { | |||
230 | chmBuffer = chmBuffer+"</HTML>"; | 240 | chmBuffer = chmBuffer+"</HTML>"; |
231 | } | 241 | } |
232 | fsize = chmBuffer.length(); | 242 | fsize = chmBuffer.length(); |
233 | 243 | ||
234 | bufpos = 0; | 244 | bufpos = 0; |
235 | m_currentstart = m_ui.start; | 245 | m_currentstart = m_ui.start; |
236 | m_currentend = m_currentstart+chmBuffer.length(); | 246 | m_currentend = m_currentstart+chmBuffer.length(); |
237 | bRetVal = true; | 247 | bRetVal = true; |
238 | } | 248 | } |
239 | return bRetVal; | 249 | return bRetVal; |
240 | } | 250 | } |
241 | 251 | ||
242 | bool CHM::getFile(const QString& href) { | 252 | bool CHM::getFile(const QString& _href, const QString& ) { |
253 | QString href = "/" + _href; | ||
243 | qDebug("Got:%s", (const char*)href); | 254 | qDebug("Got:%s", (const char*)href); |
244 | bool bRetVal = false; | 255 | bool bRetVal = false; |
245 | QString temp = chmPath; | 256 | QString temp = chmPath; |
246 | chmPath = href; | 257 | chmPath = href; |
247 | if (FillContent()) { | 258 | if (FillContent()) { |
248 | qDebug("Got it"); | 259 | qDebug("Got it"); |
249 | bRetVal = true; | 260 | bRetVal = true; |
250 | } else { | 261 | } else { |
251 | qDebug("Missed"); | 262 | qDebug("Missed"); |
252 | chmPath = temp; | 263 | chmPath = temp; |
253 | FillContent(); | 264 | FillContent(); |
254 | } | 265 | } |
@@ -310,29 +321,29 @@ int CHM::OpenFile(const char *src) { | |||
310 | setHomePath(chmPath); | 321 | setHomePath(chmPath); |
311 | FillHomeContent(); | 322 | FillHomeContent(); |
312 | } | 323 | } |
313 | } | 324 | } |
314 | m_homepos = locate(); | 325 | m_homepos = locate(); |
315 | qDebug("Home:%u", m_homepos); | 326 | qDebug("Home:%u", m_homepos); |
316 | return (chmFile==NULL); | 327 | return (chmFile==NULL); |
317 | } | 328 | } |
318 | 329 | ||
319 | int CHM::getch() { | 330 | int CHM::getch() { |
320 | if ( (bufpos+1) >= chmBuffer.length() ) | 331 | if ( (bufpos+1) >= chmBuffer.length() ) |
321 | return EOF; | 332 | return EOF; |
322 | #ifdef _WINDOWS | 333 | #ifdef _WINDOWS |
323 | QChar letter = chmBuffer.at(bufpos++); | 334 | QChar letter = chmBuffer.at(bufpos++); |
324 | #else | 335 | #else |
325 | QChar letter = chmBuffer[bufpos++]; | 336 | QChar letter = chmBuffer[bufpos++]; |
326 | #endif | 337 | #endif |
327 | return (int)(char)letter; | 338 | return (int)(char)letter; |
328 | } | 339 | } |
329 | 340 | ||
330 | void CHM::getch(tchar& ch, CStyle& sty) | 341 | void CHM::getch(tchar& ch, CStyle& sty) |
331 | { | 342 | { |
332 | int ich = getch(); | 343 | int ich = getch(); |
333 | ch = (ich == EOF) ? UEOF : ich; | 344 | ch = (ich == EOF) ? UEOF : ich; |
334 | } | 345 | } |
335 | 346 | ||
336 | void CHM::start2endSection() | 347 | void CHM::start2endSection() |
337 | { | 348 | { |
338 | m_currentstart = m_ui.start; | 349 | m_currentstart = m_ui.start; |
diff --git a/noncore/apps/opie-reader/CHM.h b/noncore/apps/opie-reader/CHM.h index 001f7fc..291818d 100644 --- a/noncore/apps/opie-reader/CHM.h +++ b/noncore/apps/opie-reader/CHM.h | |||
@@ -47,21 +47,21 @@ public: | |||
47 | unsigned int locate(); | 47 | unsigned int locate(); |
48 | void locate(unsigned int n); | 48 | void locate(unsigned int n); |
49 | bool hasrandomaccess() { return true; } | 49 | bool hasrandomaccess() { return true; } |
50 | void sizes(unsigned long& _file, unsigned long& _text); | 50 | void sizes(unsigned long& _file, unsigned long& _text); |
51 | void addContent(QString content); | 51 | void addContent(QString content); |
52 | void getch(tchar& ch, CStyle& sty); | 52 | void getch(tchar& ch, CStyle& sty); |
53 | void setPath(QString PathName) {chmPath = PathName;}; | 53 | void setPath(QString PathName) {chmPath = PathName;}; |
54 | void setHomePath(QString PathName) {chmHHCPath = PathName;}; | 54 | void setHomePath(QString PathName) {chmHHCPath = PathName;}; |
55 | 55 | ||
56 | MarkupType PreferredMarkup() { | 56 | MarkupType PreferredMarkup() { |
57 | return cCHM; | 57 | return cCHM; |
58 | } | 58 | } |
59 | bool getFile(const QString& href); | 59 | bool getFile(const QString& href, const QString& nm); |
60 | QImage *getPicture(const QString& href); | 60 | QImage *getPicture(const QString& href); |
61 | 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"); } |
62 | private : | 62 | private : |
63 | bool FillBuffer(); | 63 | bool FillBuffer(); |
64 | bool FillContent(); | 64 | bool FillContent(); |
65 | void FillHomeContent(); | 65 | void FillHomeContent(); |
66 | }; | 66 | }; |
67 | #endif | 67 | #endif |
diff --git a/noncore/apps/opie-reader/CRegExp.cpp b/noncore/apps/opie-reader/CRegExp.cpp index 77dc2dc..6318d28 100644 --- a/noncore/apps/opie-reader/CRegExp.cpp +++ b/noncore/apps/opie-reader/CRegExp.cpp | |||
@@ -52,126 +52,126 @@ void CRegExpFilt::regchar(tchar c, bool insens) | |||
52 | CV[t] = 0; | 52 | CV[t] = 0; |
53 | } | 53 | } |
54 | else | 54 | else |
55 | { | 55 | { |
56 | CV[c] = 0; | 56 | CV[c] = 0; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | void CRegExpFilt::prepreprocessing(const QString& pat, bool insens) | 60 | void CRegExpFilt::prepreprocessing(const QString& pat, bool insens) |
61 | { | 61 | { |
62 | for (unsigned int p = 0; p < pat.length(); p++) | 62 | for (unsigned int p = 0; p < pat.length(); p++) |
63 | { | 63 | { |
64 | #ifdef _WINDOWS | 64 | #ifdef _WINDOWS |
65 | switch (pat.at(p).unicode()) | 65 | switch (pat.at(p).unicode()) |
66 | #else | 66 | #else |
67 | switch (pat[p].unicode()) | 67 | switch (pat[p].unicode()) |
68 | #endif | 68 | #endif |
69 | { | 69 | { |
70 | case '{': | 70 | case '{': |
71 | { | 71 | { |
72 | break; | 72 | break; |
73 | } | 73 | } |
74 | case '}': | 74 | case '}': |
75 | { | 75 | { |
76 | break; | 76 | break; |
77 | } | 77 | } |
78 | case '^': | 78 | case '^': |
79 | { | 79 | { |
80 | break; | 80 | break; |
81 | } | 81 | } |
82 | case '.' : | 82 | case '.' : |
83 | { | 83 | { |
84 | break; | 84 | break; |
85 | } | 85 | } |
86 | case '#': | 86 | case '#': |
87 | { | 87 | { |
88 | p++; | 88 | p++; |
89 | #ifdef _WINDOWS | 89 | #ifdef _WINDOWS |
90 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') | 90 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') |
91 | #else | 91 | #else |
92 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') | 92 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') |
93 | #endif | 93 | #endif |
94 | { | 94 | { |
95 | } | 95 | } |
96 | p--; | 96 | p--; |
97 | break; | 97 | break; |
98 | } | 98 | } |
99 | case '\\' : | 99 | case '\\' : |
100 | { | 100 | { |
101 | #ifdef _WINDOWS | 101 | #ifdef _WINDOWS |
102 | tchar c = escapedchar(pat.at(++p).unicode()); | 102 | tchar c = escapedchar(pat.at(++p).unicode()); |
103 | #else | 103 | #else |
104 | tchar c = escapedchar(pat[++p].unicode()); | 104 | tchar c = escapedchar(pat[++p].unicode()); |
105 | #endif | 105 | #endif |
106 | regchar(c, insens); | 106 | regchar(c, insens); |
107 | break; | 107 | break; |
108 | } | 108 | } |
109 | 109 | ||
110 | case '[' : | 110 | case '[' : |
111 | { | 111 | { |
112 | tchar clast; | 112 | tchar clast; |
113 | bool invert = false; | 113 | bool invert = false; |
114 | tchar c; | 114 | tchar c; |
115 | #ifdef _WINDOWS | 115 | #ifdef _WINDOWS |
116 | if (pat.at(p+1).unicode() == '^') | 116 | if (pat.at(p+1).unicode() == '^') |
117 | #else | 117 | #else |
118 | if (pat[p+1].unicode() == '^') | 118 | if (pat[p+1].unicode() == '^') |
119 | #endif | 119 | #endif |
120 | { | 120 | { |
121 | p++; | 121 | p++; |
122 | invert = true; | 122 | invert = true; |
123 | } | 123 | } |
124 | #ifdef _WINDOWS | 124 | #ifdef _WINDOWS |
125 | while ((c = pat.at(++p).unicode()) != ']') | 125 | while ((c = pat.at(++p).unicode()) != ']') |
126 | #else | 126 | #else |
127 | while ((c = pat[++p].unicode()) != ']') | 127 | while ((c = pat[++p].unicode()) != ']') |
128 | #endif | 128 | #endif |
129 | { | 129 | { |
130 | if (c == '\\') | 130 | if (c == '\\') |
131 | { | 131 | { |
132 | #ifdef _WINDOWS | 132 | #ifdef _WINDOWS |
133 | c = escapedchar(pat.at(++p).unicode()); | 133 | c = escapedchar(pat.at(++p).unicode()); |
134 | #else | 134 | #else |
135 | c = escapedchar(pat[++p].unicode()); | 135 | c = escapedchar(pat[++p].unicode()); |
136 | #endif | 136 | #endif |
137 | if (c == ']') break; | 137 | if (c == ']') break; |
138 | } | 138 | } |
139 | if (c == '-') | 139 | if (c == '-') |
140 | { | 140 | { |
141 | #ifdef _WINDOWS | 141 | #ifdef _WINDOWS |
142 | c = pat.at(++p).unicode(); | 142 | c = pat.at(++p).unicode(); |
143 | #else | 143 | #else |
144 | c = pat[++p].unicode(); | 144 | c = pat[++p].unicode(); |
145 | #endif | 145 | #endif |
146 | for (tchar j = clast; j <= c; j++) | 146 | for (tchar j = clast; j <= c; j++) |
147 | { | 147 | { |
148 | regchar(j, insens); | 148 | regchar(j, insens); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | else | 151 | else |
152 | { | 152 | { |
153 | regchar(c, insens); | 153 | regchar(c, insens); |
154 | } | 154 | } |
155 | clast = c; | 155 | clast = c; |
156 | } | 156 | } |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | default : | 159 | default : |
160 | { | 160 | { |
161 | #ifdef _WINDOWS | 161 | #ifdef _WINDOWS |
162 | regchar(pat.at(p).unicode(), insens); | 162 | regchar(pat.at(p).unicode(), insens); |
163 | #else | 163 | #else |
164 | regchar(pat[p].unicode(), insens); | 164 | regchar(pat[p].unicode(), insens); |
165 | #endif | 165 | #endif |
166 | break; | 166 | break; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } | 169 | } |
170 | /* | 170 | /* |
171 | for (iter i = CV.begin(); i != CV.end(); ++i) | 171 | for (iter i = CV.begin(); i != CV.end(); ++i) |
172 | { | 172 | { |
173 | printf("Pre: [%u]\n", i.first()); | 173 | printf("Pre: [%u]\n", i.first()); |
174 | } | 174 | } |
175 | */ | 175 | */ |
176 | CV[0] = 0; | 176 | CV[0] = 0; |
177 | } | 177 | } |
@@ -184,30 +184,30 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) | |||
184 | bool inkeep = false; | 184 | bool inkeep = false; |
185 | keep = 0; | 185 | keep = 0; |
186 | replace = 0; | 186 | replace = 0; |
187 | for (unsigned int j = 0; j < WORD_SIZE; j++) | 187 | for (unsigned int j = 0; j < WORD_SIZE; j++) |
188 | { | 188 | { |
189 | bit[j] = (1 << (WORD_SIZE -j -1)); | 189 | bit[j] = (1 << (WORD_SIZE -j -1)); |
190 | lfcnt[j] = 0; | 190 | lfcnt[j] = 0; |
191 | } | 191 | } |
192 | 192 | ||
193 | for (p = 0, m = 0; p < pat.length(); p++) | 193 | for (p = 0, m = 0; p < pat.length(); p++) |
194 | { | 194 | { |
195 | qDebug("m is %u", m); | 195 | qDebug("m is %u", m); |
196 | if (inkeep) keep |= bit[m]; | 196 | if (inkeep) keep |= bit[m]; |
197 | #ifdef _WINDOWS | 197 | #ifdef _WINDOWS |
198 | switch (pat.at(p).unicode()) | 198 | switch (pat.at(p).unicode()) |
199 | #else | 199 | #else |
200 | switch (pat[p].unicode()) | 200 | switch (pat[p].unicode()) |
201 | #endif | 201 | #endif |
202 | { | 202 | { |
203 | case '{': | 203 | case '{': |
204 | { | 204 | { |
205 | inkeep = true; | 205 | inkeep = true; |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | case '}': | 208 | case '}': |
209 | { | 209 | { |
210 | keep ^= bit[m]; | 210 | keep ^= bit[m]; |
211 | inkeep = false; | 211 | inkeep = false; |
212 | break; | 212 | break; |
213 | } | 213 | } |
@@ -219,36 +219,36 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) | |||
219 | } | 219 | } |
220 | case '.' : | 220 | case '.' : |
221 | { | 221 | { |
222 | for (iter j = CV.begin(); j != CV.end(); ++j) CV[j.first()] |= bit[m]; | 222 | for (iter j = CV.begin(); j != CV.end(); ++j) CV[j.first()] |= bit[m]; |
223 | m++; | 223 | m++; |
224 | break; | 224 | break; |
225 | } | 225 | } |
226 | case '#': | 226 | case '#': |
227 | { | 227 | { |
228 | if (m > 0) | 228 | if (m > 0) |
229 | { | 229 | { |
230 | p++; | 230 | p++; |
231 | int count = 0; | 231 | int count = 0; |
232 | #ifdef _WINDOWS | 232 | #ifdef _WINDOWS |
233 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') | 233 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') |
234 | #else | 234 | #else |
235 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') | 235 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') |
236 | #endif | 236 | #endif |
237 | { | 237 | { |
238 | #ifdef _WINDOWS | 238 | #ifdef _WINDOWS |
239 | count = 10*count + pat.at(p++).unicode() - '0'; | 239 | count = 10*count + pat.at(p++).unicode() - '0'; |
240 | #else | 240 | #else |
241 | count = 10*count + pat[p++].unicode() - '0'; | 241 | count = 10*count + pat[p++].unicode() - '0'; |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | p--; | 244 | p--; |
245 | count = count-1; | 245 | count = count-1; |
246 | unsigned int mask = 0; | 246 | unsigned int mask = 0; |
247 | for (unsigned int i = m; i < m+count; i++) | 247 | for (unsigned int i = m; i < m+count; i++) |
248 | { | 248 | { |
249 | mask |= bit[i]; | 249 | mask |= bit[i]; |
250 | } | 250 | } |
251 | 251 | ||
252 | for (iter it = CV.begin(); it != CV.end(); ++it) | 252 | for (iter it = CV.begin(); it != CV.end(); ++it) |
253 | { | 253 | { |
254 | if (CV[it.first()] & bit[m-1]) | 254 | if (CV[it.first()] & bit[m-1]) |
@@ -257,78 +257,78 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) | |||
257 | } | 257 | } |
258 | } | 258 | } |
259 | if (keep & bit[m-1]) keep |= mask; | 259 | if (keep & bit[m-1]) keep |= mask; |
260 | m += count; | 260 | m += count; |
261 | } | 261 | } |
262 | else | 262 | else |
263 | { | 263 | { |
264 | p++; | 264 | p++; |
265 | } | 265 | } |
266 | break; | 266 | break; |
267 | } | 267 | } |
268 | case '\\' : | 268 | case '\\' : |
269 | { | 269 | { |
270 | #ifdef _WINDOWS | 270 | #ifdef _WINDOWS |
271 | tchar c = escapedchar(pat.at(++p).unicode()); | 271 | tchar c = escapedchar(pat.at(++p).unicode()); |
272 | #else | 272 | #else |
273 | tchar c = escapedchar(pat[++p].unicode()); | 273 | tchar c = escapedchar(pat[++p].unicode()); |
274 | #endif | 274 | #endif |
275 | if (insens) | 275 | if (insens) |
276 | { | 276 | { |
277 | CV[upper(c)] |= bit[m]; | 277 | CV[upper(c)] |= bit[m]; |
278 | CV[lower(c)] |= bit[m]; | 278 | CV[lower(c)] |= bit[m]; |
279 | } | 279 | } |
280 | else | 280 | else |
281 | { | 281 | { |
282 | CV[c] |= bit[m]; | 282 | CV[c] |= bit[m]; |
283 | } | 283 | } |
284 | m++; | 284 | m++; |
285 | break; | 285 | break; |
286 | } | 286 | } |
287 | 287 | ||
288 | case '[' : | 288 | case '[' : |
289 | { | 289 | { |
290 | tchar c, clast; | 290 | tchar c, clast; |
291 | bool invert = false; | 291 | bool invert = false; |
292 | #ifdef _WINDOWS | 292 | #ifdef _WINDOWS |
293 | if (pat.at(p+1).unicode() == '^') | 293 | if (pat.at(p+1).unicode() == '^') |
294 | #else | 294 | #else |
295 | if (pat[p+1].unicode() == '^') | 295 | if (pat[p+1].unicode() == '^') |
296 | #endif | 296 | #endif |
297 | { | 297 | { |
298 | p++; | 298 | p++; |
299 | invert = true; | 299 | invert = true; |
300 | } | 300 | } |
301 | #ifdef _WINDOWS | 301 | #ifdef _WINDOWS |
302 | while ((c = pat.at(++p).unicode()) != ']') | 302 | while ((c = pat.at(++p).unicode()) != ']') |
303 | #else | 303 | #else |
304 | while ((c = pat[++p].unicode()) != ']') | 304 | while ((c = pat[++p].unicode()) != ']') |
305 | #endif | 305 | #endif |
306 | { | 306 | { |
307 | if (c == '\\') | 307 | if (c == '\\') |
308 | { | 308 | { |
309 | #ifdef _WINDOWS | 309 | #ifdef _WINDOWS |
310 | c = escapedchar(pat.at(++p).unicode()); | 310 | c = escapedchar(pat.at(++p).unicode()); |
311 | #else | 311 | #else |
312 | c = escapedchar(pat[++p].unicode()); | 312 | c = escapedchar(pat[++p].unicode()); |
313 | #endif | 313 | #endif |
314 | if (c == ']') break; | 314 | if (c == ']') break; |
315 | } | 315 | } |
316 | if (c == '-') | 316 | if (c == '-') |
317 | { | 317 | { |
318 | #ifdef _WINDOWS | 318 | #ifdef _WINDOWS |
319 | c = pat.at(++p).unicode(); | 319 | c = pat.at(++p).unicode(); |
320 | #else | 320 | #else |
321 | c = pat[++p].unicode(); | 321 | c = pat[++p].unicode(); |
322 | #endif | 322 | #endif |
323 | for (tchar j = clast; j <= c; j++) | 323 | for (tchar j = clast; j <= c; j++) |
324 | { | 324 | { |
325 | if (insens) | 325 | if (insens) |
326 | { | 326 | { |
327 | iter it; | 327 | iter it; |
328 | if ((it = CV.find(upper(j))) != CV.end()) | 328 | if ((it = CV.find(upper(j))) != CV.end()) |
329 | CV[it] |= bit[m]; | 329 | CV[it] |= bit[m]; |
330 | else | 330 | else |
331 | CV[0] |= bit[m]; | 331 | CV[0] |= bit[m]; |
332 | if ((it = CV.find(lower(j))) != CV.end()) | 332 | if ((it = CV.find(lower(j))) != CV.end()) |
333 | CV[it] |= bit[m]; | 333 | CV[it] |= bit[m]; |
334 | else | 334 | else |
@@ -373,30 +373,30 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) | |||
373 | } | 373 | } |
374 | if (invert) | 374 | if (invert) |
375 | { | 375 | { |
376 | for (iter i = CV.begin(); i != CV.end(); ++i) | 376 | for (iter i = CV.begin(); i != CV.end(); ++i) |
377 | { | 377 | { |
378 | CV[i.first()] ^= bit[m]; | 378 | CV[i.first()] ^= bit[m]; |
379 | } | 379 | } |
380 | } | 380 | } |
381 | m++; | 381 | m++; |
382 | break; | 382 | break; |
383 | } | 383 | } |
384 | default : | 384 | default : |
385 | { | 385 | { |
386 | #ifdef _WINDOWS | 386 | #ifdef _WINDOWS |
387 | tchar c = pat.at(p).unicode(); | 387 | tchar c = pat.at(p).unicode(); |
388 | #else | 388 | #else |
389 | tchar c = pat[p].unicode(); | 389 | tchar c = pat[p].unicode(); |
390 | #endif | 390 | #endif |
391 | if (insens) | 391 | if (insens) |
392 | { | 392 | { |
393 | CV[upper(c)] |= bit[m]; | 393 | CV[upper(c)] |= bit[m]; |
394 | CV[lower(c)] |= bit[m]; | 394 | CV[lower(c)] |= bit[m]; |
395 | } | 395 | } |
396 | else CV[c] |= bit[m]; | 396 | else CV[c] |= bit[m]; |
397 | m++; | 397 | m++; |
398 | break; | 398 | break; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | } | 401 | } |
402 | qDebug("Returning:%u",m); | 402 | qDebug("Returning:%u",m); |
diff --git a/noncore/apps/opie-reader/CSource.h b/noncore/apps/opie-reader/CSource.h new file mode 100644 index 0000000..2885f72 --- a/dev/null +++ b/noncore/apps/opie-reader/CSource.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef __CSOURCE_H | ||
2 | #define __CSOURCE_H | ||
3 | |||
4 | class CInfo | ||
5 | { | ||
6 | public: | ||
7 | virtual unsigned long size() = 0; | ||
8 | }; | ||
9 | |||
10 | class CSource : public CInfo | ||
11 | { | ||
12 | public: | ||
13 | virtual int get() = 0; | ||
14 | }; | ||
15 | |||
16 | class CSink : public CInfo | ||
17 | { | ||
18 | public: | ||
19 | virtual void put(unsigned char c) = 0; | ||
20 | }; | ||
21 | |||
22 | class CMemSource : public CSource | ||
23 | { | ||
24 | unsigned long m_total_size; | ||
25 | unsigned long m_current; | ||
26 | unsigned char* m_buffer; | ||
27 | public: | ||
28 | CMemSource(unsigned char* _buffer, unsigned long _size) | ||
29 | : | ||
30 | m_total_size(_size), | ||
31 | m_current(0), | ||
32 | m_buffer(_buffer) | ||
33 | {} | ||
34 | unsigned long size() { return m_current; } | ||
35 | int get() | ||
36 | { | ||
37 | return ((m_current < m_total_size) ? m_buffer[m_current++] : -1); | ||
38 | } | ||
39 | }; | ||
40 | |||
41 | class CMemSink : public CSink | ||
42 | { | ||
43 | unsigned long m_total_size; | ||
44 | unsigned long m_current; | ||
45 | unsigned char* m_buffer; | ||
46 | public: | ||
47 | CMemSink(unsigned char* _buffer, unsigned long _size) | ||
48 | : | ||
49 | m_total_size(_size), | ||
50 | m_current(0), | ||
51 | m_buffer(_buffer) | ||
52 | {} | ||
53 | unsigned long size() { return m_current; } | ||
54 | void put(unsigned char c) | ||
55 | { | ||
56 | if (m_current < m_total_size) | ||
57 | { | ||
58 | m_buffer[m_current++] = c; | ||
59 | } | ||
60 | } | ||
61 | }; | ||
62 | #endif | ||
diff --git a/noncore/apps/opie-reader/Coder.h b/noncore/apps/opie-reader/Coder.h new file mode 100644 index 0000000..64587cf --- a/dev/null +++ b/noncore/apps/opie-reader/Coder.h | |||
@@ -0,0 +1,113 @@ | |||
1 | #include "CSource.h" | ||
2 | /**************************************************************************** | ||
3 | * This file is part of PPMd project * | ||
4 | * Contents: 'Carryless rangecoder' by Dmitry Subbotin * | ||
5 | * Comments: this implementation is claimed to be a public domain * | ||
6 | ****************************************************************************/ | ||
7 | /********************** Original text ************************************* | ||
8 | //////// Carryless rangecoder (c) 1999 by Dmitry Subbotin //////// | ||
9 | |||
10 | typedef unsigned int uint; | ||
11 | typedef unsigned char uc; | ||
12 | |||
13 | #define DO(n) for (int _=0; _<n; _++) | ||
14 | #define TOP (1<<24) | ||
15 | #define BOT (1<<16) | ||
16 | |||
17 | |||
18 | class RangeCoder | ||
19 | { | ||
20 | uint low, code, range, passed; | ||
21 | FILE *f; | ||
22 | |||
23 | void OutByte (uc c) { passed++; fputc(c,f); } | ||
24 | uc InByte () { passed++; return fgetc(f); } | ||
25 | |||
26 | public: | ||
27 | |||
28 | uint GetPassed () { return passed; } | ||
29 | void StartEncode (FILE *F) { f=F; passed=low=0; range= (uint) -1; } | ||
30 | void FinishEncode () { DO(4) OutByte(low>>24), low<<=8; } | ||
31 | void StartDecode (FILE *F) { passed=low=code=0; range= (uint) -1; | ||
32 | f=F; DO(4) code= code<<8 | InByte(); | ||
33 | } | ||
34 | |||
35 | void Encode (uint cumFreq, uint freq, uint totFreq) { | ||
36 | assert(cumFreq+freq<totFreq && freq && totFreq<=BOT); | ||
37 | low += cumFreq * (range/= totFreq); | ||
38 | range*= freq; | ||
39 | while ((low ^ low+range)<TOP || range<BOT && ((range= -low & BOT-1),1)) | ||
40 | OutByte(low>>24), range<<=8, low<<=8; | ||
41 | } | ||
42 | |||
43 | uint GetFreq (uint totFreq) { | ||
44 | uint tmp= (code-low) / (range/= totFreq); | ||
45 | if (tmp >= totFreq) throw ("Input data corrupt"); // or force it to return | ||
46 | return tmp; // a valid value :) | ||
47 | } | ||
48 | |||
49 | void Decode (uint cumFreq, uint freq, uint totFreq) { | ||
50 | assert(cumFreq+freq<totFreq && freq && totFreq<=BOT); | ||
51 | low += cumFreq*range; | ||
52 | range*= freq; | ||
53 | while ((low ^ low+range)<TOP || range<BOT && ((range= -low & BOT-1),1)) | ||
54 | code= code<<8 | InByte(), range<<=8, low<<=8; | ||
55 | } | ||
56 | }; | ||
57 | *****************************************************************************/ | ||
58 | |||
59 | static struct SUBRANGE { | ||
60 | DWORD LowCount, HighCount, scale; | ||
61 | } SubRange; | ||
62 | enum { TOP=1 << 24, BOT=1 << 15 }; | ||
63 | static DWORD low, code, range; | ||
64 | |||
65 | inline void ariInitEncoder() | ||
66 | { | ||
67 | low=0; range=DWORD(-1); | ||
68 | } | ||
69 | #define ARI_ENC_NORMALIZE(stream) { \ | ||
70 | while ((low ^ (low+range)) < TOP || range < BOT && \ | ||
71 | ((range= -low & (BOT-1)),1)) { \ | ||
72 | _PPMD_E_PUTC(low >> 24,stream); \ | ||
73 | range <<= 8; low <<= 8; \ | ||
74 | } \ | ||
75 | } | ||
76 | inline void ariEncodeSymbol() | ||
77 | { | ||
78 | low += SubRange.LowCount*(range /= SubRange.scale); | ||
79 | range *= SubRange.HighCount-SubRange.LowCount; | ||
80 | } | ||
81 | inline void ariShiftEncodeSymbol(UINT SHIFT) | ||
82 | { | ||
83 | low += SubRange.LowCount*(range >>= SHIFT); | ||
84 | range *= SubRange.HighCount-SubRange.LowCount; | ||
85 | } | ||
86 | #define ARI_FLUSH_ENCODER(stream) { \ | ||
87 | for (UINT i=0;i < 4;i++) { \ | ||
88 | _PPMD_E_PUTC(low >> 24,stream); low <<= 8; \ | ||
89 | } \ | ||
90 | } | ||
91 | #define ARI_INIT_DECODER(stream) { \ | ||
92 | low=code=0; range=DWORD(-1); \ | ||
93 | for (UINT i=0;i < 4;i++) \ | ||
94 | code=(code << 8) | _PPMD_D_GETC(stream); \ | ||
95 | } | ||
96 | #define ARI_DEC_NORMALIZE(stream) { \ | ||
97 | while ((low ^ (low+range)) < TOP || range < BOT && \ | ||
98 | ((range= -low & (BOT-1)),1)) { \ | ||
99 | code=(code << 8) | _PPMD_D_GETC(stream); \ | ||
100 | range <<= 8; low <<= 8; \ | ||
101 | } \ | ||
102 | } | ||
103 | inline UINT ariGetCurrentCount() { | ||
104 | return (code-low)/(range /= SubRange.scale); | ||
105 | } | ||
106 | inline UINT ariGetCurrentShiftCount(UINT SHIFT) { | ||
107 | return (code-low)/(range >>= SHIFT); | ||
108 | } | ||
109 | inline void ariRemoveSubrange() | ||
110 | { | ||
111 | low += range*SubRange.LowCount; | ||
112 | range *= SubRange.HighCount-SubRange.LowCount; | ||
113 | } | ||
diff --git a/noncore/apps/opie-reader/FliteCmd/.cvsignore b/noncore/apps/opie-reader/FliteCmd/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteCmd/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/FliteCmd/FliteCmd.pro b/noncore/apps/opie-reader/FliteCmd/FliteCmd.pro new file mode 100644 index 0000000..0e1a782 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteCmd/FliteCmd.pro | |||
@@ -0,0 +1,18 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = flitecmd.h | ||
6 | |||
7 | SOURCES = flitecmd.cpp | ||
8 | |||
9 | |||
10 | INTERFACES= | ||
11 | DESTDIR = $(OPIEDIR)/plugins/reader/outcodecs | ||
12 | TARGET = flitecmd | ||
13 | |||
14 | |||
15 | INCLUDEPATH+= $(OPIEDIR)/include | ||
16 | DEPENDPATH += $(OPIEDIR)/include | ||
17 | |||
18 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/apps/opie-reader/FliteDyn/.cvsignore b/noncore/apps/opie-reader/FliteDyn/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteDyn/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/FliteDyn/FliteDyn.pro b/noncore/apps/opie-reader/FliteDyn/FliteDyn.pro new file mode 100644 index 0000000..a949209 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteDyn/FliteDyn.pro | |||
@@ -0,0 +1,18 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = flitedyn.h | ||
6 | |||
7 | SOURCES = flitedyn.cpp | ||
8 | |||
9 | |||
10 | INTERFACES= | ||
11 | DESTDIR = $(OPIEDIR)/plugins/reader/outcodecs | ||
12 | TARGET = flitedyn | ||
13 | LIBS += -L/home/tim/flite/flite-1.2-release/lib -lflite_cmu_us_kal -lflite_usenglish -lflite_cmulex -lflite | ||
14 | |||
15 | INCLUDEPATH+= /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include | ||
16 | DEPENDPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include | ||
17 | |||
18 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/apps/opie-reader/FliteDyn16/.cvsignore b/noncore/apps/opie-reader/FliteDyn16/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteDyn16/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/FliteDyn16/FliteDyn16.pro b/noncore/apps/opie-reader/FliteDyn16/FliteDyn16.pro new file mode 100644 index 0000000..49c2c42 --- a/dev/null +++ b/noncore/apps/opie-reader/FliteDyn16/FliteDyn16.pro | |||
@@ -0,0 +1,18 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = flitedyn.h | ||
6 | |||
7 | SOURCES = flitedyn.cpp | ||
8 | |||
9 | |||
10 | INTERFACES= | ||
11 | DESTDIR = $(OPIEDIR)/plugins/reader/outcodecs | ||
12 | TARGET = flitedyn | ||
13 | LIBS += -L/home/tim/flite/flite-1.2-release/lib -lflite_cmu_us_kal16 -lflite_usenglish -lflite_cmulex -lflite | ||
14 | |||
15 | INCLUDEPATH+= /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include | ||
16 | DEPENDPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include | ||
17 | |||
18 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp index 9bb3bc0..08b8c52 100644 --- a/noncore/apps/opie-reader/FontControl.cpp +++ b/noncore/apps/opie-reader/FontControl.cpp | |||
@@ -1,13 +1,14 @@ | |||
1 | #include <qfontdatabase.h> | 1 | #include <qfontdatabase.h> |
2 | |||
2 | #include "FontControl.h" | 3 | #include "FontControl.h" |
3 | 4 | ||
4 | int FontControl::gzoom() | 5 | int FontControl::gzoom() |
5 | { | 6 | { |
6 | if (m_fixgraphics) | 7 | if (m_fixgraphics) |
7 | { | 8 | { |
8 | return 100; | 9 | return 100; |
9 | } | 10 | } |
10 | else | 11 | else |
11 | { | 12 | { |
12 | int ret; | 13 | int ret; |
13 | if (m_size == g_size) | 14 | if (m_size == g_size) |
diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h index 90d39b2..563e1a8 100644 --- a/noncore/apps/opie-reader/FontControl.h +++ b/noncore/apps/opie-reader/FontControl.h | |||
@@ -52,25 +52,25 @@ class FontControl | |||
52 | } | 52 | } |
53 | int getsize(int _offset) | 53 | int getsize(int _offset) |
54 | { | 54 | { |
55 | int tgt = m_size+_offset; | 55 | int tgt = m_size+_offset; |
56 | if (tgt < 0) | 56 | if (tgt < 0) |
57 | { | 57 | { |
58 | tgt = 0; | 58 | tgt = 0; |
59 | } | 59 | } |
60 | if (tgt >= m_maxsize) | 60 | if (tgt >= m_maxsize) |
61 | { | 61 | { |
62 | tgt = m_maxsize - 1; | 62 | tgt = m_maxsize - 1; |
63 | } | 63 | } |
64 | return m_fontsizes[tgt]; | 64 | return tgt >= 0 ? m_fontsizes[tgt] : 12; |
65 | } | 65 | } |
66 | int ascent() | 66 | int ascent() |
67 | { | 67 | { |
68 | QFont f(name(), currentsize()); | 68 | QFont f(name(), currentsize()); |
69 | QFontMetrics fm(f); | 69 | QFontMetrics fm(f); |
70 | return fm.ascent(); | 70 | return fm.ascent(); |
71 | } | 71 | } |
72 | int ascent(const CStyle& ch) | 72 | int ascent(const CStyle& ch) |
73 | { | 73 | { |
74 | QFont f(name(), getsize(ch)); | 74 | QFont f(name(), getsize(ch)); |
75 | QFontMetrics fm(f); | 75 | QFontMetrics fm(f); |
76 | return fm.ascent(); | 76 | return fm.ascent(); |
diff --git a/noncore/apps/opie-reader/Model.cpp b/noncore/apps/opie-reader/Model.cpp new file mode 100644 index 0000000..6b61fa0 --- a/dev/null +++ b/noncore/apps/opie-reader/Model.cpp | |||
@@ -0,0 +1,721 @@ | |||
1 | /**************************************************************************** | ||
2 | * This file is part of PPMd project * | ||
3 | * Written and distributed to public domain by Dmitry Shkarin 1997, * | ||
4 | * 1999-2001 * | ||
5 | * Contents: PPMII model description and encoding/decoding routines * | ||
6 | ****************************************************************************/ | ||
7 | #include <string.h> | ||
8 | #include "PPMd.h" | ||
9 | #pragma hdrstop | ||
10 | #include "Coder.h" | ||
11 | #include "SubAlloc.h" | ||
12 | |||
13 | enum { UP_FREQ=5, INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS, | ||
14 | INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124, O_BOUND=9 }; | ||
15 | |||
16 | #pragma pack(1) | ||
17 | static struct SEE2_CONTEXT { // SEE-contexts for PPM-contexts with masked symbols | ||
18 | WORD Summ; | ||
19 | BYTE Shift, Count; | ||
20 | void init(UINT InitVal) { Summ=InitVal << (Shift=PERIOD_BITS-4); Count=7; } | ||
21 | UINT getMean() { | ||
22 | UINT RetVal=(Summ >> Shift); Summ -= RetVal; | ||
23 | return RetVal+(RetVal == 0); | ||
24 | } | ||
25 | void update() { | ||
26 | if (Shift < PERIOD_BITS && --Count == 0) { | ||
27 | Summ += Summ; Count=3 << Shift++; | ||
28 | } | ||
29 | } | ||
30 | } _PACK_ATTR SEE2Cont[24][32], DummySEE2Cont; | ||
31 | static struct PPM_CONTEXT { // Notes: | ||
32 | BYTE NumStats, Flags; // 1. NumStats & NumMasked contain | ||
33 | WORD SummFreq; // number of symbols minus 1 | ||
34 | struct STATE { // 2. sizeof(WORD) > sizeof(BYTE) | ||
35 | BYTE Symbol, Freq; // 3. contexts example: | ||
36 | PPM_CONTEXT* Successor; // MaxOrder: | ||
37 | } _PACK_ATTR * Stats; // ABCD context | ||
38 | PPM_CONTEXT* Suffix; // BCD suffix | ||
39 | inline void encodeBinSymbol(int symbol);// BCDE successor | ||
40 | inline void encodeSymbol1(int symbol);// other orders: | ||
41 | inline void encodeSymbol2(int symbol);// BCD context | ||
42 | inline void decodeBinSymbol();// CD suffix | ||
43 | inline void decodeSymbol1();// BCDE successor | ||
44 | inline void decodeSymbol2(); | ||
45 | inline void update1(STATE* p); | ||
46 | inline void update2(STATE* p); | ||
47 | inline SEE2_CONTEXT* makeEscFreq2(); | ||
48 | void rescale(); | ||
49 | void refresh(int OldNU,BOOL Scale); | ||
50 | PPM_CONTEXT* cutOff(int Order); | ||
51 | PPM_CONTEXT* removeBinConts(int Order); | ||
52 | STATE& oneState() const { return (STATE&) SummFreq; } | ||
53 | } _PACK_ATTR* MaxContext; | ||
54 | #pragma pack() | ||
55 | |||
56 | static BYTE NS2BSIndx[256], QTable[260]; // constants | ||
57 | static PPM_CONTEXT::STATE* FoundState; // found next state transition | ||
58 | static int InitEsc, OrderFall, RunLength, InitRL, MaxOrder; | ||
59 | static BYTE CharMask[256], NumMasked, PrevSuccess, EscCount, PrintCount; | ||
60 | static WORD BinSumm[25][64]; // binary SEE-contexts | ||
61 | static MR_METHOD MRMethod; | ||
62 | |||
63 | inline void SWAP(PPM_CONTEXT::STATE& s1,PPM_CONTEXT::STATE& s2) | ||
64 | { | ||
65 | /* | ||
66 | WORD t1=(WORD&) s1; PPM_CONTEXT* t2=s1.Successor; | ||
67 | (WORD&) s1 = (WORD&) s2; s1.Successor=s2.Successor; | ||
68 | (WORD&) s2 = t1; s2.Successor=t2; | ||
69 | */ | ||
70 | PPM_CONTEXT::STATE t = s1; | ||
71 | s1 = s2; | ||
72 | s2 = t; | ||
73 | } | ||
74 | inline void StateCpy(PPM_CONTEXT::STATE& s1,const PPM_CONTEXT::STATE& s2) | ||
75 | { | ||
76 | // (WORD&) s1=(WORD&) s2; s1.Successor=s2.Successor; | ||
77 | s1 = s2; | ||
78 | } | ||
79 | struct PPMD_STARTUP { inline PPMD_STARTUP(); } PPMd_StartUp; | ||
80 | inline PPMD_STARTUP::PPMD_STARTUP() // constants initialization | ||
81 | { | ||
82 | UINT i, k, m, Step; | ||
83 | for (i=0,k=1;i < N1 ;i++,k += 1) Indx2Units[i]=k; | ||
84 | for (k++;i < N1+N2 ;i++,k += 2) Indx2Units[i]=k; | ||
85 | for (k++;i < N1+N2+N3 ;i++,k += 3) Indx2Units[i]=k; | ||
86 | for (k++;i < N1+N2+N3+N4;i++,k += 4) Indx2Units[i]=k; | ||
87 | for (k=i=0;k < 128;k++) { | ||
88 | i += (Indx2Units[i] < k+1); Units2Indx[k]=i; | ||
89 | } | ||
90 | NS2BSIndx[0]=2*0; NS2BSIndx[1]=2*1; | ||
91 | memset(NS2BSIndx+2,2*2,9); memset(NS2BSIndx+11,2*3,256-11); | ||
92 | for (i=0;i < UP_FREQ;i++) QTable[i]=i; | ||
93 | for (m=i=UP_FREQ, k=Step=1;i < 260;i++) { | ||
94 | QTable[i]=m; | ||
95 | if ( !--k ) { k = ++Step; m++; } | ||
96 | } | ||
97 | (DWORD&) DummySEE2Cont=PPMdSignature; | ||
98 | } | ||
99 | static void _STDCALL StartModelRare(int MaxOrder,MR_METHOD MRMethod) | ||
100 | { | ||
101 | UINT i, k, m; | ||
102 | memset(CharMask,0,sizeof(CharMask)); EscCount=PrintCount=1; | ||
103 | if (MaxOrder < 2) { // we are in solid mode | ||
104 | OrderFall=::MaxOrder; | ||
105 | for (PPM_CONTEXT* pc=MaxContext;pc->Suffix != NULL;pc=pc->Suffix) | ||
106 | OrderFall--; | ||
107 | return; | ||
108 | } | ||
109 | OrderFall=::MaxOrder=MaxOrder; ::MRMethod=MRMethod; | ||
110 | InitSubAllocator(); | ||
111 | RunLength=InitRL=-((MaxOrder < 12)?MaxOrder:12)-1; | ||
112 | MaxContext = (PPM_CONTEXT*) AllocContext(); | ||
113 | MaxContext->Suffix=NULL; | ||
114 | MaxContext->SummFreq=(MaxContext->NumStats=255)+2; | ||
115 | MaxContext->Stats = (PPM_CONTEXT::STATE*) AllocUnits(256/2); | ||
116 | for (PrevSuccess=i=0;i < 256;i++) { | ||
117 | MaxContext->Stats[i].Symbol=i; MaxContext->Stats[i].Freq=1; | ||
118 | MaxContext->Stats[i].Successor=NULL; | ||
119 | } | ||
120 | static const WORD InitBinEsc[]={0x3CDD,0x1F3F,0x59BF,0x48F3,0x64A1,0x5ABC,0x6632,0x6051}; | ||
121 | for (i=m=0;m < 25;m++) { | ||
122 | while (QTable[i] == m) i++; | ||
123 | for (k=0;k < 8;k++) | ||
124 | BinSumm[m][k]=BIN_SCALE-InitBinEsc[k]/(i+1); | ||
125 | for (k=8;k < 64;k += 8) | ||
126 | memcpy(BinSumm[m]+k,BinSumm[m],8*sizeof(WORD)); | ||
127 | } | ||
128 | for (i=m=0;m < 24;m++) { | ||
129 | while (QTable[i+3] == m+3) i++; | ||
130 | SEE2Cont[m][0].init(2*i+5); | ||
131 | for (k=1;k < 32;k++) SEE2Cont[m][k]=SEE2Cont[m][0]; | ||
132 | } | ||
133 | } | ||
134 | void PPM_CONTEXT::refresh(int OldNU,BOOL Scale) | ||
135 | { | ||
136 | int i=NumStats, EscFreq; | ||
137 | STATE* p = Stats = (STATE*) ShrinkUnits(Stats,OldNU,(i+2) >> 1); | ||
138 | Flags=(Flags & (0x10+0x04*Scale))+0x08*(p->Symbol >= 0x40); | ||
139 | EscFreq=SummFreq-p->Freq; | ||
140 | SummFreq = (p->Freq=(p->Freq+Scale) >> Scale); | ||
141 | do { | ||
142 | EscFreq -= (++p)->Freq; | ||
143 | SummFreq += (p->Freq=(p->Freq+Scale) >> Scale); | ||
144 | Flags |= 0x08*(p->Symbol >= 0x40); | ||
145 | } while ( --i ); | ||
146 | SummFreq += (EscFreq=(EscFreq+Scale) >> Scale); | ||
147 | } | ||
148 | #define P_CALL(F) ( PrefetchData(p->Successor), \ | ||
149 | p->Successor=p->Successor->F(Order+1)) | ||
150 | PPM_CONTEXT* PPM_CONTEXT::cutOff(int Order) | ||
151 | { | ||
152 | int i, tmp; | ||
153 | STATE* p; | ||
154 | if ( !NumStats ) { | ||
155 | if ((BYTE*) (p=&oneState())->Successor >= UnitsStart) { | ||
156 | if (Order < MaxOrder) P_CALL(cutOff); | ||
157 | else p->Successor=NULL; | ||
158 | if (!p->Successor && Order > O_BOUND) | ||
159 | goto REMOVE; | ||
160 | return this; | ||
161 | } else { | ||
162 | REMOVE: SpecialFreeUnit(this); return NULL; | ||
163 | } | ||
164 | } | ||
165 | PrefetchData(Stats); | ||
166 | Stats = (STATE*) MoveUnitsUp(Stats,tmp=(NumStats+2) >> 1); | ||
167 | for (p=Stats+(i=NumStats);p >= Stats;p--) | ||
168 | if ((BYTE*) p->Successor < UnitsStart) { | ||
169 | p->Successor=NULL; SWAP(*p,Stats[i--]); | ||
170 | } else if (Order < MaxOrder) P_CALL(cutOff); | ||
171 | else p->Successor=NULL; | ||
172 | if (i != NumStats && Order) { | ||
173 | NumStats=i; p=Stats; | ||
174 | if (i < 0) { FreeUnits(p,tmp); goto REMOVE; } | ||
175 | else if (i == 0) { | ||
176 | Flags=(Flags & 0x10)+0x08*(p->Symbol >= 0x40); | ||
177 | StateCpy(oneState(),*p); FreeUnits(p,tmp); | ||
178 | oneState().Freq=(oneState().Freq+11) >> 3; | ||
179 | } else refresh(tmp,SummFreq > 16*i); | ||
180 | } | ||
181 | return this; | ||
182 | } | ||
183 | PPM_CONTEXT* PPM_CONTEXT::removeBinConts(int Order) | ||
184 | { | ||
185 | STATE* p; | ||
186 | if ( !NumStats ) { | ||
187 | p=&oneState(); | ||
188 | if ((BYTE*) p->Successor >= UnitsStart && Order < MaxOrder) | ||
189 | P_CALL(removeBinConts); | ||
190 | else p->Successor=NULL; | ||
191 | if (!p->Successor && (!Suffix->NumStats || Suffix->Flags == 0xFF)) { | ||
192 | FreeUnits(this,1); return NULL; | ||
193 | } else return this; | ||
194 | } | ||
195 | PrefetchData(Stats); | ||
196 | for (p=Stats+NumStats;p >= Stats;p--) | ||
197 | if ((BYTE*) p->Successor >= UnitsStart && Order < MaxOrder) | ||
198 | P_CALL(removeBinConts); | ||
199 | else p->Successor=NULL; | ||
200 | return this; | ||
201 | } | ||
202 | static void RestoreModelRare(PPM_CONTEXT* pc1,PPM_CONTEXT* MinContext, | ||
203 | PPM_CONTEXT* FSuccessor) | ||
204 | { | ||
205 | PPM_CONTEXT* pc; | ||
206 | PPM_CONTEXT::STATE* p; | ||
207 | for (pc=MaxContext, pText=HeapStart;pc != pc1;pc=pc->Suffix) | ||
208 | if (--(pc->NumStats) == 0) { | ||
209 | pc->Flags=(pc->Flags & 0x10)+0x08*(pc->Stats->Symbol >= 0x40); | ||
210 | p=pc->Stats; StateCpy(pc->oneState(),*p); | ||
211 | SpecialFreeUnit(p); | ||
212 | pc->oneState().Freq=(pc->oneState().Freq+11) >> 3; | ||
213 | } else | ||
214 | pc->refresh((pc->NumStats+3) >> 1,FALSE); | ||
215 | for ( ;pc != MinContext;pc=pc->Suffix) | ||
216 | if ( !pc->NumStats ) | ||
217 | pc->oneState().Freq -= pc->oneState().Freq >> 1; | ||
218 | else if ((pc->SummFreq += 4) > 128+4*pc->NumStats) | ||
219 | pc->refresh((pc->NumStats+2) >> 1,TRUE); | ||
220 | if (MRMethod > MRM_FREEZE) { | ||
221 | MaxContext=FSuccessor; GlueCount += !(BList[1].Stamp & 1); | ||
222 | } else if (MRMethod == MRM_FREEZE) { | ||
223 | while ( MaxContext->Suffix ) MaxContext=MaxContext->Suffix; | ||
224 | MaxContext->removeBinConts(0); MRMethod=MR_METHOD(MRMethod+1); | ||
225 | GlueCount=0; OrderFall=MaxOrder; | ||
226 | } else if (MRMethod == MRM_RESTART || GetUsedMemory() < (SubAllocatorSize >> 1)) { | ||
227 | StartModelRare(MaxOrder,MRMethod); | ||
228 | EscCount=0; PrintCount=0xFF; | ||
229 | } else { | ||
230 | while ( MaxContext->Suffix ) MaxContext=MaxContext->Suffix; | ||
231 | do { | ||
232 | MaxContext->cutOff(0); ExpandTextArea(); | ||
233 | } while (GetUsedMemory() > 3*(SubAllocatorSize >> 2)); | ||
234 | GlueCount=0; OrderFall=MaxOrder; | ||
235 | } | ||
236 | } | ||
237 | static PPM_CONTEXT* _FASTCALL CreateSuccessors(BOOL Skip,PPM_CONTEXT::STATE* p, | ||
238 | PPM_CONTEXT* pc); | ||
239 | static PPM_CONTEXT* _FASTCALL ReduceOrder(PPM_CONTEXT::STATE* p,PPM_CONTEXT* pc) | ||
240 | { | ||
241 | PPM_CONTEXT::STATE* p1, * ps[MAX_O], ** pps=ps; | ||
242 | PPM_CONTEXT* pc1=pc, * UpBranch = (PPM_CONTEXT*) pText; | ||
243 | BYTE tmp, sym=FoundState->Symbol; | ||
244 | *pps++ = FoundState; FoundState->Successor=UpBranch; | ||
245 | OrderFall++; | ||
246 | if ( p ) { pc=pc->Suffix; goto LOOP_ENTRY; } | ||
247 | for ( ; ; ) { | ||
248 | if ( !pc->Suffix ) { | ||
249 | if (MRMethod > MRM_FREEZE) { | ||
250 | FROZEN: do { (*--pps)->Successor = pc; } while (pps != ps); | ||
251 | pText=HeapStart+1; OrderFall=1; | ||
252 | } | ||
253 | return pc; | ||
254 | } | ||
255 | pc=pc->Suffix; | ||
256 | if ( pc->NumStats ) { | ||
257 | if ((p=pc->Stats)->Symbol != sym) | ||
258 | do { tmp=p[1].Symbol; p++; } while (tmp != sym); | ||
259 | tmp=2*(p->Freq < MAX_FREQ-9); | ||
260 | p->Freq += tmp; pc->SummFreq += tmp; | ||
261 | } else { p=&(pc->oneState()); p->Freq += (p->Freq < 32); } | ||
262 | LOOP_ENTRY: | ||
263 | if ( p->Successor ) break; | ||
264 | *pps++ = p; p->Successor=UpBranch; | ||
265 | OrderFall++; | ||
266 | } | ||
267 | if (MRMethod > MRM_FREEZE) { | ||
268 | pc = p->Successor; goto FROZEN; | ||
269 | } else if (p->Successor <= UpBranch) { | ||
270 | p1=FoundState; FoundState=p; | ||
271 | p->Successor=CreateSuccessors(FALSE,NULL,pc); | ||
272 | FoundState=p1; | ||
273 | } | ||
274 | if (OrderFall == 1 && pc1 == MaxContext) { | ||
275 | FoundState->Successor=p->Successor; pText--; | ||
276 | } | ||
277 | return p->Successor; | ||
278 | } | ||
279 | void PPM_CONTEXT::rescale() | ||
280 | { | ||
281 | UINT OldNU, Adder, EscFreq, i=NumStats; | ||
282 | STATE tmp, * p1, * p; | ||
283 | for (p=FoundState;p != Stats;p--) SWAP(p[0],p[-1]); | ||
284 | p->Freq += 4; SummFreq += 4; | ||
285 | EscFreq=SummFreq-p->Freq; | ||
286 | Adder=(OrderFall != 0 || MRMethod > MRM_FREEZE); | ||
287 | SummFreq = (p->Freq=(p->Freq+Adder) >> 1); | ||
288 | do { | ||
289 | EscFreq -= (++p)->Freq; | ||
290 | SummFreq += (p->Freq=(p->Freq+Adder) >> 1); | ||
291 | if (p[0].Freq > p[-1].Freq) { | ||
292 | StateCpy(tmp,*(p1=p)); | ||
293 | do StateCpy(p1[0],p1[-1]); while (tmp.Freq > (--p1)[-1].Freq); | ||
294 | StateCpy(*p1,tmp); | ||
295 | } | ||
296 | } while ( --i ); | ||
297 | if (p->Freq == 0) { | ||
298 | do { i++; } while ((--p)->Freq == 0); | ||
299 | EscFreq += i; OldNU=(NumStats+2) >> 1; | ||
300 | if ((NumStats -= i) == 0) { | ||
301 | StateCpy(tmp,*Stats); | ||
302 | tmp.Freq=(2*tmp.Freq+EscFreq-1)/EscFreq; | ||
303 | if (tmp.Freq > MAX_FREQ/3) tmp.Freq=MAX_FREQ/3; | ||
304 | FreeUnits(Stats,OldNU); StateCpy(oneState(),tmp); | ||
305 | Flags=(Flags & 0x10)+0x08*(tmp.Symbol >= 0x40); | ||
306 | FoundState=&oneState(); return; | ||
307 | } | ||
308 | Stats = (STATE*) ShrinkUnits(Stats,OldNU,(NumStats+2) >> 1); | ||
309 | Flags &= ~0x08; i=NumStats; | ||
310 | Flags |= 0x08*((p=Stats)->Symbol >= 0x40); | ||
311 | do { Flags |= 0x08*((++p)->Symbol >= 0x40); } while ( --i ); | ||
312 | } | ||
313 | SummFreq += (EscFreq -= (EscFreq >> 1)); | ||
314 | Flags |= 0x04; FoundState=Stats; | ||
315 | } | ||
316 | static PPM_CONTEXT* _FASTCALL CreateSuccessors(BOOL Skip,PPM_CONTEXT::STATE* p, | ||
317 | PPM_CONTEXT* pc) | ||
318 | { | ||
319 | PPM_CONTEXT ct, * UpBranch=FoundState->Successor; | ||
320 | PPM_CONTEXT::STATE* ps[MAX_O], ** pps=ps; | ||
321 | UINT cf, s0; | ||
322 | BYTE tmp, sym=FoundState->Symbol; | ||
323 | if ( !Skip ) { | ||
324 | *pps++ = FoundState; | ||
325 | if ( !pc->Suffix ) goto NO_LOOP; | ||
326 | } | ||
327 | if ( p ) { pc=pc->Suffix; goto LOOP_ENTRY; } | ||
328 | do { | ||
329 | pc=pc->Suffix; | ||
330 | if ( pc->NumStats ) { | ||
331 | if ((p=pc->Stats)->Symbol != sym) | ||
332 | do { tmp=p[1].Symbol; p++; } while (tmp != sym); | ||
333 | tmp=(p->Freq < MAX_FREQ-9); | ||
334 | p->Freq += tmp; pc->SummFreq += tmp; | ||
335 | } else { | ||
336 | p=&(pc->oneState()); | ||
337 | p->Freq += (!pc->Suffix->NumStats & (p->Freq < 24)); | ||
338 | } | ||
339 | LOOP_ENTRY: | ||
340 | if (p->Successor != UpBranch) { | ||
341 | pc=p->Successor; break; | ||
342 | } | ||
343 | *pps++ = p; | ||
344 | } while ( pc->Suffix ); | ||
345 | NO_LOOP: | ||
346 | if (pps == ps) return pc; | ||
347 | ct.NumStats=0; ct.Flags=0x10*(sym >= 0x40); | ||
348 | ct.oneState().Symbol=sym=*(BYTE*) UpBranch; | ||
349 | ct.oneState().Successor=(PPM_CONTEXT*) (((BYTE*) UpBranch)+1); | ||
350 | ct.Flags |= 0x08*(sym >= 0x40); | ||
351 | if ( pc->NumStats ) { | ||
352 | if ((p=pc->Stats)->Symbol != sym) | ||
353 | do { tmp=p[1].Symbol; p++; } while (tmp != sym); | ||
354 | s0=pc->SummFreq-pc->NumStats-(cf=p->Freq-1); | ||
355 | ct.oneState().Freq=1+((2*cf <= s0)?(5*cf > s0):((cf+2*s0-3)/s0)); | ||
356 | } else | ||
357 | ct.oneState().Freq=pc->oneState().Freq; | ||
358 | do { | ||
359 | PPM_CONTEXT* pc1 = (PPM_CONTEXT*) AllocContext(); | ||
360 | if ( !pc1 ) return NULL; | ||
361 | ((DWORD*) pc1)[0] = ((DWORD*) &ct)[0]; | ||
362 | ((DWORD*) pc1)[1] = ((DWORD*) &ct)[1]; | ||
363 | pc1->Suffix=pc; (*--pps)->Successor=pc=pc1; | ||
364 | } while (pps != ps); | ||
365 | return pc; | ||
366 | } | ||
367 | static inline void UpdateModel(PPM_CONTEXT* MinContext) | ||
368 | { | ||
369 | PPM_CONTEXT::STATE* p=NULL; | ||
370 | PPM_CONTEXT* Successor, * FSuccessor, * pc, * pc1=MaxContext; | ||
371 | UINT ns1, ns, cf, sf, s0, FFreq=FoundState->Freq; | ||
372 | BYTE Flag, sym, FSymbol=FoundState->Symbol; | ||
373 | FSuccessor=FoundState->Successor; pc=MinContext->Suffix; | ||
374 | if (FFreq < MAX_FREQ/4 && pc) { | ||
375 | if ( pc->NumStats ) { | ||
376 | if ((p=pc->Stats)->Symbol != FSymbol) { | ||
377 | do { sym=p[1].Symbol; p++; } while (sym != FSymbol); | ||
378 | if (p[0].Freq >= p[-1].Freq) { | ||
379 | SWAP(p[0],p[-1]); p--; | ||
380 | } | ||
381 | } | ||
382 | cf=2*(p->Freq < MAX_FREQ-9); | ||
383 | p->Freq += cf; pc->SummFreq += cf; | ||
384 | } else { p=&(pc->oneState()); p->Freq += (p->Freq < 32); } | ||
385 | } | ||
386 | if (!OrderFall && FSuccessor) { | ||
387 | FoundState->Successor=CreateSuccessors(TRUE,p,MinContext); | ||
388 | if ( !FoundState->Successor ) goto RESTART_MODEL; | ||
389 | MaxContext=FoundState->Successor; return; | ||
390 | } | ||
391 | *pText++ = FSymbol; Successor = (PPM_CONTEXT*) pText; | ||
392 | if (pText >= UnitsStart) goto RESTART_MODEL; | ||
393 | if ( FSuccessor ) { | ||
394 | if ((BYTE*) FSuccessor < UnitsStart) | ||
395 | FSuccessor=CreateSuccessors(FALSE,p,MinContext); | ||
396 | } else | ||
397 | FSuccessor=ReduceOrder(p,MinContext); | ||
398 | if ( !FSuccessor ) goto RESTART_MODEL; | ||
399 | if ( !--OrderFall ) { | ||
400 | Successor=FSuccessor; pText -= (MaxContext != MinContext); | ||
401 | } else if (MRMethod > MRM_FREEZE) { | ||
402 | Successor=FSuccessor; pText=HeapStart; | ||
403 | OrderFall=0; | ||
404 | } | ||
405 | s0=MinContext->SummFreq-(ns=MinContext->NumStats)-FFreq; | ||
406 | for (Flag=0x08*(FSymbol >= 0x40);pc1 != MinContext;pc1=pc1->Suffix) { | ||
407 | if ((ns1=pc1->NumStats) != 0) { | ||
408 | if ((ns1 & 1) != 0) { | ||
409 | p=(PPM_CONTEXT::STATE*) ExpandUnits(pc1->Stats,(ns1+1) >> 1); | ||
410 | if ( !p ) goto RESTART_MODEL; | ||
411 | pc1->Stats=p; | ||
412 | } | ||
413 | pc1->SummFreq += (3*ns1+1 < ns); | ||
414 | } else { | ||
415 | p=(PPM_CONTEXT::STATE*) AllocUnits(1); | ||
416 | if ( !p ) goto RESTART_MODEL; | ||
417 | StateCpy(*p,pc1->oneState()); pc1->Stats=p; | ||
418 | if (p->Freq < MAX_FREQ/4-1) p->Freq += p->Freq; | ||
419 | else p->Freq = MAX_FREQ-4; | ||
420 | pc1->SummFreq=p->Freq+InitEsc+(ns > 2); | ||
421 | } | ||
422 | cf=2*FFreq*(pc1->SummFreq+6); sf=s0+pc1->SummFreq; | ||
423 | if (cf < 6*sf) { | ||
424 | cf=1+(cf > sf)+(cf >= 4*sf); | ||
425 | pc1->SummFreq += 4; | ||
426 | } else { | ||
427 | cf=4+(cf > 9*sf)+(cf > 12*sf)+(cf > 15*sf); | ||
428 | pc1->SummFreq += cf; | ||
429 | } | ||
430 | p=pc1->Stats+(++pc1->NumStats); p->Successor=Successor; | ||
431 | p->Symbol = FSymbol; p->Freq = cf; | ||
432 | pc1->Flags |= Flag; | ||
433 | } | ||
434 | MaxContext=FSuccessor; return; | ||
435 | RESTART_MODEL: | ||
436 | RestoreModelRare(pc1,MinContext,FSuccessor); | ||
437 | } | ||
438 | // Tabulated escapes for exponential symbol distribution | ||
439 | static const BYTE ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 }; | ||
440 | #define GET_MEAN(SUMM,SHIFT,ROUND) ((SUMM+(1 << (SHIFT-ROUND))) >> (SHIFT)) | ||
441 | inline void PPM_CONTEXT::encodeBinSymbol(int symbol) | ||
442 | { | ||
443 | BYTE indx=NS2BSIndx[Suffix->NumStats]+PrevSuccess+Flags; | ||
444 | STATE& rs=oneState(); | ||
445 | WORD& bs=BinSumm[QTable[rs.Freq-1]][indx+((RunLength >> 26) & 0x20)]; | ||
446 | if (rs.Symbol == symbol) { | ||
447 | FoundState=&rs; rs.Freq += (rs.Freq < 196); | ||
448 | SubRange.LowCount=0; SubRange.HighCount=bs; | ||
449 | bs += INTERVAL-GET_MEAN(bs,PERIOD_BITS,2); | ||
450 | PrevSuccess=1; RunLength++; | ||
451 | } else { | ||
452 | SubRange.LowCount=bs; bs -= GET_MEAN(bs,PERIOD_BITS,2); | ||
453 | SubRange.HighCount=BIN_SCALE; InitEsc=ExpEscape[bs >> 10]; | ||
454 | CharMask[rs.Symbol]=EscCount; | ||
455 | NumMasked=PrevSuccess=0; FoundState=NULL; | ||
456 | } | ||
457 | } | ||
458 | inline void PPM_CONTEXT::decodeBinSymbol() | ||
459 | { | ||
460 | BYTE indx=NS2BSIndx[Suffix->NumStats]+PrevSuccess+Flags; | ||
461 | STATE& rs=oneState(); | ||
462 | WORD& bs=BinSumm[QTable[rs.Freq-1]][indx+((RunLength >> 26) & 0x20)]; | ||
463 | if (ariGetCurrentShiftCount(TOT_BITS) < bs) { | ||
464 | FoundState=&rs; rs.Freq += (rs.Freq < 196); | ||
465 | SubRange.LowCount=0; SubRange.HighCount=bs; | ||
466 | bs += INTERVAL-GET_MEAN(bs,PERIOD_BITS,2); | ||
467 | PrevSuccess=1; RunLength++; | ||
468 | } else { | ||
469 | SubRange.LowCount=bs; bs -= GET_MEAN(bs,PERIOD_BITS,2); | ||
470 | SubRange.HighCount=BIN_SCALE; InitEsc=ExpEscape[bs >> 10]; | ||
471 | CharMask[rs.Symbol]=EscCount; | ||
472 | NumMasked=PrevSuccess=0; FoundState=NULL; | ||
473 | } | ||
474 | } | ||
475 | inline void PPM_CONTEXT::update1(STATE* p) | ||
476 | { | ||
477 | (FoundState=p)->Freq += 4; SummFreq += 4; | ||
478 | if (p[0].Freq > p[-1].Freq) { | ||
479 | SWAP(p[0],p[-1]); FoundState=--p; | ||
480 | if (p->Freq > MAX_FREQ) rescale(); | ||
481 | } | ||
482 | } | ||
483 | inline void PPM_CONTEXT::encodeSymbol1(int symbol) | ||
484 | { | ||
485 | UINT LoCnt, i=Stats->Symbol; | ||
486 | STATE* p=Stats; SubRange.scale=SummFreq; | ||
487 | if (i == symbol) { | ||
488 | PrevSuccess=(2*(SubRange.HighCount=p->Freq) >= SubRange.scale); | ||
489 | (FoundState=p)->Freq += 4; SummFreq += 4; | ||
490 | RunLength += PrevSuccess; | ||
491 | if (p->Freq > MAX_FREQ) rescale(); | ||
492 | SubRange.LowCount=0; return; | ||
493 | } | ||
494 | LoCnt=p->Freq; | ||
495 | i=NumStats; PrevSuccess=0; | ||
496 | while ((++p)->Symbol != symbol) { | ||
497 | LoCnt += p->Freq; | ||
498 | if (--i == 0) { | ||
499 | if ( Suffix ) PrefetchData(Suffix); | ||
500 | SubRange.LowCount=LoCnt; CharMask[p->Symbol]=EscCount; | ||
501 | i=NumMasked=NumStats; FoundState=NULL; | ||
502 | do { CharMask[(--p)->Symbol]=EscCount; } while ( --i ); | ||
503 | SubRange.HighCount=SubRange.scale; | ||
504 | return; | ||
505 | } | ||
506 | } | ||
507 | SubRange.HighCount=(SubRange.LowCount=LoCnt)+p->Freq; | ||
508 | update1(p); | ||
509 | } | ||
510 | inline void PPM_CONTEXT::decodeSymbol1() | ||
511 | { | ||
512 | UINT i, count, HiCnt=Stats->Freq; | ||
513 | STATE* p=Stats; SubRange.scale=SummFreq; | ||
514 | if ((count=ariGetCurrentCount()) < HiCnt) { | ||
515 | PrevSuccess=(2*(SubRange.HighCount=HiCnt) >= SubRange.scale); | ||
516 | (FoundState=p)->Freq=(HiCnt += 4); SummFreq += 4; | ||
517 | RunLength += PrevSuccess; | ||
518 | if (HiCnt > MAX_FREQ) rescale(); | ||
519 | SubRange.LowCount=0; return; | ||
520 | } | ||
521 | i=NumStats; PrevSuccess=0; | ||
522 | while ((HiCnt += (++p)->Freq) <= count) | ||
523 | if (--i == 0) { | ||
524 | if ( Suffix ) PrefetchData(Suffix); | ||
525 | SubRange.LowCount=HiCnt; CharMask[p->Symbol]=EscCount; | ||
526 | i=NumMasked=NumStats; FoundState=NULL; | ||
527 | do { CharMask[(--p)->Symbol]=EscCount; } while ( --i ); | ||
528 | SubRange.HighCount=SubRange.scale; | ||
529 | return; | ||
530 | } | ||
531 | SubRange.LowCount=(SubRange.HighCount=HiCnt)-p->Freq; | ||
532 | update1(p); | ||
533 | } | ||
534 | inline void PPM_CONTEXT::update2(STATE* p) | ||
535 | { | ||
536 | (FoundState=p)->Freq += 4; SummFreq += 4; | ||
537 | if (p->Freq > MAX_FREQ) rescale(); | ||
538 | EscCount++; RunLength=InitRL; | ||
539 | } | ||
540 | inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2() | ||
541 | { | ||
542 | BYTE* pb=(BYTE*) Stats; UINT t=2*NumStats; | ||
543 | PrefetchData(pb); PrefetchData(pb+t); | ||
544 | PrefetchData(pb += 2*t); PrefetchData(pb+t); | ||
545 | SEE2_CONTEXT* psee2c; | ||
546 | if (NumStats != 0xFF) { | ||
547 | t=Suffix->NumStats; | ||
548 | psee2c=SEE2Cont[QTable[NumStats+2]-3]+(SummFreq > 11*(NumStats+1)); | ||
549 | psee2c += 2*(2*NumStats < t+NumMasked)+Flags; | ||
550 | SubRange.scale=psee2c->getMean(); | ||
551 | } else { | ||
552 | psee2c=&DummySEE2Cont; SubRange.scale=1; | ||
553 | } | ||
554 | return psee2c; | ||
555 | } | ||
556 | inline void PPM_CONTEXT::encodeSymbol2(int symbol) | ||
557 | { | ||
558 | SEE2_CONTEXT* psee2c=makeEscFreq2(); | ||
559 | UINT Sym, LoCnt=0, i=NumStats-NumMasked; | ||
560 | STATE* p1, * p=Stats-1; | ||
561 | do { | ||
562 | do { Sym=p[1].Symbol; p++; } while (CharMask[Sym] == EscCount); | ||
563 | CharMask[Sym]=EscCount; | ||
564 | if (Sym == symbol) goto SYMBOL_FOUND; | ||
565 | LoCnt += p->Freq; | ||
566 | } while ( --i ); | ||
567 | SubRange.HighCount=(SubRange.scale += (SubRange.LowCount=LoCnt)); | ||
568 | psee2c->Summ += SubRange.scale; NumMasked = NumStats; | ||
569 | return; | ||
570 | SYMBOL_FOUND: | ||
571 | SubRange.LowCount=LoCnt; SubRange.HighCount=(LoCnt+=p->Freq); | ||
572 | for (p1=p; --i ; ) { | ||
573 | do { Sym=p1[1].Symbol; p1++; } while (CharMask[Sym] == EscCount); | ||
574 | LoCnt += p1->Freq; | ||
575 | } | ||
576 | SubRange.scale += LoCnt; | ||
577 | psee2c->update(); update2(p); | ||
578 | } | ||
579 | inline void PPM_CONTEXT::decodeSymbol2() | ||
580 | { | ||
581 | SEE2_CONTEXT* psee2c=makeEscFreq2(); | ||
582 | UINT Sym, count, HiCnt=0, i=NumStats-NumMasked; | ||
583 | STATE* ps[256], ** pps=ps, * p=Stats-1; | ||
584 | do { | ||
585 | do { Sym=p[1].Symbol; p++; } while (CharMask[Sym] == EscCount); | ||
586 | HiCnt += p->Freq; *pps++ = p; | ||
587 | } while ( --i ); | ||
588 | SubRange.scale += HiCnt; count=ariGetCurrentCount(); | ||
589 | p=*(pps=ps); | ||
590 | if (count < HiCnt) { | ||
591 | HiCnt=0; | ||
592 | while ((HiCnt += p->Freq) <= count) p=*++pps; | ||
593 | SubRange.LowCount = (SubRange.HighCount=HiCnt)-p->Freq; | ||
594 | psee2c->update(); update2(p); | ||
595 | } else { | ||
596 | SubRange.LowCount=HiCnt; SubRange.HighCount=SubRange.scale; | ||
597 | i=NumStats-NumMasked; NumMasked = NumStats; | ||
598 | do { CharMask[(*pps)->Symbol]=EscCount; pps++; } while ( --i ); | ||
599 | psee2c->Summ += SubRange.scale; | ||
600 | } | ||
601 | } | ||
602 | inline void ClearMask(CInfo* EncodedFile, CInfo* DecodedFile) | ||
603 | { | ||
604 | EscCount=1; memset(CharMask,0,sizeof(CharMask)); | ||
605 | // if (++PrintCount == 0) PrintInfo(DecodedFile,EncodedFile); | ||
606 | } | ||
607 | void _STDCALL EncodeFile(CSink* EncodedFile, CSource* DecodedFile, | ||
608 | int MaxOrder,MR_METHOD MRMethod) | ||
609 | { | ||
610 | ariInitEncoder(); StartModelRare(MaxOrder,MRMethod); | ||
611 | for (PPM_CONTEXT* MinContext; ; ) { | ||
612 | BYTE ns=(MinContext=MaxContext)->NumStats; | ||
613 | int c = _PPMD_E_GETC(DecodedFile); | ||
614 | if ( ns ) { | ||
615 | MinContext->encodeSymbol1(c); ariEncodeSymbol(); | ||
616 | } else { | ||
617 | MinContext->encodeBinSymbol(c); ariShiftEncodeSymbol(TOT_BITS); | ||
618 | } | ||
619 | while ( !FoundState ) { | ||
620 | ARI_ENC_NORMALIZE(EncodedFile); | ||
621 | do { | ||
622 | OrderFall++; MinContext=MinContext->Suffix; | ||
623 | if ( !MinContext ) goto STOP_ENCODING; | ||
624 | } while (MinContext->NumStats == NumMasked); | ||
625 | MinContext->encodeSymbol2(c); ariEncodeSymbol(); | ||
626 | } | ||
627 | if (!OrderFall && (BYTE*) FoundState->Successor >= UnitsStart) | ||
628 | PrefetchData(MaxContext=FoundState->Successor); | ||
629 | else { | ||
630 | UpdateModel(MinContext); PrefetchData(MaxContext); | ||
631 | if (EscCount == 0) ClearMask(EncodedFile,DecodedFile); | ||
632 | } | ||
633 | ARI_ENC_NORMALIZE(EncodedFile); | ||
634 | } | ||
635 | STOP_ENCODING: | ||
636 | ARI_FLUSH_ENCODER(EncodedFile); //PrintInfo(DecodedFile,EncodedFile); | ||
637 | } | ||
638 | void _STDCALL DecodeFile(CSink* DecodedFile, CSource* EncodedFile, | ||
639 | int MaxOrder,MR_METHOD MRMethod) | ||
640 | { | ||
641 | ARI_INIT_DECODER(EncodedFile); StartModelRare(MaxOrder,MRMethod); | ||
642 | PPM_CONTEXT* MinContext=MaxContext; | ||
643 | for (BYTE ns=MinContext->NumStats; ; ) { | ||
644 | ( ns )?(MinContext->decodeSymbol1()):(MinContext->decodeBinSymbol()); | ||
645 | ariRemoveSubrange(); | ||
646 | while ( !FoundState ) { | ||
647 | ARI_DEC_NORMALIZE(EncodedFile); | ||
648 | do { | ||
649 | OrderFall++; MinContext=MinContext->Suffix; | ||
650 | if ( !MinContext ) goto STOP_DECODING; | ||
651 | } while (MinContext->NumStats == NumMasked); | ||
652 | MinContext->decodeSymbol2(); ariRemoveSubrange(); | ||
653 | } | ||
654 | _PPMD_D_PUTC(FoundState->Symbol,DecodedFile); | ||
655 | if (!OrderFall && (BYTE*) FoundState->Successor >= UnitsStart) | ||
656 | PrefetchData(MaxContext=FoundState->Successor); | ||
657 | else { | ||
658 | UpdateModel(MinContext); PrefetchData(MaxContext); | ||
659 | if (EscCount == 0) ClearMask(EncodedFile,DecodedFile); | ||
660 | } | ||
661 | ns=(MinContext=MaxContext)->NumStats; | ||
662 | ARI_DEC_NORMALIZE(EncodedFile); | ||
663 | } | ||
664 | STOP_DECODING: | ||
665 | // PrintInfo(DecodedFile,EncodedFile); | ||
666 | return; | ||
667 | } | ||
668 | |||
669 | |||
670 | |||
671 | #include "PPMd.h" | ||
672 | #include "CSource.h" | ||
673 | |||
674 | size_t UnPPM(bool extra, unsigned char* readbuffer, size_t reclen, unsigned char* buffer, size_t buffersize) | ||
675 | { | ||
676 | unsigned short order, mem, offset = 1; | ||
677 | int type = 0; | ||
678 | if (extra) | ||
679 | { | ||
680 | order = readbuffer[1]; | ||
681 | mem = readbuffer[0]; | ||
682 | type = order >> 6; | ||
683 | order = (order & 63) + 2; | ||
684 | offset = 2; | ||
685 | } | ||
686 | else | ||
687 | { | ||
688 | order = readbuffer[0]; | ||
689 | mem = order >> 4; | ||
690 | order = (order & 15) + 2; | ||
691 | } | ||
692 | mem++; | ||
693 | // qDebug("Mem:%u Order:%u Type:%u\n", mem, order, type); | ||
694 | StartSubAllocator(mem); | ||
695 | CMemSink sink(buffer, buffersize); | ||
696 | CMemSource source(readbuffer+offset, reclen-offset); | ||
697 | DecodeFile(&sink,&source,order,(MR_METHOD)type); | ||
698 | StopSubAllocator(); | ||
699 | return sink.size(); | ||
700 | } | ||
701 | |||
702 | |||
703 | extern "C" | ||
704 | { | ||
705 | |||
706 | size_t PluckerDecompress3(unsigned char* a, size_t b, unsigned char* c, size_t d) | ||
707 | { | ||
708 | return UnPPM(false, a, b, c, d); | ||
709 | } | ||
710 | |||
711 | size_t PluckerDecompress4(unsigned char* a, size_t b, unsigned char* c, size_t d) | ||
712 | { | ||
713 | return UnPPM(true, a, b, c, d); | ||
714 | } | ||
715 | |||
716 | size_t RebDecompress(unsigned char* a, size_t b, unsigned char* c, size_t d) | ||
717 | { | ||
718 | return UnPPM(true, a, b, c, d); | ||
719 | } | ||
720 | |||
721 | } | ||
diff --git a/noncore/apps/opie-reader/Model.h b/noncore/apps/opie-reader/Model.h new file mode 100644 index 0000000..f3f5274 --- a/dev/null +++ b/noncore/apps/opie-reader/Model.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef __MODEL_H | ||
2 | #define __MODEL_H | ||
3 | |||
4 | extern "C" | ||
5 | { | ||
6 | size_t PluckerDecompress3(unsigned char* a, size_t b, unsigned char* c, size_t d); | ||
7 | size_t PluckerDecompress4(unsigned char* a, size_t b, unsigned char* c, size_t d); | ||
8 | size_t RebDecompress(unsigned char* a, size_t b, unsigned char* c, size_t d); | ||
9 | } | ||
10 | |||
11 | #endif | ||
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp index c6907eb..361755f 100644 --- a/noncore/apps/opie-reader/Palm2QImage.cpp +++ b/noncore/apps/opie-reader/Palm2QImage.cpp | |||
@@ -1,13 +1,14 @@ | |||
1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ | 1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ |
2 | |||
2 | #include <stdio.h> | 3 | #include <stdio.h> |
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
4 | #include <string.h> | 5 | #include <string.h> |
5 | #ifndef _WINDOWS | 6 | #ifndef _WINDOWS |
6 | #include <unistd.h> /* for link */ | 7 | #include <unistd.h> /* for link */ |
7 | #endif | 8 | #endif |
8 | #include <sys/types.h> | 9 | #include <sys/types.h> |
9 | #include <sys/stat.h> | 10 | #include <sys/stat.h> |
10 | #include <stdarg.h> | 11 | #include <stdarg.h> |
11 | 12 | ||
12 | #include <qimage.h> | 13 | #include <qimage.h> |
13 | 14 | ||
diff --git a/noncore/apps/opie-reader/Prefs.cpp b/noncore/apps/opie-reader/Prefs.cpp index 2733faa..6c4d45b 100644 --- a/noncore/apps/opie-reader/Prefs.cpp +++ b/noncore/apps/opie-reader/Prefs.cpp | |||
@@ -1,32 +1,35 @@ | |||
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 "Prefs.h" | 9 | #include "Prefs.h" |
10 | 10 | ||
11 | #include <stdlib.h> | ||
12 | |||
11 | #include <qcheckbox.h> | 13 | #include <qcheckbox.h> |
12 | #include <qlabel.h> | 14 | #include <qlabel.h> |
13 | #include <qpushbutton.h> | 15 | #include <qpushbutton.h> |
14 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
15 | #include <qlayout.h> | 17 | #include <qlayout.h> |
16 | #include <qvariant.h> | 18 | #include <qvariant.h> |
17 | #include <qtooltip.h> | 19 | #include <qtooltip.h> |
18 | #include <qwhatsthis.h> | 20 | #include <qwhatsthis.h> |
19 | #include <qbuttongroup.h> | 21 | #include <qbuttongroup.h> |
20 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
23 | #include <qdir.h> | ||
21 | #ifdef USECOMBO | 24 | #ifdef USECOMBO |
22 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
23 | #else | 26 | #else |
24 | #include <qpe/menubutton.h> | 27 | #include <qpe/menubutton.h> |
25 | #endif | 28 | #endif |
26 | #include <qfontdatabase.h> | 29 | #include <qfontdatabase.h> |
27 | 30 | ||
28 | #ifdef USECOMBO | 31 | #ifdef USECOMBO |
29 | void populate_colours(QComboBox *mb) | 32 | void populate_colours(QComboBox *mb) |
30 | #else | 33 | #else |
31 | void populate_colours(MenuButton *mb) | 34 | void populate_colours(MenuButton *mb) |
32 | #endif | 35 | #endif |
@@ -93,24 +96,29 @@ CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) | |||
93 | 96 | ||
94 | /* | 97 | /* |
95 | customhyphen = new QCheckBox( bg ); | 98 | customhyphen = new QCheckBox( bg ); |
96 | customhyphen->setText( tr( "Custom Hyphen'n" ) ); | 99 | customhyphen->setText( tr( "Custom Hyphen'n" ) ); |
97 | */ | 100 | */ |
98 | 101 | ||
99 | prepalm = new QCheckBox( bg ); | 102 | prepalm = new QCheckBox( bg ); |
100 | prepalm->setText( tr( "Repalm(Baen)" ) ); | 103 | prepalm->setText( tr( "Repalm(Baen)" ) ); |
101 | 104 | ||
102 | pkern = new QCheckBox( bg ); | 105 | pkern = new QCheckBox( bg ); |
103 | pkern->setText( tr( "Kern" ) ); | 106 | pkern->setText( tr( "Kern" ) ); |
104 | 107 | ||
108 | InlineTables = new QCheckBox( bg ); | ||
109 | InlineTables->setText( tr( "Inline Tables" ) ); | ||
110 | |||
111 | Underlinelinks = new QCheckBox( bg ); | ||
112 | Underlinelinks->setText( tr( "Underline Links" ) ); | ||
105 | /* | 113 | /* |
106 | Negative = new QCheckBox( bg ); | 114 | Negative = new QCheckBox( bg ); |
107 | Negative->setText( tr( "Negative" ) ); | 115 | Negative->setText( tr( "Negative" ) ); |
108 | */ | 116 | */ |
109 | 117 | ||
110 | // Inverse = new QCheckBox( bg ); | 118 | // Inverse = new QCheckBox( bg ); |
111 | // Inverse->setText( tr( "Inverse" ) ); | 119 | // Inverse->setText( tr( "Inverse" ) ); |
112 | } | 120 | } |
113 | 121 | ||
114 | /* | 122 | /* |
115 | * Destroys the object and frees any allocated resources | 123 | * Destroys the object and frees any allocated resources |
116 | */ | 124 | */ |
@@ -553,24 +561,27 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | |||
553 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); | 561 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); |
554 | Layout11->addWidget( bg ); | 562 | Layout11->addWidget( bg ); |
555 | 563 | ||
556 | annotation = new QCheckBox( bg ); | 564 | annotation = new QCheckBox( bg ); |
557 | annotation->setText( tr( "Annotation" ) ); | 565 | annotation->setText( tr( "Annotation" ) ); |
558 | 566 | ||
559 | dictionary = new QCheckBox( bg ); | 567 | dictionary = new QCheckBox( bg ); |
560 | dictionary->setText( tr( "Dictionary" ) ); | 568 | dictionary->setText( tr( "Dictionary" ) ); |
561 | 569 | ||
562 | clipboard = new QCheckBox( bg ); | 570 | clipboard = new QCheckBox( bg ); |
563 | clipboard->setText( tr( "Clipboard" ) ); | 571 | clipboard->setText( tr( "Clipboard" ) ); |
564 | 572 | ||
573 | QCheckBox* outcodec = new QCheckBox( bg ); | ||
574 | outcodec->setText( tr( "Output" ) ); | ||
575 | |||
565 | } | 576 | } |
566 | 577 | ||
567 | CMiscPrefs::~CMiscPrefs() | 578 | CMiscPrefs::~CMiscPrefs() |
568 | { | 579 | { |
569 | // no need to delete child widgets, Qt does it all for us | 580 | // no need to delete child widgets, Qt does it all for us |
570 | } | 581 | } |
571 | */ | 582 | */ |
572 | 583 | ||
573 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | 584 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) |
574 | : QWidget( parent, name, fl ) | 585 | : QWidget( parent, name, fl ) |
575 | { | 586 | { |
576 | 587 | ||
@@ -584,115 +595,167 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | |||
584 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Select Action", this); | 595 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Select Action", this); |
585 | hl->addWidget( gb ); | 596 | hl->addWidget( gb ); |
586 | 597 | ||
587 | annotation = new QCheckBox( gb ); | 598 | annotation = new QCheckBox( gb ); |
588 | annotation->setText( tr( "Annotation" ) ); | 599 | annotation->setText( tr( "Annotation" ) ); |
589 | 600 | ||
590 | dictionary = new QCheckBox( gb ); | 601 | dictionary = new QCheckBox( gb ); |
591 | dictionary->setText( tr( "Dictionary" ) ); | 602 | dictionary->setText( tr( "Dictionary" ) ); |
592 | 603 | ||
593 | clipboard = new QCheckBox( gb ); | 604 | clipboard = new QCheckBox( gb ); |
594 | clipboard->setText( tr( "Clipboard" ) ); | 605 | clipboard->setText( tr( "Clipboard" ) ); |
595 | 606 | ||
607 | boutput = new QCheckBox( gb ); | ||
608 | boutput->setText( tr( "Output" ) ); | ||
609 | |||
596 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Plucker", this); | 610 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Plucker", this); |
597 | hl->addWidget( bg ); | 611 | hl->addWidget( bg ); |
598 | 612 | ||
599 | Depluck = new QCheckBox( bg ); | 613 | Depluck = new QCheckBox( bg ); |
600 | Depluck->setText( tr( "Depluck" ) ); | 614 | Depluck->setText( tr( "Depluck" ) ); |
601 | 615 | ||
602 | Dejpluck = new QCheckBox( bg ); | 616 | Dejpluck = new QCheckBox( bg ); |
603 | Dejpluck->setText( tr( "Dejpluck" ) ); | 617 | Dejpluck->setText( tr( "Dejpluck" ) ); |
604 | 618 | ||
605 | Continuous = new QCheckBox( bg ); | 619 | Continuous = new QCheckBox( bg ); |
606 | Continuous->setText( tr( "Continuous" ) ); | 620 | Continuous->setText( tr( "Continuous" ) ); |
607 | 621 | bg = new QButtonGroup(2, Qt::Horizontal, "Background", this); | |
608 | bg = new QButtonGroup(2, Qt::Horizontal, "Scroll", this); | ||
609 | vl->addWidget( bg ); | 622 | vl->addWidget( bg ); |
610 | 623 | ||
611 | // scrollinplace = new QCheckBox( bg ); | 624 | // QLabel* TextLabel = new QLabel( bg ); |
612 | // scrollinplace->setText( tr( "In Place" ) ); | 625 | // TextLabel->setText( tr( "Copy an image to \"background\" in\n~/Applications/uqtreader/Theme/" ) ); |
626 | |||
613 | #ifdef USECOMBO | 627 | #ifdef USECOMBO |
614 | scrolltype = new QComboBox( bg ); | 628 | bgtype = new QComboBox( bg ); |
615 | #else | 629 | #else |
616 | scrolltype = new MenuButton( this); | 630 | bgtype = new MenuButton( this); |
617 | #endif | 631 | #endif |
618 | scrolltype->insertItem("In Place"); | 632 | bgtype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
619 | scrolltype->insertItem("Rolling (moving bg)"); | 633 | |
620 | scrolltype->insertItem("Rolling (window)"); | 634 | bgtype->insertItem( tr("Centred") ); |
621 | scrolltype->insertItem("Rolling (static bg)"); | 635 | bgtype->insertItem( tr("Tiled") ); |
622 | scrolltype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 636 | bgtype->insertItem( tr("Fitted") ); |
623 | 637 | ||
638 | DoubleBuffer = new QCheckBox( bg ); | ||
639 | DoubleBuffer->setText( tr( "Double Buffer" ) ); | ||
624 | 640 | ||
641 | QLabel* TextLabel = new QLabel( bg ); | ||
642 | TextLabel->setText( tr( "Minibar Colour" ) ); | ||
625 | #ifdef USECOMBO | 643 | #ifdef USECOMBO |
626 | scrollcolor = new QComboBox( bg ); | 644 | minibarcol = new QComboBox( bg ); |
627 | #else | 645 | #else |
628 | scrollcolor = new MenuButton( this); | 646 | minibarcol = new MenuButton( this); |
629 | #endif | 647 | #endif |
630 | populate_colours(scrollcolor); | 648 | populate_colours(minibarcol); |
631 | scrollcolor->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 649 | minibarcol->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
650 | } | ||
651 | |||
652 | CMiscPrefs::~CMiscPrefs() | ||
653 | { | ||
654 | // no need to delete child widgets, Qt does it all for us | ||
655 | } | ||
656 | |||
657 | CScrollPrefs::CScrollPrefs( QWidget* parent, const char* name, WFlags fl ) | ||
658 | : QWidget( parent, name, fl ) | ||
659 | { | ||
660 | |||
661 | QHBoxLayout* hl = new QHBoxLayout(this); | ||
632 | 662 | ||
663 | hl->setMargin( 0 ); | ||
664 | |||
665 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, "Scroll", this); | ||
666 | hl->addWidget( bg ); | ||
633 | 667 | ||
668 | // scrollinplace = new QCheckBox( bg ); | ||
669 | // scrollinplace->setText( tr( "In Place" ) ); | ||
634 | QLabel* TextLabel = new QLabel( bg ); | 670 | QLabel* TextLabel = new QLabel( bg ); |
635 | TextLabel->setText( tr( "Scroll step" ) ); | 671 | TextLabel->setText( tr( "Scroll step" ) ); |
636 | // gl->addWidget(TextLabel, 2, 0); | 672 | // gl->addWidget(TextLabel, 2, 0); |
637 | scrollstep = new QSpinBox( bg ); | 673 | scrollstep = new QSpinBox( bg ); |
638 | scrollstep->setRange(1, 10); | 674 | scrollstep->setRange(1, 10); |
639 | scrollstep->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 675 | scrollstep->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
640 | 676 | ||
641 | TextLabel = new QLabel( bg ); | 677 | TextLabel = new QLabel( bg ); |
642 | TextLabel->setText( tr( "Minibar Colour" ) ); | 678 | TextLabel->setText( tr( "Scroll type" ) ); |
643 | #ifdef USECOMBO | 679 | #ifdef USECOMBO |
644 | minibarcol = new QComboBox( bg ); | 680 | scrolltype = new QComboBox( bg ); |
645 | #else | 681 | #else |
646 | minibarcol = new MenuButton( this); | 682 | scrolltype = new MenuButton( this); |
647 | #endif | 683 | #endif |
648 | populate_colours(minibarcol); | 684 | scrolltype->insertItem("In Place"); |
649 | minibarcol->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 685 | scrolltype->insertItem("Rolling (moving bg)"); |
686 | scrolltype->insertItem("Rolling (window)"); | ||
687 | scrolltype->insertItem("Rolling (static bg)"); | ||
688 | scrolltype->insertItem("Send to output"); | ||
689 | scrolltype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
650 | 690 | ||
691 | TextLabel = new QLabel( bg ); | ||
692 | TextLabel->setText( tr( "Colour of scroll\nprogress indicator" ) ); | ||
651 | 693 | ||
652 | bg = new QButtonGroup(2, Qt::Vertical, "Background", this); | 694 | #ifdef USECOMBO |
653 | vl->addWidget( bg ); | 695 | scrollcolor = new QComboBox( bg ); |
696 | #else | ||
697 | scrollcolor = new MenuButton( this); | ||
698 | #endif | ||
699 | populate_colours(scrollcolor); | ||
700 | scrollcolor->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
654 | 701 | ||
655 | // QLabel* TextLabel = new QLabel( bg ); | 702 | TextLabel = new QLabel( bg ); |
656 | // TextLabel->setText( tr( "Copy an image to \"background\" in\n~/Applications/uqtreader/Theme/" ) ); | 703 | TextLabel->setText( tr( "Output" ) ); |
657 | 704 | ||
658 | #ifdef USECOMBO | 705 | #ifdef USECOMBO |
659 | bgtype = new QComboBox( bg ); | 706 | outcodec = new QComboBox( bg ); |
660 | #else | 707 | #else |
661 | bgtype = new MenuButton( this); | 708 | outcodec = new MenuButton( this); |
662 | #endif | 709 | #endif |
663 | bgtype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 710 | #ifdef USEQPE |
664 | 711 | #ifdef OPIE | |
665 | bgtype->insertItem( tr("Centred") ); | 712 | QString codecpath(getenv("OPIEDIR")); |
666 | bgtype->insertItem( tr("Tiled") ); | 713 | #else |
667 | bgtype->insertItem( tr("Fitted") ); | 714 | QString codecpath(getenv("QTDIR")); |
715 | #endif | ||
716 | codecpath += "/plugins/reader/outcodecs"; | ||
717 | #else | ||
718 | QString codecpath(getenv("READERDIR")); | ||
719 | codecpath += "/outcodecs"; | ||
720 | #endif | ||
721 | QDir ocd(codecpath, "lib*.so"); | ||
722 | for (int i = 0; i < ocd.count(); ++i) | ||
723 | { | ||
724 | QString tmp(ocd[i]); | ||
725 | outcodec->insertItem(tmp.mid(3,tmp.length()-6)); | ||
726 | } | ||
727 | outcodec->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
668 | } | 728 | } |
669 | 729 | ||
670 | CMiscPrefs::~CMiscPrefs() | 730 | CScrollPrefs::~CScrollPrefs() |
671 | { | 731 | { |
672 | // no need to delete child widgets, Qt does it all for us | 732 | // no need to delete child widgets, Qt does it all for us |
673 | } | 733 | } |
674 | 734 | ||
735 | |||
675 | CPrefs::CPrefs( int w, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) | 736 | CPrefs::CPrefs( int w, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) |
676 | { | 737 | { |
677 | setCaption(tr( "OpieReader Settings" ) ); | 738 | setCaption(tr( "OpieReader Settings" ) ); |
678 | QTabWidget* td = new QTabWidget(this); | 739 | QTabWidget* td = new QTabWidget(this); |
679 | layout = new CLayoutPrefs(this); | 740 | layout = new CLayoutPrefs(this); |
680 | layout2 = new CLayoutPrefs2(w, this); | 741 | layout2 = new CLayoutPrefs2(w, this); |
742 | scroll = new CScrollPrefs(this); | ||
681 | misc = new CMiscPrefs(this); | 743 | misc = new CMiscPrefs(this); |
682 | // button = new CButtonPrefs(kmap, this); | 744 | // button = new CButtonPrefs(kmap, this); |
683 | inter = new CInterPrefs(this); | 745 | inter = new CInterPrefs(this); |
684 | td->addTab(layout, tr("Layout")); | 746 | td->addTab(layout, tr("Layout")); |
685 | td->addTab(layout2, tr("Layout(2)")); | 747 | td->addTab(layout2, tr("Layout(2)")); |
686 | td->addTab(inter, tr("Locale")); | 748 | td->addTab(inter, tr("Locale")); |
749 | td->addTab(scroll, tr("Scroll")); | ||
687 | td->addTab(misc, tr("Misc")); | 750 | td->addTab(misc, tr("Misc")); |
688 | // td->addTab(button, tr("Buttons")); | 751 | // td->addTab(button, tr("Buttons")); |
689 | QVBoxLayout* v = new QVBoxLayout(this); | 752 | QVBoxLayout* v = new QVBoxLayout(this); |
690 | v->addWidget(td); | 753 | v->addWidget(td); |
691 | 754 | ||
692 | if (fs) showMaximized(); | 755 | if (fs) showMaximized(); |
693 | } | 756 | } |
694 | 757 | ||
695 | 758 | ||
696 | /* | 759 | /* |
697 | 760 | ||
698 | Unicode | 761 | Unicode |
diff --git a/noncore/apps/opie-reader/Prefs.h b/noncore/apps/opie-reader/Prefs.h index cf12b70..103484e 100644 --- a/noncore/apps/opie-reader/Prefs.h +++ b/noncore/apps/opie-reader/Prefs.h | |||
@@ -52,24 +52,26 @@ public: | |||
52 | QCheckBox* Reparagraph; | 52 | QCheckBox* Reparagraph; |
53 | QCheckBox* DoubleSpace; | 53 | QCheckBox* DoubleSpace; |
54 | QCheckBox* Remap; | 54 | QCheckBox* Remap; |
55 | QCheckBox* Embolden; | 55 | QCheckBox* Embolden; |
56 | QCheckBox* FullJustify; | 56 | QCheckBox* FullJustify; |
57 | QCheckBox* FixGraphics; | 57 | QCheckBox* FixGraphics; |
58 | QCheckBox* hyphenate; | 58 | QCheckBox* hyphenate; |
59 | // QCheckBox* customhyphen; | 59 | // QCheckBox* customhyphen; |
60 | QCheckBox* prepalm; | 60 | QCheckBox* prepalm; |
61 | QCheckBox* pkern; | 61 | QCheckBox* pkern; |
62 | // QCheckBox* Inverse; | 62 | // QCheckBox* Inverse; |
63 | // QCheckBox* Negative; | 63 | // QCheckBox* Negative; |
64 | QCheckBox* InlineTables; | ||
65 | QCheckBox* Underlinelinks; | ||
64 | }; | 66 | }; |
65 | 67 | ||
66 | class CLayoutPrefs2 : public QWidget | 68 | class CLayoutPrefs2 : public QWidget |
67 | { | 69 | { |
68 | 70 | ||
69 | public: | 71 | public: |
70 | 72 | ||
71 | friend class CPrefs; | 73 | friend class CPrefs; |
72 | 74 | ||
73 | CLayoutPrefs2( int w, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 75 | CLayoutPrefs2( int w, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
74 | ~CLayoutPrefs2(); | 76 | ~CLayoutPrefs2(); |
75 | 77 | ||
@@ -89,58 +91,76 @@ class CPluckerPrefs : public QWidget | |||
89 | { | 91 | { |
90 | 92 | ||
91 | public: | 93 | public: |
92 | 94 | ||
93 | friend class CPrefs; | 95 | friend class CPrefs; |
94 | 96 | ||
95 | CPluckerPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 97 | CPluckerPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
96 | ~CPluckerPrefs(); | 98 | ~CPluckerPrefs(); |
97 | 99 | ||
98 | QCheckBox* Depluck; | 100 | QCheckBox* Depluck; |
99 | QCheckBox* Dejpluck; | 101 | QCheckBox* Dejpluck; |
100 | QCheckBox* Continuous; | 102 | QCheckBox* Continuous; |
103 | QCheckBox* DoubleBuffer; | ||
101 | protected: | 104 | protected: |
102 | 105 | ||
103 | QHBoxLayout* Layout5; | 106 | QHBoxLayout* Layout5; |
104 | QVBoxLayout* Layout11; | 107 | QVBoxLayout* Layout11; |
105 | QGridLayout* Layout4; | 108 | QGridLayout* Layout4; |
106 | 109 | ||
107 | }; | 110 | }; |
108 | */ | 111 | */ |
109 | class CMiscPrefs : public QWidget | 112 | class CMiscPrefs : public QWidget |
110 | { | 113 | { |
111 | 114 | ||
112 | public: | 115 | public: |
113 | 116 | ||
114 | friend class CPrefs; | 117 | friend class CPrefs; |
115 | 118 | ||
116 | CMiscPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 119 | CMiscPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
117 | ~CMiscPrefs(); | 120 | ~CMiscPrefs(); |
118 | 121 | ||
119 | QCheckBox *annotation, *dictionary, *clipboard; | 122 | QCheckBox *annotation, *dictionary, *clipboard, *boutput; |
120 | QCheckBox *Depluck, *Dejpluck, *Continuous; | 123 | QCheckBox *Depluck, *Dejpluck, *Continuous, *DoubleBuffer; |
124 | |||
125 | #ifdef USECOMBO | ||
126 | QComboBox *bgtype, *minibarcol; | ||
127 | #else | ||
128 | MenuButton *bgtype, *minibarcol; | ||
129 | #endif | ||
130 | }; | ||
131 | |||
132 | class CScrollPrefs : public QWidget | ||
133 | { | ||
134 | |||
135 | public: | ||
136 | |||
137 | friend class CPrefs; | ||
138 | |||
139 | CScrollPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | ||
140 | ~CScrollPrefs(); | ||
121 | 141 | ||
122 | QSpinBox *scrollstep; | 142 | QSpinBox *scrollstep; |
123 | 143 | ||
124 | #ifdef USECOMBO | 144 | #ifdef USECOMBO |
125 | QComboBox *scrollcolor, *bgtype, *scrolltype, *minibarcol; | 145 | QComboBox *scrollcolor, *scrolltype, *outcodec; |
126 | #else | 146 | #else |
127 | MenuButton *scrollcolor, *bgtype, *scrolltype, *minibarcol; | 147 | MenuButton *scrollcolor, *scrolltype, *outcodec; |
128 | #endif | 148 | #endif |
129 | }; | 149 | }; |
130 | /* | 150 | /* |
131 | class QListView; | 151 | class QListView; |
132 | class QListViewItem; | 152 | class QListViewItem; |
133 | 153 | ||
134 | class CButtonPrefs : public QWidget | 154 | sclass CButtonPrefs : public QWidget |
135 | { | 155 | { |
136 | Q_OBJECT | 156 | Q_OBJECT |
137 | QMap<orKey, int> *kmap; | 157 | QMap<orKey, int> *kmap; |
138 | QMap<orKey, QListViewItem*> listmap; | 158 | QMap<orKey, QListViewItem*> listmap; |
139 | QListView* lb; | 159 | QListView* lb; |
140 | void keyPressEvent(QKeyEvent* e); | 160 | void keyPressEvent(QKeyEvent* e); |
141 | #ifdef USECOMBO | 161 | #ifdef USECOMBO |
142 | void populate(QComboBox*); | 162 | void populate(QComboBox*); |
143 | #else | 163 | #else |
144 | void populate(MenuButton*); | 164 | void populate(MenuButton*); |
145 | #endif | 165 | #endif |
146 | public: | 166 | public: |
@@ -180,25 +200,25 @@ public: | |||
180 | #endif | 200 | #endif |
181 | QSpinBox* ideogramwidth; | 201 | QSpinBox* ideogramwidth; |
182 | QLineEdit *application, *message; | 202 | QLineEdit *application, *message; |
183 | }; | 203 | }; |
184 | 204 | ||
185 | 205 | ||
186 | class CPrefs : public QDialog | 206 | class CPrefs : public QDialog |
187 | { | 207 | { |
188 | Q_OBJECT | 208 | Q_OBJECT |
189 | CLayoutPrefs* layout; | 209 | CLayoutPrefs* layout; |
190 | CLayoutPrefs2* layout2; | 210 | CLayoutPrefs2* layout2; |
191 | CMiscPrefs* misc; | 211 | CMiscPrefs* misc; |
192 | // CButtonPrefs* button; | 212 | CScrollPrefs* scroll; |
193 | CInterPrefs* inter; | 213 | CInterPrefs* inter; |
194 | 214 | ||
195 | void keyPressEvent(QKeyEvent* e) | 215 | void keyPressEvent(QKeyEvent* e) |
196 | { | 216 | { |
197 | switch (e->key()) | 217 | switch (e->key()) |
198 | { | 218 | { |
199 | case Key_Escape: | 219 | case Key_Escape: |
200 | e->accept(); | 220 | e->accept(); |
201 | reject(); | 221 | reject(); |
202 | break; | 222 | break; |
203 | case Key_Space: | 223 | case Key_Space: |
204 | case Key_Return: | 224 | case Key_Return: |
@@ -212,50 +232,54 @@ Q_OBJECT | |||
212 | public: | 232 | public: |
213 | CPrefs(int w, bool fs = true, QWidget* parent = 0, const char* name = 0); | 233 | CPrefs(int w, bool fs = true, QWidget* parent = 0, const char* name = 0); |
214 | ~CPrefs() | 234 | ~CPrefs() |
215 | { | 235 | { |
216 | } | 236 | } |
217 | bool hyphenate() { return layout->hyphenate->isChecked(); } | 237 | bool hyphenate() { return layout->hyphenate->isChecked(); } |
218 | void hyphenate(bool _v) { layout->hyphenate->setChecked(_v); } | 238 | void hyphenate(bool _v) { layout->hyphenate->setChecked(_v); } |
219 | /* | 239 | /* |
220 | bool customhyphen() { return layout->customhyphen->isChecked(); } | 240 | bool customhyphen() { return layout->customhyphen->isChecked(); } |
221 | void customhyphen(bool _v) { layout->customhyphen->setChecked(_v); } | 241 | void customhyphen(bool _v) { layout->customhyphen->setChecked(_v); } |
222 | */ | 242 | */ |
223 | bool StripCR() { return layout->StripCR->isChecked(); } | 243 | bool StripCR() { return layout->StripCR->isChecked(); } |
244 | bool InlineTables() { return layout->InlineTables->isChecked(); } | ||
224 | bool repalm() { return layout->prepalm->isChecked(); } | 245 | bool repalm() { return layout->prepalm->isChecked(); } |
246 | bool UnderlineLink() { return layout->Underlinelinks->isChecked(); } | ||
225 | bool kern() { return layout->pkern->isChecked(); } | 247 | bool kern() { return layout->pkern->isChecked(); } |
226 | bool Dehyphen() { return layout->Dehyphen->isChecked(); } | 248 | bool Dehyphen() { return layout->Dehyphen->isChecked(); } |
227 | bool SingleSpace() { return layout->SingleSpace->isChecked(); } | 249 | bool SingleSpace() { return layout->SingleSpace->isChecked(); } |
228 | bool Unindent() { return layout->Unindent->isChecked(); } | 250 | bool Unindent() { return layout->Unindent->isChecked(); } |
229 | bool Reparagraph() { return layout->Reparagraph->isChecked(); } | 251 | bool Reparagraph() { return layout->Reparagraph->isChecked(); } |
230 | bool DoubleSpace() { return layout->DoubleSpace->isChecked(); } | 252 | bool DoubleSpace() { return layout->DoubleSpace->isChecked(); } |
231 | bool Remap() { return layout->Remap->isChecked(); } | 253 | bool Remap() { return layout->Remap->isChecked(); } |
232 | bool Embolden() { return layout->Embolden->isChecked(); } | 254 | bool Embolden() { return layout->Embolden->isChecked(); } |
233 | bool FullJustify() { return layout->FullJustify->isChecked(); } | 255 | bool FullJustify() { return layout->FullJustify->isChecked(); } |
234 | // bool Inverse() { return layout->Inverse->isChecked(); } | 256 | // bool Inverse() { return layout->Inverse->isChecked(); } |
235 | // bool Negative() { return layout->Negative->isChecked(); } | 257 | // bool Negative() { return layout->Negative->isChecked(); } |
236 | bool FixGraphics() { return layout->FixGraphics->isChecked(); } | 258 | bool FixGraphics() { return layout->FixGraphics->isChecked(); } |
237 | int ParaLead() { return layout2->ParaLead->value(); } | 259 | int ParaLead() { return layout2->ParaLead->value(); } |
238 | int LineLead() { return layout2->LineLead->value(); } | 260 | int LineLead() { return layout2->LineLead->value(); } |
239 | int TopMargin() { return layout2->TopMargin->value(); } | 261 | int TopMargin() { return layout2->TopMargin->value(); } |
240 | int BottomMargin() { return layout2->BottomMargin->value(); } | 262 | int BottomMargin() { return layout2->BottomMargin->value(); } |
241 | int LeftMargin() { return layout2->LeftMargin->value(); } | 263 | int LeftMargin() { return layout2->LeftMargin->value(); } |
242 | int RightMargin() { return layout2->RightMargin->value(); } | 264 | int RightMargin() { return layout2->RightMargin->value(); } |
243 | int Indent() { return layout2->Indent->value(); } | 265 | int Indent() { return layout2->Indent->value(); } |
244 | int Markup() { return layout2->Markup->currentItem(); } | 266 | int Markup() { return layout2->Markup->currentItem(); } |
245 | QString Font() { return layout2->fontselector->currentText(); } | 267 | QString Font() { return layout2->fontselector->currentText(); } |
246 | 268 | ||
247 | 269 | ||
248 | void StripCR(bool v) { layout->StripCR->setChecked(v); } | 270 | void StripCR(bool v) { layout->StripCR->setChecked(v); } |
271 | void InlineTables(bool v) { layout->InlineTables->setChecked(v); } | ||
249 | void repalm(bool v) { layout->prepalm->setChecked(v); } | 272 | void repalm(bool v) { layout->prepalm->setChecked(v); } |
273 | void UnderlineLink(bool v) { layout->Underlinelinks->setChecked(v); } | ||
250 | void kern(bool v) { layout->pkern->setChecked(v); } | 274 | void kern(bool v) { layout->pkern->setChecked(v); } |
251 | void Dehyphen(bool v) { layout->Dehyphen->setChecked(v); } | 275 | void Dehyphen(bool v) { layout->Dehyphen->setChecked(v); } |
252 | void SingleSpace(bool v) { layout->SingleSpace->setChecked(v); } | 276 | void SingleSpace(bool v) { layout->SingleSpace->setChecked(v); } |
253 | void Unindent(bool v) { layout->Unindent->setChecked(v); } | 277 | void Unindent(bool v) { layout->Unindent->setChecked(v); } |
254 | void Reparagraph(bool v) { layout->Reparagraph->setChecked(v); } | 278 | void Reparagraph(bool v) { layout->Reparagraph->setChecked(v); } |
255 | void DoubleSpace(bool v) { layout->DoubleSpace->setChecked(v); } | 279 | void DoubleSpace(bool v) { layout->DoubleSpace->setChecked(v); } |
256 | void Remap(bool v) { layout->Remap->setChecked(v); } | 280 | void Remap(bool v) { layout->Remap->setChecked(v); } |
257 | void Embolden(bool v) { layout->Embolden->setChecked(v); } | 281 | void Embolden(bool v) { layout->Embolden->setChecked(v); } |
258 | void FullJustify(bool v) { layout->FullJustify->setChecked(v); } | 282 | void FullJustify(bool v) { layout->FullJustify->setChecked(v); } |
259 | // void Negative(bool v) { layout->Negative->setChecked(v); } | 283 | // void Negative(bool v) { layout->Negative->setChecked(v); } |
260 | // void Inverse(bool v) { layout->Inverse->setChecked(v); } | 284 | // void Inverse(bool v) { layout->Inverse->setChecked(v); } |
261 | void FixGraphics(bool v) { layout->FixGraphics->setChecked(v); } | 285 | void FixGraphics(bool v) { layout->FixGraphics->setChecked(v); } |
@@ -264,74 +288,95 @@ Q_OBJECT | |||
264 | void TopMargin(int v) { layout2->TopMargin->setValue(v); } | 288 | void TopMargin(int v) { layout2->TopMargin->setValue(v); } |
265 | void BottomMargin(int v) { layout2->BottomMargin->setValue(v); } | 289 | void BottomMargin(int v) { layout2->BottomMargin->setValue(v); } |
266 | void LeftMargin(int v) { layout2->LeftMargin->setValue(v); } | 290 | void LeftMargin(int v) { layout2->LeftMargin->setValue(v); } |
267 | void RightMargin(int v) { layout2->RightMargin->setValue(v); } | 291 | void RightMargin(int v) { layout2->RightMargin->setValue(v); } |
268 | void Indent(int v) { layout2->Indent->setValue(v); } | 292 | void Indent(int v) { layout2->Indent->setValue(v); } |
269 | #ifdef USECOMBO | 293 | #ifdef USECOMBO |
270 | void Markup(int v) { layout2->Markup->setCurrentItem(v); } | 294 | void Markup(int v) { layout2->Markup->setCurrentItem(v); } |
271 | #else | 295 | #else |
272 | void Markup(int v) { layout2->Markup->select(v); } | 296 | void Markup(int v) { layout2->Markup->select(v); } |
273 | #endif | 297 | #endif |
274 | #ifdef USECOMBO | 298 | #ifdef USECOMBO |
275 | void bgtype(int v) { misc->bgtype->setCurrentItem(v); } | 299 | void bgtype(int v) { misc->bgtype->setCurrentItem(v); } |
276 | void scrollcolor(int v) { misc->scrollcolor->setCurrentItem(v); } | 300 | void scrollcolor(int v) { scroll->scrollcolor->setCurrentItem(v); } |
277 | void minibarcol(int v) { misc->minibarcol->setCurrentItem(v); } | 301 | void minibarcol(int v) { misc->minibarcol->setCurrentItem(v); } |
278 | #else | 302 | #else |
279 | void bgtype(int v) { misc->bgtype->select(v); } | 303 | void bgtype(int v) { misc->bgtype->select(v); } |
280 | void scrollcolor(int v) { misc->scrollcolor->select(v); } | 304 | void scrollcolor(int v) { scroll->scrollcolor->select(v); } |
281 | void minibarcol(int v) { misc->minibarcol->select(v); } | 305 | void minibarcol(int v) { misc->minibarcol->select(v); } |
282 | #endif | 306 | #endif |
283 | int bgtype() { return misc->bgtype->currentItem(); } | 307 | int bgtype() { return misc->bgtype->currentItem(); } |
284 | int scrollcolor() { return misc->scrollcolor->currentItem(); } | 308 | int scrollcolor() { return scroll->scrollcolor->currentItem(); } |
285 | int minibarcol() { return misc->minibarcol->currentItem(); } | 309 | int minibarcol() { return misc->minibarcol->currentItem(); } |
286 | 310 | ||
287 | 311 | ||
288 | #ifdef USECOMBO | 312 | #ifdef USECOMBO |
289 | void foreground(int v) { layout2->fgsel->setCurrentItem(v); } | 313 | void foreground(int v) { layout2->fgsel->setCurrentItem(v); } |
290 | #else | 314 | #else |
291 | void foreground(int v) { layout2->fgsel->select(v); } | 315 | void foreground(int v) { layout2->fgsel->select(v); } |
292 | #endif | 316 | #endif |
293 | int foreground() { return layout2->fgsel->currentItem(); } | 317 | int foreground() { return layout2->fgsel->currentItem(); } |
294 | 318 | ||
295 | #ifdef USECOMBO | 319 | #ifdef USECOMBO |
296 | void background(int v) { layout2->bgsel->setCurrentItem(v); } | 320 | void background(int v) { layout2->bgsel->setCurrentItem(v); } |
297 | #else | 321 | #else |
298 | void background(int v) { layout2->bgsel->select(v); } | 322 | void background(int v) { layout2->bgsel->select(v); } |
299 | #endif | 323 | #endif |
300 | int background() { return layout2->bgsel->currentItem(); } | 324 | int background() { return layout2->bgsel->currentItem(); } |
301 | 325 | ||
302 | 326 | ||
303 | |||
304 | #ifdef USECOMBO | 327 | #ifdef USECOMBO |
305 | void Font(QString& s) | 328 | void Font(QString& s) |
306 | { | 329 | { |
307 | for (int i = 1; i <= layout2->fontselector->count(); i++) | 330 | for (int i = 1; i <= layout2->fontselector->count(); i++) |
308 | { | 331 | { |
309 | if (layout2->fontselector->text(i) == s) | 332 | if (layout2->fontselector->text(i) == s) |
310 | { | 333 | { |
311 | layout2->fontselector->setCurrentItem(i); | 334 | layout2->fontselector->setCurrentItem(i); |
312 | break; | 335 | break; |
313 | } | 336 | } |
314 | } | 337 | } |
315 | } | 338 | } |
316 | #else | 339 | #else |
317 | void Font(QString& s) { layout2->fontselector->select(s); } | 340 | void Font(QString& s) { layout2->fontselector->select(s); } |
318 | #endif | 341 | #endif |
319 | 342 | ||
343 | #ifdef USECOMBO | ||
344 | void outcodec(QString& s) | ||
345 | { | ||
346 | for (int i = 1; i <= scroll->outcodec->count(); i++) | ||
347 | { | ||
348 | if (scroll->outcodec->text(i) == s) | ||
349 | { | ||
350 | scroll->outcodec->setCurrentItem(i); | ||
351 | break; | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | #else | ||
356 | void outcodec(QString& s) { scroll->outcodec->select(s); } | ||
357 | #endif | ||
358 | QString outcodec() { return scroll->outcodec->currentText(); } | ||
359 | |||
360 | void miscoutput(bool v) { return misc->boutput->setChecked(v); } | ||
361 | bool miscoutput() { return misc->boutput->isChecked(); } | ||
362 | |||
320 | bool Depluck() { return misc->Depluck->isChecked(); } | 363 | bool Depluck() { return misc->Depluck->isChecked(); } |
321 | void Depluck(bool v) { misc->Depluck->setChecked(v); } | 364 | void Depluck(bool v) { misc->Depluck->setChecked(v); } |
322 | bool Dejpluck() { return misc->Dejpluck->isChecked(); } | 365 | bool Dejpluck() { return misc->Dejpluck->isChecked(); } |
323 | void Dejpluck(bool v) { misc->Dejpluck->setChecked(v); } | 366 | void Dejpluck(bool v) { misc->Dejpluck->setChecked(v); } |
324 | bool Continuous() { return misc->Continuous->isChecked(); } | 367 | bool Continuous() { return misc->Continuous->isChecked(); } |
325 | void Continuous(bool v) { misc->Continuous->setChecked(v); } | 368 | void Continuous(bool v) { misc->Continuous->setChecked(v); } |
369 | bool DoubleBuffer() { return misc->DoubleBuffer->isChecked(); } | ||
370 | void DoubleBuffer(bool v) { misc->DoubleBuffer->setChecked(v); } | ||
326 | bool SwapMouse() { return inter->SwapMouse->isChecked(); } | 371 | bool SwapMouse() { return inter->SwapMouse->isChecked(); } |
327 | void SwapMouse(bool v) { inter->SwapMouse->setChecked(v); } | 372 | void SwapMouse(bool v) { inter->SwapMouse->setChecked(v); } |
328 | 373 | ||
329 | 374 | ||
330 | void dictApplication(const QString& v) { inter->application->setText(v); } | 375 | void dictApplication(const QString& v) { inter->application->setText(v); } |
331 | QString dictApplication() { return inter->application->text(); } | 376 | QString dictApplication() { return inter->application->text(); } |
332 | void dictMessage(const QString& v) { inter->message->setText(v); } | 377 | void dictMessage(const QString& v) { inter->message->setText(v); } |
333 | QString dictMessage() { return inter->message->text(); } | 378 | QString dictMessage() { return inter->message->text(); } |
334 | 379 | ||
335 | void miscannotation(bool v) { misc->annotation->setChecked(v); } | 380 | void miscannotation(bool v) { misc->annotation->setChecked(v); } |
336 | void miscdictionary(bool v) { misc->dictionary->setChecked(v); } | 381 | void miscdictionary(bool v) { misc->dictionary->setChecked(v); } |
337 | void miscclipboard(bool v) { misc->clipboard->setChecked(v); } | 382 | void miscclipboard(bool v) { misc->clipboard->setChecked(v); } |
@@ -362,24 +407,24 @@ Q_OBJECT | |||
362 | void twotouch(bool v) { inter->twotouch->setChecked(v); } | 407 | void twotouch(bool v) { inter->twotouch->setChecked(v); } |
363 | 408 | ||
364 | bool ideogram() { return inter->ideogram->isChecked(); } | 409 | bool ideogram() { return inter->ideogram->isChecked(); } |
365 | void ideogram(bool v) { inter->ideogram->setChecked(v); } | 410 | void ideogram(bool v) { inter->ideogram->setChecked(v); } |
366 | 411 | ||
367 | int ideogramwidth() { return inter->ideogramwidth->value(); } | 412 | int ideogramwidth() { return inter->ideogramwidth->value(); } |
368 | void ideogramwidth(int v) { inter->ideogramwidth->setValue(v); } | 413 | void ideogramwidth(int v) { inter->ideogramwidth->setValue(v); } |
369 | 414 | ||
370 | bool propfontchange() { return inter->propfontchange->isChecked(); } | 415 | bool propfontchange() { return inter->propfontchange->isChecked(); } |
371 | void propfontchange(bool v) { inter->propfontchange->setChecked(v); } | 416 | void propfontchange(bool v) { inter->propfontchange->setChecked(v); } |
372 | 417 | ||
373 | int encoding() { return inter->encoding->currentItem(); } | 418 | int encoding() { return inter->encoding->currentItem(); } |
374 | int scrolltype() { return misc->scrolltype->currentItem(); } | 419 | int scrolltype() { return scroll->scrolltype->currentItem(); } |
375 | #ifdef USECOMBO | 420 | #ifdef USECOMBO |
376 | void encoding(int v) { inter->encoding->setCurrentItem(v); } | 421 | void encoding(int v) { inter->encoding->setCurrentItem(v); } |
377 | void scrolltype(int v) { misc->scrolltype->setCurrentItem(v); } | 422 | void scrolltype(int v) { scroll->scrolltype->setCurrentItem(v); } |
378 | #else | 423 | #else |
379 | void encoding(int v) { inter->encoding->select(v); } | 424 | void encoding(int v) { inter->encoding->select(v); } |
380 | void scrolltype(int v) { misc->scrolltype->select(v); } | 425 | void scrolltype(int v) { scroll->scrolltype->select(v); } |
381 | #endif | 426 | #endif |
382 | void scrollstep(int v) { misc->scrollstep->setValue(v); } | 427 | void scrollstep(int v) { scroll->scrollstep->setValue(v); } |
383 | int scrollstep() { return misc->scrollstep->value(); } | 428 | int scrollstep() { return scroll->scrollstep->value(); } |
384 | }; | 429 | }; |
385 | #endif // CPREFS_H | 430 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index 33884a0..0c56dd4 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -23,44 +23,48 @@ const int _SBARHEIGHT = 3; | |||
23 | #endif | 23 | #endif |
24 | #include <math.h> | 24 | #include <math.h> |
25 | #include <ctype.h> | 25 | #include <ctype.h> |
26 | #include <stdio.h> //for sprintf | 26 | #include <stdio.h> //for sprintf |
27 | #ifdef USEQPE | 27 | #ifdef USEQPE |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | #endif | 32 | #endif |
33 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include "TableDialog.h" | ||
36 | #include "outputcodec.h" | ||
35 | 37 | ||
38 | /* | ||
36 | #ifdef _UNICODE | 39 | #ifdef _UNICODE |
37 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; | 40 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; |
38 | #else | 41 | #else |
39 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | 42 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; |
40 | #endif | 43 | #endif |
44 | */ | ||
41 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; | 45 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; |
42 | 46 | ||
43 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; | 47 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; |
44 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; | 48 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; |
45 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; | 49 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 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}; | 50 | //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}; |
47 | 51 | ||
48 | tchar QTReader::pluckernextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; | 52 | tchar QTReader::pluckernextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; |
49 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 53 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
50 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 54 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
51 | 55 | ||
52 | |||
53 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | 56 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : |
54 | QWidget(parent, name, f), | 57 | QWidget(parent, name, f | WRepaintNoErase | WResizeNoErase), |
58 | m_outofdate(true), | ||
55 | m_default_fg(0,0,0), | 59 | m_default_fg(0,0,0), |
56 | m_default_bg(255,255,255), | 60 | m_default_bg(255,255,255), |
57 | m_bg(255,255,255), | 61 | m_bg(255,255,255), |
58 | m_delay(100), | 62 | m_delay(100), |
59 | m_scrolldy1(0), | 63 | m_scrolldy1(0), |
60 | m_scrolldy2(0), | 64 | m_scrolldy2(0), |
61 | m_totalscroll(0), | 65 | m_totalscroll(0), |
62 | m_autoScroll(false), | 66 | m_autoScroll(false), |
63 | //textarray(NULL), | 67 | //textarray(NULL), |
64 | //locnarray(NULL), | 68 | //locnarray(NULL), |
65 | numlines(0), | 69 | numlines(0), |
66 | m_fontname("unifont"), | 70 | m_fontname("unifont"), |
@@ -80,110 +84,251 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | |||
80 | // bNegative(false), | 84 | // bNegative(false), |
81 | bInverse(false), | 85 | bInverse(false), |
82 | m_highlightfilter(NULL), | 86 | m_highlightfilter(NULL), |
83 | m_bgIsScaled(false), | 87 | m_bgIsScaled(false), |
84 | m_scrollstep(2), | 88 | m_scrollstep(2), |
85 | m_topmargin(5), | 89 | m_topmargin(5), |
86 | m_bottommargin(5), | 90 | m_bottommargin(5), |
87 | m_reparastring("{\\n[\\n ]}"), | 91 | m_reparastring("{\\n[\\n ]}"), |
88 | m_currentlinkstyle(NULL), | 92 | m_currentlinkstyle(NULL), |
89 | m_currentlinkoffset(-1), | 93 | m_currentlinkoffset(-1), |
90 | m_currentlink(-1) | 94 | m_currentlink(-1) |
91 | { | 95 | { |
96 | m_output = NULL; | ||
92 | m_overlap = 1; | 97 | m_overlap = 1; |
93 | setKeyCompression ( true ); | 98 | setKeyCompression ( true ); |
94 | #ifdef DOUBLEBUFFER | ||
95 | dbuff = new QPixmap(); | ||
96 | dbp = new QPainter(); | ||
97 | // if (painter->isActive()) painter->end(); | ||
98 | // painter->begin(frame); | ||
99 | #endif | ||
100 | // init(); | ||
101 | 99 | ||
100 | dbuff = NULL; | ||
101 | dbp = NULL; | ||
102 | } | 102 | } |
103 | 103 | ||
104 | /* | 104 | /* |
105 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : | 105 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : |
106 | QWidget(parent, name, f), | 106 | QWidget(parent, name, f), |
107 | m_textfont(0), | 107 | m_textfont(0), |
108 | m_textsize(1), | 108 | m_textsize(1), |
109 | textarray(NULL), | 109 | textarray(NULL), |
110 | numlines(0), | 110 | numlines(0), |
111 | bstripcr(true), | 111 | bstripcr(true), |
112 | bunindent(false), | 112 | bunindent(false), |
113 | brepara(false), | 113 | brepara(false), |
114 | bdblspce(false), | 114 | bdblspce(false), |
115 | btight(false), | 115 | btight(false), |
116 | bindenter(0), | 116 | bindenter(0), |
117 | m_fm(NULL) | 117 | m_fm(NULL) |
118 | { | 118 | { |
119 | init(); | 119 | init(); |
120 | // // qDebug("Load_file(1)"); | 120 | // // qDeb2ug("Load_file(1)"); |
121 | load_file((const tchar*)filename); | 121 | load_file((const tchar*)filename); |
122 | } | 122 | } |
123 | */ | 123 | */ |
124 | 124 | ||
125 | /* | 125 | /* |
126 | void QTReader::mouseMoveEvent(QMouseEvent* _e) | 126 | void QTReader::mouseMoveEvent(QMouseEvent* _e) |
127 | { | 127 | { |
128 | 128 | ||
129 | mouseUpOn = !(_e->pos().x() == -1); | 129 | mouseUpOn = !(_e->pos().x() == -1); |
130 | 130 | ||
131 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); | 131 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); |
132 | } | 132 | } |
133 | */ | 133 | */ |
134 | long QTReader::real_delay() | 134 | long QTReader::real_delay() |
135 | { | 135 | { |
136 | return m_scrollstep*( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); | 136 | return m_scrollstep*( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); |
137 | } | 137 | } |
138 | 138 | ||
139 | void QTReader::mousePressEvent( QMouseEvent* _e ) | 139 | void QTReader::mousePressEvent( QMouseEvent* _e ) |
140 | { | 140 | { |
141 | buffdoc.unsuspend(); | 141 | m_drageligible = false; |
142 | qDebug("Mouse pressed at (%u, %u)", _e->x(), _e->y()); | ||
142 | int x, y, ht, wh; | 143 | int x, y, ht, wh; |
143 | if (m_rotated) | 144 | if (m_rotated) |
144 | { | 145 | { |
145 | x = _e->y(); | 146 | x = _e->y(); |
146 | y = width()-_e->x(); | 147 | y = width()-_e->x(); |
147 | ht = width(); | 148 | ht = width(); |
148 | wh = height(); | 149 | wh = height(); |
149 | } | 150 | } |
150 | else | 151 | else |
151 | { | 152 | { |
152 | x = _e->x(); | 153 | x = _e->x(); |
153 | y = _e->y(); | 154 | y = _e->y(); |
154 | ht = height(); | 155 | ht = height(); |
155 | wh = width(); | 156 | wh = width(); |
156 | } | 157 | } |
157 | if (_e->button() == RightButton) | 158 | if (x >= m_left_border && x <= wh - m_right_border && y >= m_topmargin && y <= ht-m_bottommargin) |
158 | { | 159 | { |
159 | //qDebug("MousePress"); | 160 | if (_e->button() == RightButton) |
160 | mouseUpOn = false; | ||
161 | if (m_swapmouse) | ||
162 | { | 161 | { |
163 | int lineno = 0; | 162 | //qDebug("MousePress"); |
164 | /* | 163 | mouseUpOn = false; |
164 | if (m_swapmouse) | ||
165 | { | ||
166 | int lineno = 0; | ||
167 | /* | ||
165 | int hgt = textarray[0]->lineSpacing(); | 168 | int hgt = textarray[0]->lineSpacing(); |
166 | while ((hgt < y) && (lineno < numlines)) | 169 | while ((hgt < y) && (lineno < numlines)) |
167 | { | 170 | { |
168 | hgt += textarray[++lineno]->lineSpacing(); | 171 | hgt += textarray[++lineno]->lineSpacing(); |
169 | } | 172 | } |
170 | */ | 173 | */ |
171 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; | 174 | size_t startpos, startoffset, tgt, tgtoffset, pictgt, tabtgt; |
172 | QImage* img; | 175 | QImage* img; |
173 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); | 176 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img, tabtgt); |
174 | processmousewordevent(startpos, startoffset, _e, lineno); | 177 | processmousewordevent(startpos, startoffset, _e, lineno); |
178 | } | ||
179 | else | ||
180 | { | ||
181 | processmousepositionevent(_e); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | int ln = -1; | ||
188 | int mp; | ||
189 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | ||
190 | switch (m_scrollpos) | ||
191 | { | ||
192 | case 1: | ||
193 | { | ||
194 | if (m_rotated) | ||
195 | { | ||
196 | if (_e->x() < m_bottommargin) | ||
197 | { | ||
198 | ln = height(); | ||
199 | mp = _e->y(); | ||
200 | } | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | if (_e->y() > height()-m_bottommargin) | ||
205 | { | ||
206 | ln = width(); | ||
207 | mp = _e->x(); | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | break; | ||
212 | case 2: | ||
213 | { | ||
214 | if (m_rotated) | ||
215 | { | ||
216 | if (_e->y() > height() - m_right_border) | ||
217 | { | ||
218 | ln = width(); | ||
219 | mp = width()-_e->x(); | ||
220 | } | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | if (_e->x() > width() - m_right_border) | ||
225 | { | ||
226 | ln = height(); | ||
227 | mp = _e->y(); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | break; | ||
232 | case 3: | ||
233 | { | ||
234 | if (m_rotated) | ||
235 | { | ||
236 | if (_e->y() < m_left_border) | ||
237 | { | ||
238 | ln = width(); | ||
239 | mp = width()-_e->x(); | ||
240 | } | ||
241 | } | ||
242 | else | ||
243 | { | ||
244 | if (_e->x() < m_left_border) | ||
245 | { | ||
246 | ln = height(); | ||
247 | mp = _e->y(); | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | break; | ||
252 | case 0: | ||
253 | default: | ||
254 | ln = -1; | ||
255 | break; | ||
256 | } | ||
257 | if (ln >= 0) | ||
258 | { | ||
259 | int dp = (sectionsize*mp+ln/2)/ln + buffdoc.startSection(); | ||
260 | int winsize = locnarray[numlines]-locnarray[0]; | ||
261 | int slidersize = 10*(sectionsize+ln/2)/ln; | ||
262 | if (slidersize > winsize) | ||
263 | { | ||
264 | int mid = (locnarray[0] + locnarray[numlines])/2; | ||
265 | slidersize /= 2; | ||
266 | if (dp < mid-slidersize) | ||
267 | { | ||
268 | dopageup(); | ||
269 | } | ||
270 | else if (dp > mid+slidersize) | ||
271 | { | ||
272 | dopagedn(); | ||
273 | } | ||
274 | //if (mid-slidersize < dp && dp < mid+slidersize) | ||
275 | else | ||
276 | { | ||
277 | m_drageligible = true; | ||
278 | } | ||
279 | } | ||
280 | else | ||
281 | { | ||
282 | if (dp < locnarray[0]) | ||
283 | { | ||
284 | dopageup(); | ||
285 | } | ||
286 | else if (dp > locnarray[numlines]) | ||
287 | { | ||
288 | dopagedn(); | ||
289 | } | ||
290 | //if (locnarray[0] < dp && dp < locnarray[numlines]) | ||
291 | else | ||
292 | { | ||
293 | m_drageligible = true; | ||
294 | } | ||
295 | } | ||
296 | qDebug("Drag eligible:%s", (m_drageligible) ? "true" : "false"); | ||
297 | } | ||
298 | else | ||
299 | { | ||
300 | if (m_scrollpos == 1) | ||
301 | { | ||
302 | if (x < m_left_border) | ||
303 | { | ||
304 | lineUp(); | ||
305 | } | ||
306 | if (y > ht - m_bottommargin) | ||
307 | { | ||
308 | lineDown(); | ||
309 | } | ||
310 | } | ||
311 | else if (m_scrollpos != 0) | ||
312 | { | ||
313 | if (y < m_topmargin) | ||
314 | { | ||
315 | lineUp(); | ||
316 | } | ||
317 | if (y > ht - m_bottommargin) | ||
318 | { | ||
319 | lineDown(); | ||
320 | } | ||
321 | } | ||
175 | } | 322 | } |
176 | else | ||
177 | processmousepositionevent(_e); | ||
178 | } | 323 | } |
179 | } | 324 | } |
180 | 325 | ||
181 | void QTReader::processmousepositionevent( QMouseEvent* _e ) | 326 | void QTReader::processmousepositionevent( QMouseEvent* _e ) |
182 | { | 327 | { |
183 | int x, y, ht, wh; | 328 | int x, y, ht, wh; |
184 | if (m_rotated) | 329 | if (m_rotated) |
185 | { | 330 | { |
186 | x = _e->y(); | 331 | x = _e->y(); |
187 | y = width()-_e->x(); | 332 | y = width()-_e->x(); |
188 | ht = width(); | 333 | ht = width(); |
189 | wh = height(); | 334 | wh = height(); |
@@ -286,25 +431,25 @@ void QTReader::goForward() | |||
286 | { | 431 | { |
287 | emit NewFileRequest(nxt); | 432 | emit NewFileRequest(nxt); |
288 | } | 433 | } |
289 | locate(target); | 434 | locate(target); |
290 | } | 435 | } |
291 | else if ((lt & eLink) != 0) | 436 | else if ((lt & eLink) != 0) |
292 | { | 437 | { |
293 | locate(target); | 438 | locate(target); |
294 | } | 439 | } |
295 | } | 440 | } |
296 | } | 441 | } |
297 | 442 | ||
298 | linkType 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) | 443 | linkType 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, size_t& tabtgt) |
299 | { | 444 | { |
300 | int ht; | 445 | int ht; |
301 | if (m_scrolldy == m_topmargin) | 446 | if (m_scrolldy == m_topmargin) |
302 | { | 447 | { |
303 | lineno = 0; | 448 | lineno = 0; |
304 | ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin; | 449 | ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin; |
305 | } | 450 | } |
306 | else | 451 | else |
307 | { | 452 | { |
308 | if (y >= m_scrolldy) | 453 | if (y >= m_scrolldy) |
309 | { | 454 | { |
310 | lineno = 0; | 455 | lineno = 0; |
@@ -331,47 +476,78 @@ linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t | |||
331 | if (m_bMonoSpaced) | 476 | if (m_bMonoSpaced) |
332 | { | 477 | { |
333 | offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth; | 478 | offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth; |
334 | } | 479 | } |
335 | else | 480 | else |
336 | { | 481 | { |
337 | int i; | 482 | int i; |
338 | CDrawBuffer* t = textarray[lineno]; | 483 | CDrawBuffer* t = textarray[lineno]; |
339 | x = x - t->offset(width(), m_left_border, m_right_border, availht); | 484 | x = x - t->offset(width(), m_left_border, m_right_border, availht); |
340 | for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--); | 485 | for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--); |
341 | offset = i; | 486 | offset = i; |
342 | } | 487 | } |
343 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img); | 488 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img, tabtgt); |
344 | } | 489 | } |
345 | 490 | ||
346 | void QTReader::suspend() | 491 | void QTReader::suspend() |
347 | { | 492 | { |
348 | buffdoc.suspend(); | 493 | buffdoc.suspend(); |
349 | /*#ifdef OPIE | 494 | /*#ifdef OPIE |
350 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); | 495 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); |
351 | #else | 496 | #else |
352 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); | 497 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); |
353 | #endif | 498 | #endif |
354 | */ | 499 | */ |
355 | } | 500 | } |
356 | 501 | ||
502 | void QTReader::setDoubleBuffer(bool _b) | ||
503 | { | ||
504 | m_doubleBuffered = _b; | ||
505 | if (_b || m_rotated) | ||
506 | { | ||
507 | if (dbuff == NULL) | ||
508 | { | ||
509 | dbuff = new QPixmap(); | ||
510 | dbp = new QPainter(); | ||
511 | } | ||
512 | if (m_rotated) | ||
513 | { | ||
514 | dbuff->resize(height(), width()); | ||
515 | } | ||
516 | else | ||
517 | { | ||
518 | dbuff->resize(width(), height()); | ||
519 | } | ||
520 | m_outofdate = true; | ||
521 | } | ||
522 | else | ||
523 | { | ||
524 | if (dbuff != NULL) | ||
525 | { | ||
526 | delete dbuff; | ||
527 | delete dbp; | ||
528 | } | ||
529 | dbuff = NULL; | ||
530 | dbp = NULL; | ||
531 | } | ||
532 | } | ||
533 | |||
357 | void QTReader::setTwoTouch(bool _b) | 534 | void QTReader::setTwoTouch(bool _b) |
358 | { | 535 | { |
359 | setBackgroundColor( m_bg ); | 536 | setBackgroundColor( m_bg ); |
360 | m_twotouch = m_touchone = _b; | 537 | m_twotouch = m_touchone = _b; |
361 | } | 538 | } |
362 | 539 | ||
363 | void QTReader::setContinuous(bool _b) | 540 | void QTReader::setContinuous(bool _b) |
364 | { | 541 | { |
365 | buffdoc.unsuspend(); | ||
366 | buffdoc.setContinuous(m_continuousDocument = _b); | 542 | buffdoc.setContinuous(m_continuousDocument = _b); |
367 | } | 543 | } |
368 | 544 | ||
369 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) | 545 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) |
370 | { | 546 | { |
371 | unsigned long wrdstart, wrdend; | 547 | unsigned long wrdstart, wrdend; |
372 | QString wrd; | 548 | QString wrd; |
373 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 549 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
374 | if (m_twotouch) | 550 | if (m_twotouch) |
375 | { | 551 | { |
376 | if (m_touchone) | 552 | if (m_touchone) |
377 | { | 553 | { |
@@ -446,250 +622,393 @@ void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouse | |||
446 | { | 622 | { |
447 | wrd = toQString(t->data()+first, i - first); | 623 | wrd = toQString(t->data()+first, i - first); |
448 | // qDebug("Got %s", (const char *)wrd); | 624 | // qDebug("Got %s", (const char *)wrd); |
449 | break; | 625 | break; |
450 | } | 626 | } |
451 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 627 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
452 | if ((*t)[i] == 0) break; | 628 | if ((*t)[i] == 0) break; |
453 | first = i; | 629 | first = i; |
454 | } | 630 | } |
455 | } | 631 | } |
456 | if (!wrd.isEmpty()) | 632 | if (!wrd.isEmpty()) |
457 | { | 633 | { |
458 | qDebug("Selecteed:%s", (const char*)wrd); | 634 | qDebug("Selected:%s", (const char*)wrd); |
459 | if (m_twotouch) | 635 | if (m_twotouch) |
460 | { | 636 | { |
461 | emit OnWordSelected(wrd, wrdstart, wrdend, wrd); | 637 | emit OnWordSelected(wrd, wrdstart, wrdend, wrd); |
462 | } | 638 | } |
463 | else | 639 | else |
464 | { | 640 | { |
465 | QString line = toQString(textarray[lineno]->data()); | 641 | QString line = toQString(textarray[lineno]->data()); |
466 | emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line); | 642 | emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line); |
467 | } | 643 | } |
468 | } | 644 | } |
469 | } | 645 | } |
470 | 646 | ||
471 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | 647 | #ifdef USETIMER |
648 | void QTReader::actionDrag() | ||
472 | { | 649 | { |
473 | buffdoc.unsuspend(); | 650 | if (m_drageligible) |
474 | int x, y, ht, wh; | ||
475 | if (m_rotated) | ||
476 | { | 651 | { |
477 | x = _e->y(); | 652 | int fivepages = 5*((2*width()+m_textsize/2)/m_textsize)*((height()+m_textsize/2)/m_textsize); |
478 | y = width()-_e->x(); | 653 | if (m_dragtarget > fivepages && locnarray[numlines] < m_dragtarget - fivepages) |
479 | ht = width(); | 654 | { |
480 | wh = height(); | 655 | int tgt = m_dragtarget - fivepages/2; |
656 | //qDebug("Jumping to %u (%u)", tgt, fivepages); | ||
657 | if (tgt < buffdoc.startSection()) | ||
658 | { | ||
659 | tgt = buffdoc.startSection(); | ||
660 | } | ||
661 | locate(tgt); | ||
662 | drawFonts(); | ||
663 | } | ||
664 | else if (locnarray[0] > m_dragtarget+fivepages) | ||
665 | { | ||
666 | int tgt = m_dragtarget + fivepages/2; | ||
667 | //qDebug("Jumping to %u (%u)", tgt, fivepages); | ||
668 | if (tgt > buffdoc.endSection()) | ||
669 | { | ||
670 | dopageup(); | ||
671 | } | ||
672 | else | ||
673 | { | ||
674 | locate(tgt); | ||
675 | drawFonts(); | ||
676 | } | ||
677 | } | ||
678 | else if (locnarray[numlines] <= m_dragtarget) | ||
679 | { | ||
680 | dopagedn(); | ||
681 | } | ||
682 | else if (locnarray[0] > m_dragtarget) | ||
683 | { | ||
684 | dopageup(); | ||
685 | } | ||
481 | } | 686 | } |
482 | else | 687 | else |
483 | { | 688 | { |
484 | x = _e->x(); | 689 | m_dragtimer->stop(); |
485 | y = _e->y(); | ||
486 | ht = height(); | ||
487 | wh = width(); | ||
488 | } | 690 | } |
489 | if (_e->button() == LeftButton) | 691 | } |
692 | #endif | ||
693 | |||
694 | void QTReader::mouseMoveEvent( QMouseEvent* _e ) | ||
695 | { | ||
696 | if (m_drageligible) | ||
490 | { | 697 | { |
491 | if (mouseUpOn) | 698 | int ht; |
699 | int mp; | ||
700 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | ||
701 | //qDebug("Mouse moved to (%u, %u)", _e->x(), _e->y()); | ||
702 | switch (m_scrollpos) | ||
492 | { | 703 | { |
493 | // qDebug("MouseRelease"); | 704 | case 1: |
494 | switch(m_scrollpos) | 705 | { |
706 | if (m_rotated) | ||
707 | { | ||
708 | ht = height(); | ||
709 | mp = _e->y(); | ||
710 | } | ||
711 | else | ||
712 | { | ||
713 | ht = width(); | ||
714 | mp = _e->x(); | ||
715 | } | ||
716 | } | ||
717 | break; | ||
718 | case 2: | ||
719 | case 3: | ||
720 | { | ||
721 | if (m_rotated) | ||
722 | { | ||
723 | ht = width(); | ||
724 | mp = width()-_e->x(); | ||
725 | } | ||
726 | else | ||
727 | { | ||
728 | ht = height(); | ||
729 | mp = _e->y(); | ||
730 | } | ||
731 | } | ||
732 | break; | ||
733 | case 0: | ||
734 | default: | ||
735 | ht = -1; | ||
736 | break; | ||
737 | } | ||
738 | if (ht >= 0) | ||
739 | { | ||
740 | #ifdef USETIMER | ||
741 | m_dragtarget = (sectionsize*mp+ht/2)/ht + buffdoc.startSection(); | ||
742 | if (!m_dragtimer->isActive()) | ||
495 | { | 743 | { |
496 | case 1: // Bottom | 744 | m_dragtimer->start(0, false); |
497 | if (y > ht - 5) | ||
498 | { | ||
499 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh); | ||
500 | return; | ||
501 | } | ||
502 | break; | ||
503 | case 2: // right | ||
504 | if (x > wh - m_right_border) | ||
505 | { | ||
506 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); | ||
507 | return; | ||
508 | } | ||
509 | break; | ||
510 | case 3: // left | ||
511 | if (x < m_left_border) | ||
512 | { | ||
513 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); | ||
514 | return; | ||
515 | } | ||
516 | break; | ||
517 | case 0: | ||
518 | default: | ||
519 | break; | ||
520 | } | 745 | } |
521 | if (textarray[0] != NULL) | 746 | #else |
747 | int dp = (sectionsize*mp+ht/2)/ht + buffdoc.startSection(); | ||
748 | locate(dp); | ||
749 | #endif | ||
750 | } | ||
751 | } | ||
752 | } | ||
753 | |||
754 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | ||
755 | { | ||
756 | qDebug("Mouse released at (%u, %u)", _e->x(), _e->y()); | ||
757 | if (m_drageligible) | ||
758 | { | ||
759 | m_drageligible = false; | ||
760 | } | ||
761 | else | ||
762 | { | ||
763 | int x, y, ht, wh; | ||
764 | if (m_rotated) | ||
765 | { | ||
766 | x = _e->y(); | ||
767 | y = width()-_e->x(); | ||
768 | ht = width(); | ||
769 | wh = height(); | ||
770 | } | ||
771 | else | ||
772 | { | ||
773 | x = _e->x(); | ||
774 | y = _e->y(); | ||
775 | ht = height(); | ||
776 | wh = width(); | ||
777 | } | ||
778 | if (_e->button() == LeftButton) | ||
779 | { | ||
780 | if (mouseUpOn) | ||
522 | { | 781 | { |
523 | QString line; | 782 | // qDebug("MouseRelease"); |
524 | // int lineno = _e->y()/m_linespacing; | 783 | /* |
525 | int lineno = 0; | 784 | switch(m_scrollpos) |
526 | /* | ||
527 | int ht = textarray[0]->lineSpacing(); | ||
528 | while ((ht < y) && (lineno < numlines)) | ||
529 | { | 785 | { |
530 | ht += textarray[++lineno]->lineSpacing(); | 786 | case 1: // Bottom |
787 | if (y > ht - 5) | ||
788 | { | ||
789 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh); | ||
790 | return; | ||
531 | } | 791 | } |
532 | */ | 792 | break; |
533 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; | 793 | case 2: // right |
534 | QImage* img; | 794 | if (x > wh - m_right_border) |
535 | if (m_currentlinkstyle != NULL) | 795 | { |
536 | { | 796 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); |
537 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 797 | return; |
538 | m_currentlinkstyle = NULL; | 798 | } |
539 | m_currentlink = -1; | 799 | break; |
540 | m_currentlinkoffset = -1; | 800 | case 3: // left |
541 | } | 801 | if (x < m_left_border) |
542 | linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); | 802 | { |
543 | if ((glt & eLink) != 0) | 803 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); |
544 | { | 804 | return; |
545 | if ((glt & ePicture) != 0) | 805 | } |
546 | { | 806 | break; |
547 | qDebug("Big Picture:%x", pictgt); | 807 | case 0: |
548 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | 808 | default: |
549 | { | 809 | break; |
550 | QImage* pm = buffdoc.getPicture(pictgt); | 810 | } |
551 | if (pm != NULL) | 811 | */ |
552 | { | 812 | if (textarray[0] != NULL) |
553 | emit OnShowPicture(*pm); | 813 | { |
554 | delete pm; | 814 | QString line; |
555 | return; | 815 | // int lineno = _e->y()/m_linespacing; |
556 | } | 816 | int lineno = 0; |
557 | } | 817 | /* |
558 | } | 818 | int ht = textarray[0]->lineSpacing(); |
559 | else if (img != NULL) | 819 | while ((ht < y) && (lineno < numlines)) |
560 | { | 820 | { |
561 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | 821 | ht += textarray[++lineno]->lineSpacing(); |
562 | { | 822 | } |
563 | emit OnShowPicture(*img); | 823 | */ |
564 | return; | 824 | size_t startpos, startoffset, tgt, tgtoffset, pictgt, tabtgt; |
565 | } | 825 | QImage* img; |
566 | } | 826 | if (m_currentlinkstyle != NULL) |
567 | size_t saveposn = pagelocate(); | 827 | { |
568 | QString href, nm; | 828 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
569 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); | 829 | m_currentlinkstyle = NULL; |
570 | qDebug("URL(1):%s", (const char*)href); | 830 | m_currentlink = -1; |
571 | if ((lt & eFile) != 0) | 831 | m_currentlinkoffset = -1; |
572 | { | 832 | } |
573 | buffdoc.saveposn(m_lastfile, saveposn); | 833 | linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img, tabtgt); |
834 | if (bNoInlineTables && ((glt & eTable) != 0)) | ||
835 | { | ||
836 | size_t currentpos = locate(); | ||
837 | QString tabtext = buffdoc.getTableAsHtml(tabtgt); | ||
838 | qDebug("TABLE:%u:%u:%s", currentpos, tabtgt, (const char*)tabtext); | ||
839 | QFont f(m_fontname, m_fontControl.currentsize()); | ||
574 | #ifdef USEQPE | 840 | #ifdef USEQPE |
841 | CTableDialog td(f, tabtext, true, this); | ||
842 | #else | ||
843 | CTableDialog td(f, tabtext, false, this); | ||
844 | #endif | ||
845 | td.exec(); | ||
846 | jumpto(currentpos); | ||
847 | } | ||
848 | if ((glt & eLink) != 0) | ||
849 | { | ||
850 | if ((glt & ePicture) != 0) | ||
575 | { | 851 | { |
576 | QCopEnvelope e("QPE/System", "busy()"); | 852 | qDebug("Big Picture:%x", pictgt); |
853 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | ||
854 | { | ||
855 | QImage* pm = buffdoc.getPicture(pictgt); | ||
856 | if (pm != NULL) | ||
857 | { | ||
858 | emit OnShowPicture(*pm); | ||
859 | delete pm; | ||
860 | return; | ||
861 | } | ||
862 | } | ||
577 | } | 863 | } |
578 | #endif | 864 | else if (img != NULL) |
579 | ResetScroll(); | ||
580 | if (!href.isEmpty()) | ||
581 | { | ||
582 | if (!buffdoc.getFile(href)) | ||
583 | { | ||
584 | emit NewFileRequest(href); | ||
585 | } | ||
586 | else | ||
587 | { | ||
588 | ResetScroll(); | ||
589 | fillbuffer(); | ||
590 | update(); | ||
591 | } | ||
592 | } | ||
593 | if (!nm.isEmpty()) | ||
594 | { | ||
595 | qDebug("QTReader:Finding %s", (const char*)nm); | ||
596 | if (buffdoc.findanchor(nm)) | ||
597 | { | ||
598 | fillbuffer(); | ||
599 | update(); | ||
600 | } | ||
601 | } | ||
602 | //fillbuffer(); | ||
603 | //update(); | ||
604 | #ifdef USEQPE | ||
605 | { | 865 | { |
606 | QCopEnvelope e("QPE/System", "notBusy()"); | 866 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) |
867 | { | ||
868 | emit OnShowPicture(*img); | ||
869 | return; | ||
870 | } | ||
607 | } | 871 | } |
608 | #endif | 872 | size_t saveposn = pagelocate(); |
609 | } | 873 | QString href, nm; |
610 | else if ((lt & eLink) != 0) | 874 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); |
611 | { | 875 | qDebug("URL(1):%s", (const char*)href); |
612 | buffdoc.saveposn(m_lastfile, saveposn); | 876 | if ((lt & eFile) != 0) |
613 | ResetScroll(); | 877 | { |
614 | fillbuffer(); | 878 | buffdoc.saveposn(m_lastfile, saveposn); |
615 | update(); | 879 | #ifdef USEQPE |
616 | } | ||
617 | else | ||
618 | { | ||
619 | if ((lt & ePicture) != 0) | ||
620 | { | 880 | { |
621 | QImage* pm = buffdoc.getPicture(tgt); | 881 | QCopEnvelope e("QPE/System", "busy()"); |
622 | if (pm != NULL) | ||
623 | { | ||
624 | emit OnShowPicture(*pm); | ||
625 | delete pm; | ||
626 | } | ||
627 | } | 882 | } |
628 | else | 883 | #endif |
884 | ResetScroll(); | ||
885 | if (!href.isEmpty()) | ||
886 | { | ||
887 | if (!buffdoc.getFile(href, nm)) | ||
888 | { | ||
889 | emit NewFileRequest(href); | ||
890 | } | ||
891 | else | ||
892 | { | ||
893 | qDebug("BEFORE:%u", pagelocate()); | ||
894 | buffdoc.resetPos(); | ||
895 | ResetScroll(); | ||
896 | fillbuffer(); | ||
897 | qDebug("AFTER:%u", pagelocate()); | ||
898 | m_outofdate = true; | ||
899 | update(); | ||
900 | } | ||
901 | } | ||
902 | if (!nm.isEmpty()) | ||
903 | { | ||
904 | qDebug("QTReader:Finding %s", (const char*)nm); | ||
905 | if (buffdoc.findanchor(nm)) | ||
906 | { | ||
907 | buffdoc.resetPos(); | ||
908 | fillbuffer(); | ||
909 | m_outofdate = true; | ||
910 | update(); | ||
911 | } | ||
912 | } | ||
913 | //fillbuffer(); | ||
914 | //update(); | ||
915 | #ifdef USEQPE | ||
629 | { | 916 | { |
630 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); | 917 | QCopEnvelope e("QPE/System", "notBusy()"); |
631 | if (!href.isEmpty()) | ||
632 | { | ||
633 | emit OnURLSelected(href, tgt); | ||
634 | } | ||
635 | } | 918 | } |
636 | locate(pagelocate()); | 919 | #endif |
637 | } | 920 | } |
638 | return; | 921 | else if ((lt & eLink) != 0) |
639 | } | 922 | { |
640 | else if ((glt & ePicture) != 0) | 923 | buffdoc.saveposn(m_lastfile, saveposn); |
641 | { | 924 | ResetScroll(); |
642 | qDebug("Big Picture:%x", pictgt); | 925 | fillbuffer(); |
643 | QImage* pm = buffdoc.getPicture(pictgt); | 926 | m_outofdate = true; |
644 | if (pm != NULL) | 927 | update(); |
645 | { | 928 | } |
646 | emit OnShowPicture(*pm); | 929 | else |
647 | delete pm; | 930 | { |
648 | } | 931 | if ((lt & ePicture) != 0) |
649 | else | 932 | { |
650 | { | 933 | QImage* pm = buffdoc.getPicture(tgt); |
651 | locate(pagelocate()); | 934 | if (pm != NULL) |
652 | } | 935 | { |
653 | return; | 936 | emit OnShowPicture(*pm); |
654 | } | 937 | delete pm; |
655 | else if (img != NULL) | 938 | } |
656 | { | 939 | } |
657 | emit OnShowPicture(*img); | 940 | else |
658 | return; | 941 | { |
659 | } | 942 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); |
660 | if (m_swapmouse) | 943 | if (!href.isEmpty()) |
944 | { | ||
945 | emit OnURLSelected(href, tgt); | ||
946 | } | ||
947 | } | ||
948 | } | ||
949 | return; | ||
950 | } | ||
951 | else if ((glt & ePicture) != 0) | ||
952 | { | ||
953 | qDebug("Big Picture:%x", pictgt); | ||
954 | QImage* pm = buffdoc.getPicture(pictgt); | ||
955 | if (pm != NULL) | ||
956 | { | ||
957 | emit OnShowPicture(*pm); | ||
958 | delete pm; | ||
959 | } | ||
960 | else | ||
961 | { | ||
962 | update(); | ||
963 | } | ||
964 | return; | ||
965 | } | ||
966 | else if (img != NULL) | ||
967 | { | ||
968 | emit OnShowPicture(*img); | ||
969 | return; | ||
970 | } | ||
971 | if (m_swapmouse) | ||
661 | processmousepositionevent(_e); | 972 | processmousepositionevent(_e); |
662 | else | 973 | else |
663 | processmousewordevent(startpos, startoffset, _e, lineno); | 974 | processmousewordevent(startpos, startoffset, _e, lineno); |
975 | } | ||
976 | } | ||
977 | else | ||
978 | { | ||
979 | mouseUpOn = true; | ||
664 | } | 980 | } |
665 | } | ||
666 | else | ||
667 | { | ||
668 | mouseUpOn = true; | ||
669 | } | 981 | } |
670 | } | 982 | } |
671 | } | 983 | } |
672 | 984 | ||
673 | void QTReader::focusInEvent(QFocusEvent* e) | 985 | void QTReader::focusInEvent(QFocusEvent* e) |
674 | { | 986 | { |
675 | if (m_autoScroll) timer->start(real_delay(), false); | 987 | if (m_autoScroll && (m_scrolltype != 4)) timer->start(real_delay(), false); |
676 | update(); | 988 | update(); |
677 | } | 989 | } |
678 | 990 | ||
679 | void QTReader::focusOutEvent(QFocusEvent* e) | 991 | void QTReader::focusOutEvent(QFocusEvent* e) |
680 | { | 992 | { |
681 | if (m_autoScroll) | 993 | if (m_autoScroll) |
682 | { | 994 | { |
683 | timer->stop(); | 995 | if (m_scrolltype != 4) |
996 | { | ||
997 | timer->stop(); | ||
998 | } | ||
999 | else | ||
1000 | { | ||
1001 | m_autoScroll = false; | ||
1002 | } | ||
684 | //m_scrolldy1 = m_scrolldy2 = 0; | 1003 | //m_scrolldy1 = m_scrolldy2 = 0; |
685 | } | 1004 | } |
686 | } | 1005 | } |
687 | 1006 | ||
688 | #include <qapplication.h> | 1007 | #include <qapplication.h> |
689 | #include <qdrawutil.h> | 1008 | #include <qdrawutil.h> |
690 | #ifndef _WINDOWS | 1009 | #ifndef _WINDOWS |
691 | #include <unistd.h> | 1010 | #include <unistd.h> |
692 | #endif | 1011 | #endif |
693 | 1012 | ||
694 | void QTReader::goDown() | 1013 | void QTReader::goDown() |
695 | { | 1014 | { |
@@ -708,84 +1027,80 @@ void QTReader::goUp() | |||
708 | if (m_bpagemode) | 1027 | if (m_bpagemode) |
709 | { | 1028 | { |
710 | dopageup(); | 1029 | dopageup(); |
711 | } | 1030 | } |
712 | else | 1031 | else |
713 | { | 1032 | { |
714 | lineUp(); | 1033 | lineUp(); |
715 | } | 1034 | } |
716 | } | 1035 | } |
717 | 1036 | ||
718 | void QTReader::NavUp() | 1037 | void QTReader::NavUp() |
719 | { | 1038 | { |
720 | buffdoc.unsuspend(); | ||
721 | if (buffdoc.hasnavigation()) | 1039 | if (buffdoc.hasnavigation()) |
722 | { | 1040 | { |
723 | /* | 1041 | /* |
724 | size_t target = pagelocate(); | 1042 | size_t target = pagelocate(); |
725 | if (buffdoc.back(target)) | 1043 | if (buffdoc.back(target)) |
726 | { | 1044 | { |
727 | locate(target); | 1045 | locate(target); |
728 | } | 1046 | } |
729 | */ | 1047 | */ |
730 | locate(buffdoc.startSection()); | 1048 | locate(buffdoc.startSection()); |
731 | } | 1049 | } |
732 | else | 1050 | else |
733 | { | 1051 | { |
734 | goUp(); | 1052 | goUp(); |
735 | } | 1053 | } |
736 | } | 1054 | } |
737 | 1055 | ||
738 | void QTReader::NavDown() | 1056 | void QTReader::NavDown() |
739 | { | 1057 | { |
740 | buffdoc.unsuspend(); | ||
741 | if (buffdoc.hasnavigation()) | 1058 | if (buffdoc.hasnavigation()) |
742 | { | 1059 | { |
743 | /* | 1060 | /* |
744 | size_t target = pagelocate(); | 1061 | size_t target = pagelocate(); |
745 | if (buffdoc.forward(target)) | 1062 | if (buffdoc.forward(target)) |
746 | { | 1063 | { |
747 | locate(target); | 1064 | locate(target); |
748 | } | 1065 | } |
749 | */ | 1066 | */ |
750 | dopageup(buffdoc.endSection()); | 1067 | dopageup(buffdoc.endSection()); |
751 | } | 1068 | } |
752 | else | 1069 | else |
753 | { | 1070 | { |
754 | goDown(); | 1071 | goDown(); |
755 | } | 1072 | } |
756 | } | 1073 | } |
757 | 1074 | ||
758 | void QTReader::zoomin() | 1075 | void QTReader::zoomin() |
759 | { | 1076 | { |
760 | if (m_fontControl.increasesize()) | 1077 | if (m_fontControl.increasesize()) |
761 | { | 1078 | { |
762 | bool sc = m_autoScroll; | 1079 | bool sc = m_autoScroll; |
763 | setautoscroll(false); | 1080 | setautoscroll(false); |
764 | setfont(); | 1081 | setfont(); |
765 | locate(pagelocate()); | 1082 | refresh(); |
766 | repaint(); | ||
767 | setautoscroll(sc); | 1083 | setautoscroll(sc); |
768 | } | 1084 | } |
769 | } | 1085 | } |
770 | 1086 | ||
771 | void QTReader::zoomout() | 1087 | void QTReader::zoomout() |
772 | { | 1088 | { |
773 | if (m_fontControl.decreasesize()) | 1089 | if (m_fontControl.decreasesize()) |
774 | { | 1090 | { |
775 | bool sc = m_autoScroll; | 1091 | bool sc = m_autoScroll; |
776 | setautoscroll(false); | 1092 | setautoscroll(false); |
777 | setfont(); | 1093 | setfont(); |
778 | locate(pagelocate()); | 1094 | refresh(); |
779 | repaint(); | ||
780 | setautoscroll(sc); | 1095 | setautoscroll(sc); |
781 | } | 1096 | } |
782 | } | 1097 | } |
783 | 1098 | ||
784 | void QTReader::reduceScroll() | 1099 | void QTReader::reduceScroll() |
785 | { | 1100 | { |
786 | if (m_delay < 59049) | 1101 | if (m_delay < 59049) |
787 | { | 1102 | { |
788 | m_delay = (3*m_delay)/2; | 1103 | m_delay = (3*m_delay)/2; |
789 | timer->changeInterval(real_delay()); | 1104 | timer->changeInterval(real_delay()); |
790 | } | 1105 | } |
791 | else | 1106 | else |
@@ -800,26 +1115,25 @@ void QTReader::increaseScroll() | |||
800 | { | 1115 | { |
801 | m_delay = (2*m_delay)/3; | 1116 | m_delay = (2*m_delay)/3; |
802 | timer->changeInterval(real_delay()); | 1117 | timer->changeInterval(real_delay()); |
803 | } | 1118 | } |
804 | else | 1119 | else |
805 | { | 1120 | { |
806 | m_delay = 454; | 1121 | m_delay = 454; |
807 | } | 1122 | } |
808 | } | 1123 | } |
809 | 1124 | ||
810 | void QTReader::keyPressEvent(QKeyEvent* e) | 1125 | void QTReader::keyPressEvent(QKeyEvent* e) |
811 | { | 1126 | { |
812 | buffdoc.unsuspend(); | 1127 | |
813 | |||
814 | //((QTReaderApp*)parent()->parent())->handlekey(e); | 1128 | //((QTReaderApp*)parent()->parent())->handlekey(e); |
815 | emit HandleKeyRequest(e); | 1129 | emit HandleKeyRequest(e); |
816 | // e->ignore(); | 1130 | // e->ignore(); |
817 | return; | 1131 | return; |
818 | #ifdef _SCROLLPIPE | 1132 | #ifdef _SCROLLPIPE |
819 | if (m_isPaused) | 1133 | if (m_isPaused) |
820 | { | 1134 | { |
821 | m_isPaused = false; | 1135 | m_isPaused = false; |
822 | if (e->key() != Key_Space) | 1136 | if (e->key() != Key_Space) |
823 | { | 1137 | { |
824 | m_autoScroll = false; | 1138 | m_autoScroll = false; |
825 | if (m_pipeout != NULL) | 1139 | if (m_pipeout != NULL) |
@@ -897,66 +1211,69 @@ void QTReader::CalculateScrollParameters() | |||
897 | + | 1211 | + |
898 | ((numlines > 1) ? textarray[numlines-1]->lineExtraSpacing() : 0) | 1212 | ((numlines > 1) ? textarray[numlines-1]->lineExtraSpacing() : 0) |
899 | )/2 + | 1213 | )/2 + |
900 | m_scrolldy1 - 2; | 1214 | m_scrolldy1 - 2; |
901 | m_scrolldy2 = ((m_rotated) ? width() : height()) - ypos - bmargin; | 1215 | m_scrolldy2 = ((m_rotated) ? width() : height()) - ypos - bmargin; |
902 | } | 1216 | } |
903 | break; | 1217 | break; |
904 | } | 1218 | } |
905 | } | 1219 | } |
906 | 1220 | ||
907 | void QTReader::setautoscroll(bool _sc) | 1221 | void QTReader::setautoscroll(bool _sc) |
908 | { | 1222 | { |
1223 | m_outofdate = true; | ||
909 | if (_sc == m_autoScroll) return; | 1224 | if (_sc == m_autoScroll) return; |
910 | if (m_autoScroll) | 1225 | if (m_autoScroll) |
911 | { | 1226 | { |
912 | m_autoScroll = false; | 1227 | m_autoScroll = false; |
913 | #ifdef USEQPE | 1228 | #ifdef USEQPE |
914 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1229 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
915 | #endif | 1230 | #endif |
916 | #ifdef _SCROLLPIPE | 1231 | #ifdef _SCROLLPIPE |
917 | if (m_pipeout != NULL) | 1232 | if (m_pipeout != NULL) |
918 | { | 1233 | { |
919 | pclose(m_pipeout); | 1234 | pclose(m_pipeout); |
920 | m_pipeout = NULL; | 1235 | m_pipeout = NULL; |
921 | } | 1236 | } |
922 | #endif | 1237 | #endif |
923 | //m_scrolldy1 = 0; | 1238 | //m_scrolldy1 = 0; |
924 | //refresh(); | 1239 | //refresh(); |
925 | } | 1240 | } |
926 | else | 1241 | else |
927 | { | 1242 | { |
928 | CDrawBuffer* reusebuffer = textarray[numlines]; | 1243 | CDrawBuffer* reusebuffer = textarray[numlines]; |
929 | if (reusebuffer == NULL || reusebuffer->eof()) return; | 1244 | if (reusebuffer == NULL || reusebuffer->eof()) return; |
1245 | #ifndef __STATIC | ||
1246 | if ((m_scrolltype == 4) && !checkoutput()) return; | ||
1247 | #endif | ||
930 | m_autoScroll = true; | 1248 | m_autoScroll = true; |
931 | CalculateScrollParameters(); | 1249 | CalculateScrollParameters(); |
932 | 1250 | ||
933 | #ifdef _SCROLLPIPE | 1251 | #ifdef _SCROLLPIPE |
934 | if (!m_pipetarget.isEmpty()) | 1252 | if (!m_pipetarget.isEmpty()) |
935 | { | 1253 | { |
936 | // qDebug("Opening pipe to %s", (const char*)m_pipetarget); | 1254 | // qDebug("Opening pipe to %s", (const char*)m_pipetarget); |
937 | m_pipeout = popen((const char*)m_pipetarget, "w"); | 1255 | m_pipeout = popen((const char*)m_pipetarget, "w"); |
938 | m_isPaused = false; | 1256 | m_isPaused = false; |
939 | } | 1257 | } |
940 | #endif | 1258 | #endif |
941 | autoscroll(); | 1259 | autoscroll(); |
942 | #ifdef USEQPE | 1260 | #ifdef USEQPE |
943 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed | 1261 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; // light is even not dimmed |
944 | #endif | 1262 | #endif |
945 | } | 1263 | } |
946 | } | 1264 | } |
947 | 1265 | ||
948 | bool QTReader::getline(CDrawBuffer *buff) | 1266 | bool QTReader::getline(CDrawBuffer *buff) |
949 | { | 1267 | { |
950 | buffdoc.unsuspend(); | ||
951 | bool bRet; | 1268 | bool bRet; |
952 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 1269 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
953 | if (m_bMonoSpaced) | 1270 | if (m_bMonoSpaced) |
954 | { | 1271 | { |
955 | bRet = buffdoc.getline(buff ,(m_rotated) ? height() : width(), m_charWidth, m_left_border, m_right_border, availht); | 1272 | bRet = buffdoc.getline(buff ,(m_rotated) ? height() : width(), m_charWidth, m_left_border, m_right_border, availht); |
956 | } | 1273 | } |
957 | else | 1274 | else |
958 | { | 1275 | { |
959 | bRet = buffdoc.getline(buff, (m_rotated) ? height() : width(), m_left_border, m_right_border, hyphenate, availht); | 1276 | bRet = buffdoc.getline(buff, (m_rotated) ? height() : width(), m_left_border, m_right_border, hyphenate, availht); |
960 | } | 1277 | } |
961 | buff->resize(availht); | 1278 | buff->resize(availht); |
962 | return bRet; | 1279 | return bRet; |
@@ -1056,59 +1373,40 @@ void QTReader::doinplacescroll() | |||
1056 | p.fillRect(m_left_border,m_scrolldy-textarray[numlines-1]->lineSpacing(),width()-(m_left_border+m_right_border),textarray[numlines-1]->lineSpacing(),m_bg); | 1373 | p.fillRect(m_left_border,m_scrolldy-textarray[numlines-1]->lineSpacing(),width()-(m_left_border+m_right_border),textarray[numlines-1]->lineSpacing(),m_bg); |
1057 | } | 1374 | } |
1058 | else | 1375 | else |
1059 | { | 1376 | { |
1060 | int h_tmp = textarray[numlines-1]->lineSpacing(); | 1377 | int h_tmp = textarray[numlines-1]->lineSpacing(); |
1061 | bitBlt(this, m_left_border, m_scrolldy-h_tmp, dbuff, m_left_border, m_scrolldy-h_tmp, width()-(m_left_border+m_right_border), h_tmp); | 1378 | bitBlt(this, m_left_border, m_scrolldy-h_tmp, dbuff, m_left_border, m_scrolldy-h_tmp, width()-(m_left_border+m_right_border), h_tmp); |
1062 | } | 1379 | } |
1063 | textarray[numlines-1]->render(&p, m_scrolldy -textarray[numlines-1]->lineSpacing()+ textarray[numlines-1]->ascent(), m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | 1380 | textarray[numlines-1]->render(&p, m_scrolldy -textarray[numlines-1]->lineSpacing()+ textarray[numlines-1]->ascent(), m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); |
1064 | } | 1381 | } |
1065 | mylastpos = locate(); | 1382 | mylastpos = locate(); |
1066 | if (!ch) | 1383 | if (!ch) |
1067 | { | 1384 | { |
1068 | /* | ||
1069 | if (m_rotated) | ||
1070 | { | ||
1071 | blitRot2(0,0,height(),width()-m_scrolldy,NULL); | ||
1072 | // blitRot2(0,0,0,height(),width()-m_scrolldy,NULL); | ||
1073 | } | ||
1074 | else | ||
1075 | { | ||
1076 | if (m_bgpm.isNull()) | ||
1077 | { | ||
1078 | p.fillRect(0,m_scrolldy,width(),height()-m_scrolldy,m_bg); | ||
1079 | } | ||
1080 | else | ||
1081 | { | ||
1082 | bitBlt(this, 0, m_scrolldy, dbuff, 0, m_scrolldy, width(), height()-m_scrolldy); | ||
1083 | } | ||
1084 | } | ||
1085 | */ | ||
1086 | m_scrolldy = m_topmargin; | 1385 | m_scrolldy = m_topmargin; |
1087 | m_autoScroll = false; | 1386 | m_autoScroll = false; |
1088 | #ifdef _SCROLLPIPE | 1387 | #ifdef _SCROLLPIPE |
1089 | for (int i = 0; i < numlines; i++) | 1388 | for (int i = 0; i < numlines; i++) |
1090 | { | 1389 | { |
1091 | if (m_pipeout != NULL) | 1390 | if (m_pipeout != NULL) |
1092 | { | 1391 | { |
1093 | QString outstr = toQString(textarray[i]->data()); | 1392 | QString outstr = toQString(textarray[i]->data()); |
1094 | if (!outstr.isEmpty()) | 1393 | if (!outstr.isEmpty()) |
1095 | { | 1394 | { |
1096 | fprintf(m_pipeout, "%s\n", (const char*)outstr); | 1395 | fprintf(m_pipeout, "%s\n", (const char*)outstr); |
1097 | fflush(m_pipeout); | 1396 | fflush(m_pipeout); |
1098 | } | 1397 | } |
1099 | } | 1398 | } |
1100 | } | 1399 | } |
1101 | #endif | 1400 | #endif |
1102 | //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | ||
1103 | emit SetScrollState(m_autoScroll); | 1401 | emit SetScrollState(m_autoScroll); |
1104 | #ifdef USEQPE | 1402 | #ifdef USEQPE |
1105 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 1403 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1106 | #endif | 1404 | #endif |
1107 | } | 1405 | } |
1108 | if (m_scrolldy > ht-textarray[numlines]->lineSpacing()) | 1406 | if (m_scrolldy > ht-textarray[numlines]->lineSpacing()) |
1109 | { | 1407 | { |
1110 | if (m_rotated) | 1408 | if (m_rotated) |
1111 | { | 1409 | { |
1112 | if (m_bgpm.isNull()) | 1410 | if (m_bgpm.isNull()) |
1113 | { | 1411 | { |
1114 | p.fillRect(bmargin, m_left_border, ht-m_scrolldy, wh-(m_left_border+m_right_border), m_bg); | 1412 | p.fillRect(bmargin, m_left_border, ht-m_scrolldy, wh-(m_left_border+m_right_border), m_bg); |
@@ -1485,27 +1783,38 @@ void QTReader::redrawScroll(QPainter* p) | |||
1485 | } | 1783 | } |
1486 | } | 1784 | } |
1487 | break; | 1785 | break; |
1488 | case 0: | 1786 | case 0: |
1489 | default: | 1787 | default: |
1490 | break; | 1788 | break; |
1491 | } | 1789 | } |
1492 | if (m_scrollpos != 0) DrawScroll(p, width(), height()); | 1790 | if (m_scrollpos != 0) DrawScroll(p, width(), height()); |
1493 | } | 1791 | } |
1494 | 1792 | ||
1495 | void QTReader::autoscroll() | 1793 | void QTReader::autoscroll() |
1496 | { | 1794 | { |
1497 | drawBackground(); | 1795 | if (m_scrolltype == 4) |
1498 | dbp->end(); | 1796 | { |
1499 | timer->start(real_delay(), false); | 1797 | readAloud(); |
1798 | } | ||
1799 | else | ||
1800 | { | ||
1801 | if (dbuff != NULL) | ||
1802 | { | ||
1803 | dbp->begin(dbuff); | ||
1804 | drawBackground(dbp); | ||
1805 | dbp->end(); | ||
1806 | } | ||
1807 | timer->start(real_delay(), false); | ||
1808 | } | ||
1500 | } | 1809 | } |
1501 | 1810 | ||
1502 | void QTReader::setfont() | 1811 | void QTReader::setfont() |
1503 | { | 1812 | { |
1504 | // m_fontControl.Change | 1813 | // m_fontControl.Change |
1505 | m_charWidth = (m_charpc*m_fontControl.currentsize())/100; | 1814 | m_charWidth = (m_charpc*m_fontControl.currentsize())/100; |
1506 | if (m_charWidth <= 0) m_charWidth = 1; | 1815 | if (m_charWidth <= 0) m_charWidth = 1; |
1507 | m_ascent = m_fontControl.ascent(); | 1816 | m_ascent = m_fontControl.ascent(); |
1508 | m_descent = m_fontControl.descent(); | 1817 | m_descent = m_fontControl.descent(); |
1509 | m_linespacing = m_fontControl.lineSpacing(); | 1818 | m_linespacing = m_fontControl.lineSpacing(); |
1510 | } | 1819 | } |
1511 | 1820 | ||
@@ -1548,79 +1857,117 @@ void QTReader::DrawStraight(QPainter* p, int w, int h) | |||
1548 | } | 1857 | } |
1549 | bool wasrotated = m_rotated; | 1858 | bool wasrotated = m_rotated; |
1550 | m_rotated = false; | 1859 | m_rotated = false; |
1551 | DrawScroll(p, w, h); | 1860 | DrawScroll(p, w, h); |
1552 | m_rotated = wasrotated; | 1861 | m_rotated = wasrotated; |
1553 | 1862 | ||
1554 | } | 1863 | } |
1555 | 1864 | ||
1556 | void QTReader::redrawall() | 1865 | void QTReader::redrawall() |
1557 | { | 1866 | { |
1558 | if (m_rotated) | 1867 | if (m_rotated) |
1559 | { | 1868 | { |
1560 | #ifdef DOUBLEBUFFER | 1869 | if (dbuff != NULL) |
1561 | drawBackground(); | 1870 | { |
1562 | DrawStraight(dbp, height(), width()); | 1871 | dbp->begin(dbuff); |
1563 | dbp->end(); | 1872 | drawBackground(dbp); |
1564 | 1873 | DrawStraight(dbp, height(), width()); | |
1565 | QWMatrix m; | 1874 | dbp->end(); |
1566 | m.rotate(90); | 1875 | |
1567 | QPixmap rp = dbuff->xForm(m); | 1876 | QWMatrix m; |
1568 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | 1877 | m.rotate(90); |
1569 | #else | 1878 | QPixmap rp = dbuff->xForm(m); |
1570 | QPixmap dbuff(height(), width()); | 1879 | bitBlt(this, 0,0,&rp,0,0,-1,-1); |
1571 | QPainter dbp(&dbuff); | 1880 | } |
1572 | // dbp.setBackgroundMode(OpaqueMode); | 1881 | else |
1573 | dbp.fillRect(dbuff.rect(), m_bg); | 1882 | { |
1574 | 1883 | qDebug("This shouldn't happen but it doesn't matter if it does (rotated == double buffered)"); | |
1575 | DrawStraight(&dbp, height(), width()); | 1884 | QPixmap dbuff(height(), width()); |
1576 | 1885 | QPainter dbp(&dbuff); | |
1577 | QWMatrix m; | 1886 | |
1578 | m.rotate(90); | 1887 | drawBackground(&dbp); |
1579 | QPixmap rp = dbuff.xForm(m); | 1888 | DrawStraight(&dbp, height(), width()); |
1580 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | 1889 | |
1581 | #endif | 1890 | QWMatrix m; |
1891 | m.rotate(90); | ||
1892 | QPixmap rp = dbuff.xForm(m); | ||
1893 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | ||
1894 | } | ||
1582 | } | 1895 | } |
1583 | else | 1896 | else |
1584 | { | 1897 | { |
1585 | #ifdef DOUBLEBUFFER | 1898 | if (dbuff != NULL) |
1586 | drawBackground(); | 1899 | { |
1587 | DrawStraight(dbp, width(), height()); | 1900 | dbp->begin(dbuff); |
1588 | dbp->end(); | 1901 | drawBackground(dbp); |
1589 | bitBlt(this, 0,0,dbuff,0,0,-1,-1); | 1902 | DrawStraight(dbp, width(), height()); |
1590 | #else | 1903 | dbp->end(); |
1591 | DrawStraight(p, width(), height()); | 1904 | bitBlt(this, 0,0,dbuff,0,0,-1,-1); |
1592 | #endif | 1905 | } |
1906 | else | ||
1907 | { | ||
1908 | QPainter p(this); | ||
1909 | drawBackground(&p); | ||
1910 | DrawStraight(&p, width(), height()); | ||
1911 | } | ||
1593 | } | 1912 | } |
1594 | } | 1913 | } |
1595 | 1914 | ||
1596 | void QTReader::drawFonts() | 1915 | void QTReader::drawFonts() |
1597 | { | 1916 | { |
1598 | if (bDoUpdates) | 1917 | if (bDoUpdates) |
1599 | { | 1918 | { |
1600 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 1919 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
1601 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 1920 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
1602 | //qDebug("How refreshing..."); | 1921 | //qDebug("How refreshing..."); |
1603 | if (buffdoc.empty()) return; | 1922 | if (buffdoc.empty()) |
1923 | { | ||
1924 | if (dbuff != NULL) | ||
1925 | { | ||
1926 | dbp->begin(dbuff); | ||
1927 | drawBackground(dbp); | ||
1928 | dbp->end(); | ||
1929 | } | ||
1930 | else | ||
1931 | { | ||
1932 | QPainter p(this); | ||
1933 | drawBackground(&p); | ||
1934 | } | ||
1935 | return; | ||
1936 | } | ||
1604 | setfont(); | 1937 | setfont(); |
1605 | //if (!m_autoScroll) m_scrolldy1 = 0; | 1938 | //if (!m_autoScroll) m_scrolldy1 = 0; |
1606 | #ifdef ROTATION_ENABLED | 1939 | if (dbuff != NULL && (dbuff->width() != width() || dbuff->height() != height())) |
1940 | { | ||
1941 | qDebug("Oh no! A resize event was missed..."); | ||
1942 | if (m_rotated) | ||
1943 | { | ||
1944 | dbuff->resize(height(), width()); | ||
1945 | } | ||
1946 | else | ||
1947 | { | ||
1948 | dbuff->resize(width(), height()); | ||
1949 | } | ||
1950 | m_lastwidth = 0; | ||
1951 | } | ||
1607 | if (m_lastwidth != ((m_rotated) ? height() : width())) | 1952 | if (m_lastwidth != ((m_rotated) ? height() : width())) |
1608 | { | 1953 | { |
1609 | m_scrolldy = m_topmargin; | 1954 | m_scrolldy = m_topmargin; |
1610 | // qDebug("Not Optimised %d", m_lastwidth); | 1955 | // qDebug("Not Optimised %d", m_lastwidth); |
1611 | m_lastwidth = ((m_rotated) ? height() : width()); | 1956 | m_lastwidth = ((m_rotated) ? height() : width()); |
1612 | m_lastheight = ((m_rotated) ? width() : height()); | 1957 | m_lastheight = ((m_rotated) ? width() : height()); |
1613 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | 1958 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); |
1614 | locate(pagelocate()); | 1959 | buffdoc.locate(pagelocate()); |
1960 | fillbuffer(); | ||
1961 | redrawall(); | ||
1615 | // qDebug("Not Optimised %d", m_lastwidth); | 1962 | // qDebug("Not Optimised %d", m_lastwidth); |
1616 | } | 1963 | } |
1617 | else | 1964 | else |
1618 | { | 1965 | { |
1619 | int newht = ((m_rotated) ? width() : height()); | 1966 | int newht = ((m_rotated) ? width() : height()); |
1620 | if (m_lastheight > newht) | 1967 | if (m_lastheight > newht) |
1621 | { | 1968 | { |
1622 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); | 1969 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); |
1623 | m_scrolldy = m_topmargin; | 1970 | m_scrolldy = m_topmargin; |
1624 | int ypos = m_scrolldy1+m_topmargin; | 1971 | int ypos = m_scrolldy1+m_topmargin; |
1625 | for (int i = 0; i < numlines; i++) | 1972 | for (int i = 0; i < numlines; i++) |
1626 | { | 1973 | { |
@@ -1642,81 +1989,24 @@ void QTReader::drawFonts() | |||
1642 | for (int i = 0; i <= numlines; i++) | 1989 | for (int i = 0; i <= numlines; i++) |
1643 | { | 1990 | { |
1644 | ypos += textarray[i]->lineSpacing(); | 1991 | ypos += textarray[i]->lineSpacing(); |
1645 | } | 1992 | } |
1646 | fillbuffer(numlines+1, ypos, newht); | 1993 | fillbuffer(numlines+1, ypos, newht); |
1647 | // qDebug("Optimised > %d", numlines); | 1994 | // qDebug("Optimised > %d", numlines); |
1648 | } | 1995 | } |
1649 | if (numlines > 0) | 1996 | if (numlines > 0) |
1650 | { | 1997 | { |
1651 | redrawall(); | 1998 | redrawall(); |
1652 | } | 1999 | } |
1653 | } | 2000 | } |
1654 | #else | ||
1655 | if (m_lastwidth != width()) | ||
1656 | { | ||
1657 | // qDebug("Not Optimised %d", m_lastwidth); | ||
1658 | m_lastwidth = width(); | ||
1659 | m_lastheight = height(); | ||
1660 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | ||
1661 | locate(pagelocate()); | ||
1662 | // qDebug("Not Optimised %d", m_lastwidth); | ||
1663 | } | ||
1664 | else | ||
1665 | { | ||
1666 | int newht = height(); | ||
1667 | if (m_lastheight > newht) | ||
1668 | { | ||
1669 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); | ||
1670 | int ypos = m_topmargin; | ||
1671 | for (int i = 0; i < numlines; i++) | ||
1672 | { | ||
1673 | if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin) | ||
1674 | { | ||
1675 | numlines = i; | ||
1676 | jumpto(mylastpos = locnarray[i+1]); | ||
1677 | break; | ||
1678 | } | ||
1679 | } | ||
1680 | // qDebug("Optimised < %d", numlines); | ||
1681 | m_lastheight = newht; | ||
1682 | } | ||
1683 | else if (m_lastheight < newht) | ||
1684 | { | ||
1685 | // qDebug("Optimised > %d", numlines); | ||
1686 | int ypos = m_topmargin; | ||
1687 | for (int i = 0; i <= numlines; i++) | ||
1688 | { | ||
1689 | ypos += textarray[i]->lineSpacing(); | ||
1690 | } | ||
1691 | fillbuffer(numlines+1, ypos, newht); | ||
1692 | // qDebug("Optimised > %d", numlines); | ||
1693 | } | ||
1694 | if (numlines > 0) | ||
1695 | { | ||
1696 | int ypos = textarray[0]->ascent()+m_topmargin; | ||
1697 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | ||
1698 | // int last = (m_showlast) ? numlines : numlines-1; | ||
1699 | // for (int i = 1; i <= last; i++) | ||
1700 | for (int i = 1; i < numlines; i++) | ||
1701 | { | ||
1702 | // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; | ||
1703 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | ||
1704 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | ||
1705 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | ||
1706 | } | ||
1707 | // mylastpos = locate(); | ||
1708 | } | ||
1709 | } | ||
1710 | #endif | ||
1711 | emitRedraw(); | 2001 | emitRedraw(); |
1712 | } | 2002 | } |
1713 | /* | 2003 | /* |
1714 | else | 2004 | else |
1715 | { | 2005 | { |
1716 | qDebug("Not so refreshing..."); | 2006 | qDebug("Not so refreshing..."); |
1717 | } | 2007 | } |
1718 | */ | 2008 | */ |
1719 | } | 2009 | } |
1720 | 2010 | ||
1721 | void QTReader::DrawScroll( QPainter *p, int _w, int _h ) | 2011 | void QTReader::DrawScroll( QPainter *p, int _w, int _h ) |
1722 | { | 2012 | { |
@@ -1919,44 +2209,52 @@ QString QTReader::firstword() | |||
1919 | 2209 | ||
1920 | // | 2210 | // |
1921 | // Construct the QTReader with buttons. | 2211 | // Construct the QTReader with buttons. |
1922 | // | 2212 | // |
1923 | 2213 | ||
1924 | bool QTReader::ChangeFont(int tgt) | 2214 | bool QTReader::ChangeFont(int tgt) |
1925 | { | 2215 | { |
1926 | return m_fontControl.ChangeFont(m_fontname, tgt); | 2216 | return m_fontControl.ChangeFont(m_fontname, tgt); |
1927 | } | 2217 | } |
1928 | 2218 | ||
1929 | void QTReader::init() | 2219 | void QTReader::init() |
1930 | { | 2220 | { |
1931 | buffdoc.unsuspend(); | ||
1932 | setBackgroundColor( m_bg ); | 2221 | setBackgroundColor( m_bg ); |
1933 | buffdoc.setfilter(getfilter()); | 2222 | buffdoc.setfilter(getfilter()); |
1934 | ChangeFont(m_textsize); | 2223 | ChangeFont(m_textsize); |
1935 | setFocusPolicy(QWidget::StrongFocus); | 2224 | setFocusPolicy(QWidget::StrongFocus); |
1936 | timer = new QTimer(this); | 2225 | timer = new QTimer(this); |
1937 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); | 2226 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); |
2227 | #ifdef USETIMER | ||
2228 | m_dragtimer = new QTimer(this); | ||
2229 | connect(m_dragtimer, SIGNAL(timeout()), this, SLOT(actionDrag())); | ||
2230 | #endif | ||
1938 | // QMessageBox::information(this, "init", m_lastfile, 1); | 2231 | // QMessageBox::information(this, "init", m_lastfile, 1); |
1939 | setfont(); | 2232 | setfont(); |
1940 | } | 2233 | } |
1941 | 2234 | ||
1942 | // | 2235 | // |
1943 | // Clean up | 2236 | // Clean up |
1944 | // | 2237 | // |
1945 | QTReader::~QTReader() | 2238 | QTReader::~QTReader() |
1946 | { | 2239 | { |
1947 | #ifdef DOUBLEBUFFER | 2240 | if (m_output != NULL) |
1948 | delete dbuff; | 2241 | { |
1949 | delete dbp; | 2242 | delete m_output; |
1950 | #endif | 2243 | } |
2244 | if (dbuff != NULL) | ||
2245 | { | ||
2246 | delete dbuff; | ||
2247 | delete dbp; | ||
2248 | } | ||
1951 | #ifdef USEQPE | 2249 | #ifdef USEQPE |
1952 | if (m_autoScroll) | 2250 | if (m_autoScroll) |
1953 | { | 2251 | { |
1954 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 2252 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
1955 | } | 2253 | } |
1956 | #endif | 2254 | #endif |
1957 | #ifdef _SCROLLPIPE | 2255 | #ifdef _SCROLLPIPE |
1958 | if (m_pipeout != NULL) | 2256 | if (m_pipeout != NULL) |
1959 | { | 2257 | { |
1960 | fclose(m_pipeout); | 2258 | fclose(m_pipeout); |
1961 | } | 2259 | } |
1962 | #endif | 2260 | #endif |
@@ -1973,27 +2271,65 @@ void QTReader::printIt() | |||
1973 | QPainter paint; | 2271 | QPainter paint; |
1974 | if ( !paint.begin( printer ) ) | 2272 | if ( !paint.begin( printer ) ) |
1975 | return; | 2273 | return; |
1976 | drawIt( &paint ); | 2274 | drawIt( &paint ); |
1977 | } | 2275 | } |
1978 | #endif | 2276 | #endif |
1979 | } | 2277 | } |
1980 | */ | 2278 | */ |
1981 | // | 2279 | // |
1982 | // Called when the widget needs to be updated. | 2280 | // Called when the widget needs to be updated. |
1983 | // | 2281 | // |
1984 | 2282 | ||
1985 | void QTReader::paintEvent( QPaintEvent * ) | 2283 | void QTReader::paintEvent( QPaintEvent * p ) |
1986 | { | 2284 | { |
1987 | drawFonts(); | 2285 | if ((dbuff != NULL) && !m_outofdate) |
2286 | { | ||
2287 | if (m_rotated) | ||
2288 | { | ||
2289 | if ((p->rect().width() != width()) || (p->rect().height() != height())) | ||
2290 | { | ||
2291 | qDebug("Partial paint"); | ||
2292 | QRect r; | ||
2293 | r.setTop(width()-p->rect().right()-1); | ||
2294 | r.setLeft(p->rect().top()); | ||
2295 | r.setHeight(p->rect().width()); | ||
2296 | r.setWidth(p->rect().height()); | ||
2297 | QPixmap p1(r.width(), r.height()); | ||
2298 | bitBlt(&p1, QPoint(0, 0), dbuff, r); | ||
2299 | QWMatrix m; | ||
2300 | m.rotate(90); | ||
2301 | QPixmap p2 = p1.xForm(m); | ||
2302 | bitBlt(this, p->rect().left(), p->rect().top(), &p2, 0, 0, -1, -1); | ||
2303 | } | ||
2304 | else | ||
2305 | { | ||
2306 | qDebug("Full paint"); | ||
2307 | QWMatrix m; | ||
2308 | m.rotate(90); | ||
2309 | QPixmap rp = dbuff->xForm(m); | ||
2310 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | ||
2311 | } | ||
2312 | } | ||
2313 | else | ||
2314 | { | ||
2315 | //bitBlt(this, 0,0,dbuff,0,0,-1,-1); | ||
2316 | bitBlt(this,p->rect().topLeft(),dbuff,p->rect()); | ||
2317 | } | ||
2318 | } | ||
2319 | else | ||
2320 | { | ||
2321 | drawFonts(); | ||
2322 | } | ||
2323 | m_outofdate = false; | ||
1988 | } | 2324 | } |
1989 | 2325 | ||
1990 | // | 2326 | // |
1991 | // Called when the widget has been resized. | 2327 | // Called when the widget has been resized. |
1992 | // Moves the button group to the upper right corner | 2328 | // Moves the button group to the upper right corner |
1993 | // of the widget. | 2329 | // of the widget. |
1994 | 2330 | ||
1995 | /* | 2331 | /* |
1996 | void QTReader::resizeEvent( QResizeEvent * ) | 2332 | void QTReader::resizeEvent( QResizeEvent * ) |
1997 | { | 2333 | { |
1998 | // // qDebug("resize:(%u,%u)", width(), height()); | 2334 | // // qDebug("resize:(%u,%u)", width(), height()); |
1999 | // bgroup->move( width()-bgroup->width(), 0 ); | 2335 | // bgroup->move( width()-bgroup->width(), 0 ); |
@@ -2007,79 +2343,97 @@ void QTReader::resizeEvent( QResizeEvent * ) | |||
2007 | int main( int argc, tchar **argv ) | 2343 | int main( int argc, tchar **argv ) |
2008 | { | 2344 | { |
2009 | QApplication app( argc, argv ); | 2345 | QApplication app( argc, argv ); |
2010 | QTReader draw; | 2346 | QTReader draw; |
2011 | app.setMainWidget( &draw ); | 2347 | app.setMainWidget( &draw ); |
2012 | draw.setCaption("Qt Example - Drawdemo"); | 2348 | draw.setCaption("Qt Example - Drawdemo"); |
2013 | draw.show(); | 2349 | draw.show(); |
2014 | return app.exec(); | 2350 | return app.exec(); |
2015 | } | 2351 | } |
2016 | */ | 2352 | */ |
2017 | 2353 | ||
2018 | 2354 | ||
2355 | bool QTReader::locate(unsigned long n) | ||
2356 | { | ||
2357 | m_outofdate = true; | ||
2358 | m_lastwidth = 0; | ||
2359 | locnarray[0] = n; | ||
2360 | ResetScroll(); | ||
2361 | update(); | ||
2362 | return true; | ||
2363 | } | ||
2364 | /* | ||
2019 | bool QTReader::locate(unsigned long n) { | 2365 | bool QTReader::locate(unsigned long n) { |
2020 | //printf("Locate\n"); | 2366 | //printf("Locate\n"); |
2021 | buffdoc.unsuspend(); | ||
2022 | buffdoc.locate(n); | 2367 | buffdoc.locate(n); |
2023 | // // qDebug("&buffdoc.located"); | 2368 | // // qDebug("&buffdoc.located"); |
2024 | ResetScroll(); | 2369 | ResetScroll(); |
2025 | fillbuffer(); | 2370 | fillbuffer(); |
2371 | m_outofdate = true; | ||
2026 | // // qDebug("&Buffer filled"); | 2372 | // // qDebug("&Buffer filled"); |
2027 | update(); | 2373 | update(); |
2028 | // // qDebug("&Located"); | 2374 | // // qDebug("&Located"); |
2029 | emitRedraw(); | 2375 | emitRedraw(); |
2030 | return true; | 2376 | return true; |
2031 | } | 2377 | } |
2032 | 2378 | */ | |
2033 | unsigned int QTReader::screenlines() | 2379 | unsigned int QTReader::screenlines() |
2034 | { | 2380 | { |
2035 | // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; | 2381 | // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; |
2036 | // return (height()-m_descent)/(m_linespacing); | 2382 | // return (height()-m_descent)/(m_linespacing); |
2037 | return (height()-2)/(m_linespacing); | 2383 | return (height()-2)/(m_linespacing); |
2038 | }; | 2384 | }; |
2039 | 2385 | ||
2040 | bool QTReader::fillbuffer(int reuse, int ht, int newht) | 2386 | bool QTReader::fillbuffer(int reuse, int ht, int newht) |
2041 | { | 2387 | { |
2042 | buffdoc.unsuspend(); | ||
2043 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 2388 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
2044 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 2389 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
2045 | if (ht < 0) ht = m_topmargin; | 2390 | if (ht < 0) ht = m_topmargin; |
2046 | if (buffdoc.empty()) return false; | 2391 | if (buffdoc.empty()) return false; |
2047 | if (newht < 0) | 2392 | if (newht < 0) |
2048 | m_lastheight = (m_rotated) ? width() : height(); | 2393 | m_lastheight = (m_rotated) ? width() : height(); |
2049 | else | 2394 | else |
2050 | m_lastheight = newht; | 2395 | m_lastheight = newht; |
2051 | int ch; | 2396 | int ch; |
2052 | bool ret = false; | 2397 | bool ret = false; |
2053 | unsigned int oldpagepos = locnarray[reuse]; | 2398 | unsigned int oldpagepos = locnarray[reuse]; |
2054 | int lastypos = ht, ypos = ht; | 2399 | int lastypos = ht, ypos = ht; |
2055 | numlines = reuse; | 2400 | numlines = reuse; |
2056 | while (ypos < m_lastheight - hmargin || numlines < 2) | 2401 | while (ypos < m_lastheight - hmargin || numlines < 2) |
2057 | { | 2402 | { |
2058 | lastypos = ypos; | 2403 | lastypos = ypos; |
2059 | if (textarray[numlines] == NULL) | 2404 | if (textarray[numlines] == NULL) |
2060 | { | 2405 | { |
2061 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 2406 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
2062 | } | 2407 | } |
2063 | locnarray[numlines] = locate(); | 2408 | locnarray[numlines] = locate(); |
2064 | int ch = getline(textarray[numlines]); | 2409 | int ch = getline(textarray[numlines]); |
2065 | ypos += textarray[numlines]->lineSpacing(); | 2410 | ypos += textarray[numlines]->lineSpacing(); |
2411 | /* | ||
2412 | QString tmp = toQString(textarray[numlines]->data()); | ||
2413 | printf("[%u, %u, %u](%s):%s\n", lastypos, m_lastheight-hmargin, ypos, | ||
2414 | ((textarray[numlines]->showPartial()) ? "TRUE" : "FALSE"), | ||
2415 | (const char*)tmp); | ||
2416 | */ | ||
2066 | numlines++; | 2417 | numlines++; |
2067 | if (!ch) | 2418 | if (!ch) |
2068 | { | 2419 | { |
2069 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) | 2420 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) |
2070 | { | 2421 | { |
2071 | qDebug("FALSE"); | 2422 | qDebug("FALSE"); |
2423 | if (oldpagepos < buffdoc.endSection()) | ||
2072 | locate(oldpagepos); | 2424 | locate(oldpagepos); |
2073 | return false; | 2425 | else |
2426 | dopageup(buffdoc.endSection()); | ||
2427 | return false; | ||
2074 | } | 2428 | } |
2075 | else | 2429 | else |
2076 | { | 2430 | { |
2077 | qDebug("TRUE"); | 2431 | qDebug("TRUE"); |
2078 | --numlines; | 2432 | --numlines; |
2079 | mylastpos = locate(); | 2433 | mylastpos = locate(); |
2080 | return true; | 2434 | return true; |
2081 | } | 2435 | } |
2082 | } | 2436 | } |
2083 | if (numlines > 1 && textarray[numlines-2]->isBop()) | 2437 | if (numlines > 1 && textarray[numlines-2]->isBop()) |
2084 | { | 2438 | { |
2085 | --numlines; | 2439 | --numlines; |
@@ -2092,25 +2446,24 @@ bool QTReader::fillbuffer(int reuse, int ht, int newht) | |||
2092 | mylastpos = locate(); | 2446 | mylastpos = locate(); |
2093 | m_scrollpart = m_lastheight - lastypos - hmargin; | 2447 | m_scrollpart = m_lastheight - lastypos - hmargin; |
2094 | if (m_autoScroll) | 2448 | if (m_autoScroll) |
2095 | { | 2449 | { |
2096 | CalculateScrollParameters(); | 2450 | CalculateScrollParameters(); |
2097 | } | 2451 | } |
2098 | return true; | 2452 | return true; |
2099 | } | 2453 | } |
2100 | 2454 | ||
2101 | void QTReader::dopagedn() | 2455 | void QTReader::dopagedn() |
2102 | { | 2456 | { |
2103 | // qDebug("HEIGHT(2):%d", m_lastheight); | 2457 | // qDebug("HEIGHT(2):%d", m_lastheight); |
2104 | buffdoc.unsuspend(); | ||
2105 | ResetScroll(); | 2458 | ResetScroll(); |
2106 | int skip = 0, ypos = m_topmargin; | 2459 | int skip = 0, ypos = m_topmargin; |
2107 | if (locate() != mylastpos) | 2460 | if (locate() != mylastpos) |
2108 | { | 2461 | { |
2109 | jumpto(mylastpos); | 2462 | jumpto(mylastpos); |
2110 | } | 2463 | } |
2111 | CDrawBuffer* reusebuffer = textarray[numlines]; | 2464 | CDrawBuffer* reusebuffer = textarray[numlines]; |
2112 | if (reusebuffer != NULL) | 2465 | if (reusebuffer != NULL) |
2113 | { | 2466 | { |
2114 | if (reusebuffer->eof()) return; | 2467 | if (reusebuffer->eof()) return; |
2115 | for (int i = 0; i <= m_overlap; i++) | 2468 | for (int i = 0; i <= m_overlap; i++) |
2116 | { | 2469 | { |
@@ -2141,70 +2494,72 @@ void QTReader::dopagedn() | |||
2141 | void QTReader::dopageup() | 2494 | void QTReader::dopageup() |
2142 | { | 2495 | { |
2143 | dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); | 2496 | dopageup(locnarray[(m_overlap < numlines) ? m_overlap : numlines/2]); |
2144 | } | 2497 | } |
2145 | 2498 | ||
2146 | bool QTReader::synch(size_t start, size_t end) | 2499 | bool QTReader::synch(size_t start, size_t end) |
2147 | { | 2500 | { |
2148 | jumpto(start); | 2501 | jumpto(start); |
2149 | while (start++ < end) | 2502 | while (start++ < end) |
2150 | { | 2503 | { |
2151 | tchar ch = getch(); | 2504 | tchar ch = getch(); |
2152 | if (ch == 10) return true; | 2505 | if (ch == 10) return true; |
2153 | if (ch == UEOF) return false; | 2506 | if ((ch == UEOF) || (ch == 6)) |
2154 | if (ch == 6) return false; | 2507 | { |
2508 | return false; | ||
2509 | } | ||
2155 | } | 2510 | } |
2156 | return false; | 2511 | return false; |
2157 | } | 2512 | } |
2158 | 2513 | ||
2159 | void QTReader::dopageup(unsigned int target) | 2514 | void QTReader::dopageup(unsigned int target) |
2160 | { | 2515 | { |
2161 | buffdoc.unsuspend(); | ||
2162 | ResetScroll(); | 2516 | ResetScroll(); |
2163 | CBufferFace<CDrawBuffer*> buff; | 2517 | CBufferFace<CDrawBuffer*> buff; |
2164 | CBufferFace<size_t> loc; | 2518 | CBufferFace<size_t> loc; |
2165 | |||
2166 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; | 2519 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; |
2520 | qDebug("dopageup:: locate():%u pagelocate():%u guess:%u", locate(), pagelocate(), guess); | ||
2167 | bool ch = true; | 2521 | bool ch = true; |
2168 | int nbfl, ypos = m_topmargin; | 2522 | int nbfl, ypos = m_topmargin; |
2169 | if (guess < 128) guess = 128; | 2523 | if (guess < 128) guess = 128; |
2170 | while (1) | 2524 | while (1) |
2171 | { | 2525 | { |
2172 | // qDebug("Guess:%u", guess); | 2526 | // qDebug("Guess:%u", guess); |
2173 | 2527 | ||
2174 | ch = true; | 2528 | ch = true; |
2175 | if (target < guess) | 2529 | if (target < guess) |
2176 | { | 2530 | { |
2177 | delta = 0; // 0 is a flag to say don't guess any more | 2531 | delta = 0; // 0 is a flag to say don't guess any more |
2178 | jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); | 2532 | jumpto( (m_continuousDocument) ? 0 : buffdoc.startSection() ); |
2179 | } | 2533 | } |
2180 | else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) | 2534 | else if (!m_continuousDocument && (target - guess < buffdoc.startSection())) |
2181 | { | 2535 | { |
2182 | delta = 0; // 0 is a flag to say don't guess any more | 2536 | delta = 0; // 0 is a flag to say don't guess any more |
2537 | qDebug("Jumping to startsection:%d", buffdoc.startSection()); | ||
2183 | jumpto(buffdoc.startSection()); | 2538 | jumpto(buffdoc.startSection()); |
2184 | } | 2539 | } |
2185 | else | 2540 | else |
2186 | { | 2541 | { |
2187 | delta = guess; | 2542 | delta = guess; |
2188 | if (!synch(target-delta, target-lastdelta)) | 2543 | if (!synch(target-delta, target-lastdelta)) |
2189 | { | 2544 | { |
2190 | lastdelta = delta; | 2545 | lastdelta = delta; |
2191 | if (guess < 4000) | 2546 | if (guess < 4000) |
2192 | { | 2547 | { |
2193 | guess <<= 1; | 2548 | guess <<= 1; |
2194 | continue; | 2549 | continue; |
2195 | } | 2550 | } |
2196 | else | 2551 | else |
2197 | { | 2552 | { |
2198 | jumpto(target-delta); | 2553 | jumpto(target-delta); |
2199 | } | 2554 | } |
2200 | } | 2555 | } |
2201 | } | 2556 | } |
2202 | 2557 | ||
2203 | nbfl = 0; | 2558 | nbfl = 0; |
2204 | ypos = m_topmargin; | 2559 | ypos = m_topmargin; |
2205 | 2560 | ||
2206 | while (locate() < target) | 2561 | while (locate() < target) |
2207 | { | 2562 | { |
2208 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); | 2563 | if (buff[nbfl] == NULL) buff[nbfl] = new CDrawBuffer(&m_fontControl); |
2209 | loc[nbfl] = locate(); | 2564 | loc[nbfl] = locate(); |
2210 | ch = getline(buff[nbfl]); | 2565 | ch = getline(buff[nbfl]); |
@@ -2284,52 +2639,53 @@ void QTReader::dopageup(unsigned int target) | |||
2284 | CalculateScrollParameters(); | 2639 | CalculateScrollParameters(); |
2285 | drawFonts(); | 2640 | drawFonts(); |
2286 | // repaint(); | 2641 | // repaint(); |
2287 | } | 2642 | } |
2288 | 2643 | ||
2289 | bool QTReader::load_file(const char *newfile, unsigned int _lcn) | 2644 | bool QTReader::load_file(const char *newfile, unsigned int _lcn) |
2290 | { | 2645 | { |
2291 | // QMessageBox::information(this, "Name", name, 1); | 2646 | // QMessageBox::information(this, "Name", name, 1); |
2292 | // QMessageBox::information(this, "load_file", newfile, 1); | 2647 | // QMessageBox::information(this, "load_file", newfile, 1); |
2293 | int prog = 0; | 2648 | int prog = 0; |
2294 | bool bRC = false; | 2649 | bool bRC = false; |
2295 | unsigned int lcn = _lcn; | 2650 | unsigned int lcn = _lcn; |
2651 | bDoUpdates = false; | ||
2296 | ResetScroll(); | 2652 | ResetScroll(); |
2297 | if (m_lastfile == newfile) | 2653 | if (m_lastfile == newfile && lcn == 0) |
2298 | { | 2654 | { |
2299 | lcn = m_lastposn; | 2655 | lcn = m_lastposn; |
2300 | } | 2656 | } |
2301 | // QMessageBox::information(0, "Opening...", newfile); | 2657 | // QMessageBox::information(0, "Opening...", newfile); |
2302 | if (m_rotated) | 2658 | if (m_rotated) |
2303 | { | 2659 | { |
2304 | m_lastwidth = height(); | 2660 | m_lastwidth = height(); |
2305 | m_lastheight = width(); | 2661 | m_lastheight = width(); |
2306 | } | 2662 | } |
2307 | else | 2663 | else |
2308 | { | 2664 | { |
2309 | m_lastwidth = width(); | 2665 | m_lastwidth = width(); |
2310 | m_lastheight = height(); | 2666 | m_lastheight = height(); |
2311 | } | 2667 | } |
2312 | if (buffdoc.openfile(this,newfile) == 0) | 2668 | if (buffdoc.openfile(this,newfile) == 0) |
2313 | { | 2669 | { |
2314 | m_lastfile = newfile; | 2670 | m_lastfile = newfile; |
2315 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | 2671 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); |
2316 | bRC = true; | 2672 | bRC = true; |
2317 | buffdoc.setContinuous(m_continuousDocument); | 2673 | buffdoc.setContinuous(m_continuousDocument); |
2318 | qDebug("buffdoc.openfile done"); | 2674 | qDebug("buffdoc.openfile done"); |
2319 | locate(lcn); | ||
2320 | qDebug("buffdoc.locate done"); | ||
2321 | } | 2675 | } |
2322 | setfilter(getfilter()); | 2676 | setfilter(getfilter()); |
2323 | qDebug("Updated"); | 2677 | qDebug("Updated"); |
2678 | bDoUpdates = true; | ||
2679 | locate(lcn); | ||
2324 | return bRC; | 2680 | return bRC; |
2325 | } | 2681 | } |
2326 | 2682 | ||
2327 | void QTReader::lineDown() | 2683 | void QTReader::lineDown() |
2328 | { | 2684 | { |
2329 | int ypos = m_topmargin; | 2685 | int ypos = m_topmargin; |
2330 | ResetScroll(); | 2686 | ResetScroll(); |
2331 | int offset = numlines; | 2687 | int offset = numlines; |
2332 | 2688 | ||
2333 | for (int i = 0; i <= numlines; i++) | 2689 | for (int i = 0; i <= numlines; i++) |
2334 | { | 2690 | { |
2335 | if ((ypos += textarray[numlines-i]->lineSpacing()) > ((m_rotated) ? width() : height())) | 2691 | if ((ypos += textarray[numlines-i]->lineSpacing()) > ((m_rotated) ? width() : height())) |
@@ -2349,24 +2705,25 @@ void QTReader::lineDown() | |||
2349 | textarray[i-offset] = textarray[i]; | 2705 | textarray[i-offset] = textarray[i]; |
2350 | locnarray[i-offset] = locnarray[i]; | 2706 | locnarray[i-offset] = locnarray[i]; |
2351 | textarray[i] = buff; | 2707 | textarray[i] = buff; |
2352 | } | 2708 | } |
2353 | numlines = numlines - offset + 1; | 2709 | numlines = numlines - offset + 1; |
2354 | locnarray[numlines] = locate(); | 2710 | locnarray[numlines] = locate(); |
2355 | if (textarray[numlines] == NULL) | 2711 | if (textarray[numlines] == NULL) |
2356 | { | 2712 | { |
2357 | textarray[numlines] = new CDrawBuffer(&m_fontControl); | 2713 | textarray[numlines] = new CDrawBuffer(&m_fontControl); |
2358 | } | 2714 | } |
2359 | getline(textarray[numlines]); | 2715 | getline(textarray[numlines]); |
2360 | mylastpos = locate(); | 2716 | mylastpos = locate(); |
2717 | m_outofdate = true; | ||
2361 | update(); | 2718 | update(); |
2362 | } | 2719 | } |
2363 | /* | 2720 | /* |
2364 | void QTReader::lineUp() | 2721 | void QTReader::lineUp() |
2365 | { | 2722 | { |
2366 | CBuffer** buff = textarray; | 2723 | CBuffer** buff = textarray; |
2367 | unsigned int *loc = new unsigned int[numlines]; | 2724 | unsigned int *loc = new unsigned int[numlines]; |
2368 | int cbptr = 0; | 2725 | int cbptr = 0; |
2369 | if (locate() != mylastpos) jumpto(mylastpos); | 2726 | if (locate() != mylastpos) jumpto(mylastpos); |
2370 | unsigned int target = locnarray[numlines-1]; | 2727 | unsigned int target = locnarray[numlines-1]; |
2371 | if (buffdoc.hasrandomaccess()) | 2728 | if (buffdoc.hasrandomaccess()) |
2372 | { | 2729 | { |
@@ -2563,149 +2920,174 @@ MarkupType QTReader::PreferredMarkup() | |||
2563 | int ext = m_lastfile.findRev('.'); | 2920 | int ext = m_lastfile.findRev('.'); |
2564 | if (ext >= 0) | 2921 | if (ext >= 0) |
2565 | { | 2922 | { |
2566 | QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper(); | 2923 | QString ft = m_lastfile.right(m_lastfile.length()-ext-1).upper(); |
2567 | if (ft.left(3) == "HTM") | 2924 | if (ft.left(3) == "HTM") |
2568 | { | 2925 | { |
2569 | m = cHTML; | 2926 | m = cHTML; |
2570 | } | 2927 | } |
2571 | } | 2928 | } |
2572 | } | 2929 | } |
2573 | return m; | 2930 | return m; |
2574 | } | 2931 | } |
2575 | #ifdef DOUBLEBUFFER | 2932 | |
2576 | void QTReader::resizeEvent( QResizeEvent * p ) | 2933 | void QTReader::resizeEvent( QResizeEvent * p ) |
2577 | { | 2934 | { |
2578 | if (m_rotated) | 2935 | qDebug("Resizing"); |
2579 | { | 2936 | m_outofdate = true; |
2580 | dbuff->resize(p->size().height(),p->size().width()); | 2937 | if (dbuff != NULL) |
2581 | } | ||
2582 | else | ||
2583 | { | 2938 | { |
2584 | dbuff->resize(p->size()); | 2939 | if (m_rotated) |
2940 | { | ||
2941 | dbuff->resize(p->size().height(),p->size().width()); | ||
2942 | } | ||
2943 | else | ||
2944 | { | ||
2945 | dbuff->resize(p->size()); | ||
2946 | } | ||
2585 | } | 2947 | } |
2586 | m_bgIsScaled = false; | 2948 | m_bgIsScaled = false; |
2587 | if (m_bgtype == bgStretched) | 2949 | if (m_bgtype == bgStretched) |
2588 | { | 2950 | { |
2589 | emit RefreshBitmap(); | 2951 | emit RefreshBitmap(); |
2590 | } | 2952 | } |
2591 | 2953 | ||
2592 | { | 2954 | { |
2593 | int h, w; | 2955 | int h, w; |
2594 | if (m_rotated) | 2956 | if (m_rotated) |
2595 | { | 2957 | { |
2596 | h = p->size().width(); | 2958 | h = p->size().width(); |
2597 | w = p->size().height(); | 2959 | w = p->size().height(); |
2598 | } | 2960 | } |
2599 | else | 2961 | else |
2600 | { | 2962 | { |
2601 | w = p->size().width(); | 2963 | w = p->size().width(); |
2602 | h = p->size().height(); | 2964 | h = p->size().height(); |
2603 | } | 2965 | } |
2604 | m_topmargin = (h*m_abstopmargin+500)/1000; | 2966 | m_topmargin = (h*m_abstopmargin+500)/1000; |
2605 | m_bottommargin = (h*m_absbottommargin+500)/1000; | 2967 | m_bottommargin = (h*m_absbottommargin+500)/1000; |
2606 | m_left_border = (w*m_absleft_border+500)/1000; | 2968 | m_left_border = (w*m_absleft_border+500)/1000; |
2607 | m_right_border = (w*m_absright_border+500)/1000; | 2969 | m_right_border = (w*m_absright_border+500)/1000; |
2608 | |||
2609 | qDebug("Top margin:%u", m_topmargin ); | ||
2610 | qDebug("Bottom margin:%u", m_bottommargin ); | ||
2611 | qDebug("Left margin:%u", m_left_border ); | ||
2612 | qDebug("Right margin:%u", m_right_border ); | ||
2613 | } | 2970 | } |
2971 | if (dbuff != NULL && buffdoc.empty()) | ||
2972 | { | ||
2973 | dbp->begin(dbuff); | ||
2974 | drawBackground(dbp); | ||
2975 | dbp->end(); | ||
2976 | } | ||
2614 | } | 2977 | } |
2615 | #endif | ||
2616 | 2978 | ||
2617 | void QTReader::setrotated(bool sfs) | 2979 | void QTReader::setrotated(bool sfs) |
2618 | { | 2980 | { |
2981 | qDebug("Rotating"); | ||
2619 | m_rotated = sfs; | 2982 | m_rotated = sfs; |
2620 | #ifdef DOUBLEBUFFER | 2983 | setDoubleBuffer(m_doubleBuffered); |
2621 | if (m_rotated) | ||
2622 | { | ||
2623 | dbuff->resize(height(), width()); | ||
2624 | } | ||
2625 | else | ||
2626 | { | ||
2627 | dbuff->resize(width(), height()); | ||
2628 | } | ||
2629 | m_bgIsScaled = false; | 2984 | m_bgIsScaled = false; |
2630 | #endif | 2985 | m_outofdate = true; |
2986 | /* | ||
2631 | int h, w; | 2987 | int h, w; |
2632 | if (m_rotated) | 2988 | if (m_rotated) |
2633 | { | 2989 | { |
2634 | h = width(); | 2990 | h = width(); |
2635 | w = height(); | 2991 | w = height(); |
2636 | } | 2992 | } |
2637 | else | 2993 | else |
2638 | { | 2994 | { |
2639 | w = width(); | 2995 | w = width(); |
2640 | h = height(); | 2996 | h = height(); |
2641 | } | 2997 | } |
2642 | m_topmargin = (h*m_abstopmargin+500)/1000; | 2998 | m_topmargin = (h*m_abstopmargin+500)/1000; |
2643 | m_bottommargin = (h*m_absbottommargin+500)/1000; | 2999 | m_bottommargin = (h*m_absbottommargin+500)/1000; |
2644 | m_left_border = (w*m_absleft_border+500)/1000; | 3000 | m_left_border = (w*m_absleft_border+500)/1000; |
2645 | m_right_border = (w*m_absright_border+500)/1000; | 3001 | m_right_border = (w*m_absright_border+500)/1000; |
2646 | 3002 | ||
2647 | qDebug("Top margin:%u", m_topmargin ); | 3003 | qDebug("Top margin:%u", m_topmargin ); |
2648 | qDebug("Bottom margin:%u", m_bottommargin ); | 3004 | qDebug("Bottom margin:%u", m_bottommargin ); |
2649 | qDebug("Left margin:%u", m_left_border ); | 3005 | qDebug("Left margin:%u", m_left_border ); |
2650 | qDebug("Right margin:%u", m_right_border ); | 3006 | qDebug("Right margin:%u", m_right_border ); |
3007 | */ | ||
2651 | } | 3008 | } |
2652 | 3009 | ||
2653 | void QTReader::drawBackground() | 3010 | void QTReader::drawBackground(QPainter *p) |
2654 | { | 3011 | { |
2655 | dbp->begin(dbuff); | 3012 | // p->setBackgroundMode(OpaqueMode); |
2656 | // dbp->setBackgroundMode(OpaqueMode); | 3013 | p->setBackgroundColor(m_bg); |
2657 | dbp->setBackgroundColor(m_bg); | 3014 | if (dbuff != NULL) |
2658 | dbp->eraseRect(dbuff->rect()); | 3015 | { |
3016 | p->eraseRect(dbuff->rect()); | ||
3017 | } | ||
3018 | else | ||
3019 | { | ||
3020 | if (m_rotated) | ||
3021 | { | ||
3022 | p->eraseRect(0,0,height(),width()); | ||
3023 | } | ||
3024 | else | ||
3025 | { | ||
3026 | p->eraseRect(rect()); | ||
3027 | } | ||
3028 | } | ||
2659 | if (!m_bgpm.isNull()) | 3029 | if (!m_bgpm.isNull()) |
2660 | { | 3030 | { |
2661 | // dbp->setBackgroundMode(TransparentMode); | 3031 | // p->setBackgroundMode(TransparentMode); |
2662 | switch (m_bgtype) | 3032 | switch (m_bgtype) |
2663 | { | 3033 | { |
2664 | case bgCentred: | 3034 | case bgCentred: |
2665 | { | 3035 | { |
2666 | int w = (dbuff->rect().width()-m_bgpm.width())/2; | 3036 | if (dbuff == NULL) |
2667 | int h = (dbuff->rect().height()-m_bgpm.height())/2; | 3037 | { |
2668 | dbp->drawPixmap(w,h,m_bgpm); | 3038 | p->drawPixmap(width(),height(),m_bgpm); |
3039 | } | ||
3040 | else | ||
3041 | { | ||
3042 | int w = (dbuff->rect().width()-m_bgpm.width())/2; | ||
3043 | int h = (dbuff->rect().height()-m_bgpm.height())/2; | ||
3044 | p->drawPixmap(w,h,m_bgpm); | ||
3045 | } | ||
2669 | } | 3046 | } |
2670 | break; | 3047 | break; |
2671 | case bgTiled: | 3048 | case bgTiled: |
2672 | { | 3049 | { |
2673 | dbp->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm); | 3050 | if (dbuff == NULL) |
2674 | /* | ||
2675 | for (int h = 0; h < dbuff->rect().height(); h += m_bgpm.height()) | ||
2676 | { | 3051 | { |
2677 | for (int w = 0; w < dbuff->rect().width(); w += m_bgpm.width()) | 3052 | p->drawTiledPixmap(0,0,width(),height(),m_bgpm); |
2678 | { | 3053 | } |
2679 | dbp->drawPixmap(w,h,m_bgpm); | 3054 | else |
2680 | } | 3055 | { |
3056 | p->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm); | ||
2681 | } | 3057 | } |
2682 | */ | ||
2683 | } | 3058 | } |
2684 | break; | 3059 | break; |
2685 | case bgStretched: | 3060 | case bgStretched: |
2686 | { | 3061 | { |
2687 | if (!m_bgIsScaled) | 3062 | if (!m_bgIsScaled) |
2688 | { | 3063 | { |
2689 | m_bgIsScaled = true; | 3064 | m_bgIsScaled = true; |
2690 | QImage im = m_bgpm.convertToImage(); | 3065 | QImage im = m_bgpm.convertToImage(); |
2691 | m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height())); | 3066 | if (dbuff == NULL) |
3067 | { | ||
3068 | m_bgpm.convertFromImage(im.smoothScale(width(),height())); | ||
3069 | } | ||
3070 | else | ||
3071 | { | ||
3072 | m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height())); | ||
3073 | } | ||
2692 | } | 3074 | } |
2693 | dbp->drawPixmap(0,0,m_bgpm); | 3075 | p->drawPixmap(0,0,m_bgpm); |
2694 | } | 3076 | } |
2695 | break; | 3077 | break; |
2696 | default: | 3078 | default: |
2697 | qDebug("Unknown background type"); | 3079 | qDebug("Unknown background type"); |
2698 | } | 3080 | } |
2699 | // dbp->setBackgroundMode(OpaqueMode); | 3081 | // p->setBackgroundMode(OpaqueMode); |
2700 | } | 3082 | } |
2701 | } | 3083 | } |
2702 | 3084 | ||
2703 | void QTReader::blitRot(int dx, int dy, int sw, int sh, CDrawBuffer* txt) | 3085 | void QTReader::blitRot(int dx, int dy, int sw, int sh, CDrawBuffer* txt) |
2704 | { | 3086 | { |
2705 | if (txt != NULL) | 3087 | if (txt != NULL) |
2706 | { | 3088 | { |
2707 | sh = txt->lineSpacing(); | 3089 | sh = txt->lineSpacing(); |
2708 | } | 3090 | } |
2709 | int sy = width()-dx-sh; | 3091 | int sy = width()-dx-sh; |
2710 | if (m_autoScroll && !(m_scrolltype == 0)) | 3092 | if (m_autoScroll && !(m_scrolltype == 0)) |
2711 | { | 3093 | { |
@@ -2750,25 +3132,30 @@ void QTReader::blitRot(int dx, int dy, int sw, int sh, CDrawBuffer* txt) | |||
2750 | } | 3132 | } |
2751 | QWMatrix m; | 3133 | QWMatrix m; |
2752 | m.rotate(90); | 3134 | m.rotate(90); |
2753 | QPixmap rp = pm.xForm(m); | 3135 | QPixmap rp = pm.xForm(m); |
2754 | /* | 3136 | /* |
2755 | p.drawPixmap(QPoint(dx, dy), rp); | 3137 | p.drawPixmap(QPoint(dx, dy), rp); |
2756 | */ | 3138 | */ |
2757 | bitBlt(this, dx, dy, &rp, 0, 0, -1, -1, CopyROP); | 3139 | bitBlt(this, dx, dy, &rp, 0, 0, -1, -1, CopyROP); |
2758 | } | 3140 | } |
2759 | 3141 | ||
2760 | QString QTReader::about() | 3142 | QString QTReader::about() |
2761 | { | 3143 | { |
2762 | return QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka"; | 3144 | QString ab = QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka"; |
3145 | if (m_output != NULL) | ||
3146 | { | ||
3147 | ab += QString("\n") + m_output->about(); | ||
3148 | } | ||
3149 | return ab; | ||
2763 | } | 3150 | } |
2764 | 3151 | ||
2765 | void QTReader::getNextLink() | 3152 | void QTReader::getNextLink() |
2766 | { | 3153 | { |
2767 | if (m_scrolldy != 0) | 3154 | if (m_scrolldy != 0) |
2768 | { | 3155 | { |
2769 | setautoscroll(false); | 3156 | setautoscroll(false); |
2770 | ResetScroll(); | 3157 | ResetScroll(); |
2771 | redrawall(); | 3158 | redrawall(); |
2772 | } | 3159 | } |
2773 | bool redraw = false; | 3160 | bool redraw = false; |
2774 | bool found = false; | 3161 | bool found = false; |
@@ -2888,98 +3275,218 @@ void QTReader::gotoLink() | |||
2888 | qDebug("URL(1):%s", (const char*)href); | 3275 | qDebug("URL(1):%s", (const char*)href); |
2889 | if ((lt & eFile) != 0) | 3276 | if ((lt & eFile) != 0) |
2890 | { | 3277 | { |
2891 | buffdoc.saveposn(m_lastfile, saveposn); | 3278 | buffdoc.saveposn(m_lastfile, saveposn); |
2892 | #ifdef USEQPE | 3279 | #ifdef USEQPE |
2893 | { | 3280 | { |
2894 | QCopEnvelope e("QPE/System", "busy()"); | 3281 | QCopEnvelope e("QPE/System", "busy()"); |
2895 | } | 3282 | } |
2896 | #endif | 3283 | #endif |
2897 | ResetScroll(); | 3284 | ResetScroll(); |
2898 | if (!href.isEmpty()) | 3285 | if (!href.isEmpty()) |
2899 | { | 3286 | { |
2900 | if (!buffdoc.getFile(href)) | 3287 | if (!buffdoc.getFile(href, nm)) |
2901 | { | 3288 | { |
2902 | emit NewFileRequest(href); | 3289 | emit NewFileRequest(href); |
2903 | } | 3290 | } |
2904 | else | 3291 | else |
2905 | { | 3292 | { |
2906 | ResetScroll(); | 3293 | ResetScroll(); |
2907 | fillbuffer(); | 3294 | fillbuffer(); |
3295 | m_outofdate = true; | ||
2908 | update(); | 3296 | update(); |
2909 | } | 3297 | } |
2910 | } | 3298 | } |
2911 | if (!nm.isEmpty()) | 3299 | if (!nm.isEmpty()) |
2912 | { | 3300 | { |
2913 | qDebug("QTReader:Finding %s", (const char*)nm); | 3301 | qDebug("QTReader:Finding %s", (const char*)nm); |
2914 | if (buffdoc.findanchor(nm)) | 3302 | if (buffdoc.findanchor(nm)) |
2915 | { | 3303 | { |
3304 | buffdoc.resetPos(); | ||
2916 | fillbuffer(); | 3305 | fillbuffer(); |
3306 | m_outofdate = true; | ||
2917 | update(); | 3307 | update(); |
2918 | } | 3308 | } |
2919 | } | 3309 | } |
2920 | //fillbuffer(); | 3310 | //fillbuffer(); |
2921 | //update(); | 3311 | //update(); |
2922 | #ifdef USEQPE | 3312 | #ifdef USEQPE |
2923 | { | 3313 | { |
2924 | QCopEnvelope e("QPE/System", "notBusy()"); | 3314 | QCopEnvelope e("QPE/System", "notBusy()"); |
2925 | } | 3315 | } |
2926 | #endif | 3316 | #endif |
2927 | } | 3317 | } |
2928 | else if ((lt & eLink) != 0) | 3318 | else if ((lt & eLink) != 0) |
2929 | { | 3319 | { |
2930 | buffdoc.saveposn(m_lastfile, saveposn); | 3320 | buffdoc.saveposn(m_lastfile, saveposn); |
2931 | ResetScroll(); | 3321 | ResetScroll(); |
2932 | fillbuffer(); | 3322 | fillbuffer(); |
3323 | m_outofdate = true; | ||
2933 | update(); | 3324 | update(); |
2934 | } | 3325 | } |
2935 | else | 3326 | else |
2936 | { | 3327 | { |
2937 | if ((lt & ePicture) != 0) | 3328 | if ((lt & ePicture) != 0) |
2938 | { | 3329 | { |
2939 | QImage* pm = buffdoc.getPicture(tgt); | 3330 | QImage* pm = buffdoc.getPicture(tgt); |
2940 | if (pm != NULL) | 3331 | if (pm != NULL) |
2941 | { | 3332 | { |
2942 | emit OnShowPicture(*pm); | 3333 | emit OnShowPicture(*pm); |
2943 | delete pm; | 3334 | delete pm; |
2944 | } | 3335 | } |
2945 | } | 3336 | } |
2946 | else | 3337 | else |
2947 | { | 3338 | { |
2948 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); | 3339 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); |
2949 | if (!href.isEmpty()) | 3340 | if (!href.isEmpty()) |
2950 | { | 3341 | { |
2951 | emit OnURLSelected(href, tgt); | 3342 | emit OnURLSelected(href, tgt); |
3343 | refresh(); | ||
2952 | } | 3344 | } |
2953 | } | 3345 | } |
2954 | locate(pagelocate()); | ||
2955 | } | 3346 | } |
2956 | m_currentlinkstyle = NULL; | 3347 | m_currentlinkstyle = NULL; |
2957 | m_currentlink = -1; | 3348 | m_currentlink = -1; |
2958 | m_currentlinkoffset = -1; | 3349 | m_currentlinkoffset = -1; |
2959 | } | 3350 | } |
2960 | 3351 | ||
2961 | void QTReader::refresh(bool full) | 3352 | void QTReader::refresh(bool full) |
2962 | { | 3353 | { |
3354 | qDebug("Refreshing"); | ||
2963 | int h, w; | 3355 | int h, w; |
2964 | if (m_rotated) | 3356 | if (m_rotated) |
2965 | { | 3357 | { |
2966 | h = width(); | 3358 | h = width(); |
2967 | w = height(); | 3359 | w = height(); |
2968 | } | 3360 | } |
2969 | else | 3361 | else |
2970 | { | 3362 | { |
2971 | w = width(); | 3363 | w = width(); |
2972 | h = height(); | 3364 | h = height(); |
2973 | } | 3365 | } |
2974 | m_topmargin = (h*m_abstopmargin+500)/1000; | 3366 | m_topmargin = (h*m_abstopmargin+500)/1000; |
2975 | m_bottommargin = (h*m_absbottommargin+500)/1000; | 3367 | m_bottommargin = (h*m_absbottommargin+500)/1000; |
2976 | m_left_border = (w*m_absleft_border+500)/1000; | 3368 | m_left_border = (w*m_absleft_border+500)/1000; |
2977 | m_right_border = (w*m_absright_border+500)/1000; | 3369 | m_right_border = (w*m_absright_border+500)/1000; |
2978 | 3370 | ||
2979 | qDebug("Top margin:%u", m_topmargin ); | 3371 | qDebug("Top margin:%u", m_topmargin ); |
2980 | qDebug("Bottom margin:%u", m_bottommargin ); | 3372 | qDebug("Bottom margin:%u", m_bottommargin ); |
2981 | qDebug("Left margin:%u", m_left_border ); | 3373 | qDebug("Left margin:%u", m_left_border ); |
2982 | qDebug("Right margin:%u", m_right_border ); | 3374 | qDebug("Right margin:%u", m_right_border ); |
2983 | if (full && m_highlightfilter) m_highlightfilter->refresh(pagelocate()); | 3375 | if (full && m_highlightfilter) m_highlightfilter->refresh(pagelocate()); |
3376 | m_outofdate = true; | ||
2984 | locate(pagelocate()); | 3377 | locate(pagelocate()); |
2985 | } | 3378 | } |
3379 | |||
3380 | #include "striphtml.h" | ||
3381 | |||
3382 | CFilterChain* QTReader::getfilter() | ||
3383 | { | ||
3384 | CFilterChain * filt = new CFilterChain(getencoding()); | ||
3385 | if (bstripcr) filt->addfilter(new stripcr); | ||
3386 | |||
3387 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | ||
3388 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | ||
3389 | // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
3390 | |||
3391 | #ifdef __STATIC | ||
3392 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
3393 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
3394 | { | ||
3395 | striphtml* f = new striphtml(m_lastfile); | ||
3396 | f->setchm(true); | ||
3397 | filt->addfilter(f); | ||
3398 | } | ||
3399 | #else | ||
3400 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile)); | ||
3401 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
3402 | { | ||
3403 | ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile); | ||
3404 | ((striphtml*)f->filter())->setchm(true); | ||
3405 | filt->addfilter(f); | ||
3406 | } | ||
3407 | #endif | ||
3408 | m_highlightfilter = new HighlightFilter(this); | ||
3409 | filt->addfilter(m_highlightfilter); | ||
3410 | |||
3411 | if (bdehyphen) filt->addfilter(new dehyphen); | ||
3412 | if (bunindent) filt->addfilter(new unindent); | ||
3413 | if (brepara) filt->addfilter(new repara(m_reparastring)); | ||
3414 | if (bonespace) filt->addfilter(new OnePara); | ||
3415 | if (bindenter) filt->addfilter(new indenter(bindenter)); | ||
3416 | if (bdblspce) filt->addfilter(new dblspce); | ||
3417 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); | ||
3418 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); | ||
3419 | if (brepalm) filt->addfilter(new repalm); | ||
3420 | if (bunderlineLink) filt->addfilter(new underlineLink); | ||
3421 | if (bkern) filt->addfilter(new kern); | ||
3422 | if (bremap) filt->addfilter(new remap); | ||
3423 | if (bmakebold) filt->addfilter(new embolden); | ||
3424 | if (bfulljust) filt->addfilter(new FullJust); | ||
3425 | int r,g,b; | ||
3426 | m_default_bg.rgb(&r, &g, &b); | ||
3427 | if (r != 255 || g != 255 || b != 255) | ||
3428 | filt->addfilter(new setbg(r,g,b)); | ||
3429 | m_default_fg.rgb(&r, &g, &b); | ||
3430 | if (r != 0 || g != 0 || b != 0) | ||
3431 | filt->addfilter(new setfg(r,g,b)); | ||
3432 | // if (bNegative) filt->addfilter(new makeNegative); | ||
3433 | if (bInverse) filt->addfilter(new makeInverse); | ||
3434 | if (bNoInlineTables) filt->addfilter(new tableLink); | ||
3435 | return filt; | ||
3436 | } | ||
3437 | |||
3438 | void QTReader::readAloud() | ||
3439 | { | ||
3440 | #ifdef __STATIC | ||
3441 | return; | ||
3442 | #else | ||
3443 | CBuffer para; | ||
3444 | jumpto(pagelocate()); | ||
3445 | while (m_autoScroll && (buffdoc.getpara(para) != -1)) | ||
3446 | { | ||
3447 | if (para.length() > 0) | ||
3448 | { | ||
3449 | unsigned long lastpos = buffdoc.explocate(); | ||
3450 | while (lastpos > mylastpos) | ||
3451 | { | ||
3452 | dopagedn(); | ||
3453 | qApp->processEvents(); | ||
3454 | } | ||
3455 | jumpto(lastpos); | ||
3456 | QString txt = toQString(para.data()); | ||
3457 | |||
3458 | doOutput(txt); | ||
3459 | } | ||
3460 | qApp->processEvents(); | ||
3461 | } | ||
3462 | #endif | ||
3463 | } | ||
3464 | |||
3465 | bool QTReader::doOutput(const QString& wrd) | ||
3466 | { | ||
3467 | if (m_output != NULL) | ||
3468 | { | ||
3469 | m_output->output(wrd); | ||
3470 | return true; | ||
3471 | } | ||
3472 | else | ||
3473 | { | ||
3474 | return false; | ||
3475 | } | ||
3476 | } | ||
3477 | |||
3478 | bool QTReader::checkoutput() | ||
3479 | { | ||
3480 | if (m_output == NULL) | ||
3481 | { | ||
3482 | m_output = new outputcodec(m_outputName); | ||
3483 | if (reinterpret_cast<outputcodec*>(m_output)->getStatus() != 0) | ||
3484 | { | ||
3485 | delete m_output; | ||
3486 | m_output = NULL; | ||
3487 | QMessageBox::warning(this, PROGNAME, QString("Couldn't find output codec\n")+m_outputName); | ||
3488 | return false; | ||
3489 | } | ||
3490 | } | ||
3491 | return true; | ||
3492 | } | ||
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index 3bcdde4..9daa07a 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -9,43 +9,46 @@ | |||
9 | #include "FontControl.h" | 9 | #include "FontControl.h" |
10 | 10 | ||
11 | //#include <qtimer.h> | 11 | //#include <qtimer.h> |
12 | 12 | ||
13 | class CDrawBuffer; | 13 | class CDrawBuffer; |
14 | //class CBuffer; | 14 | //class CBuffer; |
15 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
16 | class QPainter; | 16 | class QPainter; |
17 | class QTimer; | 17 | class QTimer; |
18 | class QImage; | 18 | class QImage; |
19 | 19 | ||
20 | #include "BGType.h" | 20 | #include "BGType.h" |
21 | #include "striphtml.h" | ||
22 | 21 | ||
23 | #define ROTATION_ENABLED | ||
24 | #define SPECIALSCROLL | 22 | #define SPECIALSCROLL |
25 | #define DOUBLEBUFFER | 23 | |
26 | #ifdef DOUBLEBUFFER | ||
27 | class QPainter; | 24 | class QPainter; |
28 | #endif | 25 | class COutput; |
29 | 26 | ||
30 | class CStyle; | 27 | class CStyle; |
28 | #define USETIMER | ||
31 | 29 | ||
32 | class QTReader : public QWidget | 30 | class QTReader : public QWidget |
33 | { | 31 | { |
34 | Q_OBJECT | 32 | Q_OBJECT |
35 | friend class QTReaderApp; | 33 | friend class QTReaderApp; |
36 | #ifdef DOUBLEBUFFER | 34 | #ifdef USETIMER |
35 | QTimer* m_dragtimer; | ||
36 | unsigned long m_dragtarget; | ||
37 | #endif | ||
38 | COutput* m_output; | ||
39 | bool checkoutput(); | ||
40 | bool m_outofdate, m_drageligible; | ||
37 | QPixmap *dbuff; | 41 | QPixmap *dbuff; |
38 | QPainter* dbp; | 42 | QPainter* dbp; |
39 | #endif | ||
40 | void drawSingleLine(int lineno); | 43 | void drawSingleLine(int lineno); |
41 | void gotoLink(); | 44 | void gotoLink(); |
42 | void emitRedraw(); | 45 | void emitRedraw(); |
43 | CStyle* m_currentlinkstyle; | 46 | CStyle* m_currentlinkstyle; |
44 | int m_currentlink; | 47 | int m_currentlink; |
45 | int m_currentlinkoffset; | 48 | int m_currentlinkoffset; |
46 | QPixmap m_bgpm; | 49 | QPixmap m_bgpm; |
47 | bool m_bgIsScaled; | 50 | bool m_bgIsScaled; |
48 | bground m_bgtype; | 51 | bground m_bgtype; |
49 | int m_scrollpos; | 52 | int m_scrollpos; |
50 | unsigned short m_scrollstep; | 53 | unsigned short m_scrollstep; |
51 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); | 54 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); |
@@ -65,56 +68,56 @@ class QTReader : public QWidget | |||
65 | void increaseScroll(); | 68 | void increaseScroll(); |
66 | void reduceScroll(); | 69 | void reduceScroll(); |
67 | void drawText(QPainter& p, int x, int y, tchar* text); | 70 | void drawText(QPainter& p, int x, int y, tchar* text); |
68 | void DrawScroll( QPainter *p, int w, int h ); | 71 | void DrawScroll( QPainter *p, int w, int h ); |
69 | void dorollingscroll(bool); | 72 | void dorollingscroll(bool); |
70 | void doinplacescroll(); | 73 | void doinplacescroll(); |
71 | void dostaticscroll(); | 74 | void dostaticscroll(); |
72 | void suspend(); | 75 | void suspend(); |
73 | void redrawScroll(QPainter* p); | 76 | void redrawScroll(QPainter* p); |
74 | int m_delay, m_scrolltype; | 77 | int m_delay, m_scrolltype; |
75 | unsigned int m_overlap; | 78 | unsigned int m_overlap; |
76 | bool m_autoScroll, m_swapmouse; | 79 | bool m_autoScroll, m_swapmouse; |
77 | void drawBackground(); | 80 | void drawBackground(QPainter*); |
78 | #ifdef ROTATION_ENABLED | ||
79 | bool m_rotated; | 81 | bool m_rotated; |
80 | void setrotated(bool); | 82 | void setrotated(bool); |
81 | #endif | ||
82 | void autoscroll(); | 83 | void autoscroll(); |
83 | QTimer* timer; | 84 | QTimer* timer; |
84 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; | 85 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; |
85 | void focusInEvent(QFocusEvent*); | 86 | void focusInEvent(QFocusEvent*); |
86 | void focusOutEvent(QFocusEvent*); | 87 | void focusOutEvent(QFocusEvent*); |
87 | void processmousepositionevent( QMouseEvent* _e ); | 88 | void processmousepositionevent( QMouseEvent* _e ); |
88 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); | 89 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); |
89 | bool ChangeFont(int); | 90 | bool ChangeFont(int); |
90 | bool getline(CDrawBuffer*); | 91 | bool getline(CDrawBuffer*); |
91 | int m_charWidth; | 92 | int m_charWidth; |
92 | int m_charpc; | 93 | int m_charpc; |
93 | unsigned short m_absleft_border, m_absright_border; | 94 | unsigned short m_absleft_border, m_absright_border; |
94 | unsigned short m_left_border, m_right_border; | 95 | unsigned short m_left_border, m_right_border; |
95 | FontControl m_fontControl; | 96 | FontControl m_fontControl; |
96 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } | 97 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } |
97 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } | 98 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } |
99 | QString m_outputName; | ||
98 | #ifdef _SCROLLPIPE | 100 | #ifdef _SCROLLPIPE |
99 | FILE* m_pipeout; | 101 | FILE* m_pipeout; |
100 | QString m_pipetarget; | 102 | QString m_pipetarget; |
101 | bool m_isPaused; | 103 | bool m_isPaused; |
102 | bool m_pauseAfterEachPara; | 104 | bool m_pauseAfterEachPara; |
103 | #endif | 105 | #endif |
104 | public: | 106 | public: |
105 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); | 107 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); |
106 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); | 108 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); |
107 | ~QTReader(); | 109 | ~QTReader(); |
108 | QString about(); | 110 | QString about(); |
111 | void readAloud(); | ||
109 | CList<Bkmk>* Bkmklist() { return pBkmklist; } | 112 | CList<Bkmk>* Bkmklist() { return pBkmklist; } |
110 | void setBackground(const QColor& _c) | 113 | void setBackground(const QColor& _c) |
111 | { | 114 | { |
112 | m_default_bg = _c; | 115 | m_default_bg = _c; |
113 | reset_bg(); | 116 | reset_bg(); |
114 | } | 117 | } |
115 | void setForeground(const QColor& _c) | 118 | void setForeground(const QColor& _c) |
116 | { | 119 | { |
117 | m_default_fg = _c; | 120 | m_default_fg = _c; |
118 | int r,g,b; | 121 | int r,g,b; |
119 | m_default_fg.rgb(&r, &g, &b); | 122 | m_default_fg.rgb(&r, &g, &b); |
120 | r = 255-r; | 123 | r = 255-r; |
@@ -144,25 +147,25 @@ public: | |||
144 | jumpto(m_mark); | 147 | jumpto(m_mark); |
145 | QString text; | 148 | QString text; |
146 | while (m_mark < nd) | 149 | while (m_mark < nd) |
147 | { | 150 | { |
148 | text += buffdoc.getch(); | 151 | text += buffdoc.getch(); |
149 | m_mark++; | 152 | m_mark++; |
150 | } | 153 | } |
151 | QApplication::clipboard()->setText(text); | 154 | QApplication::clipboard()->setText(text); |
152 | jumpto(nd); | 155 | jumpto(nd); |
153 | */ | 156 | */ |
154 | }; | 157 | }; |
155 | void clear() {}; | 158 | void clear() {}; |
156 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; | 159 | void setText(const QString& n, const QString& s, unsigned int lcn = 0) { m_string = n; load_file((const char*)s, lcn); }; |
157 | /* | 160 | /* |
158 | void setText(bool oldfile) | 161 | void setText(bool oldfile) |
159 | { | 162 | { |
160 | if (oldfile) | 163 | if (oldfile) |
161 | { | 164 | { |
162 | m_string = m_lastfile; | 165 | m_string = m_lastfile; |
163 | load_file((const tchar*)m_string); | 166 | load_file((const tchar*)m_string); |
164 | } | 167 | } |
165 | else | 168 | else |
166 | { | 169 | { |
167 | m_string = QString::null; | 170 | m_string = QString::null; |
168 | } | 171 | } |
@@ -216,129 +219,86 @@ public: | |||
216 | return new CUcs16be; | 219 | return new CUcs16be; |
217 | case 3: | 220 | case 3: |
218 | // qDebug("ucs16le"); | 221 | // qDebug("ucs16le"); |
219 | return new CUcs16le; | 222 | return new CUcs16le; |
220 | case 0: | 223 | case 0: |
221 | // qDebug("ascii"); | 224 | // qDebug("ascii"); |
222 | return new CAscii; | 225 | return new CAscii; |
223 | default: | 226 | default: |
224 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); | 227 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); |
225 | } | 228 | } |
226 | } | 229 | } |
227 | HighlightFilter* m_highlightfilter; | 230 | HighlightFilter* m_highlightfilter; |
228 | CFilterChain* getfilter() | 231 | CFilterChain* getfilter(); |
229 | { | ||
230 | CFilterChain * filt = new CFilterChain(getencoding()); | ||
231 | if (bstripcr) filt->addfilter(new stripcr); | ||
232 | |||
233 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | ||
234 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | ||
235 | // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
236 | |||
237 | #ifdef __STATIC | ||
238 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
239 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
240 | { | ||
241 | filt->addfilter(new striphtml(m_lastfile)); | ||
242 | } | ||
243 | #else | ||
244 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile)); | ||
245 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
246 | { | ||
247 | ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile); | ||
248 | ((striphtml*)f->filter())->setchm(true); | ||
249 | filt->addfilter(f); | ||
250 | } | ||
251 | #endif | ||
252 | m_highlightfilter = new HighlightFilter(this); | ||
253 | filt->addfilter(m_highlightfilter); | ||
254 | |||
255 | if (bdehyphen) filt->addfilter(new dehyphen); | ||
256 | if (bunindent) filt->addfilter(new unindent); | ||
257 | if (brepara) filt->addfilter(new repara(m_reparastring)); | ||
258 | if (bonespace) filt->addfilter(new OnePara); | ||
259 | if (bindenter) filt->addfilter(new indenter(bindenter)); | ||
260 | if (bdblspce) filt->addfilter(new dblspce); | ||
261 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); | ||
262 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); | ||
263 | if (brepalm) filt->addfilter(new repalm); | ||
264 | if (bkern) filt->addfilter(new kern); | ||
265 | if (bremap) filt->addfilter(new remap); | ||
266 | if (bmakebold) filt->addfilter(new embolden); | ||
267 | if (bfulljust) filt->addfilter(new FullJust); | ||
268 | int r,g,b; | ||
269 | m_default_bg.rgb(&r, &g, &b); | ||
270 | if (r != 255 || g != 255 || b != 255) | ||
271 | filt->addfilter(new setbg(r,g,b)); | ||
272 | m_default_fg.rgb(&r, &g, &b); | ||
273 | if (r != 0 || g != 0 || b != 0) | ||
274 | filt->addfilter(new setfg(r,g,b)); | ||
275 | // if (bNegative) filt->addfilter(new makeNegative); | ||
276 | if (bInverse) filt->addfilter(new makeInverse); | ||
277 | return filt; | ||
278 | } | ||
279 | |||
280 | 232 | ||
281 | private slots: | 233 | private slots: |
234 | #ifdef USETIMER | ||
235 | void actionDrag(); | ||
236 | #endif | ||
282 | void dopageup(); | 237 | void dopageup(); |
283 | void lineDown(); | 238 | void lineDown(); |
284 | void lineUp(); | 239 | void lineUp(); |
285 | void dopagedn(); | 240 | void dopagedn(); |
286 | void goHome(); | 241 | void goHome(); |
287 | void goBack(); | 242 | void goBack(); |
288 | void goForward(); | 243 | void goForward(); |
289 | void doscroll(); | 244 | void doscroll(); |
290 | void paintEvent( QPaintEvent * ); | 245 | void paintEvent( QPaintEvent * ); |
291 | #ifdef DOUBLEBUFFER | 246 | |
292 | void resizeEvent( QResizeEvent * p ); | 247 | void resizeEvent( QResizeEvent * p ); |
293 | #endif | 248 | |
294 | void keyPressEvent(QKeyEvent*); | 249 | void keyPressEvent(QKeyEvent*); |
295 | private: | 250 | private: |
296 | // void drawIt( QPainter * ); | 251 | // void drawIt( QPainter * ); |
297 | void redrawall(); | 252 | void redrawall(); |
298 | void drawFonts(); | 253 | void drawFonts(); |
299 | void DrawStraight(QPainter* p, int w, int h); | 254 | void DrawStraight(QPainter* p, int w, int h); |
300 | QColor m_scrollcolor, m_scrollbarcolor; | 255 | QColor m_scrollcolor, m_scrollbarcolor; |
301 | void setTwoTouch(bool _b); | 256 | void setTwoTouch(bool _b); |
302 | void init(); | 257 | void init(); |
258 | void mouseMoveEvent( QMouseEvent* ); | ||
303 | void mousePressEvent( QMouseEvent* ); | 259 | void mousePressEvent( QMouseEvent* ); |
304 | void mouseReleaseEvent( QMouseEvent* ); | 260 | void mouseReleaseEvent( QMouseEvent* ); |
305 | // void mouseDoubleClickEvent( QMouseEvent* ); | 261 | // void mouseDoubleClickEvent( QMouseEvent* ); |
306 | QString m_string, m_fontname, m_reparastring; | 262 | QString m_string, m_fontname, m_reparastring; |
307 | void setfont(); | 263 | void setfont(); |
264 | bool m_doubleBuffered; | ||
265 | |||
266 | void setDoubleBuffer(bool _b); | ||
308 | //myoutput stuff | 267 | //myoutput stuff |
309 | private: | 268 | private: |
310 | #ifdef SPECIALSCROLL | 269 | #ifdef SPECIALSCROLL |
311 | int m_scrolldy; | 270 | int m_scrolldy; |
312 | #endif | 271 | #endif |
313 | bool mouseUpOn; | 272 | bool mouseUpOn; |
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*&); | 273 | 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*&, size_t&); |
315 | bool m_twotouch, m_touchone; | 274 | bool m_twotouch, m_touchone; |
316 | size_t m_startpos, m_startoffset; | 275 | size_t m_startpos, m_startoffset; |
317 | void dopageup(unsigned int); | 276 | void dopageup(unsigned int); |
318 | long real_delay(); | 277 | long real_delay(); |
319 | int m_textsize; | 278 | int m_textsize; |
320 | int m_lastwidth, m_lastheight; | 279 | int m_lastwidth, m_lastheight; |
321 | CBufferFace<CDrawBuffer*> textarray; | 280 | CBufferFace<CDrawBuffer*> textarray; |
322 | CBufferFace<size_t> locnarray; | 281 | CBufferFace<size_t> locnarray; |
323 | unsigned int numlines; | 282 | unsigned int numlines; |
324 | // bool m_showlast; | 283 | // bool m_showlast; |
325 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse; | 284 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse, bNoInlineTables; |
326 | bool bkern, brepalm; | 285 | bool bkern, brepalm, bunderlineLink; |
327 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; | 286 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; |
328 | unsigned char bindenter; | 287 | unsigned char bindenter; |
329 | QString m_lastfile; | 288 | QString m_lastfile; |
330 | size_t m_lastposn; | 289 | size_t m_lastposn; |
331 | bool bDoUpdates; | 290 | bool bDoUpdates; |
332 | public: | 291 | public: |
292 | bool doOutput(const QString& wrd); | ||
333 | void setDoUpdates(bool b) { bDoUpdates = b; } | 293 | void setDoUpdates(bool b) { bDoUpdates = b; } |
334 | void setStripCR(bool b) { bstripcr = b; } | 294 | void setStripCR(bool b) { bstripcr = b; } |
335 | void NavUp(); | 295 | void NavUp(); |
336 | void NavDown(); | 296 | void NavDown(); |
337 | tchar getch() { return buffdoc.getch(); } | 297 | tchar getch() { return buffdoc.getch(); } |
338 | bool synch(size_t, size_t); | 298 | bool synch(size_t, size_t); |
339 | bool tight; | 299 | bool tight; |
340 | bool load_file(const char *newfile, unsigned int lcn=0); | 300 | bool load_file(const char *newfile, unsigned int lcn=0); |
341 | BuffDoc buffdoc; | 301 | BuffDoc buffdoc; |
342 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } | 302 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } |
343 | bool locate(unsigned long n); | 303 | bool locate(unsigned long n); |
344 | void jumpto(unsigned long n) { buffdoc.locate(n); } | 304 | void jumpto(unsigned long n) { buffdoc.locate(n); } |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 876b65a..6753698 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -8,24 +8,25 @@ | |||
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 | |||
20 | #include <qregexp.h> | 21 | #include <qregexp.h> |
21 | #include <qclipboard.h> | 22 | #include <qclipboard.h> |
22 | #include <qwidgetstack.h> | 23 | #include <qwidgetstack.h> |
23 | #ifdef USEQPE | 24 | #ifdef USEQPE |
24 | #include <qpe/qpemenubar.h> | 25 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 26 | #include <qpe/qpetoolbar.h> |
26 | #endif | 27 | #endif |
27 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
28 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
29 | #ifdef USEQPE | 30 | #ifdef USEQPE |
30 | #include <qpe/menubutton.h> | 31 | #include <qpe/menubutton.h> |
31 | #endif | 32 | #endif |
@@ -57,47 +58,52 @@ | |||
57 | #include "GraphicWin.h" | 58 | #include "GraphicWin.h" |
58 | #include "Bkmks.h" | 59 | #include "Bkmks.h" |
59 | #include "cbkmkselector.h" | 60 | #include "cbkmkselector.h" |
60 | #include "infowin.h" | 61 | #include "infowin.h" |
61 | #include "ToolbarPrefs.h" | 62 | #include "ToolbarPrefs.h" |
62 | #include "Prefs.h" | 63 | #include "Prefs.h" |
63 | #include "CAnnoEdit.h" | 64 | #include "CAnnoEdit.h" |
64 | #include "QFloatBar.h" | 65 | #include "QFloatBar.h" |
65 | #include "FixedFont.h" | 66 | #include "FixedFont.h" |
66 | #include "URLDialog.h" | 67 | #include "URLDialog.h" |
67 | #include "util.h" | 68 | #include "util.h" |
68 | #include <qfontdatabase.h> | 69 | #include <qfontdatabase.h> |
70 | |||
69 | #ifdef USEQPE | 71 | #ifdef USEQPE |
70 | #include <qpe/resource.h> | 72 | #include <qpe/resource.h> |
71 | #ifdef OPIE | 73 | #ifdef OPIE |
72 | //#include <qpe/applnk.h> | 74 | #if defined(OPIEFILEDIALOG) |
75 | #include <qpe/applnk.h> | ||
73 | #include <opie2/ofiledialog.h> | 76 | #include <opie2/ofiledialog.h> |
74 | using namespace Opie::Ui; | 77 | using namespace Opie::Ui; |
75 | #else | 78 | #else |
76 | #include "fileBrowser.h" | 79 | #include "fileBrowser.h" |
77 | #endif | 80 | #endif |
78 | #else | 81 | #else |
82 | #include "fileBrowser.h" | ||
83 | #endif | ||
84 | #else | ||
79 | #include "qfiledialog.h" | 85 | #include "qfiledialog.h" |
80 | #endif | 86 | #endif |
81 | 87 | ||
82 | #include "QTReaderApp.h" | 88 | #include "QTReaderApp.h" |
83 | #include "CDrawBuffer.h" | 89 | #include "CDrawBuffer.h" |
84 | #include "Filedata.h" | 90 | #include "Filedata.h" |
85 | #include "names.h" | 91 | #include "names.h" |
86 | #include "CEncoding_tables.h" | 92 | #include "CEncoding_tables.h" |
87 | #include "CloseDialog.h" | 93 | #include "CloseDialog.h" |
88 | 94 | ||
89 | #include "ButtonPrefs.h" | 95 | #include "ButtonPrefs.h" |
90 | 96 | ||
91 | bool CheckVersion(int&, int&, char&); | 97 | bool CheckVersion(int&, int&, char&, QWidget*); |
92 | 98 | ||
93 | #ifdef _WINDOWS | 99 | #ifdef _WINDOWS |
94 | #define PICDIR "c:\\uqtreader\\pics\\" | 100 | #define PICDIR "c:\\uqtreader\\pics\\" |
95 | #else | 101 | #else |
96 | #ifdef USEQPE | 102 | #ifdef USEQPE |
97 | #define USEMSGS | 103 | #define USEMSGS |
98 | #define PICDIR "opie-reader/" | 104 | #define PICDIR "opie-reader/" |
99 | #else | 105 | #else |
100 | //#define PICDIR "/home/tim/uqtreader/pics/" | 106 | //#define PICDIR "/home/tim/uqtreader/pics/" |
101 | QString picdir() | 107 | QString picdir() |
102 | { | 108 | { |
103 | QString hd(getenv("READERDIR")); | 109 | QString hd(getenv("READERDIR")); |
@@ -144,74 +150,71 @@ void QTReaderApp::listBkmkFiles() | |||
144 | d.cd(APPDIR); | 150 | d.cd(APPDIR); |
145 | } | 151 | } |
146 | 152 | ||
147 | 153 | ||
148 | 154 | ||
149 | 155 | ||
150 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 156 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
151 | // d.setSorting( QDir::Size | QDir::Reversed ); | 157 | // d.setSorting( QDir::Size | QDir::Reversed ); |
152 | 158 | ||
153 | const QFileInfoList *list = d.entryInfoList(); | 159 | const QFileInfoList *list = d.entryInfoList(); |
154 | QFileInfoListIterator it( *list ); // create list iterator | 160 | QFileInfoListIterator it( *list ); // create list iterator |
155 | QFileInfo *fi; // pointer for traversing | 161 | QFileInfo *fi; // pointer for traversing |
156 | |||
157 | while ( (fi=it.current()) ) { // for each file... | 162 | while ( (fi=it.current()) ) { // for each file... |
158 | 163 | ||
159 | bkmkselector->insertItem(fi->fileName()); | 164 | bkmkselector->insertItem(fi->fileName(), cnt++); |
160 | cnt++; | ||
161 | 165 | ||
162 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 166 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
163 | ++it; // goto next list element | 167 | ++it; // goto next list element |
164 | } | 168 | } |
165 | 169 | ||
166 | #else /* USEQPE */ | 170 | #else /* USEQPE */ |
167 | int cnt = 0; | 171 | int cnt = 0; |
168 | DIR *d; | 172 | DIR *d; |
169 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); | 173 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); |
170 | 174 | ||
171 | while(1) | 175 | while(1) |
172 | { | 176 | { |
173 | struct dirent* de; | 177 | struct dirent* de; |
174 | struct stat buf; | 178 | struct stat buf; |
175 | de = readdir(d); | 179 | de = readdir(d); |
176 | if (de == NULL) break; | 180 | if (de == NULL) break; |
177 | 181 | ||
178 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 182 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
179 | { | 183 | { |
180 | bkmkselector->insertItem(de->d_name); | 184 | bkmkselector->insertItem(de->d_name, cnt++); |
181 | cnt++; | ||
182 | } | 185 | } |
183 | } | 186 | } |
184 | 187 | ||
185 | closedir(d); | 188 | closedir(d); |
186 | #endif | 189 | #endif |
187 | if (cnt > 0) | 190 | if (cnt > 0) |
188 | { | 191 | { |
189 | //tjw menu->hide(); | 192 | //tjw menu->hide(); |
190 | 193 | ||
191 | 194 | ||
192 | editorStack->raiseWidget( bkmkselector ); | 195 | editorStack->raiseWidget( bkmkselector ); |
193 | hidetoolbars(); | 196 | hidetoolbars(); |
194 | m_nBkmkAction = cRmBkmkFile; | 197 | m_nBkmkAction = cRmBkmkFile; |
195 | } | 198 | } |
196 | else | 199 | else |
197 | QMessageBox::information(this, PROGNAME, "No bookmark files"); | 200 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
198 | } | 201 | } |
199 | 202 | ||
200 | void QTReaderApp::hidetoolbars() | 203 | void QTReaderApp::hidetoolbars() |
201 | { | 204 | { |
202 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 205 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
203 | if (m_prog != NULL) m_prog->hide(); | 206 | if (m_prog != NULL) m_prog->hide(); |
204 | 207 | ||
205 | #ifdef USEQPE | 208 | #if defined(USEQPE) |
206 | menubar->hide(); | 209 | menubar->hide(); |
207 | #endif | 210 | #endif |
208 | 211 | ||
209 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 212 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
210 | 213 | ||
211 | if (fileBar != NULL) fileBar->hide(); | 214 | if (fileBar != NULL) fileBar->hide(); |
212 | if (viewBar != NULL) viewBar->hide(); | 215 | if (viewBar != NULL) viewBar->hide(); |
213 | if (navBar != NULL) navBar->hide(); | 216 | if (navBar != NULL) navBar->hide(); |
214 | if (markBar != NULL) markBar->hide(); | 217 | if (markBar != NULL) markBar->hide(); |
215 | if (m_fontVisible) m_fontBar->hide(); | 218 | if (m_fontVisible) m_fontBar->hide(); |
216 | if (regVisible) | 219 | if (regVisible) |
217 | { | 220 | { |
@@ -324,32 +327,32 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
324 | config.setGroup("Toolbar"); | 327 | config.setGroup("Toolbar"); |
325 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 328 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
326 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 329 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
327 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 330 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
328 | m_qtscroll = config.readNumEntry("QTScrollBar", false); | 331 | m_qtscroll = config.readNumEntry("QTScrollBar", false); |
329 | m_localscroll = config.readNumEntry("LocalScrollBar", false); | 332 | m_localscroll = config.readNumEntry("LocalScrollBar", false); |
330 | 333 | ||
331 | // fileBar = new QToolBar("File", this); | 334 | // fileBar = new QToolBar("File", this); |
332 | // QToolBar* viewBar = new QToolBar("File", this); | 335 | // QToolBar* viewBar = new QToolBar("File", this); |
333 | // QToolBar* navBar = new QToolBar("File", this); | 336 | // QToolBar* navBar = new QToolBar("File", this); |
334 | // QToolBar* markBar = new QToolBar("File", this); | 337 | // QToolBar* markBar = new QToolBar("File", this); |
335 | 338 | ||
336 | #ifdef USEQPE | 339 | #if defined(USEQPE) |
337 | menubar = new QToolBar("Menus", this, m_tbposition); | 340 | menubar = new QToolBar("Menus", this, m_tbposition); |
338 | mb = new QPEMenuBar( menubar ); | 341 | mb = new QPEMenuBar( menubar ); |
339 | #else | 342 | #else |
340 | mb = new QMenuBar( this ); | 343 | mb = new QMenuBar( this ); |
341 | #endif | 344 | #endif |
342 | 345 | ||
343 | #ifdef USEQPE | 346 | #if defined(USEQPE) |
344 | QPopupMenu* tmp = new QPopupMenu(mb); | 347 | QPopupMenu* tmp = new QPopupMenu(mb); |
345 | mb->insertItem( geticon( "AppsIcon" ), tmp ); | 348 | mb->insertItem( geticon( "AppsIcon" ), tmp ); |
346 | #else | 349 | #else |
347 | QMenuBar* tmp = mb; | 350 | QMenuBar* tmp = mb; |
348 | #endif | 351 | #endif |
349 | 352 | ||
350 | QPopupMenu *file = new QPopupMenu( mb ); | 353 | QPopupMenu *file = new QPopupMenu( mb ); |
351 | tmp->insertItem( tr( "File" ), file ); | 354 | tmp->insertItem( tr( "File" ), file ); |
352 | 355 | ||
353 | QPopupMenu *navigation = new QPopupMenu(mb); | 356 | QPopupMenu *navigation = new QPopupMenu(mb); |
354 | tmp->insertItem( tr( "Navigation" ), navigation ); | 357 | tmp->insertItem( tr( "Navigation" ), navigation ); |
355 | 358 | ||
@@ -427,59 +430,65 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
427 | 430 | ||
428 | reader = new QTReader( editorStack ); | 431 | reader = new QTReader( editorStack ); |
429 | 432 | ||
430 | reader->setDoUpdates(false); | 433 | reader->setDoUpdates(false); |
431 | 434 | ||
432 | #ifdef USEQPE | 435 | #ifdef USEQPE |
433 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 436 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
434 | #endif | 437 | #endif |
435 | 438 | ||
436 | // qDebug("Reading config"); | 439 | // qDebug("Reading config"); |
437 | // Config config( APPDIR ); | 440 | // Config config( APPDIR ); |
438 | config.setGroup( "View" ); | 441 | config.setGroup( "View" ); |
442 | #if defined(USEQPE) && defined(USENEWFULLSCREEN) | ||
443 | m_usenewfullscreen = config.readBoolEntry("NewFullScreen", false); | ||
444 | #endif | ||
439 | m_debounce = config.readNumEntry("Debounce", 0); | 445 | m_debounce = config.readNumEntry("Debounce", 0); |
440 | m_buttonprefs->Debounce(m_debounce); | 446 | m_buttonprefs->Debounce(m_debounce); |
441 | #ifdef USEQPE | 447 | #ifdef USEQPE |
442 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 448 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
443 | #else | 449 | #else |
444 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); | 450 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); |
445 | #endif | 451 | #endif |
446 | reader->setStripCR(config.readBoolEntry( "StripCr", true )); | 452 | reader->setStripCR(config.readBoolEntry( "StripCr", true )); |
447 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 453 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
448 | /* | 454 | /* |
449 | bool btmp = config.readBoolEntry("Negative", false); | 455 | bool btmp = config.readBoolEntry("Negative", false); |
450 | if (btmp) reader->setNegative(); | 456 | if (btmp) reader->setNegative(); |
451 | */ | 457 | */ |
452 | reader->bInverse = config.readBoolEntry("Inverse", false); | 458 | reader->bInverse = config.readBoolEntry("Inverse", false); |
453 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false )); | 459 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false )); |
454 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 460 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
455 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 461 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
456 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 462 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
457 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 463 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
458 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 464 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
465 | reader->bNoInlineTables = config.readBoolEntry( "NoInlineTables", false ); | ||
459 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 466 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
460 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 467 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
461 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 468 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
462 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 469 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
463 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 470 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
464 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 471 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
465 | reader->brepara = config.readBoolEntry( "Repara", false ); | 472 | reader->brepara = config.readBoolEntry( "Repara", false ); |
466 | reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}"); | 473 | reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}"); |
467 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 ); | 474 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 ); |
468 | m_themename = config.readEntry("Theme", QString::null ); | 475 | m_themename = config.readEntry("Theme", QString::null ); |
469 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 476 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
470 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 477 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
471 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 478 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
472 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 479 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
473 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1); | 480 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1); |
481 | reader->m_outputName = config.readEntry( "OutputCodec", ""); | ||
482 | |||
474 | 483 | ||
475 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 484 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
476 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 485 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
477 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 486 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
478 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 487 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
479 | reader->m_rotated = config.readBoolEntry( "IsRotated", false ); | 488 | reader->m_rotated = config.readBoolEntry( "IsRotated", false ); |
480 | reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 ); | 489 | reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 ); |
481 | m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%"); | 490 | m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%"); |
482 | m_statusishidden = config.readBoolEntry("StatusHidden", false); | 491 | m_statusishidden = config.readBoolEntry("StatusHidden", false); |
483 | m_background = config.readNumEntry( "Background", 0 ); | 492 | m_background = config.readNumEntry( "Background", 0 ); |
484 | reader->setBackground(getcolour(m_background)); | 493 | reader->setBackground(getcolour(m_background)); |
485 | m_foreground = config.readNumEntry( "Foreground", 1 ); | 494 | m_foreground = config.readNumEntry( "Foreground", 1 ); |
@@ -491,40 +500,44 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
491 | reader->hyphenate = config.readBoolEntry( "Hyphenate", false ); | 500 | reader->hyphenate = config.readBoolEntry( "Hyphenate", false ); |
492 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 501 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
493 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 502 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
494 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 503 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
495 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 504 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
496 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 505 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
497 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 ); | 506 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 ); |
498 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 ); | 507 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 ); |
499 | reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 ); | 508 | reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 ); |
500 | reader->m_absright_border = config.readNumEntry( "Right Margin", 100 ); | 509 | reader->m_absright_border = config.readNumEntry( "Right Margin", 100 ); |
501 | 510 | ||
502 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", false ); | 511 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", false ); |
512 | m_hidebars = config.readBoolEntry( "HideToolBar", false ); | ||
503 | 513 | ||
504 | reader->brepalm = config.readBoolEntry( "Repalm", false ); | 514 | reader->brepalm = config.readBoolEntry( "Repalm", false ); |
515 | reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", true ); | ||
505 | reader->bkern = config.readBoolEntry( "Kern", false ); | 516 | reader->bkern = config.readBoolEntry( "Kern", false ); |
506 | reader->bremap = config.readBoolEntry( "Remap", true ); | 517 | reader->bremap = config.readBoolEntry( "Remap", true ); |
507 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 518 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
508 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 519 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
520 | reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", true)); | ||
509 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 521 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
510 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 522 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
511 | #ifdef _SCROLLPIPE | 523 | #ifdef _SCROLLPIPE |
512 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 524 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
513 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 525 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
514 | #endif | 526 | #endif |
515 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 527 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
516 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 528 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
517 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 529 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
518 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 530 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
531 | m_doOutput = config.readBoolEntry( "OutputTgt", false); | ||
519 | /* | 532 | /* |
520 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 533 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
521 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 534 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
522 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 535 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
523 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 536 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
524 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 537 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
525 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 538 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
526 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 539 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
527 | 540 | ||
528 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 541 | m_leftScroll = config.readBoolEntry("LeftScroll", false); |
529 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 542 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
530 | m_upScroll = config.readBoolEntry("UpScroll", true); | 543 | m_upScroll = config.readBoolEntry("UpScroll", true); |
@@ -833,24 +846,36 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
833 | marks->insertSeparator(); | 846 | marks->insertSeparator(); |
834 | m_startBlock_action->addTo( marks ); | 847 | m_startBlock_action->addTo( marks ); |
835 | 848 | ||
836 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); | 849 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); |
837 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 850 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
838 | m_endBlock_action->addTo( marks ); | 851 | m_endBlock_action->addTo( marks ); |
839 | 852 | ||
840 | m_bkmkAvail = NULL; | 853 | m_bkmkAvail = NULL; |
841 | 854 | ||
842 | 855 | ||
843 | setToolBarsMovable(m_tbmove); | 856 | setToolBarsMovable(m_tbmove); |
844 | addtoolbars(&config); | 857 | addtoolbars(&config); |
858 | if (m_hidebars) | ||
859 | { | ||
860 | #if defined(USEQPE) | ||
861 | menubar->hide(); | ||
862 | #endif | ||
863 | if (fileBar != NULL) fileBar->hide(); | ||
864 | if (viewBar != NULL) viewBar->hide(); | ||
865 | if (navBar != NULL) navBar->hide(); | ||
866 | if (markBar != NULL) markBar->hide(); | ||
867 | mb->hide(); | ||
868 | } | ||
869 | |||
845 | 870 | ||
846 | pbar = new QProgressBar(this); | 871 | pbar = new QProgressBar(this); |
847 | pbar->hide(); | 872 | pbar->hide(); |
848 | 873 | ||
849 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 874 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
850 | 875 | ||
851 | searchBar->setHorizontalStretchable( TRUE ); | 876 | searchBar->setHorizontalStretchable( TRUE ); |
852 | 877 | ||
853 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 878 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
854 | 879 | ||
855 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 880 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
856 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 881 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
@@ -963,24 +988,25 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
963 | setBackgroundBitmap(); | 988 | setBackgroundBitmap(); |
964 | m_inverse_action->setOn(reader->bInverse); | 989 | m_inverse_action->setOn(reader->bInverse); |
965 | reader->init(); | 990 | reader->init(); |
966 | 991 | ||
967 | // qDebug("Inited"); | 992 | // qDebug("Inited"); |
968 | // m_buttonAction[m_spaceTarget]->setOn(true); | 993 | // m_buttonAction[m_spaceTarget]->setOn(true); |
969 | // qDebug("fonting"); | 994 | // qDebug("fonting"); |
970 | do_setfont(reader->m_fontname); | 995 | do_setfont(reader->m_fontname); |
971 | // qDebug("fonted"); | 996 | // qDebug("fonted"); |
972 | QFont progfont(reader->m_fontname, reader->m_fontControl.getsize(0)); | 997 | QFont progfont(reader->m_fontname, reader->m_fontControl.getsize(0)); |
973 | m_prog->setFont( progfont ); | 998 | m_prog->setFont( progfont ); |
974 | if (m_statusishidden) m_prog->hide(); | 999 | if (m_statusishidden) m_prog->hide(); |
1000 | showEditTools(); | ||
975 | if (!reader->m_lastfile.isEmpty()) | 1001 | if (!reader->m_lastfile.isEmpty()) |
976 | { | 1002 | { |
977 | //qDebug("doclnk"); | 1003 | //qDebug("doclnk"); |
978 | //doc = new DocLnk(reader->m_lastfile); | 1004 | //doc = new DocLnk(reader->m_lastfile); |
979 | //qDebug("doclnk done"); | 1005 | //qDebug("doclnk done"); |
980 | if (pOpenlist != NULL) | 1006 | if (pOpenlist != NULL) |
981 | { | 1007 | { |
982 | 1008 | ||
983 | /* | 1009 | /* |
984 | int ind = 0; | 1010 | int ind = 0; |
985 | Bkmk* p = (*pOpenlist)[ind]; | 1011 | Bkmk* p = (*pOpenlist)[ind]; |
986 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 1012 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
@@ -1023,31 +1049,31 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
1023 | { | 1049 | { |
1024 | showEditTools(); | 1050 | showEditTools(); |
1025 | } | 1051 | } |
1026 | // qApp->processEvents(); | 1052 | // qApp->processEvents(); |
1027 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) | 1053 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) |
1028 | { | 1054 | { |
1029 | reader->m_scrollpos = m_localscroll; | 1055 | reader->m_scrollpos = m_localscroll; |
1030 | } | 1056 | } |
1031 | else | 1057 | else |
1032 | { | 1058 | { |
1033 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; | 1059 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
1034 | } | 1060 | } |
1035 | reader->bDoUpdates = true; | 1061 | // reader->bDoUpdates = true; |
1036 | reader->update(); | 1062 | // reader->update(); |
1037 | config.setGroup("Version"); | 1063 | config.setGroup("Version"); |
1038 | int major = config.readNumEntry("Major", 0); | 1064 | int major = config.readNumEntry("Major", 0); |
1039 | int bkmktype = config.readNumEntry("BkmkType", 0); | 1065 | int bkmktype = config.readNumEntry("BkmkType", 0); |
1040 | char minor = config.readNumEntry("Minor", 0); | 1066 | char minor = config.readNumEntry("Minor", 0); |
1041 | if (CheckVersion(major, bkmktype, minor)) | 1067 | if (CheckVersion(major, bkmktype, minor, this)) |
1042 | { | 1068 | { |
1043 | config.writeEntry("Major", major); | 1069 | config.writeEntry("Major", major); |
1044 | config.writeEntry("BkmkType", bkmktype); | 1070 | config.writeEntry("BkmkType", bkmktype); |
1045 | config.writeEntry("Minor", (int)minor); | 1071 | config.writeEntry("Minor", (int)minor); |
1046 | } | 1072 | } |
1047 | // qDebug("finished update"); | 1073 | // qDebug("finished update"); |
1048 | if (kmap.isEmpty()) | 1074 | if (kmap.isEmpty()) |
1049 | { | 1075 | { |
1050 | QMessageBox::warning(this, PROGNAME, "You haven't mapped any keys yet!\n\nYou will be taken to the key\nmapping dialog.\nA few defaults are provided\nbut you can change then to\nsuit yourself.\n\nYou can change the key\nmapping at any time by\nselecting the Settings/Button\noption on the menu."); | 1076 | QMessageBox::warning(this, PROGNAME, "You haven't mapped any keys yet!\n\nYou will be taken to the key\nmapping dialog.\nA few defaults are provided\nbut you can change then to\nsuit yourself.\n\nYou can change the key\nmapping at any time by\nselecting the Settings/Button\noption on the menu."); |
1051 | 1077 | ||
1052 | m_buttonprefs->mapkey(Qt::NoButton, Key_Up, cesPageUp); | 1078 | m_buttonprefs->mapkey(Qt::NoButton, Key_Up, cesPageUp); |
1053 | m_buttonprefs->mapkey(Qt::NoButton, Key_Down, cesPageDown); | 1079 | m_buttonprefs->mapkey(Qt::NoButton, Key_Down, cesPageDown); |
@@ -1056,25 +1082,25 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
1056 | m_buttonprefs->mapkey(Qt::NoButton, Key_Left, cesZoomOut); | 1082 | m_buttonprefs->mapkey(Qt::NoButton, Key_Left, cesZoomOut); |
1057 | 1083 | ||
1058 | showbuttonprefs(); | 1084 | showbuttonprefs(); |
1059 | } | 1085 | } |
1060 | } | 1086 | } |
1061 | 1087 | ||
1062 | void QTReaderApp::addtoolbars(Config* config) | 1088 | void QTReaderApp::addtoolbars(Config* config) |
1063 | { | 1089 | { |
1064 | config->setGroup("Toolbar"); | 1090 | config->setGroup("Toolbar"); |
1065 | 1091 | ||
1066 | if (fileBar != NULL) | 1092 | if (fileBar != NULL) |
1067 | { | 1093 | { |
1068 | #ifdef USEQPE | 1094 | #if defined(USEQPE) |
1069 | if (fileBar != menubar) | 1095 | if (fileBar != menubar) |
1070 | { | 1096 | { |
1071 | fileBar->clear(); | 1097 | fileBar->clear(); |
1072 | } | 1098 | } |
1073 | else | 1099 | else |
1074 | { | 1100 | { |
1075 | m_preferences_action->removeFrom( filebar() ); | 1101 | m_preferences_action->removeFrom( filebar() ); |
1076 | m_open_action->removeFrom( filebar() ); | 1102 | m_open_action->removeFrom( filebar() ); |
1077 | m_close_action->removeFrom( filebar() ); | 1103 | m_close_action->removeFrom( filebar() ); |
1078 | m_info_action->removeFrom( filebar() ); | 1104 | m_info_action->removeFrom( filebar() ); |
1079 | m_touch_action->removeFrom( filebar() ); | 1105 | m_touch_action->removeFrom( filebar() ); |
1080 | m_find_action->removeFrom( filebar() ); | 1106 | m_find_action->removeFrom( filebar() ); |
@@ -1084,25 +1110,25 @@ void QTReaderApp::addtoolbars(Config* config) | |||
1084 | #endif | 1110 | #endif |
1085 | } | 1111 | } |
1086 | 1112 | ||
1087 | m_preferences_action->addTo( filebar() ); | 1113 | m_preferences_action->addTo( filebar() ); |
1088 | addfilebar(config, "Open", m_open_action); | 1114 | addfilebar(config, "Open", m_open_action); |
1089 | addfilebar(config, "Close", m_close_action); | 1115 | addfilebar(config, "Close", m_close_action); |
1090 | addfilebar(config, "Info", m_info_action); | 1116 | addfilebar(config, "Info", m_info_action); |
1091 | addfilebar(config, "Two/One Touch", m_touch_action); | 1117 | addfilebar(config, "Two/One Touch", m_touch_action); |
1092 | addfilebar(config, "Find", m_find_action); | 1118 | addfilebar(config, "Find", m_find_action); |
1093 | 1119 | ||
1094 | if (navBar != NULL) | 1120 | if (navBar != NULL) |
1095 | { | 1121 | { |
1096 | #ifdef USEQPE | 1122 | #if defined(USEQPE) |
1097 | if ((navBar == fileBar) && (fileBar == menubar)) | 1123 | if ((navBar == fileBar) && (fileBar == menubar)) |
1098 | #else | 1124 | #else |
1099 | if (navBar == fileBar) | 1125 | if (navBar == fileBar) |
1100 | #endif | 1126 | #endif |
1101 | { | 1127 | { |
1102 | m_scrollButton->removeFrom( navbar() ); | 1128 | m_scrollButton->removeFrom( navbar() ); |
1103 | m_start_action->removeFrom( navbar() ); | 1129 | m_start_action->removeFrom( navbar() ); |
1104 | m_end_action->removeFrom( navbar() ); | 1130 | m_end_action->removeFrom( navbar() ); |
1105 | m_jump_action->removeFrom( navbar() ); | 1131 | m_jump_action->removeFrom( navbar() ); |
1106 | m_pageline_action->removeFrom( navbar() ); | 1132 | m_pageline_action->removeFrom( navbar() ); |
1107 | m_pageup_action->removeFrom( navbar() ); | 1133 | m_pageup_action->removeFrom( navbar() ); |
1108 | m_pagedn_action->removeFrom( navbar() ); | 1134 | m_pagedn_action->removeFrom( navbar() ); |
@@ -1123,25 +1149,25 @@ void QTReaderApp::addtoolbars(Config* config) | |||
1123 | addnavbar(config, "Jump", m_jump_action); | 1149 | addnavbar(config, "Jump", m_jump_action); |
1124 | addnavbar(config, "Page/Line Scroll", m_pageline_action); | 1150 | addnavbar(config, "Page/Line Scroll", m_pageline_action); |
1125 | 1151 | ||
1126 | addnavbar(config, "Page Up", m_pageup_action); | 1152 | addnavbar(config, "Page Up", m_pageup_action); |
1127 | addnavbar(config, "Page Down", m_pagedn_action); | 1153 | addnavbar(config, "Page Down", m_pagedn_action); |
1128 | 1154 | ||
1129 | addnavbar(config, "Back", m_back_action); | 1155 | addnavbar(config, "Back", m_back_action); |
1130 | addnavbar(config, "Home", m_home_action); | 1156 | addnavbar(config, "Home", m_home_action); |
1131 | addnavbar(config, "Forward", m_forward_action); | 1157 | addnavbar(config, "Forward", m_forward_action); |
1132 | 1158 | ||
1133 | if (viewBar != NULL) | 1159 | if (viewBar != NULL) |
1134 | { | 1160 | { |
1135 | #ifdef USEQPE | 1161 | #if defined(USEQPE) |
1136 | if ((viewBar == fileBar) && (fileBar == menubar)) | 1162 | if ((viewBar == fileBar) && (fileBar == menubar)) |
1137 | #else | 1163 | #else |
1138 | if (viewBar == fileBar) | 1164 | if (viewBar == fileBar) |
1139 | #endif | 1165 | #endif |
1140 | { | 1166 | { |
1141 | m_actFullscreen->removeFrom( filebar() ); | 1167 | m_actFullscreen->removeFrom( filebar() ); |
1142 | m_rotate_action->removeFrom( viewbar() ); | 1168 | m_rotate_action->removeFrom( viewbar() ); |
1143 | m_inverse_action->removeFrom( viewbar() ); | 1169 | m_inverse_action->removeFrom( viewbar() ); |
1144 | m_zoomin_action->removeFrom( viewbar() ); | 1170 | m_zoomin_action->removeFrom( viewbar() ); |
1145 | m_zoomout_action->removeFrom( viewbar() ); | 1171 | m_zoomout_action->removeFrom( viewbar() ); |
1146 | m_setfont_action->removeFrom( viewbar() ); | 1172 | m_setfont_action->removeFrom( viewbar() ); |
1147 | m_setenc_action->removeFrom( viewbar() ); | 1173 | m_setenc_action->removeFrom( viewbar() ); |
@@ -1155,25 +1181,25 @@ void QTReaderApp::addtoolbars(Config* config) | |||
1155 | 1181 | ||
1156 | addviewbar(config, "Fullscreen", m_actFullscreen); | 1182 | addviewbar(config, "Fullscreen", m_actFullscreen); |
1157 | addviewbar(config, "Rotate", m_rotate_action); | 1183 | addviewbar(config, "Rotate", m_rotate_action); |
1158 | addviewbar(config, "Invert Action", m_inverse_action); | 1184 | addviewbar(config, "Invert Action", m_inverse_action); |
1159 | addviewbar(config, "Zoom In", m_zoomin_action); | 1185 | addviewbar(config, "Zoom In", m_zoomin_action); |
1160 | addviewbar(config, "Zoom Out", m_zoomout_action); | 1186 | addviewbar(config, "Zoom Out", m_zoomout_action); |
1161 | addviewbar(config, "Set Font", m_setfont_action); | 1187 | addviewbar(config, "Set Font", m_setfont_action); |
1162 | addviewbar(config, "Encoding Select", m_setenc_action); | 1188 | addviewbar(config, "Encoding Select", m_setenc_action); |
1163 | addviewbar(config, "Ideogram Mode", m_setmono_action); | 1189 | addviewbar(config, "Ideogram Mode", m_setmono_action); |
1164 | 1190 | ||
1165 | if (markBar != NULL) | 1191 | if (markBar != NULL) |
1166 | { | 1192 | { |
1167 | #ifdef USEQPE | 1193 | #if defined(USEQPE) |
1168 | if ((markBar == fileBar) && (fileBar == menubar)) | 1194 | if ((markBar == fileBar) && (fileBar == menubar)) |
1169 | #else | 1195 | #else |
1170 | if (markBar == fileBar) | 1196 | if (markBar == fileBar) |
1171 | #endif | 1197 | #endif |
1172 | { | 1198 | { |
1173 | m_mark_action->removeFrom( markbar() ); | 1199 | m_mark_action->removeFrom( markbar() ); |
1174 | m_annotate_action->removeFrom( markbar()); | 1200 | m_annotate_action->removeFrom( markbar()); |
1175 | m_goto_action->removeFrom( markbar() ); | 1201 | m_goto_action->removeFrom( markbar() ); |
1176 | m_delete_action->removeFrom( markbar() ); | 1202 | m_delete_action->removeFrom( markbar() ); |
1177 | m_autogen_action->removeFrom( markbar() ); | 1203 | m_autogen_action->removeFrom( markbar() ); |
1178 | m_clear_action->removeFrom( markbar() ); | 1204 | m_clear_action->removeFrom( markbar() ); |
1179 | m_save_action->removeFrom( markbar() ); | 1205 | m_save_action->removeFrom( markbar() ); |
@@ -1224,25 +1250,25 @@ void QTReaderApp::addtoolbars(Config* config) | |||
1224 | bool QTReaderApp::checkbar(Config* _config, const QString& key) | 1250 | bool QTReaderApp::checkbar(Config* _config, const QString& key) |
1225 | { | 1251 | { |
1226 | return _config->readBoolEntry(key, false); | 1252 | return _config->readBoolEntry(key, false); |
1227 | } | 1253 | } |
1228 | 1254 | ||
1229 | 1255 | ||
1230 | QToolBar* QTReaderApp::filebar() | 1256 | QToolBar* QTReaderApp::filebar() |
1231 | { | 1257 | { |
1232 | if (fileBar == NULL) | 1258 | if (fileBar == NULL) |
1233 | { | 1259 | { |
1234 | switch (m_tbpol) | 1260 | switch (m_tbpol) |
1235 | { | 1261 | { |
1236 | #ifdef USEQPE | 1262 | #if defined(USEQPE) |
1237 | case cesSingle: | 1263 | case cesSingle: |
1238 | // qDebug("Setting filebar to menubar"); | 1264 | // qDebug("Setting filebar to menubar"); |
1239 | fileBar = menubar; | 1265 | fileBar = menubar; |
1240 | break; | 1266 | break; |
1241 | #endif | 1267 | #endif |
1242 | default: | 1268 | default: |
1243 | qDebug("Incorrect toolbar policy set"); | 1269 | qDebug("Incorrect toolbar policy set"); |
1244 | case cesMenuTool: | 1270 | case cesMenuTool: |
1245 | case cesMultiple: | 1271 | case cesMultiple: |
1246 | // qDebug("Creating new file bar"); | 1272 | // qDebug("Creating new file bar"); |
1247 | fileBar = new QToolBar("File", this, m_tbposition); | 1273 | fileBar = new QToolBar("File", this, m_tbposition); |
1248 | break; | 1274 | break; |
@@ -1708,43 +1734,41 @@ void QTReaderApp::setrotated(bool sfs) | |||
1708 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::BottomToTop : QBoxLayout::TopToBottom ); | 1734 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::BottomToTop : QBoxLayout::TopToBottom ); |
1709 | if (m_scrollbar != NULL) | 1735 | if (m_scrollbar != NULL) |
1710 | { | 1736 | { |
1711 | scrollbar->disconnect(); | 1737 | scrollbar->disconnect(); |
1712 | m_scrollbar->setOrientation(Qt::Horizontal); | 1738 | m_scrollbar->setOrientation(Qt::Horizontal); |
1713 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineUp()) ); | 1739 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineUp()) ); |
1714 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineDown()) ); | 1740 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineDown()) ); |
1715 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopageup()) ); | 1741 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopageup()) ); |
1716 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopagedn()) ); | 1742 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopagedn()) ); |
1717 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); | 1743 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
1718 | } | 1744 | } |
1719 | //reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border); | 1745 | //reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border); |
1720 | reader->repaint(); | ||
1721 | } | 1746 | } |
1722 | else | 1747 | else |
1723 | { | 1748 | { |
1724 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight ); | 1749 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight ); |
1725 | if (m_scrollbar != NULL) | 1750 | if (m_scrollbar != NULL) |
1726 | { | 1751 | { |
1727 | scrollbar->disconnect(); | 1752 | scrollbar->disconnect(); |
1728 | m_scrollbar->setOrientation(Qt::Vertical); | 1753 | m_scrollbar->setOrientation(Qt::Vertical); |
1729 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineDown()) ); | 1754 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineDown()) ); |
1730 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineUp()) ); | 1755 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineUp()) ); |
1731 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopagedn()) ); | 1756 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopagedn()) ); |
1732 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopageup()) ); | 1757 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopageup()) ); |
1733 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); | 1758 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
1734 | } | 1759 | } |
1735 | //reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height()); | 1760 | //reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height()); |
1736 | reader->repaint(); | ||
1737 | } | 1761 | } |
1738 | // reader->update(); | 1762 | reader->refresh(); |
1739 | } | 1763 | } |
1740 | 1764 | ||
1741 | void QTReaderApp::setgrab(bool sfs) | 1765 | void QTReaderApp::setgrab(bool sfs) |
1742 | { | 1766 | { |
1743 | #ifdef USEQPE | 1767 | #ifdef USEQPE |
1744 | m_grabkeyboard = sfs; | 1768 | m_grabkeyboard = sfs; |
1745 | if (m_grabkeyboard) | 1769 | if (m_grabkeyboard) |
1746 | { | 1770 | { |
1747 | ((QPEApplication*)qApp)->grabKeyboard(); | 1771 | ((QPEApplication*)qApp)->grabKeyboard(); |
1748 | } | 1772 | } |
1749 | else | 1773 | else |
1750 | { | 1774 | { |
@@ -1919,48 +1943,48 @@ void QTReaderApp::fileOpen2() | |||
1919 | reader->pBkmklist = pBkmklist = NULL; | 1943 | reader->pBkmklist = pBkmklist = NULL; |
1920 | m_fBkmksChanged = false; | 1944 | m_fBkmksChanged = false; |
1921 | } | 1945 | } |
1922 | reader->disableAutoscroll(); | 1946 | reader->disableAutoscroll(); |
1923 | /* | 1947 | /* |
1924 | editorStack->raiseWidget( fileSelector ); | 1948 | editorStack->raiseWidget( fileSelector ); |
1925 | fileSelector->reread(); | 1949 | fileSelector->reread(); |
1926 | */ | 1950 | */ |
1927 | bool usebrowser = true; | 1951 | bool usebrowser = true; |
1928 | if (pOpenlist != NULL) | 1952 | if (pOpenlist != NULL) |
1929 | { | 1953 | { |
1930 | m_nBkmkAction = cOpenFile; | 1954 | m_nBkmkAction = cOpenFile; |
1931 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; | 1955 | if (listbkmk(pOpenlist, "Browse", true)) usebrowser = false; |
1932 | } | 1956 | } |
1933 | if (usebrowser) | 1957 | if (usebrowser) |
1934 | { | 1958 | { |
1935 | QString fn = usefilebrowser(); | 1959 | QString fn = usefilebrowser(); |
1936 | //qApp->processEvents(); | 1960 | //qApp->processEvents(); |
1937 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 1961 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
1938 | { | 1962 | { |
1939 | openFile(fn); | 1963 | openFile(fn); |
1940 | } | 1964 | } |
1941 | reader->setFocus(); | 1965 | reader->setFocus(); |
1942 | } | 1966 | } |
1943 | // reader->refresh(); | 1967 | // reader->refresh(); |
1944 | // qDebug("HEIGHT:%d", reader->m_lastheight); | 1968 | // qDebug("HEIGHT:%d", reader->m_lastheight); |
1945 | } | 1969 | } |
1946 | 1970 | ||
1947 | QString QTReaderApp::usefilebrowser() | 1971 | QString QTReaderApp::usefilebrowser() |
1948 | { | 1972 | { |
1949 | #ifndef USEQPE | 1973 | #ifndef USEQPE |
1950 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); | 1974 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); |
1951 | return s; | 1975 | return s; |
1952 | #else | 1976 | #else |
1953 | QString fn; | 1977 | QString fn; |
1954 | #ifdef OPIE | 1978 | #if defined(OPIE) && defined(OPIEFILEDIALOG) |
1955 | QMap<QString, QStringList> mimeTypes; | 1979 | QMap<QString, QStringList> mimeTypes; |
1956 | QStringList etypes; | 1980 | QStringList etypes; |
1957 | etypes << "etext/*"; | 1981 | etypes << "etext/*"; |
1958 | mimeTypes.insert( tr("eText"), etypes ); | 1982 | mimeTypes.insert( tr("eText"), etypes ); |
1959 | QStringList types; | 1983 | QStringList types; |
1960 | types << "text/*"; | 1984 | types << "text/*"; |
1961 | mimeTypes.insert( tr("Text"), types ); | 1985 | mimeTypes.insert( tr("Text"), types ); |
1962 | mimeTypes.insert( tr("All"), "*/*" ); | 1986 | mimeTypes.insert( tr("All"), "*/*" ); |
1963 | fn = OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL, QFileInfo(reader->m_lastfile).dirPath(true), QString::null, mimeTypes, 0, "OpieReader"); | 1987 | fn = OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL, QFileInfo(reader->m_lastfile).dirPath(true), QString::null, mimeTypes, 0, "OpieReader"); |
1964 | #else | 1988 | #else |
1965 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, | 1989 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, |
1966 | 0, | 1990 | 0, |
@@ -1994,36 +2018,38 @@ void QTReaderApp::showbuttonprefs() | |||
1994 | hidetoolbars(); | 2018 | hidetoolbars(); |
1995 | m_buttonprefs->setFocus(); | 2019 | m_buttonprefs->setFocus(); |
1996 | m_kmapchanged = true; | 2020 | m_kmapchanged = true; |
1997 | } | 2021 | } |
1998 | 2022 | ||
1999 | void QTReaderApp::showprefs() | 2023 | void QTReaderApp::showprefs() |
2000 | { | 2024 | { |
2001 | CPrefs* prefwin = new CPrefs(reader->width(), !m_bFloatingDialog, this); | 2025 | CPrefs* prefwin = new CPrefs(reader->width(), !m_bFloatingDialog, this); |
2002 | 2026 | ||
2003 | // prefwin->Debounce(m_debounce); | 2027 | // prefwin->Debounce(m_debounce); |
2004 | prefwin->bgtype(m_bgtype); | 2028 | prefwin->bgtype(m_bgtype); |
2005 | prefwin->repalm(reader->brepalm); | 2029 | prefwin->repalm(reader->brepalm); |
2030 | prefwin->UnderlineLink(reader->bunderlineLink); | ||
2006 | prefwin->kern(reader->bkern); | 2031 | prefwin->kern(reader->bkern); |
2007 | prefwin->hyphenate(reader->hyphenate); | 2032 | prefwin->hyphenate(reader->hyphenate); |
2008 | // prefwin->customhyphen(reader->buffdoc.getCustomHyphen()); | 2033 | // prefwin->customhyphen(reader->buffdoc.getCustomHyphen()); |
2009 | prefwin->scrolltype(reader->m_scrolltype); | 2034 | prefwin->scrolltype(reader->m_scrolltype); |
2010 | prefwin->scrollstep(reader->m_scrollstep); | 2035 | prefwin->scrollstep(reader->m_scrollstep); |
2011 | prefwin->scrollcolor(m_scrollcolor); | 2036 | prefwin->scrollcolor(m_scrollcolor); |
2012 | prefwin->minibarcol(m_scrollbarcolor); | 2037 | prefwin->minibarcol(m_scrollbarcolor); |
2013 | prefwin->foreground(m_foreground); | 2038 | prefwin->foreground(m_foreground); |
2014 | prefwin->background(m_background); | 2039 | prefwin->background(m_background); |
2015 | prefwin->twotouch(m_twoTouch); | 2040 | prefwin->twotouch(m_twoTouch); |
2016 | prefwin->propfontchange(m_propogatefontchange); | 2041 | prefwin->propfontchange(m_propogatefontchange); |
2017 | prefwin->StripCR(reader->bstripcr); | 2042 | prefwin->StripCR(reader->bstripcr); |
2043 | prefwin->InlineTables(!reader->bNoInlineTables); | ||
2018 | prefwin->Dehyphen(reader->bdehyphen); | 2044 | prefwin->Dehyphen(reader->bdehyphen); |
2019 | prefwin->SingleSpace(reader->bonespace); | 2045 | prefwin->SingleSpace(reader->bonespace); |
2020 | prefwin->Unindent(reader->bunindent); | 2046 | prefwin->Unindent(reader->bunindent); |
2021 | prefwin->Reparagraph(reader->brepara); | 2047 | prefwin->Reparagraph(reader->brepara); |
2022 | prefwin->DoubleSpace(reader->bdblspce); | 2048 | prefwin->DoubleSpace(reader->bdblspce); |
2023 | prefwin->Remap(reader->bremap); | 2049 | prefwin->Remap(reader->bremap); |
2024 | prefwin->Embolden(reader->bmakebold); | 2050 | prefwin->Embolden(reader->bmakebold); |
2025 | prefwin->FullJustify(reader->bfulljust); | 2051 | prefwin->FullJustify(reader->bfulljust); |
2026 | // prefwin->Inverse(reader->bInverse); | 2052 | // prefwin->Inverse(reader->bInverse); |
2027 | // prefwin->Negative(reader->bNegative); | 2053 | // prefwin->Negative(reader->bNegative); |
2028 | prefwin->FixGraphics(reader->m_fontControl.FixGraphics()); | 2054 | prefwin->FixGraphics(reader->m_fontControl.FixGraphics()); |
2029 | prefwin->ParaLead(reader->getextraspace()); | 2055 | prefwin->ParaLead(reader->getextraspace()); |
@@ -2047,75 +2073,82 @@ void QTReaderApp::showprefs() | |||
2047 | } | 2073 | } |
2048 | else if (reader->bpeanut) | 2074 | else if (reader->bpeanut) |
2049 | { | 2075 | { |
2050 | prefwin->Markup(4); | 2076 | prefwin->Markup(4); |
2051 | } | 2077 | } |
2052 | else | 2078 | else |
2053 | { | 2079 | { |
2054 | prefwin->Markup(1); | 2080 | prefwin->Markup(1); |
2055 | } | 2081 | } |
2056 | prefwin->Depluck(reader->bdepluck); | 2082 | prefwin->Depluck(reader->bdepluck); |
2057 | prefwin->Dejpluck(reader->bdejpluck); | 2083 | prefwin->Dejpluck(reader->bdejpluck); |
2058 | prefwin->Continuous(reader->m_continuousDocument); | 2084 | prefwin->Continuous(reader->m_continuousDocument); |
2085 | prefwin->DoubleBuffer(reader->m_doubleBuffered); | ||
2059 | 2086 | ||
2060 | prefwin->dictApplication(m_targetapp); | 2087 | prefwin->dictApplication(m_targetapp); |
2061 | prefwin->dictMessage(m_targetmsg); | 2088 | prefwin->dictMessage(m_targetmsg); |
2062 | 2089 | ||
2063 | /* | 2090 | /* |
2064 | prefwin->leftScroll(m_leftScroll); | 2091 | prefwin->leftScroll(m_leftScroll); |
2065 | prefwin->rightScroll(m_rightScroll); | 2092 | prefwin->rightScroll(m_rightScroll); |
2066 | prefwin->upScroll(m_upScroll); | 2093 | prefwin->upScroll(m_upScroll); |
2067 | prefwin->downScroll(m_downScroll); | 2094 | prefwin->downScroll(m_downScroll); |
2068 | */ | 2095 | */ |
2069 | 2096 | ||
2070 | prefwin->miscannotation(m_doAnnotation); | 2097 | prefwin->miscannotation(m_doAnnotation); |
2071 | prefwin->miscdictionary(m_doDictionary); | 2098 | prefwin->miscdictionary(m_doDictionary); |
2072 | prefwin->miscclipboard(m_doClipboard); | 2099 | prefwin->miscclipboard(m_doClipboard); |
2100 | prefwin->miscoutput(m_doOutput); | ||
2073 | 2101 | ||
2074 | prefwin->SwapMouse(reader->m_swapmouse); | 2102 | prefwin->SwapMouse(reader->m_swapmouse); |
2075 | 2103 | ||
2076 | prefwin->Font(reader->m_fontname); | 2104 | prefwin->Font(reader->m_fontname); |
2077 | 2105 | ||
2078 | prefwin->gfxsize(reader->getBaseSize()); | 2106 | prefwin->gfxsize(reader->getBaseSize()); |
2079 | 2107 | ||
2080 | prefwin->pageoverlap(reader->m_overlap); | 2108 | prefwin->pageoverlap(reader->m_overlap); |
2081 | 2109 | ||
2082 | prefwin->ideogram(reader->m_bMonoSpaced); | 2110 | prefwin->ideogram(reader->m_bMonoSpaced); |
2083 | 2111 | ||
2084 | prefwin->encoding(reader->m_encd); | 2112 | prefwin->encoding(reader->m_encd); |
2085 | 2113 | ||
2086 | prefwin->ideogramwidth(reader->m_charpc); | 2114 | prefwin->ideogramwidth(reader->m_charpc); |
2087 | 2115 | ||
2116 | prefwin->outcodec(reader->m_outputName); | ||
2117 | |||
2088 | if (prefwin->exec()) | 2118 | if (prefwin->exec()) |
2089 | { | 2119 | { |
2090 | // m_debounce = prefwin->Debounce(); | 2120 | // m_debounce = prefwin->Debounce(); |
2091 | reader->brepalm = prefwin->repalm(); | 2121 | reader->brepalm = prefwin->repalm(); |
2122 | reader->bunderlineLink = prefwin->UnderlineLink(); | ||
2123 | |||
2092 | reader->bkern = prefwin->kern(); | 2124 | reader->bkern = prefwin->kern(); |
2093 | reader->hyphenate = prefwin->hyphenate(); | 2125 | reader->hyphenate = prefwin->hyphenate(); |
2094 | // reader->buffdoc.setCustomHyphen(prefwin->customhyphen()); | 2126 | // reader->buffdoc.setCustomHyphen(prefwin->customhyphen()); |
2095 | reader->m_scrolltype = prefwin->scrolltype(); | 2127 | reader->m_scrolltype = prefwin->scrolltype(); |
2096 | reader->m_scrollstep = prefwin->scrollstep(); | 2128 | reader->m_scrollstep = prefwin->scrollstep(); |
2097 | m_scrollcolor = prefwin->scrollcolor(); | 2129 | m_scrollcolor = prefwin->scrollcolor(); |
2098 | setscrollcolour(); | 2130 | setscrollcolour(); |
2099 | m_scrollbarcolor = prefwin->minibarcol(); | 2131 | m_scrollbarcolor = prefwin->minibarcol(); |
2100 | setscrollbarcolour(); | 2132 | setscrollbarcolour(); |
2101 | m_foreground = prefwin->foreground(); | 2133 | m_foreground = prefwin->foreground(); |
2102 | reader->setForeground(getcolour(m_foreground)); | 2134 | reader->setForeground(getcolour(m_foreground)); |
2103 | m_background = prefwin->background(); | 2135 | m_background = prefwin->background(); |
2104 | reader->setBackground(getcolour(m_background)); | 2136 | reader->setBackground(getcolour(m_background)); |
2105 | m_twoTouch = prefwin->twotouch(); | 2137 | m_twoTouch = prefwin->twotouch(); |
2106 | reader->setTwoTouch(m_twoTouch); | 2138 | reader->setTwoTouch(m_twoTouch); |
2107 | m_touch_action->setOn(m_twoTouch); | 2139 | m_touch_action->setOn(m_twoTouch); |
2108 | 2140 | ||
2109 | reader->bstripcr = prefwin->StripCR(); | 2141 | reader->bstripcr = prefwin->StripCR(); |
2142 | reader->bNoInlineTables = !prefwin->InlineTables(); | ||
2110 | reader->bdehyphen = prefwin->Dehyphen(); | 2143 | reader->bdehyphen = prefwin->Dehyphen(); |
2111 | reader->bonespace = prefwin->SingleSpace(); | 2144 | reader->bonespace = prefwin->SingleSpace(); |
2112 | reader->bunindent = prefwin->Unindent(); | 2145 | reader->bunindent = prefwin->Unindent(); |
2113 | reader->brepara = prefwin->Reparagraph(); | 2146 | reader->brepara = prefwin->Reparagraph(); |
2114 | reader->bdblspce = prefwin->DoubleSpace(); | 2147 | reader->bdblspce = prefwin->DoubleSpace(); |
2115 | reader->bremap = prefwin->Remap(); | 2148 | reader->bremap = prefwin->Remap(); |
2116 | reader->bmakebold = prefwin->Embolden(); | 2149 | reader->bmakebold = prefwin->Embolden(); |
2117 | reader->bfulljust = prefwin->FullJustify(); | 2150 | reader->bfulljust = prefwin->FullJustify(); |
2118 | //if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse()); | 2151 | //if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse()); |
2119 | //if (reader->bNegative != prefwin->Negative()) reader->setNegative(); | 2152 | //if (reader->bNegative != prefwin->Negative()) reader->setNegative(); |
2120 | reader->m_fontControl.FixGraphics(prefwin->FixGraphics()); | 2153 | reader->m_fontControl.FixGraphics(prefwin->FixGraphics()); |
2121 | 2154 | ||
@@ -2140,58 +2173,69 @@ void QTReaderApp::showprefs() | |||
2140 | case 3: | 2173 | case 3: |
2141 | reader->bstriphtml = true; | 2174 | reader->bstriphtml = true; |
2142 | break; | 2175 | break; |
2143 | case 4: | 2176 | case 4: |
2144 | reader->bpeanut = true; | 2177 | reader->bpeanut = true; |
2145 | break; | 2178 | break; |
2146 | default: | 2179 | default: |
2147 | qDebug("Format out of range"); | 2180 | qDebug("Format out of range"); |
2148 | } | 2181 | } |
2149 | reader->bdepluck = prefwin->Depluck(); | 2182 | reader->bdepluck = prefwin->Depluck(); |
2150 | reader->bdejpluck = prefwin->Dejpluck(); | 2183 | reader->bdejpluck = prefwin->Dejpluck(); |
2151 | reader->setContinuous(prefwin->Continuous()); | 2184 | reader->setContinuous(prefwin->Continuous()); |
2185 | reader->setDoubleBuffer(prefwin->DoubleBuffer()); | ||
2152 | 2186 | ||
2153 | /* | 2187 | /* |
2154 | m_leftScroll = prefwin->leftScroll(); | 2188 | m_leftScroll = prefwin->leftScroll(); |
2155 | m_rightScroll = prefwin->rightScroll(); | 2189 | m_rightScroll = prefwin->rightScroll(); |
2156 | m_upScroll = prefwin->upScroll(); | 2190 | m_upScroll = prefwin->upScroll(); |
2157 | m_downScroll = prefwin->downScroll(); | 2191 | m_downScroll = prefwin->downScroll(); |
2158 | */ | 2192 | */ |
2159 | m_targetapp = prefwin->dictApplication(); | 2193 | m_targetapp = prefwin->dictApplication(); |
2160 | m_targetmsg = prefwin->dictMessage(); | 2194 | m_targetmsg = prefwin->dictMessage(); |
2161 | 2195 | ||
2162 | m_doAnnotation = prefwin->miscannotation(); | 2196 | m_doAnnotation = prefwin->miscannotation(); |
2163 | m_doDictionary = prefwin->miscdictionary(); | 2197 | m_doDictionary = prefwin->miscdictionary(); |
2164 | m_doClipboard = prefwin->miscclipboard(); | 2198 | m_doClipboard = prefwin->miscclipboard(); |
2199 | m_doOutput = prefwin->miscoutput(); | ||
2165 | reader->m_swapmouse = prefwin->SwapMouse(); | 2200 | reader->m_swapmouse = prefwin->SwapMouse(); |
2166 | reader->setBaseSize(prefwin->gfxsize()); | 2201 | reader->setBaseSize(prefwin->gfxsize()); |
2167 | reader->m_overlap = prefwin->pageoverlap(); | 2202 | reader->m_overlap = prefwin->pageoverlap(); |
2168 | reader->m_bMonoSpaced = prefwin->ideogram(); | 2203 | reader->m_bMonoSpaced = prefwin->ideogram(); |
2169 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 2204 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
2170 | reader->m_encd = prefwin->encoding(); | 2205 | reader->m_encd = prefwin->encoding(); |
2171 | reader->m_charpc = prefwin->ideogramwidth(); | 2206 | reader->m_charpc = prefwin->ideogramwidth(); |
2172 | 2207 | ||
2173 | if ( | 2208 | if ( |
2174 | reader->m_fontname != prefwin->Font() | 2209 | reader->m_fontname != prefwin->Font() |
2175 | || | 2210 | || |
2176 | m_propogatefontchange != prefwin->propfontchange()) | 2211 | m_propogatefontchange != prefwin->propfontchange()) |
2177 | { | 2212 | { |
2178 | m_propogatefontchange = prefwin->propfontchange(); | 2213 | m_propogatefontchange = prefwin->propfontchange(); |
2179 | setfontHelper(prefwin->Font()); | 2214 | setfontHelper(prefwin->Font()); |
2180 | } | 2215 | } |
2181 | if (m_bgtype != (bground)prefwin->bgtype()) | 2216 | if (m_bgtype != (bground)prefwin->bgtype()) |
2182 | { | 2217 | { |
2183 | m_bgtype = (bground)prefwin->bgtype(); | 2218 | m_bgtype = (bground)prefwin->bgtype(); |
2184 | setBackgroundBitmap(); | 2219 | setBackgroundBitmap(); |
2185 | } | 2220 | } |
2221 | qDebug("OutCodec:%s", (const char*)prefwin->outcodec()); | ||
2222 | if (reader->m_outputName != prefwin->outcodec()) | ||
2223 | { | ||
2224 | if (reader->m_output != NULL) | ||
2225 | { | ||
2226 | QMessageBox::warning(this, PROGNAME, "Change of output codec\nrequires a restart"); | ||
2227 | } | ||
2228 | reader->m_outputName = prefwin->outcodec(); | ||
2229 | } | ||
2186 | delete prefwin; | 2230 | delete prefwin; |
2187 | reader->setfilter(reader->getfilter()); | 2231 | reader->setfilter(reader->getfilter()); |
2188 | reader->refresh(); | 2232 | reader->refresh(); |
2189 | } | 2233 | } |
2190 | else | 2234 | else |
2191 | { | 2235 | { |
2192 | delete prefwin; | 2236 | delete prefwin; |
2193 | } | 2237 | } |
2194 | } | 2238 | } |
2195 | 2239 | ||
2196 | void QTReaderApp::showtoolbarprefs() | 2240 | void QTReaderApp::showtoolbarprefs() |
2197 | { | 2241 | { |
@@ -2281,30 +2325,54 @@ void QTReaderApp::showinfo() | |||
2281 | if (reader->empty()) | 2325 | if (reader->empty()) |
2282 | { | 2326 | { |
2283 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2327 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2284 | } | 2328 | } |
2285 | else | 2329 | else |
2286 | { | 2330 | { |
2287 | reader->sizes(fs,ts); | 2331 | reader->sizes(fs,ts); |
2288 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); | 2332 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); |
2289 | pl = reader->pagelocate(); | 2333 | pl = reader->pagelocate(); |
2290 | dl = pl - reader->buffdoc.startSection(); | 2334 | dl = pl - reader->buffdoc.startSection(); |
2291 | m_infoWin->setFileSize(fs); | 2335 | m_infoWin->setFileSize(fs); |
2292 | m_infoWin->setTextSize(ts); | 2336 | m_infoWin->setTextSize(ts); |
2293 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 2337 | if (fs > UINT_MAX/100) |
2338 | { | ||
2339 | unsigned long t1 = (ts+50)/100; | ||
2340 | m_infoWin->setRatio(100-(fs + (t1 >> 1))/t1); | ||
2341 | } | ||
2342 | else | ||
2343 | { | ||
2344 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | ||
2345 | } | ||
2294 | m_infoWin->setLocation(pl); | 2346 | m_infoWin->setLocation(pl); |
2295 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 2347 | if (pl > UINT_MAX/100) |
2348 | { | ||
2349 | unsigned long t1 = (ts+50)/100; | ||
2350 | m_infoWin->setRead((pl + (t1 >> 1))/t1); | ||
2351 | } | ||
2352 | else | ||
2353 | { | ||
2354 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | ||
2355 | } | ||
2296 | m_infoWin->setDocSize(ds); | 2356 | m_infoWin->setDocSize(ds); |
2297 | m_infoWin->setDocLocation(dl); | 2357 | m_infoWin->setDocLocation(dl); |
2298 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); | 2358 | if (dl > UINT_MAX/100) |
2359 | { | ||
2360 | unsigned long d1 = (ds+50)/100; | ||
2361 | m_infoWin->setDocRead((dl + (d1 >> 1))/d1); | ||
2362 | } | ||
2363 | else | ||
2364 | { | ||
2365 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); | ||
2366 | } | ||
2299 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); | 2367 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); |
2300 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); | 2368 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); |
2301 | editorStack->raiseWidget( m_infoWin ); | 2369 | editorStack->raiseWidget( m_infoWin ); |
2302 | hidetoolbars(); | 2370 | hidetoolbars(); |
2303 | m_infoWin->setFocus(); | 2371 | m_infoWin->setFocus(); |
2304 | } | 2372 | } |
2305 | } | 2373 | } |
2306 | 2374 | ||
2307 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) | 2375 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) |
2308 | { | 2376 | { |
2309 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; | 2377 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
2310 | #ifdef _UNICODE | 2378 | #ifdef _UNICODE |
@@ -2733,48 +2801,48 @@ void QTReaderApp::search(const QString & arg) | |||
2733 | reader->jumpto(start); | 2801 | reader->jumpto(start); |
2734 | searchStack->push(new searchrecord(arg,start)); | 2802 | searchStack->push(new searchrecord(arg,start)); |
2735 | } | 2803 | } |
2736 | dosearch(start, test, arg); | 2804 | dosearch(start, test, arg); |
2737 | } | 2805 | } |
2738 | #else | 2806 | #else |
2739 | void QTReaderApp::search() | 2807 | void QTReaderApp::search() |
2740 | { | 2808 | { |
2741 | findNext(); | 2809 | findNext(); |
2742 | } | 2810 | } |
2743 | #endif | 2811 | #endif |
2744 | 2812 | ||
2745 | void QTReaderApp::openFile( const QString &f ) | 2813 | void QTReaderApp::openFile( const QString &f, unsigned int loc ) |
2746 | { | 2814 | { |
2747 | // qDebug("File:%s", (const char*)f); | 2815 | // qDebug("File:%s", (const char*)f); |
2748 | // openFile(DocLnk(f)); | 2816 | // openFile(DocLnk(f)); |
2749 | //} | 2817 | //} |
2750 | // | 2818 | // |
2751 | //void QTReaderApp::openFile( const DocLnk &f ) | 2819 | //void QTReaderApp::openFile( const DocLnk &f ) |
2752 | //{ | 2820 | //{ |
2753 | clear(); | 2821 | clear(); |
2754 | QFileInfo fm(f); | 2822 | QFileInfo fm(f); |
2755 | if ( fm.exists() ) | 2823 | if ( fm.exists() ) |
2756 | { | 2824 | { |
2757 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 2825 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
2758 | #ifdef USEQPE | 2826 | #ifdef USEQPE |
2759 | if (fm.extension( FALSE ) == "desktop") | 2827 | if (fm.extension( FALSE ) == "desktop") |
2760 | { | 2828 | { |
2761 | DocLnk d(f); | 2829 | DocLnk d(f); |
2762 | QFileInfo fnew(d.file()); | 2830 | QFileInfo fnew(d.file()); |
2763 | fm = fnew; | 2831 | fm = fnew; |
2764 | if (!fm.exists()) return; | 2832 | if (!fm.exists()) return; |
2765 | } | 2833 | } |
2766 | #endif | 2834 | #endif |
2767 | clear(); | 2835 | clear(); |
2768 | reader->setText(fm.baseName(), fm.absFilePath()); | 2836 | reader->setText(fm.baseName(), fm.absFilePath(), loc); |
2769 | m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); | 2837 | m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); |
2770 | qDebug("Showing tools"); | 2838 | qDebug("Showing tools"); |
2771 | showEditTools(); | 2839 | showEditTools(); |
2772 | qDebug("Shown tools"); | 2840 | qDebug("Shown tools"); |
2773 | readbkmks(); | 2841 | readbkmks(); |
2774 | qDebug("read markss"); | 2842 | qDebug("read markss"); |
2775 | m_savedpos = 0xffffffff; | 2843 | m_savedpos = 0xffffffff; |
2776 | } | 2844 | } |
2777 | else | 2845 | else |
2778 | { | 2846 | { |
2779 | QString msg = f; | 2847 | QString msg = f; |
2780 | msg += "\nFile does not exist"; | 2848 | msg += "\nFile does not exist"; |
@@ -2797,25 +2865,25 @@ void QTReaderApp::handlekey(QKeyEvent* e) | |||
2797 | { | 2865 | { |
2798 | // qDebug("Keypress event"); | 2866 | // qDebug("Keypress event"); |
2799 | timeb now; | 2867 | timeb now; |
2800 | ftime(&now); | 2868 | ftime(&now); |
2801 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; | 2869 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; |
2802 | if (etime < m_debounce) | 2870 | if (etime < m_debounce) |
2803 | { | 2871 | { |
2804 | return; | 2872 | return; |
2805 | } | 2873 | } |
2806 | switch(e->key()) | 2874 | switch(e->key()) |
2807 | { | 2875 | { |
2808 | case Key_Escape: | 2876 | case Key_Escape: |
2809 | // qDebug("escape event"); | 2877 | qDebug("escape event"); |
2810 | if (m_disableesckey) | 2878 | if (m_disableesckey) |
2811 | { | 2879 | { |
2812 | m_disableesckey = false; | 2880 | m_disableesckey = false; |
2813 | } | 2881 | } |
2814 | else | 2882 | else |
2815 | { | 2883 | { |
2816 | m_bcloseDisabled = true; | 2884 | m_bcloseDisabled = true; |
2817 | if (m_fullscreen) | 2885 | if (m_fullscreen) |
2818 | { | 2886 | { |
2819 | m_actFullscreen->setOn(false); | 2887 | m_actFullscreen->setOn(false); |
2820 | e->accept(); | 2888 | e->accept(); |
2821 | } | 2889 | } |
@@ -2882,104 +2950,101 @@ void QTReaderApp::handlekey(QKeyEvent* e) | |||
2882 | } | 2950 | } |
2883 | 2951 | ||
2884 | /* | 2952 | /* |
2885 | QString msg("Key press was:"); | 2953 | QString msg("Key press was:"); |
2886 | QString key; | 2954 | QString key; |
2887 | msg += key.setNum(e->key()); | 2955 | msg += key.setNum(e->key()); |
2888 | QMessageBox::information(this, PROGNAME, msg); | 2956 | QMessageBox::information(this, PROGNAME, msg); |
2889 | */ | 2957 | */ |
2890 | } | 2958 | } |
2891 | ftime(&m_lastkeytime); | 2959 | ftime(&m_lastkeytime); |
2892 | } | 2960 | } |
2893 | 2961 | ||
2894 | #ifdef NEWFULLSCREEN | 2962 | #if defined(USEQPE) && defined(USENEWFULLSCREEN) |
2895 | void QTReaderApp::enableFullscreen() | 2963 | void QTReaderApp::focusInEvent(QFocusEvent *) |
2896 | { | ||
2897 | setFixedSize(qApp->desktop()->size()); | ||
2898 | showNormal(); | ||
2899 | reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); | ||
2900 | showFullScreen(); | ||
2901 | } | ||
2902 | |||
2903 | void QTReaderApp::resizeEvent(QResizeEvent *) | ||
2904 | { | 2964 | { |
2905 | if (m_fullscreen && (size() != qApp->desktop()->size())) | 2965 | if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) |
2906 | { | 2966 | { |
2907 | enableFullscreen(); | 2967 | m_usenewfullscreen = false; |
2968 | reader->bDoUpdates = false; | ||
2969 | showEditTools(); | ||
2970 | reader->bDoUpdates = true; | ||
2971 | reader->update(); | ||
2972 | m_usenewfullscreen = true; | ||
2908 | } | 2973 | } |
2909 | } | 2974 | } |
2910 | 2975 | ||
2911 | void QTReaderApp::focusInEvent(QFocusEvent*) | 2976 | void QTReaderApp::resizeEvent(QResizeEvent *) |
2912 | { | 2977 | { |
2913 | if (m_fullscreen) | 2978 | if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) |
2914 | { | 2979 | { |
2915 | enableFullscreen(); | 2980 | m_usenewfullscreen = false; |
2916 | raise(); | 2981 | reader->bDoUpdates = false; |
2982 | showEditTools(); | ||
2983 | reader->bDoUpdates = true; | ||
2984 | reader->update(); | ||
2985 | m_usenewfullscreen = true; | ||
2917 | } | 2986 | } |
2918 | } | 2987 | } |
2919 | #endif | 2988 | #endif |
2920 | 2989 | ||
2921 | void QTReaderApp::showEditTools() | 2990 | void QTReaderApp::showEditTools() |
2922 | { | 2991 | { |
2923 | // if ( !doc ) | 2992 | // if ( !doc ) |
2924 | //close(); | 2993 | //close(); |
2925 | if (m_fullscreen) | 2994 | if (m_fullscreen) |
2926 | { | 2995 | { |
2927 | #ifdef USEQPE | 2996 | #if defined(USEQPE) |
2928 | if (menubar != NULL) menubar->hide(); | 2997 | if (menubar != NULL) menubar->hide(); |
2929 | #endif | 2998 | #endif |
2930 | if (fileBar != NULL) fileBar->hide(); | 2999 | if (fileBar != NULL) fileBar->hide(); |
2931 | if (viewBar != NULL) viewBar->hide(); | 3000 | if (viewBar != NULL) viewBar->hide(); |
2932 | if (navBar != NULL) navBar->hide(); | 3001 | if (navBar != NULL) navBar->hide(); |
2933 | if (markBar != NULL) markBar->hide(); | 3002 | if (markBar != NULL) markBar->hide(); |
2934 | if (m_prog != NULL) | 3003 | if (m_prog != NULL) |
2935 | { | 3004 | { |
2936 | // qDebug("Hiding status"); | 3005 | // qDebug("Hiding status"); |
2937 | m_prog->hide(); | 3006 | m_prog->hide(); |
2938 | } | 3007 | } |
2939 | searchBar->hide(); | 3008 | searchBar->hide(); |
2940 | regBar->hide(); | 3009 | regBar->hide(); |
2941 | #ifdef USEQPE | 3010 | #ifdef USEQPE |
2942 | Global::hideInputMethod(); | 3011 | Global::hideInputMethod(); |
2943 | #endif | 3012 | #endif |
2944 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 3013 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
2945 | m_fontBar->hide(); | 3014 | m_fontBar->hide(); |
2946 | //showNormal(); | 3015 | //showNormal(); |
2947 | #ifdef NEWFULLSCREEN | ||
2948 | enableFullscreen(); | ||
2949 | #else | ||
2950 | showFullScreen(); | 3016 | showFullScreen(); |
2951 | #endif | 3017 | } |
2952 | } | ||
2953 | else | 3018 | else |
2954 | { | 3019 | { |
2955 | //qDebug("him"); | 3020 | //qDebug("him"); |
2956 | #ifdef USEQPE | 3021 | #ifdef USEQPE |
2957 | Global::hideInputMethod(); | 3022 | Global::hideInputMethod(); |
2958 | #endif | 3023 | #endif |
2959 | //qDebug("eb"); | 3024 | //qDebug("eb"); |
2960 | if (m_scrollbar != NULL) | 3025 | if (m_scrollbar != NULL) |
2961 | { | 3026 | { |
2962 | if (m_scrollishidden) | 3027 | if (m_scrollishidden) |
2963 | { | 3028 | { |
2964 | m_scrollbar->hide(); | 3029 | m_scrollbar->hide(); |
2965 | } | 3030 | } |
2966 | else | 3031 | else |
2967 | { | 3032 | { |
2968 | m_scrollbar->show(); | 3033 | m_scrollbar->show(); |
2969 | } | 3034 | } |
2970 | } | 3035 | } |
2971 | if (!m_hidebars) | 3036 | if (!m_hidebars) |
2972 | { | 3037 | { |
2973 | #ifdef USEQPE | 3038 | #if defined(USEQPE) |
2974 | menubar->show(); | 3039 | menubar->show(); |
2975 | #endif | 3040 | #endif |
2976 | if (fileBar != NULL) fileBar->show(); | 3041 | if (fileBar != NULL) fileBar->show(); |
2977 | if (viewBar != NULL) viewBar->show(); | 3042 | if (viewBar != NULL) viewBar->show(); |
2978 | if (navBar != NULL) navBar->show(); | 3043 | if (navBar != NULL) navBar->show(); |
2979 | if (markBar != NULL) markBar->show(); | 3044 | if (markBar != NULL) markBar->show(); |
2980 | if (m_prog != NULL && !m_statusishidden) | 3045 | if (m_prog != NULL && !m_statusishidden) |
2981 | { | 3046 | { |
2982 | // qDebug("Showing status"); | 3047 | // qDebug("Showing status"); |
2983 | m_prog->show(); | 3048 | m_prog->show(); |
2984 | // qDebug("Shown status"); | 3049 | // qDebug("Shown status"); |
2985 | } | 3050 | } |
@@ -2995,38 +3060,38 @@ void QTReaderApp::showEditTools() | |||
2995 | } | 3060 | } |
2996 | if ( regVisible ) | 3061 | if ( regVisible ) |
2997 | { | 3062 | { |
2998 | #ifdef USEQPE | 3063 | #ifdef USEQPE |
2999 | Global::showInputMethod(); | 3064 | Global::showInputMethod(); |
3000 | #endif | 3065 | #endif |
3001 | regBar->show(); | 3066 | regBar->show(); |
3002 | } | 3067 | } |
3003 | if (m_fontVisible) m_fontBar->show(); | 3068 | if (m_fontVisible) m_fontBar->show(); |
3004 | //qDebug("sn"); | 3069 | //qDebug("sn"); |
3005 | showNormal(); | 3070 | showNormal(); |
3006 | //qDebug("sm"); | 3071 | //qDebug("sm"); |
3007 | #ifdef USEQPE | 3072 | #if defined(USEQPE) && !defined(SIMPAD) |
3008 | showMaximized(); | 3073 | showMaximized(); |
3009 | #endif | 3074 | #endif |
3010 | //setCentralWidget(reader); | 3075 | //setCentralWidget(reader); |
3011 | } | 3076 | } |
3012 | 3077 | ||
3013 | // qDebug("uc"); | 3078 | // qDebug("uc"); |
3014 | updateCaption(); | 3079 | updateCaption(); |
3015 | // qDebug("rw"); | 3080 | // qDebug("rw"); |
3016 | editorStack->raiseWidget( reader ); | 3081 | editorStack->raiseWidget( reader ); |
3017 | // qDebug("sf"); | 3082 | // qDebug("sf"); |
3018 | reader->setFocus(); | 3083 | reader->setFocus(); |
3019 | // qDebug("ref"); | 3084 | // qDebug("ref"); |
3020 | reader->refresh(true); | 3085 | //reader->refresh(true); |
3021 | // qDebug("done"); | 3086 | // qDebug("done"); |
3022 | } | 3087 | } |
3023 | /* | 3088 | /* |
3024 | void QTReaderApp::save() | 3089 | void QTReaderApp::save() |
3025 | { | 3090 | { |
3026 | if ( !doc ) | 3091 | if ( !doc ) |
3027 | return; | 3092 | return; |
3028 | if ( !editor->edited() ) | 3093 | if ( !editor->edited() ) |
3029 | return; | 3094 | return; |
3030 | 3095 | ||
3031 | QString rt = editor->text(); | 3096 | QString rt = editor->text(); |
3032 | QString pt = rt; | 3097 | QString pt = rt; |
@@ -3165,49 +3230,59 @@ void QTReaderApp::do_gotomark() | |||
3165 | m_nBkmkAction = cGotoBkmk; | 3230 | m_nBkmkAction = cGotoBkmk; |
3166 | if (!listbkmk(pBkmklist)) | 3231 | if (!listbkmk(pBkmklist)) |
3167 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 3232 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3168 | } | 3233 | } |
3169 | 3234 | ||
3170 | void QTReaderApp::do_delmark() | 3235 | void QTReaderApp::do_delmark() |
3171 | { | 3236 | { |
3172 | m_nBkmkAction = cDelBkmk; | 3237 | m_nBkmkAction = cDelBkmk; |
3173 | if (!listbkmk(pBkmklist)) | 3238 | if (!listbkmk(pBkmklist)) |
3174 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 3239 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3175 | } | 3240 | } |
3176 | 3241 | ||
3177 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | 3242 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel) |
3178 | { | 3243 | { |
3179 | bkmkselector->clear(); | 3244 | bkmkselector->clear(); |
3180 | if (_lab.isEmpty()) | 3245 | if (_lab.isEmpty()) |
3181 | bkmkselector->setText("Cancel"); | 3246 | bkmkselector->setText("Cancel"); |
3182 | else | 3247 | else |
3183 | bkmkselector->setText(_lab); | 3248 | bkmkselector->setText(_lab); |
3184 | int cnt = 0; | 3249 | int cnt = 0; |
3250 | int slt = -1; | ||
3185 | if (plist != NULL) | 3251 | if (plist != NULL) |
3186 | { | 3252 | { |
3187 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) | 3253 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
3188 | { | 3254 | { |
3255 | if (presel) | ||
3256 | { | ||
3257 | Bkmk* p = i.pContent(); | ||
3258 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | ||
3259 | { | ||
3260 | slt = cnt; | ||
3261 | } | ||
3262 | } | ||
3189 | #ifdef _UNICODE | 3263 | #ifdef _UNICODE |
3190 | // qDebug("Item:%s", (const char*)toQString(i->name())); | 3264 | // qDebug("Item:%s", (const char*)toQString(i->name())); |
3191 | bkmkselector->insertItem(toQString(i->name())); | 3265 | bkmkselector->insertItem(toQString(i->name()), cnt++); |
3192 | #else | 3266 | #else |
3193 | bkmkselector->insertItem(i->name()); | 3267 | bkmkselector->insertItem(i->name(), cnt++); |
3194 | #endif | 3268 | #endif |
3195 | cnt++; | 3269 | |
3196 | } | 3270 | } |
3197 | } | 3271 | } |
3198 | if (cnt > 0) | 3272 | if (cnt > 0) |
3199 | { | 3273 | { |
3200 | hidetoolbars(); | 3274 | hidetoolbars(); |
3201 | editorStack->raiseWidget( bkmkselector ); | 3275 | editorStack->raiseWidget( bkmkselector ); |
3276 | if (slt != -1) bkmkselector->setCurrentItem(slt); | ||
3202 | return true; | 3277 | return true; |
3203 | } | 3278 | } |
3204 | else | 3279 | else |
3205 | return false; | 3280 | return false; |
3206 | } | 3281 | } |
3207 | 3282 | ||
3208 | void QTReaderApp::do_autogen() | 3283 | void QTReaderApp::do_autogen() |
3209 | { | 3284 | { |
3210 | m_nRegAction = cAutoGen; | 3285 | m_nRegAction = cAutoGen; |
3211 | regEdit->setText(m_autogenstr); | 3286 | regEdit->setText(m_autogenstr); |
3212 | do_regedit(); | 3287 | do_regedit(); |
3213 | } | 3288 | } |
@@ -3229,48 +3304,49 @@ void QTReaderApp::do_regedit() | |||
3229 | reader->update(); | 3304 | reader->update(); |
3230 | } | 3305 | } |
3231 | 3306 | ||
3232 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | 3307 | bool QTReaderApp::openfrombkmk(Bkmk* bk) |
3233 | { | 3308 | { |
3234 | QString fn = toQString( | 3309 | QString fn = toQString( |
3235 | CFiledata(bk->anno()).name() | 3310 | CFiledata(bk->anno()).name() |
3236 | ); | 3311 | ); |
3237 | //qDebug("fileinfo"); | 3312 | //qDebug("fileinfo"); |
3238 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 3313 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
3239 | { | 3314 | { |
3240 | //qDebug("Opening"); | 3315 | //qDebug("Opening"); |
3241 | openFile(fn); | ||
3242 | struct stat fnstat; | 3316 | struct stat fnstat; |
3243 | stat((const char *)reader->m_lastfile, &fnstat); | 3317 | stat((const char *)fn, &fnstat); |
3244 | 3318 | ||
3245 | if (CFiledata(bk->anno()).date() | 3319 | if (CFiledata(bk->anno()).date() |
3246 | != fnstat.st_mtime) | 3320 | != fnstat.st_mtime) |
3247 | { | 3321 | { |
3248 | CFiledata fd(bk->anno()); | 3322 | CFiledata fd(bk->anno()); |
3249 | fd.setdate(fnstat.st_mtime); | 3323 | fd.setdate(fnstat.st_mtime); |
3250 | bk->value(0); | 3324 | bk->value(0); |
3325 | reader->m_lastposn = 0; | ||
3326 | openFile(fn); | ||
3251 | } | 3327 | } |
3252 | else | 3328 | else |
3253 | { | 3329 | { |
3254 | unsigned short svlen = bk->filedatalen(); | 3330 | unsigned short svlen = bk->filedatalen(); |
3255 | unsigned char* svdata = bk->filedata(); | 3331 | unsigned char* svdata = bk->filedata(); |
3332 | openFile(fn, bk->value()); | ||
3256 | reader->putSaveData(svdata, svlen); | 3333 | reader->putSaveData(svdata, svlen); |
3257 | // setstate(svdata, svlen); | 3334 | // setstate(svdata, svlen); |
3258 | if (svlen != 0) | 3335 | if (svlen != 0) |
3259 | { | 3336 | { |
3260 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | 3337 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); |
3261 | } | 3338 | } |
3262 | // qDebug("updating"); | 3339 | // qDebug("updating"); |
3263 | // showEditTools(); | 3340 | // showEditTools(); |
3264 | reader->locate(bk->value()); | ||
3265 | } | 3341 | } |
3266 | return true; | 3342 | return true; |
3267 | } | 3343 | } |
3268 | else | 3344 | else |
3269 | { | 3345 | { |
3270 | return false; | 3346 | return false; |
3271 | } | 3347 | } |
3272 | } | 3348 | } |
3273 | 3349 | ||
3274 | void QTReaderApp::gotobkmk(int ind) | 3350 | void QTReaderApp::gotobkmk(int ind) |
3275 | { | 3351 | { |
3276 | qDebug("gbkmk"); | 3352 | qDebug("gbkmk"); |
@@ -3357,25 +3433,25 @@ void QTReaderApp::gotobkmk(int ind) | |||
3357 | } | 3433 | } |
3358 | fclose(fout); | 3434 | fclose(fout); |
3359 | } | 3435 | } |
3360 | else | 3436 | else |
3361 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 3437 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3362 | } | 3438 | } |
3363 | } | 3439 | } |
3364 | #else /* USEQPE */ | 3440 | #else /* USEQPE */ |
3365 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 3441 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
3366 | if (fin != NULL) | 3442 | if (fin != NULL) |
3367 | { | 3443 | { |
3368 | bool allok = false; | 3444 | bool allok = false; |
3369 | #ifdef OPIE | 3445 | #if defined(OPIE) && defined(OPIEFILEDIALOG) |
3370 | QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); | 3446 | QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); |
3371 | if (!outfile.isEmpty()) | 3447 | if (!outfile.isEmpty()) |
3372 | { | 3448 | { |
3373 | FILE* fout = fopen((const char *)outfile, "w"); | 3449 | FILE* fout = fopen((const char *)outfile, "w"); |
3374 | if (fout != NULL) | 3450 | if (fout != NULL) |
3375 | { | 3451 | { |
3376 | fprintf(fout, "<html><body>\n"); | 3452 | fprintf(fout, "<html><body>\n"); |
3377 | int ch = 0; | 3453 | int ch = 0; |
3378 | while ((ch = fgetc(fin)) != EOF) | 3454 | while ((ch = fgetc(fin)) != EOF) |
3379 | { | 3455 | { |
3380 | fputc(ch, fout); | 3456 | fputc(ch, fout); |
3381 | } | 3457 | } |
@@ -3694,43 +3770,52 @@ void QTReaderApp::do_autogen(const QString& regText) | |||
3694 | m_fBkmksChanged = true; | 3770 | m_fBkmksChanged = true; |
3695 | 3771 | ||
3696 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); | 3772 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); |
3697 | pbar->show(); | 3773 | pbar->show(); |
3698 | pbar->raise(); | 3774 | pbar->raise(); |
3699 | pbar->reset(); | 3775 | pbar->reset(); |
3700 | reader->update(); | 3776 | reader->update(); |
3701 | qApp->processEvents(); | 3777 | qApp->processEvents(); |
3702 | reader->setFocus(); | 3778 | reader->setFocus(); |
3703 | reader->jumpto(0); | 3779 | reader->jumpto(0); |
3704 | int lastpc = 0; | 3780 | int lastpc = 0; |
3705 | int i = 0; | 3781 | int i = 0; |
3782 | unsigned int llcn = reader->locate(); | ||
3706 | while (i >= 0) | 3783 | while (i >= 0) |
3707 | { | 3784 | { |
3708 | unsigned int lcn = reader->locate(); | 3785 | unsigned int lcn = llcn; |
3709 | int pc = (100*lcn)/ts; | 3786 | int pc = (100*lcn)/ts; |
3710 | if (pc != lastpc) | 3787 | if (pc != lastpc) |
3711 | { | 3788 | { |
3712 | pbar->setProgress(pc); | 3789 | pbar->setProgress(pc); |
3713 | qApp->processEvents(); | 3790 | qApp->processEvents(); |
3714 | if (reader->locate() != lcn) reader->jumpto(lcn); | 3791 | if (reader->locate() != lcn) reader->jumpto(lcn); |
3715 | reader->setFocus(); | 3792 | reader->setFocus(); |
3716 | lastpc = pc; | 3793 | lastpc = pc; |
3717 | } | 3794 | } |
3718 | i = reader->buffdoc.getpara(buff); | 3795 | i = reader->buffdoc.getpara(buff); |
3719 | #ifdef _UNICODE | 3796 | #ifdef _UNICODE |
3720 | if (re.match(toQString(buff.data())) != -1) | 3797 | if (re.match(toQString(buff.data())) != -1) |
3721 | #else | 3798 | #else |
3722 | if (re.match(buff.data()) != -1) | 3799 | if (re.match(buff.data()) != -1) |
3723 | #endif | 3800 | #endif |
3724 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 3801 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
3802 | /* | ||
3803 | llcn = reader->locate(); | ||
3804 | if ((i == 0) && (llcn+1 < ts)) | ||
3805 | { | ||
3806 | reader->jumpto(++llcn); | ||
3807 | i = 1; | ||
3808 | } | ||
3809 | */ | ||
3725 | } | 3810 | } |
3726 | pBkmklist->sort(); | 3811 | pBkmklist->sort(); |
3727 | pbar->setProgress(100); | 3812 | pbar->setProgress(100); |
3728 | qApp->processEvents(); | 3813 | qApp->processEvents(); |
3729 | pbar->hide(); | 3814 | pbar->hide(); |
3730 | reader->refresh(); | 3815 | reader->refresh(); |
3731 | } | 3816 | } |
3732 | 3817 | ||
3733 | void QTReaderApp::saveprefs() | 3818 | void QTReaderApp::saveprefs() |
3734 | { | 3819 | { |
3735 | do_saveconfig( APPDIR, true ); | 3820 | do_saveconfig( APPDIR, true ); |
3736 | savefilelist(); | 3821 | savefilelist(); |
@@ -4023,24 +4108,28 @@ void QTReaderApp::showAnnotation() | |||
4023 | #ifdef USEQPE | 4108 | #ifdef USEQPE |
4024 | Global::showInputMethod(); | 4109 | Global::showInputMethod(); |
4025 | #endif | 4110 | #endif |
4026 | editorStack->raiseWidget( m_annoWin ); | 4111 | editorStack->raiseWidget( m_annoWin ); |
4027 | hidetoolbars(); | 4112 | hidetoolbars(); |
4028 | m_annoWin->setFocus(); | 4113 | m_annoWin->setFocus(); |
4029 | } | 4114 | } |
4030 | 4115 | ||
4031 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line) | 4116 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line) |
4032 | { | 4117 | { |
4033 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); | 4118 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); |
4034 | 4119 | ||
4120 | if (m_doOutput && reader->checkoutput()) | ||
4121 | { | ||
4122 | reader->doOutput(wrd); | ||
4123 | } | ||
4035 | if (m_doClipboard) | 4124 | if (m_doClipboard) |
4036 | { | 4125 | { |
4037 | QClipboard* cb = QApplication::clipboard(); | 4126 | QClipboard* cb = QApplication::clipboard(); |
4038 | cb->setText(wrd); | 4127 | cb->setText(wrd); |
4039 | #ifdef USEQPE | 4128 | #ifdef USEQPE |
4040 | if (wrd.length() > 10) | 4129 | if (wrd.length() > 10) |
4041 | { | 4130 | { |
4042 | Global::statusMessage(wrd.left(8) + ".."); | 4131 | Global::statusMessage(wrd.left(8) + ".."); |
4043 | } | 4132 | } |
4044 | else | 4133 | else |
4045 | { | 4134 | { |
4046 | Global::statusMessage(wrd); | 4135 | Global::statusMessage(wrd); |
@@ -4107,36 +4196,36 @@ void QTReaderApp::doAction(QKeyEvent* e) | |||
4107 | case cesNextLink: | 4196 | case cesNextLink: |
4108 | { | 4197 | { |
4109 | reader->getNextLink(); | 4198 | reader->getNextLink(); |
4110 | } | 4199 | } |
4111 | break; | 4200 | break; |
4112 | case cesInvertColours: | 4201 | case cesInvertColours: |
4113 | m_inverse_action->setOn(!reader->bInverse); | 4202 | m_inverse_action->setOn(!reader->bInverse); |
4114 | break; | 4203 | break; |
4115 | case cesToggleBars: | 4204 | case cesToggleBars: |
4116 | m_hidebars = !m_hidebars; | 4205 | m_hidebars = !m_hidebars; |
4117 | if (m_hidebars) | 4206 | if (m_hidebars) |
4118 | { | 4207 | { |
4119 | #ifdef USEQPE | 4208 | #if defined(USEQPE) |
4120 | menubar->hide(); | 4209 | menubar->hide(); |
4121 | #endif | 4210 | #endif |
4122 | if (fileBar != NULL) fileBar->hide(); | 4211 | if (fileBar != NULL) fileBar->hide(); |
4123 | if (viewBar != NULL) viewBar->hide(); | 4212 | if (viewBar != NULL) viewBar->hide(); |
4124 | if (navBar != NULL) navBar->hide(); | 4213 | if (navBar != NULL) navBar->hide(); |
4125 | if (markBar != NULL) markBar->hide(); | 4214 | if (markBar != NULL) markBar->hide(); |
4126 | mb->hide(); | 4215 | mb->hide(); |
4127 | } | 4216 | } |
4128 | else | 4217 | else |
4129 | { | 4218 | { |
4130 | #ifdef USEQPE | 4219 | #if defined(USEQPE) |
4131 | menubar->show(); | 4220 | menubar->show(); |
4132 | #endif | 4221 | #endif |
4133 | if (fileBar != NULL) fileBar->show(); | 4222 | if (fileBar != NULL) fileBar->show(); |
4134 | if (viewBar != NULL) viewBar->show(); | 4223 | if (viewBar != NULL) viewBar->show(); |
4135 | if (navBar != NULL) navBar->show(); | 4224 | if (navBar != NULL) navBar->show(); |
4136 | if (markBar != NULL) markBar->show(); | 4225 | if (markBar != NULL) markBar->show(); |
4137 | mb->show(); | 4226 | mb->show(); |
4138 | } | 4227 | } |
4139 | break; | 4228 | break; |
4140 | case cesToggleScrollBar: | 4229 | case cesToggleScrollBar: |
4141 | if (m_scrollbar != NULL) | 4230 | if (m_scrollbar != NULL) |
4142 | { | 4231 | { |
@@ -4331,24 +4420,25 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | |||
4331 | d.cd(APPDIR); | 4420 | d.cd(APPDIR); |
4332 | d.mkdir("configs"); | 4421 | d.mkdir("configs"); |
4333 | d.cd("configs"); | 4422 | d.cd("configs"); |
4334 | } | 4423 | } |
4335 | fi.setFile(d, _txt); | 4424 | fi.setFile(d, _txt); |
4336 | } | 4425 | } |
4337 | //qDebug("Path:%s", (const char*)fi.absFilePath()); | 4426 | //qDebug("Path:%s", (const char*)fi.absFilePath()); |
4338 | Config config(fi.absFilePath()); | 4427 | Config config(fi.absFilePath()); |
4339 | #endif | 4428 | #endif |
4340 | 4429 | ||
4341 | 4430 | ||
4342 | config.writeEntry( "StripCr", reader->bstripcr ); | 4431 | config.writeEntry( "StripCr", reader->bstripcr ); |
4432 | config.writeEntry( "NoInlineTables", reader->bNoInlineTables ); | ||
4343 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 4433 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
4344 | config.writeEntry( "TextFmt", reader->btextfmt ); | 4434 | config.writeEntry( "TextFmt", reader->btextfmt ); |
4345 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 4435 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
4346 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 4436 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
4347 | config.writeEntry( "Depluck", reader->bdepluck ); | 4437 | config.writeEntry( "Depluck", reader->bdepluck ); |
4348 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 4438 | config.writeEntry( "Dejpluck", reader->bdejpluck ); |
4349 | config.writeEntry( "OneSpace", reader->bonespace ); | 4439 | config.writeEntry( "OneSpace", reader->bonespace ); |
4350 | config.writeEntry( "Unindent", reader->bunindent ); | 4440 | config.writeEntry( "Unindent", reader->bunindent ); |
4351 | config.writeEntry( "Repara", reader->brepara ); | 4441 | config.writeEntry( "Repara", reader->brepara ); |
4352 | config.writeEntry( "ReparaString", reader->m_reparastring); | 4442 | config.writeEntry( "ReparaString", reader->m_reparastring); |
4353 | config.writeEntry( "BackgroundType" , (int)m_bgtype ); | 4443 | config.writeEntry( "BackgroundType" , (int)m_bgtype ); |
4354 | config.writeEntry( "Theme", m_themename ); | 4444 | config.writeEntry( "Theme", m_themename ); |
@@ -4356,24 +4446,25 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | |||
4356 | config.writeEntry( "Indent", reader->bindenter ); | 4446 | config.writeEntry( "Indent", reader->bindenter ); |
4357 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 4447 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
4358 | config.writeEntry( "ScrollDelay", reader->m_delay); | 4448 | config.writeEntry( "ScrollDelay", reader->m_delay); |
4359 | config.writeEntry( "ScrollStep", reader->m_scrollstep); | 4449 | config.writeEntry( "ScrollStep", reader->m_scrollstep); |
4360 | config.writeEntry( "ScrollType", reader->m_scrolltype ); | 4450 | config.writeEntry( "ScrollType", reader->m_scrolltype ); |
4361 | if (full) | 4451 | if (full) |
4362 | { | 4452 | { |
4363 | config.writeEntry("Debounce", m_debounce); | 4453 | config.writeEntry("Debounce", m_debounce); |
4364 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 4454 | config.writeEntry("FloatDialogs", m_bFloatingDialog); |
4365 | reader->m_lastposn = reader->pagelocate(); | 4455 | reader->m_lastposn = reader->pagelocate(); |
4366 | config.writeEntry( "LastFile", reader->m_lastfile ); | 4456 | config.writeEntry( "LastFile", reader->m_lastfile ); |
4367 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 4457 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
4458 | config.writeEntry( "OutputCodec", reader->m_outputName); | ||
4368 | } | 4459 | } |
4369 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 4460 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
4370 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 4461 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
4371 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 4462 | config.writeEntry( "SwapMouse", reader->m_swapmouse); |
4372 | config.writeEntry( "IsRotated", reader->m_rotated ); | 4463 | config.writeEntry( "IsRotated", reader->m_rotated ); |
4373 | config.writeEntry("StatusContent", m_statusstring); | 4464 | config.writeEntry("StatusContent", m_statusstring); |
4374 | config.writeEntry("StatusHidden", m_statusishidden); | 4465 | config.writeEntry("StatusHidden", m_statusishidden); |
4375 | config.writeEntry( "Background", m_background ); | 4466 | config.writeEntry( "Background", m_background ); |
4376 | config.writeEntry( "Foreground", m_foreground ); | 4467 | config.writeEntry( "Foreground", m_foreground ); |
4377 | config.writeEntry( "ScrollColour", m_scrollcolor ); | 4468 | config.writeEntry( "ScrollColour", m_scrollcolor ); |
4378 | config.writeEntry( "ScrollBarColour", m_scrollbarcolor ); | 4469 | config.writeEntry( "ScrollBarColour", m_scrollbarcolor ); |
4379 | config.writeEntry( "Hyphenate", reader->hyphenate ); | 4470 | config.writeEntry( "Hyphenate", reader->hyphenate ); |
@@ -4387,44 +4478,48 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | |||
4387 | config.writeEntry( "Left Margin", (int)reader->m_absleft_border ); | 4478 | config.writeEntry( "Left Margin", (int)reader->m_absleft_border ); |
4388 | config.writeEntry( "Right Margin", (int)reader->m_absright_border ); | 4479 | config.writeEntry( "Right Margin", (int)reader->m_absright_border ); |
4389 | config.writeEntry( "TargetApp", m_targetapp ); | 4480 | config.writeEntry( "TargetApp", m_targetapp ); |
4390 | config.writeEntry( "TargetMsg", m_targetmsg ); | 4481 | config.writeEntry( "TargetMsg", m_targetmsg ); |
4391 | #ifdef _SCROLLPIPE | 4482 | #ifdef _SCROLLPIPE |
4392 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 4483 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); |
4393 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 4484 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
4394 | #endif | 4485 | #endif |
4395 | config.writeEntry( "TwoTouch", m_twoTouch ); | 4486 | config.writeEntry( "TwoTouch", m_twoTouch ); |
4396 | config.writeEntry( "Annotation", m_doAnnotation); | 4487 | config.writeEntry( "Annotation", m_doAnnotation); |
4397 | config.writeEntry( "Dictionary", m_doDictionary); | 4488 | config.writeEntry( "Dictionary", m_doDictionary); |
4398 | config.writeEntry( "Clipboard", m_doClipboard); | 4489 | config.writeEntry( "Clipboard", m_doClipboard); |
4490 | config.writeEntry( "OutputTgt", m_doOutput); | ||
4399 | /* | 4491 | /* |
4400 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 4492 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
4401 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 4493 | config.writeEntry( "EscapeTarget", m_escapeTarget); |
4402 | config.writeEntry( "ReturnTarget", m_returnTarget); | 4494 | config.writeEntry( "ReturnTarget", m_returnTarget); |
4403 | config.writeEntry( "LeftTarget", m_leftTarget); | 4495 | config.writeEntry( "LeftTarget", m_leftTarget); |
4404 | config.writeEntry( "RightTarget", m_rightTarget); | 4496 | config.writeEntry( "RightTarget", m_rightTarget); |
4405 | config.writeEntry( "UpTarget", m_upTarget); | 4497 | config.writeEntry( "UpTarget", m_upTarget); |
4406 | config.writeEntry( "DownTarget", m_downTarget); | 4498 | config.writeEntry( "DownTarget", m_downTarget); |
4407 | config.writeEntry("LeftScroll", m_leftScroll); | 4499 | config.writeEntry("LeftScroll", m_leftScroll); |
4408 | config.writeEntry("RightScroll", m_rightScroll); | 4500 | config.writeEntry("RightScroll", m_rightScroll); |
4409 | config.writeEntry("UpScroll", m_upScroll); | 4501 | config.writeEntry("UpScroll", m_upScroll); |
4410 | config.writeEntry("DownScroll", m_downScroll); | 4502 | config.writeEntry("DownScroll", m_downScroll); |
4411 | */ | 4503 | */ |
4412 | config.writeEntry( "Repalm", reader->brepalm ); | 4504 | config.writeEntry( "Repalm", reader->brepalm ); |
4505 | config.writeEntry( "UnderlineLink", reader->bunderlineLink ); | ||
4413 | config.writeEntry( "HideScrollBar", m_scrollishidden ); | 4506 | config.writeEntry( "HideScrollBar", m_scrollishidden ); |
4507 | config.writeEntry( "HideToolBar", m_hidebars ); | ||
4414 | config.writeEntry( "Kern", reader->bkern ); | 4508 | config.writeEntry( "Kern", reader->bkern ); |
4415 | config.writeEntry( "Remap", reader->bremap ); | 4509 | config.writeEntry( "Remap", reader->bremap ); |
4416 | config.writeEntry( "Peanut", reader->bpeanut ); | 4510 | config.writeEntry( "Peanut", reader->bpeanut ); |
4417 | config.writeEntry( "MakeBold", reader->bmakebold ); | 4511 | config.writeEntry( "MakeBold", reader->bmakebold ); |
4418 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 4512 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
4513 | config.writeEntry( "DoubleBuffer", reader->m_doubleBuffered); | ||
4419 | config.writeEntry( "FullJust", reader->bfulljust ); | 4514 | config.writeEntry( "FullJust", reader->bfulljust ); |
4420 | // config.writeEntry( "Negative", reader->bNegative ); | 4515 | // config.writeEntry( "Negative", reader->bNegative ); |
4421 | config.writeEntry( "Inverse", reader->bInverse ); | 4516 | config.writeEntry( "Inverse", reader->bInverse ); |
4422 | config.writeEntry( "FixGraphics", reader->m_fontControl.FixGraphics()); | 4517 | config.writeEntry( "FixGraphics", reader->m_fontControl.FixGraphics()); |
4423 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 4518 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); |
4424 | config.writeEntry( "ExtraLead", reader->getlead() ); | 4519 | config.writeEntry( "ExtraLead", reader->getlead() ); |
4425 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 4520 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); |
4426 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 4521 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); |
4427 | #ifdef USEQPE | 4522 | #ifdef USEQPE |
4428 | config.writeEntry( "GrabKeyboard", m_grabkeyboard ); | 4523 | config.writeEntry( "GrabKeyboard", m_grabkeyboard ); |
4429 | #endif | 4524 | #endif |
4430 | if (full) | 4525 | if (full) |
@@ -4510,24 +4605,25 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f | |||
4510 | Config config(fullname); | 4605 | Config config(fullname); |
4511 | #endif | 4606 | #endif |
4512 | if (full) | 4607 | if (full) |
4513 | { | 4608 | { |
4514 | config.setGroup("Toolbar"); | 4609 | config.setGroup("Toolbar"); |
4515 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", m_tbmovesave); | 4610 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", m_tbmovesave); |
4516 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", m_tbpolsave); | 4611 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", m_tbpolsave); |
4517 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", m_tbposition); | 4612 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", m_tbposition); |
4518 | } | 4613 | } |
4519 | config.setGroup( "View" ); | 4614 | config.setGroup( "View" ); |
4520 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", m_bFloatingDialog); | 4615 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", m_bFloatingDialog); |
4521 | reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr ); | 4616 | reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr ); |
4617 | reader->bNoInlineTables = config.readBoolEntry( "NoInlineTables", reader->bNoInlineTables ); | ||
4522 | reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust ); | 4618 | reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust ); |
4523 | reader->bInverse = config.readBoolEntry( "Inverse", reader->bInverse ); | 4619 | reader->bInverse = config.readBoolEntry( "Inverse", reader->bInverse ); |
4524 | // reader->bNegative = config.readBoolEntry( "Negative", false ); | 4620 | // reader->bNegative = config.readBoolEntry( "Negative", false ); |
4525 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", reader->m_fontControl.FixGraphics() )); | 4621 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", reader->m_fontControl.FixGraphics() )); |
4526 | reader->setextraspace(config.readNumEntry( "ExtraSpace", reader->getextraspace() )); | 4622 | reader->setextraspace(config.readNumEntry( "ExtraSpace", reader->getextraspace() )); |
4527 | reader->setlead(config.readNumEntry( "ExtraLead", reader->getlead() )); | 4623 | reader->setlead(config.readNumEntry( "ExtraLead", reader->getlead() )); |
4528 | reader->btextfmt = config.readBoolEntry( "TextFmt", reader->btextfmt ); | 4624 | reader->btextfmt = config.readBoolEntry( "TextFmt", reader->btextfmt ); |
4529 | reader->bautofmt = config.readBoolEntry( "AutoFmt", reader->bautofmt ); | 4625 | reader->bautofmt = config.readBoolEntry( "AutoFmt", reader->bautofmt ); |
4530 | reader->bstriphtml = config.readBoolEntry( "StripHtml", reader->bstriphtml ); | 4626 | reader->bstriphtml = config.readBoolEntry( "StripHtml", reader->bstriphtml ); |
4531 | reader->bpeanut = config.readBoolEntry( "Peanut", reader->bpeanut ); | 4627 | reader->bpeanut = config.readBoolEntry( "Peanut", reader->bpeanut ); |
4532 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", reader->bdehyphen ); | 4628 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", reader->bdehyphen ); |
4533 | reader->bdepluck = config.readBoolEntry( "Depluck", reader->bdepluck ); | 4629 | reader->bdepluck = config.readBoolEntry( "Depluck", reader->bdepluck ); |
@@ -4565,45 +4661,51 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f | |||
4565 | reader->hyphenate = config.readBoolEntry( "Hyphenate", reader->hyphenate ); | 4661 | reader->hyphenate = config.readBoolEntry( "Hyphenate", reader->hyphenate ); |
4566 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); | 4662 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); |
4567 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", reader->m_swapmouse); | 4663 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", reader->m_swapmouse); |
4568 | reader->m_fontname = config.readEntry( "Fontname", reader->m_fontname ); | 4664 | reader->m_fontname = config.readEntry( "Fontname", reader->m_fontname ); |
4569 | reader->m_encd = config.readNumEntry( "Encoding", reader->m_encd ); | 4665 | reader->m_encd = config.readNumEntry( "Encoding", reader->m_encd ); |
4570 | reader->m_charpc = config.readNumEntry( "CharSpacing", reader->m_charpc ); | 4666 | reader->m_charpc = config.readNumEntry( "CharSpacing", reader->m_charpc ); |
4571 | reader->m_overlap = config.readNumEntry( "Overlap", reader->m_overlap ); | 4667 | reader->m_overlap = config.readNumEntry( "Overlap", reader->m_overlap ); |
4572 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", reader->m_abstopmargin ); | 4668 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", reader->m_abstopmargin ); |
4573 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", reader->m_absbottommargin ); | 4669 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", reader->m_absbottommargin ); |
4574 | reader->m_absleft_border = config.readNumEntry( "Left Margin", reader->m_absleft_border ); | 4670 | reader->m_absleft_border = config.readNumEntry( "Left Margin", reader->m_absleft_border ); |
4575 | reader->m_absright_border = config.readNumEntry( "Right Margin", reader->m_absright_border ); | 4671 | reader->m_absright_border = config.readNumEntry( "Right Margin", reader->m_absright_border ); |
4576 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden ); | 4672 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden ); |
4673 | m_hidebars = config.readBoolEntry( "HideToolBar", m_hidebars ); | ||
4577 | reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm ); | 4674 | reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm ); |
4675 | reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", reader->bunderlineLink ); | ||
4578 | reader->bkern = config.readBoolEntry( "Kern", reader->bkern ); | 4676 | reader->bkern = config.readBoolEntry( "Kern", reader->bkern ); |
4579 | reader->bremap = config.readBoolEntry( "Remap", reader->bremap ); | 4677 | reader->bremap = config.readBoolEntry( "Remap", reader->bremap ); |
4580 | reader->bmakebold = config.readBoolEntry( "MakeBold", reader->bmakebold ); | 4678 | reader->bmakebold = config.readBoolEntry( "MakeBold", reader->bmakebold ); |
4581 | reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument )); | 4679 | reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument )); |
4680 | reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", reader->m_doubleBuffered)); | ||
4582 | m_targetapp = config.readEntry( "TargetApp", m_targetapp ); | 4681 | m_targetapp = config.readEntry( "TargetApp", m_targetapp ); |
4583 | m_targetmsg = config.readEntry( "TargetMsg", m_targetmsg ); | 4682 | m_targetmsg = config.readEntry( "TargetMsg", m_targetmsg ); |
4584 | #ifdef _SCROLLPIPE | 4683 | #ifdef _SCROLLPIPE |
4585 | reader->m_pipetarget = config.readEntry( "PipeTarget", reader->m_pipetarget ); | 4684 | reader->m_pipetarget = config.readEntry( "PipeTarget", reader->m_pipetarget ); |
4586 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 4685 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
4587 | #endif | 4686 | #endif |
4588 | m_twoTouch = config.readBoolEntry( "TwoTouch", m_twoTouch); | 4687 | m_twoTouch = config.readBoolEntry( "TwoTouch", m_twoTouch); |
4589 | m_doAnnotation = config.readBoolEntry( "Annotation", m_doAnnotation); | 4688 | m_doAnnotation = config.readBoolEntry( "Annotation", m_doAnnotation); |
4590 | m_doDictionary = config.readBoolEntry( "Dictionary", m_doDictionary); | 4689 | m_doDictionary = config.readBoolEntry( "Dictionary", m_doDictionary); |
4591 | m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard); | 4690 | m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard); |
4691 | m_doOutput = config.readBoolEntry( "OutputTgt", m_doOutput); | ||
4592 | #ifdef USEQPE | 4692 | #ifdef USEQPE |
4593 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", m_grabkeyboard); | 4693 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", m_grabkeyboard); |
4594 | #endif | 4694 | #endif |
4595 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", m_propogatefontchange); | 4695 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", m_propogatefontchange); |
4596 | reader->setBaseSize(config.readNumEntry( "Basesize", reader->getBaseSize() )); | 4696 | reader->setBaseSize(config.readNumEntry( "Basesize", reader->getBaseSize() )); |
4597 | reader->setTwoTouch(m_twoTouch); | 4697 | reader->setTwoTouch(m_twoTouch); |
4698 | |||
4699 | reader->m_outputName = config.readEntry( "OutputCodec", reader->m_outputName); | ||
4598 | 4700 | ||
4599 | m_touch_action->setOn(m_twoTouch); | 4701 | m_touch_action->setOn(m_twoTouch); |
4600 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 4702 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
4601 | setfontHelper(reader->m_fontname); | 4703 | setfontHelper(reader->m_fontname); |
4602 | if (full) | 4704 | if (full) |
4603 | { | 4705 | { |
4604 | addtoolbars(&config); | 4706 | addtoolbars(&config); |
4605 | } | 4707 | } |
4606 | reader->setfilter(reader->getfilter()); | 4708 | reader->setfilter(reader->getfilter()); |
4607 | reader->refresh(); | 4709 | reader->refresh(); |
4608 | return true; | 4710 | return true; |
4609 | } | 4711 | } |
@@ -4628,52 +4730,50 @@ bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs) | |||
4628 | d.mkdir(tgtdir); | 4730 | d.mkdir(tgtdir); |
4629 | d.cd(tgtdir); | 4731 | d.cd(tgtdir); |
4630 | } | 4732 | } |
4631 | d.setFilter( ((usedirs) ? QDir::Dirs : QDir::Files) | QDir::NoSymLinks ); | 4733 | d.setFilter( ((usedirs) ? QDir::Dirs : QDir::Files) | QDir::NoSymLinks ); |
4632 | // d.setSorting( QDir::Size | QDir::Reversed ); | 4734 | // d.setSorting( QDir::Size | QDir::Reversed ); |
4633 | 4735 | ||
4634 | const QFileInfoList *list = d.entryInfoList(); | 4736 | const QFileInfoList *list = d.entryInfoList(); |
4635 | QFileInfoListIterator it( *list ); // create list iterator | 4737 | QFileInfoListIterator it( *list ); // create list iterator |
4636 | QFileInfo *fi; // pointer for traversing | 4738 | QFileInfo *fi; // pointer for traversing |
4637 | 4739 | ||
4638 | while ( (fi=it.current()) ) { // for each file... | 4740 | while ( (fi=it.current()) ) { // for each file... |
4639 | 4741 | ||
4640 | bkmkselector->insertItem(fi->fileName()); | 4742 | bkmkselector->insertItem(fi->fileName(), cnt++); |
4641 | cnt++; | ||
4642 | 4743 | ||
4643 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 4744 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
4644 | ++it; // goto next list element | 4745 | ++it; // goto next list element |
4645 | } | 4746 | } |
4646 | 4747 | ||
4647 | #else /* USEQPE */ | 4748 | #else /* USEQPE */ |
4648 | int cnt = 0; | 4749 | int cnt = 0; |
4649 | DIR *d; | 4750 | DIR *d; |
4650 | char* finaldir; | 4751 | char* finaldir; |
4651 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; | 4752 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; |
4652 | strcpy(finaldir, APPDIR); | 4753 | strcpy(finaldir, APPDIR); |
4653 | strcat(finaldir, "/"); | 4754 | strcat(finaldir, "/"); |
4654 | strcat(finaldir, tgtdir); | 4755 | strcat(finaldir, tgtdir); |
4655 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); | 4756 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); |
4656 | 4757 | ||
4657 | while(1) | 4758 | while(1) |
4658 | { | 4759 | { |
4659 | struct dirent* de; | 4760 | struct dirent* de; |
4660 | struct stat buf; | 4761 | struct stat buf; |
4661 | de = readdir(d); | 4762 | de = readdir(d); |
4662 | if (de == NULL) break; | 4763 | if (de == NULL) break; |
4663 | 4764 | ||
4664 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && ((usedirs && S_ISDIR(buf.st_mode)) || (!usedirs && S_ISREG(buf.st_mode)))) | 4765 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && ((usedirs && S_ISDIR(buf.st_mode)) || (!usedirs && S_ISREG(buf.st_mode)))) |
4665 | { | 4766 | { |
4666 | bkmkselector->insertItem(de->d_name); | 4767 | bkmkselector->insertItem(de->d_name, cnt++); |
4667 | cnt++; | ||
4668 | } | 4768 | } |
4669 | } | 4769 | } |
4670 | delete [] finaldir; | 4770 | delete [] finaldir; |
4671 | closedir(d); | 4771 | closedir(d); |
4672 | #endif | 4772 | #endif |
4673 | return (cnt > 0); | 4773 | return (cnt > 0); |
4674 | } | 4774 | } |
4675 | 4775 | ||
4676 | void QTReaderApp::LoadTheme() | 4776 | void QTReaderApp::LoadTheme() |
4677 | { | 4777 | { |
4678 | if (PopulateConfig("Themes", true)) | 4778 | if (PopulateConfig("Themes", true)) |
4679 | { | 4779 | { |
@@ -4726,24 +4826,26 @@ void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt) | |||
4726 | #ifndef USEQPE | 4826 | #ifndef USEQPE |
4727 | qDebug("URL:%s", (const char*)href); | 4827 | qDebug("URL:%s", (const char*)href); |
4728 | int col = href.find(':'); | 4828 | int col = href.find(':'); |
4729 | if (col > 0) | 4829 | if (col > 0) |
4730 | { | 4830 | { |
4731 | QString type = href.left(col); | 4831 | QString type = href.left(col); |
4732 | qDebug("Type:%s", (const char*)type); | 4832 | qDebug("Type:%s", (const char*)type); |
4733 | } | 4833 | } |
4734 | else | 4834 | else |
4735 | { | 4835 | { |
4736 | qDebug("No type"); | 4836 | qDebug("No type"); |
4737 | } | 4837 | } |
4838 | QString msg = "External URL\n" + href; | ||
4839 | QMessageBox::information(this, PROGNAME, msg); | ||
4738 | #else | 4840 | #else |
4739 | if (href.isEmpty()) | 4841 | if (href.isEmpty()) |
4740 | { | 4842 | { |
4741 | QMessageBox::information(this, PROGNAME, "No URL information supplied"); | 4843 | QMessageBox::information(this, PROGNAME, "No URL information supplied"); |
4742 | } | 4844 | } |
4743 | else | 4845 | else |
4744 | { | 4846 | { |
4745 | CURLDialog* urld = new CURLDialog(href, false, this); | 4847 | CURLDialog* urld = new CURLDialog(href, false, this); |
4746 | urld->clipboard(m_url_clipboard); | 4848 | urld->clipboard(m_url_clipboard); |
4747 | urld->localfile(m_url_localfile); | 4849 | urld->localfile(m_url_localfile); |
4748 | urld->globalfile(m_url_globalfile); | 4850 | urld->globalfile(m_url_globalfile); |
4749 | if (urld->exec()) | 4851 | if (urld->exec()) |
@@ -4892,41 +4994,45 @@ void QTReaderApp::setscrollbarcolour() | |||
4892 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); | 4994 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); |
4893 | */ | 4995 | */ |
4894 | reader->m_scrollbarcolor = getcolour(m_scrollbarcolor); | 4996 | reader->m_scrollbarcolor = getcolour(m_scrollbarcolor); |
4895 | } | 4997 | } |
4896 | 4998 | ||
4897 | void QTReaderApp::forceopen(const QString& filename) | 4999 | void QTReaderApp::forceopen(const QString& filename) |
4898 | { | 5000 | { |
4899 | /* | 5001 | /* |
4900 | QFileInfo fi(reader->m_lastfile); | 5002 | QFileInfo fi(reader->m_lastfile); |
4901 | fi = QFileInfo(filename); | 5003 | fi = QFileInfo(filename); |
4902 | QString flnm = fi.absFilePath(); | 5004 | QString flnm = fi.absFilePath(); |
4903 | */ | 5005 | */ |
4904 | if (!filename.isEmpty()) | 5006 | if (!filename.isEmpty() && QFileInfo(filename).exists()) |
4905 | { | 5007 | { |
4906 | updatefileinfo(); | 5008 | updatefileinfo(); |
4907 | if (pBkmklist != NULL) | 5009 | if (pBkmklist != NULL) |
4908 | { | 5010 | { |
4909 | if (m_fBkmksChanged) | 5011 | if (m_fBkmksChanged) |
4910 | { | 5012 | { |
4911 | savebkmks(); | 5013 | savebkmks(); |
4912 | } | 5014 | } |
4913 | delete pBkmklist; | 5015 | delete pBkmklist; |
4914 | pBkmklist = NULL; | 5016 | pBkmklist = NULL; |
4915 | m_fBkmksChanged = false; | 5017 | m_fBkmksChanged = false; |
4916 | } | 5018 | } |
4917 | reader->disableAutoscroll(); | 5019 | reader->disableAutoscroll(); |
4918 | openFile(filename); | 5020 | openFile(filename); |
4919 | reader->setFocus(); | 5021 | reader->setFocus(); |
4920 | } | 5022 | } |
5023 | else | ||
5024 | { | ||
5025 | OnURLSelected(filename, 0); | ||
5026 | } | ||
4921 | } | 5027 | } |
4922 | 5028 | ||
4923 | void QTReaderApp::actionscroll(int v) | 5029 | void QTReaderApp::actionscroll(int v) |
4924 | { | 5030 | { |
4925 | if (reader->m_rotated) | 5031 | if (reader->m_rotated) |
4926 | { | 5032 | { |
4927 | reader->dopageup(reader->buffdoc.startSection()+reader->buffdoc.endSection()-v); | 5033 | reader->dopageup(reader->buffdoc.startSection()+reader->buffdoc.endSection()-v); |
4928 | } | 5034 | } |
4929 | else | 5035 | else |
4930 | { | 5036 | { |
4931 | /* | 5037 | /* |
4932 | if (reader->pagelocate() < v) | 5038 | if (reader->pagelocate() < v) |
diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h index ad47fc9..ab1b7ad 100644 --- a/noncore/apps/opie-reader/QTReaderApp.h +++ b/noncore/apps/opie-reader/QTReaderApp.h | |||
@@ -166,57 +166,58 @@ class QTReaderApp : public QMainWindow | |||
166 | suspend(); | 166 | suspend(); |
167 | } | 167 | } |
168 | #ifdef USEQPE | 168 | #ifdef USEQPE |
169 | void showEvent(QShowEvent*) | 169 | void showEvent(QShowEvent*) |
170 | { | 170 | { |
171 | if (m_grabkeyboard) | 171 | if (m_grabkeyboard) |
172 | { | 172 | { |
173 | ((QPEApplication*)qApp)->grabKeyboard(); | 173 | ((QPEApplication*)qApp)->grabKeyboard(); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | #endif | 176 | #endif |
177 | void suspend(); | 177 | void suspend(); |
178 | void openFile( const QString & ); | 178 | void openFile( const QString &, unsigned int loc = 0 ); |
179 | 179 | ||
180 | 180 | ||
181 | protected: | 181 | protected: |
182 | void setfontHelper(const QString& lcn, int size = 0); | 182 | void setfontHelper(const QString& lcn, int size = 0); |
183 | QAction* m_bkmkAvail, *m_actFullscreen; | 183 | QAction* m_bkmkAvail, *m_actFullscreen; |
184 | CAnnoEdit* m_annoWin; | 184 | CAnnoEdit* m_annoWin; |
185 | Bkmk* m_anno; | 185 | Bkmk* m_anno; |
186 | int m_scrollcolor, m_scrollbarcolor, m_background, m_foreground; | 186 | int m_scrollcolor, m_scrollbarcolor, m_background, m_foreground; |
187 | // void resizeEvent(QResizeEvent* e); | 187 | // void resizeEvent(QResizeEvent* e); |
188 | void closeEvent( QCloseEvent *e ); | 188 | void closeEvent( QCloseEvent *e ); |
189 | #ifdef NEWFULLSCREEN | 189 | #if defined(USEQPE) && defined(USENEWFULLSCREEN) |
190 | bool m_usenewfullscreen; | ||
190 | void resizeEvent(QResizeEvent *); | 191 | void resizeEvent(QResizeEvent *); |
191 | void focusInEvent(QFocusEvent*); | 192 | void focusInEvent(QFocusEvent*); |
192 | void enableFullscreen(); | ||
193 | #endif | 193 | #endif |
194 | void readbkmks(); | 194 | void readbkmks(); |
195 | void do_mono(const QString&); | 195 | void do_mono(const QString&); |
196 | void do_jump(const QString&); | 196 | void do_jump(const QString&); |
197 | void do_reparastring(const QString&); | 197 | void do_reparastring(const QString&); |
198 | void do_settarget(const QString&); | 198 | void do_settarget(const QString&); |
199 | #ifdef _SCROLLPIPE | 199 | #ifdef _SCROLLPIPE |
200 | //void do_setpipetarget(const QString&); | 200 | //void do_setpipetarget(const QString&); |
201 | #endif | 201 | #endif |
202 | void do_saveconfig(const QString&, bool); | 202 | void do_saveconfig(const QString&, bool); |
203 | bool readconfig(const QString&, const QString&, bool); | 203 | bool readconfig(const QString&, const QString&, bool); |
204 | bool PopulateConfig(const char*, bool usedirs = false); | 204 | bool PopulateConfig(const char*, bool usedirs = false); |
205 | ActionTypes ActNameToInt(const QString&); | 205 | ActionTypes ActNameToInt(const QString&); |
206 | #ifdef USEQPE | 206 | #ifdef USEQPE |
207 | bool m_grabkeyboard; | 207 | bool m_grabkeyboard; |
208 | #endif | 208 | #endif |
209 | bool m_doAnnotation; | 209 | bool m_doAnnotation; |
210 | bool m_doDictionary; | 210 | bool m_doDictionary; |
211 | bool m_doOutput; | ||
211 | bool m_doClipboard; | 212 | bool m_doClipboard; |
212 | bool m_fullscreen; | 213 | bool m_fullscreen; |
213 | bool m_loadedconfig; | 214 | bool m_loadedconfig; |
214 | public: | 215 | public: |
215 | void saveprefs(); | 216 | void saveprefs(); |
216 | public slots: | 217 | public slots: |
217 | void setBackgroundBitmap(); | 218 | void setBackgroundBitmap(); |
218 | void UpdateStatus(); | 219 | void UpdateStatus(); |
219 | void setScrollState(bool _b); | 220 | void setScrollState(bool _b); |
220 | void handlekey(QKeyEvent* e); | 221 | void handlekey(QKeyEvent* e); |
221 | void forceopen(const QString& filename); | 222 | void forceopen(const QString& filename); |
222 | void setDocument(const QString&); | 223 | void setDocument(const QString&); |
@@ -379,25 +380,25 @@ private slots: | |||
379 | void SaveScript(const char* sname); | 380 | void SaveScript(const char* sname); |
380 | #endif | 381 | #endif |
381 | /* | 382 | /* |
382 | void setstate(unsigned char* _sd, unsigned short _sdlen); | 383 | void setstate(unsigned char* _sd, unsigned short _sdlen); |
383 | void getstate(unsigned char*& data, unsigned short& len); | 384 | void getstate(unsigned char*& data, unsigned short& len); |
384 | */ | 385 | */ |
385 | void fileOpen2(); | 386 | void fileOpen2(); |
386 | void readfilelist(); | 387 | void readfilelist(); |
387 | void savefilelist(); | 388 | void savefilelist(); |
388 | void updatefileinfo(); | 389 | void updatefileinfo(); |
389 | bool openfrombkmk(Bkmk*); | 390 | bool openfrombkmk(Bkmk*); |
390 | QString m_targetapp, m_targetmsg, m_statusstring, m_themename; | 391 | QString m_targetapp, m_targetmsg, m_statusstring, m_themename; |
391 | bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); | 392 | bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null, bool presel=false); |
392 | QString usefilebrowser(); | 393 | QString usefilebrowser(); |
393 | void do_regedit(); | 394 | void do_regedit(); |
394 | void colorChanged( const QColor &c ); | 395 | void colorChanged( const QColor &c ); |
395 | void clear(); | 396 | void clear(); |
396 | void updateCaption(); | 397 | void updateCaption(); |
397 | void do_autogen(const QString&); | 398 | void do_autogen(const QString&); |
398 | void do_addbkmk(const QString&); | 399 | void do_addbkmk(const QString&); |
399 | bool findNextBookmark(size_t start); | 400 | bool findNextBookmark(size_t start); |
400 | 401 | ||
401 | private: | 402 | private: |
402 | 403 | ||
403 | QAction* m_scrollButton; | 404 | QAction* m_scrollButton; |
@@ -412,29 +413,29 @@ private slots: | |||
412 | bool m_bcloseDisabled, m_disableesckey; | 413 | bool m_bcloseDisabled, m_disableesckey; |
413 | size_t searchStart; | 414 | size_t searchStart; |
414 | #ifdef __ISEARCH | 415 | #ifdef __ISEARCH |
415 | QStack<searchrecord>* searchStack; | 416 | QStack<searchrecord>* searchStack; |
416 | bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); | 417 | bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); |
417 | #else | 418 | #else |
418 | bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); | 419 | bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); |
419 | #endif | 420 | #endif |
420 | QWidgetStack *editorStack; | 421 | QWidgetStack *editorStack; |
421 | QTReader* reader; | 422 | QTReader* reader; |
422 | QComboBox* m_fontSelector; | 423 | QComboBox* m_fontSelector; |
423 | // QPEToolBar /* *menu,*/ *fileBar; | 424 | // QPEToolBar /* *menu,*/ *fileBar; |
424 | #ifdef USEQPE | 425 | #if defined(USEQPE) |
425 | QToolBar *menubar; | 426 | QToolBar *menubar; |
426 | #endif | 427 | #endif |
427 | QToolBar *fileBar, *navBar, *viewBar, *markBar; | 428 | QToolBar *fileBar, *navBar, *viewBar, *markBar; |
428 | #ifdef USEQPE | 429 | #if defined(USEQPE) |
429 | QPEMenuBar *mb; | 430 | QPEMenuBar *mb; |
430 | #else | 431 | #else |
431 | QMenuBar *mb; | 432 | QMenuBar *mb; |
432 | #endif | 433 | #endif |
433 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; | 434 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; |
434 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; | 435 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; |
435 | QLineEdit *searchEdit, *regEdit; | 436 | QLineEdit *searchEdit, *regEdit; |
436 | bool searchVisible; | 437 | bool searchVisible; |
437 | bool regVisible; | 438 | bool regVisible; |
438 | bool m_fontVisible, m_twoTouch; | 439 | bool m_fontVisible, m_twoTouch; |
439 | static unsigned long m_uid; | 440 | static unsigned long m_uid; |
440 | long unsigned get_unique_id() { return m_uid++; } | 441 | long unsigned get_unique_id() { return m_uid++; } |
diff --git a/noncore/apps/opie-reader/Reb.cpp b/noncore/apps/opie-reader/Reb.cpp new file mode 100644 index 0000000..2e6c1fc --- a/dev/null +++ b/noncore/apps/opie-reader/Reb.cpp | |||
@@ -0,0 +1,789 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <string.h> | ||
3 | #include <qimage.h> | ||
4 | #include "decompress.h" | ||
5 | #include "Reb.h" | ||
6 | #include "my_list.h" | ||
7 | #include "Bkmks.h" | ||
8 | #include "Model.h" | ||
9 | /* | ||
10 | #ifdef offsetof | ||
11 | #define OffsetOf(type, field) ((int) offsetof(type, field)) | ||
12 | #else | ||
13 | #define OffsetOf(type, field) ((int) ((char *) &((type *) 0)->field)) | ||
14 | #endif | ||
15 | |||
16 | template<class T> | ||
17 | UInt32 binarychop(T* data, UInt32 n, T val) | ||
18 | { | ||
19 | UInt32 jl = 0,jh = n-1,jm = (jl+jh)/2; | ||
20 | while (jh > jl+1) | ||
21 | { | ||
22 | if (data[jm] > val) | ||
23 | { | ||
24 | jh = jm; | ||
25 | } | ||
26 | else | ||
27 | { | ||
28 | jl = jm; | ||
29 | } | ||
30 | jm = (jl+jh)/2; | ||
31 | } | ||
32 | return jl; | ||
33 | } | ||
34 | |||
35 | template<class T, class D> | ||
36 | UInt32 binarychop(D* data, UInt32 n, T val, UInt32 offset) | ||
37 | { | ||
38 | UInt32 jl = 0,jh = n-1,jm = (jl+jh)/2; | ||
39 | while (jh > jl+1) | ||
40 | { | ||
41 | T* d = reinterpret_cast<T*>(reinterpret_cast<char*>(data+jm)+offset); | ||
42 | if (*d > val) | ||
43 | { | ||
44 | jh = jm; | ||
45 | } | ||
46 | else | ||
47 | { | ||
48 | jl = jm; | ||
49 | } | ||
50 | jm = (jl+jh)/2; | ||
51 | } | ||
52 | return jl; | ||
53 | } | ||
54 | */ | ||
55 | |||
56 | CReb::CReb() | ||
57 | : | ||
58 | fin(NULL), m_indexpages(NULL), m_pagedetails(NULL),tagoffset(0), | ||
59 | tags(NULL), paras(NULL), noparas(0), joins(NULL), nojoins(0) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | CReb::~CReb() | ||
64 | { | ||
65 | if (fin != NULL) fclose(fin); | ||
66 | if (m_indexpages != NULL) delete [] m_indexpages; | ||
67 | if (m_pagedetails != NULL) delete [] m_pagedetails; | ||
68 | if (tags != NULL) delete [] tags; | ||
69 | if (paras != NULL) delete [] paras; | ||
70 | if (joins != NULL) delete [] joins; | ||
71 | } | ||
72 | |||
73 | unsigned int CReb::locate() | ||
74 | { | ||
75 | return m_pagedetails[currentpage.pageno()].pagestart+currentpage.offset(); | ||
76 | } | ||
77 | |||
78 | void CReb::locate(unsigned int n) | ||
79 | { | ||
80 | /* | ||
81 | UInt32 cp = nopages-1; | ||
82 | for (int i = 0; i < nopages; ++i) | ||
83 | { | ||
84 | if (m_pagedetails[i].pagestart > n) | ||
85 | { | ||
86 | cp = i-1; | ||
87 | break; | ||
88 | } | ||
89 | } | ||
90 | qDebug("Requesting %u from page %u [%u]", n, cp, n - m_pagedetails[cp].pagestart); | ||
91 | */ | ||
92 | //UInt32 jl = binarychop<UInt32, Page_detail>(m_pagedetails, nopages, n, OffsetOf(Page_detail, pagestart)); | ||
93 | |||
94 | UInt32 jl = 0,jh = nopages-1,jm = (jl+jh)/2; | ||
95 | while (jh > jl+1) | ||
96 | { | ||
97 | if (m_pagedetails[jm].pagestart > n) | ||
98 | { | ||
99 | jh = jm; | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | jl = jm; | ||
104 | } | ||
105 | jm = (jl+jh)/2; | ||
106 | } | ||
107 | |||
108 | unsuspend(); | ||
109 | Page_detail rs = m_pagedetails[jl]; | ||
110 | UInt32 val = n - rs.pagestart; | ||
111 | if (jl != currentpage.pageno()) readindex(jl); | ||
112 | currentpage.setoffset(page2pos(jl), jl, ((rs.flags & 8) != 0), rs.len, val); | ||
113 | if (noparas > 0) | ||
114 | { | ||
115 | //jl = binarychop<int, ParaRef>(paras, noparas, val, OffsetOf(ParaRef, pos)); | ||
116 | |||
117 | UInt32 jl = 0,jh = noparas-1,jm = (jl+jh)/2; | ||
118 | while (jh > jl+1) | ||
119 | { | ||
120 | if (paras[jm].pos > val) | ||
121 | { | ||
122 | jh = jm; | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | jl = jm; | ||
127 | } | ||
128 | jm = (jl+jh)/2; | ||
129 | } | ||
130 | |||
131 | qDebug("TAGS:%s", (const char*)tags[paras[jl].tag]); | ||
132 | tagstring = tags[paras[jl].tag]+"<br>"; // Add br to set extra space to 0 | ||
133 | tagoffset = 0; | ||
134 | } | ||
135 | unsigned long current = locate(); | ||
136 | if (m_currentstart > current || current > m_currentend) | ||
137 | { | ||
138 | start2endSection(); | ||
139 | } | ||
140 | if (current != n) qDebug("ERROR:Ended up at %u", current); | ||
141 | } | ||
142 | |||
143 | bool CReb::getFile(const QString& href, const QString& nm) | ||
144 | { | ||
145 | qDebug("File:%s, Name:%s", (const char*)href, (const char*)nm); | ||
146 | QMap<QString, UInt32>::Iterator iter = m_index.find(href); | ||
147 | if (iter != m_index.end()) | ||
148 | { | ||
149 | qDebug("REB:BEFORE:%u", locate()); | ||
150 | startpage(iter.data()); | ||
151 | qDebug("REB:AFTER:%u", locate()); | ||
152 | return true; | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | return false; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | QImage* CReb::getPicture(const QString& ref) | ||
161 | { | ||
162 | QMap<QString, UInt32>::Iterator iter = m_index.find(ref); | ||
163 | if (iter != m_index.end()) | ||
164 | { | ||
165 | unsuspend(); | ||
166 | Page_detail rs = m_pagedetails[iter.data()]; | ||
167 | char* imgbuffer = new char[rs.len]; | ||
168 | fseek(fin, page2pos(iter.data()), SEEK_SET); | ||
169 | fread(imgbuffer, rs.len, 1, fin); | ||
170 | QByteArray arr; | ||
171 | arr.assign((const char*)imgbuffer, rs.len); | ||
172 | QImage* qimage = new QImage(arr); | ||
173 | return qimage; | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | return NULL; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | CList<Bkmk>* CReb::getbkmklist() { return NULL; } | ||
182 | |||
183 | void CReb::home() | ||
184 | { | ||
185 | startpage(m_homepage); | ||
186 | } | ||
187 | |||
188 | int CReb::OpenFile(const char *src) | ||
189 | { | ||
190 | m_binary = false; | ||
191 | if (fin != NULL) fclose(fin); | ||
192 | fin = fopen(src, "r"); | ||
193 | if (fin == NULL) | ||
194 | { | ||
195 | return -1; | ||
196 | } | ||
197 | UInt32 type; | ||
198 | fseek(fin, 6, SEEK_SET); | ||
199 | fread(&type, 1, sizeof(type), fin); | ||
200 | qDebug("CREB:Okay %x", type); | ||
201 | |||
202 | if (type == 0x4f56554e || type == 0x574d4954 || type == 0x576d6954) | ||
203 | { | ||
204 | struct stat _stat; | ||
205 | stat(src, &_stat); | ||
206 | file_length = _stat.st_size; | ||
207 | fread(&m_blocksize, 1, sizeof(m_blocksize), fin); | ||
208 | if (type == 0x574d4954 || type == 0x576d6954) | ||
209 | { | ||
210 | if (type == 0x576d6954) m_binary = true; | ||
211 | qDebug("Blocksize(1) %x", m_blocksize); | ||
212 | unsigned char ct = (m_blocksize >> 24) & 0xff; | ||
213 | qDebug("Compress type:%x", ct); | ||
214 | switch (ct) | ||
215 | { | ||
216 | case 0: | ||
217 | m_decompress = UnZip; | ||
218 | break; | ||
219 | case 3: | ||
220 | m_decompress = getdecompressor("PluckerDecompress3"); | ||
221 | break; | ||
222 | case 4: | ||
223 | m_decompress = getdecompressor("PluckerDecompress4"); | ||
224 | break; | ||
225 | } | ||
226 | if (m_decompress == NULL) return -1; | ||
227 | m_blocksize = 1024*(m_blocksize & 0xffffff); | ||
228 | } | ||
229 | else | ||
230 | { | ||
231 | m_blocksize = 4096; | ||
232 | m_decompress = UnZip; | ||
233 | } | ||
234 | qDebug("Blocksize %u", m_blocksize); | ||
235 | currentpage.init(fin, m_blocksize, m_decompress); | ||
236 | qDebug("Its a REB!!!!"); | ||
237 | fseek(fin, 0x18, SEEK_SET); | ||
238 | fread(&toc, 1, sizeof(toc), fin); | ||
239 | qDebug("Expect this to be 128 or 20:%x", toc); | ||
240 | fread(&type, 1, sizeof(type), fin); | ||
241 | qDebug("File length:%u", type); | ||
242 | fseek(fin, toc, SEEK_SET); | ||
243 | fread(&nopages, 1, sizeof(nopages), fin); | ||
244 | m_indexpages = new UInt32[nopages]; | ||
245 | m_pagedetails = new Page_detail[nopages]; | ||
246 | qDebug("There are %u pages", nopages); | ||
247 | UInt32 loc = 0; | ||
248 | UInt32 homeguess = nopages-1; | ||
249 | QString homeurl; | ||
250 | for (int i = 0; i < nopages; ++i) | ||
251 | { | ||
252 | char name[32]; | ||
253 | UInt32 len, pos, flags; | ||
254 | fread(name, 1, 32, fin); | ||
255 | fread(&len, 1, 4, fin); | ||
256 | fread(&pos, 1, 4, fin); | ||
257 | fread(&flags, 1, 4, fin); | ||
258 | //qDebug("Page %u (%s) is %u bytes at %u (%u) of type %u", i, name, len, pos, loc, flags); | ||
259 | m_index[name] = i; | ||
260 | m_pagedetails[i] = Page_detail(loc, len, flags); | ||
261 | |||
262 | if (QString(name).find(".htm", 0, false) >= 0) | ||
263 | { | ||
264 | if (homeguess > i) homeguess = i; | ||
265 | if ((flags & 8) != 0) | ||
266 | { | ||
267 | UInt32 lastpos = ftell(fin); | ||
268 | loc += pagelength(i); | ||
269 | fseek(fin, lastpos, SEEK_SET); | ||
270 | } | ||
271 | else | ||
272 | { | ||
273 | loc += len; | ||
274 | } | ||
275 | } | ||
276 | if ((flags & 2) != 0) | ||
277 | { | ||
278 | UInt32 lastpos = ftell(fin); | ||
279 | RBPage* idx = new RBPage(); | ||
280 | idx->init(fin, m_blocksize, m_decompress); | ||
281 | idx->startpage(page2pos(i), i, ((flags & 8) != 0), len); | ||
282 | int c = 0; | ||
283 | while (c != EOF) | ||
284 | { | ||
285 | QString s(""); | ||
286 | while (1) | ||
287 | { | ||
288 | c = idx->getch(this); | ||
289 | if (c == 10 || c == EOF) break; | ||
290 | s += c; | ||
291 | } | ||
292 | if (s.left(5) == "BODY=") | ||
293 | { | ||
294 | homeurl = s.right(s.length()-5); | ||
295 | qDebug("Home:%s", (const char*)homeurl); | ||
296 | } | ||
297 | else | ||
298 | { | ||
299 | qDebug("Info:%s", (const char*)s); | ||
300 | } | ||
301 | } | ||
302 | delete idx; | ||
303 | fseek(fin, lastpos, SEEK_SET); | ||
304 | } | ||
305 | } | ||
306 | text_length = loc; | ||
307 | qDebug("Looking for homepage"); | ||
308 | if (homeurl.isEmpty()) | ||
309 | { | ||
310 | m_homepage = homeguess; | ||
311 | } | ||
312 | else | ||
313 | { | ||
314 | QMap<QString, UInt32>::Iterator iter = m_index.find(homeurl); | ||
315 | if (iter != m_index.end()) | ||
316 | { | ||
317 | m_homepage = iter.data(); | ||
318 | } | ||
319 | else | ||
320 | { | ||
321 | m_homepage = homeguess; | ||
322 | } | ||
323 | } | ||
324 | m_homepos = m_pagedetails[m_homepage].pagestart; | ||
325 | qDebug("Finding indices"); | ||
326 | for (QMap<QString, UInt32>::Iterator iter = m_index.begin(); iter != m_index.end(); ++iter) | ||
327 | { | ||
328 | QString href = iter.key(); | ||
329 | if (href.find(".htm", 0, false) >= 0) | ||
330 | { | ||
331 | QString hind = href.left(href.find(".htm", 0, false))+".hidx"; | ||
332 | //qDebug("Index is %s", (const char*)hind); | ||
333 | QMap<QString, UInt32>::Iterator iter2 = m_index.find(hind); | ||
334 | if (iter2 != m_index.end()) | ||
335 | { | ||
336 | m_indexpages[iter.data()] = iter2.data(); | ||
337 | } | ||
338 | } | ||
339 | } | ||
340 | qDebug("Going home"); | ||
341 | home(); | ||
342 | return 0; | ||
343 | } | ||
344 | else | ||
345 | { | ||
346 | char * tmp = (char*)(&type); | ||
347 | for (int i = 0; i < 4; ++i) qDebug("%d:%c", i, tmp[i]); | ||
348 | return -1; | ||
349 | } | ||
350 | } | ||
351 | |||
352 | UInt32 CReb::page2pos(UInt32 page) | ||
353 | { | ||
354 | fseek(fin, toc+40+44*page, SEEK_SET); | ||
355 | UInt32 pos; | ||
356 | fread(&pos, 1, 4, fin); | ||
357 | return pos; | ||
358 | } | ||
359 | |||
360 | UInt32 CReb::pagelength(UInt32 pagenum) | ||
361 | { | ||
362 | fseek(fin, toc+40+44*pagenum, SEEK_SET); | ||
363 | UInt32 pos; | ||
364 | fread(&pos, 1, 4, fin); | ||
365 | fseek(fin, pos+4, SEEK_SET); | ||
366 | UInt32 len; | ||
367 | fread(&len, 1, sizeof(len), fin); | ||
368 | return len; | ||
369 | } | ||
370 | |||
371 | void CReb::readindex(UInt32 cp) | ||
372 | { | ||
373 | if (joins != NULL) | ||
374 | { | ||
375 | delete [] joins; | ||
376 | joins = NULL; | ||
377 | } | ||
378 | if (tags != NULL) | ||
379 | { | ||
380 | delete [] tags; | ||
381 | tags = NULL; | ||
382 | } | ||
383 | if (paras != NULL) | ||
384 | { | ||
385 | delete [] paras; | ||
386 | paras = NULL; | ||
387 | } | ||
388 | noparas = 0; | ||
389 | nojoins = 0; | ||
390 | names.clear(); | ||
391 | |||
392 | UInt32 rspage = m_indexpages[cp]; | ||
393 | if (rspage != 0) | ||
394 | { | ||
395 | Page_detail rs = m_pagedetails[rspage]; | ||
396 | int count = 0; | ||
397 | RBPage* idx = new RBPage(); | ||
398 | idx->init(fin, m_blocksize, m_decompress); | ||
399 | idx->startpage(page2pos(rspage), rspage, ((rs.flags & 8) != 0), rs.len); | ||
400 | int c = 0; | ||
401 | int phase = 0; | ||
402 | int i; | ||
403 | if (m_binary) | ||
404 | { | ||
405 | count = idx->getuint(this); | ||
406 | qDebug("tag count:%d", count); | ||
407 | tags = new QString[count]; | ||
408 | for (int i = 0; i < count; ++i) | ||
409 | { | ||
410 | QString s; | ||
411 | while (1) | ||
412 | { | ||
413 | c = idx->getch(this); | ||
414 | if (c == 0 || c == EOF) break; | ||
415 | s += c; | ||
416 | } | ||
417 | unsigned short val = idx->getuint(this); | ||
418 | if (val != 0xffff) | ||
419 | { | ||
420 | tags[i] = tags[val]+s; | ||
421 | } | ||
422 | else | ||
423 | { | ||
424 | tags[i] = s; | ||
425 | } | ||
426 | //qDebug("tags[%d](%d) = %s", i, val, (const char*)tags[i]); | ||
427 | } | ||
428 | noparas = idx->getint(this); | ||
429 | qDebug("Para count %d", noparas); | ||
430 | paras = new ParaRef[noparas]; | ||
431 | for (int i = 0; i < noparas; ++i) | ||
432 | { | ||
433 | paras[i] = ParaRef(idx->getint(this), idx->getuint(this)); | ||
434 | } | ||
435 | count = idx->getint(this); | ||
436 | qDebug("Name count %d", count); | ||
437 | for (int i = 0; i < count; ++i) | ||
438 | { | ||
439 | QString s; | ||
440 | while (1) | ||
441 | { | ||
442 | c = idx->getch(this); | ||
443 | if (c == 0 || c == EOF) break; | ||
444 | s += c; | ||
445 | } | ||
446 | int val = idx->getint(this); | ||
447 | names[s.mid(1,s.length()-2)] = val; | ||
448 | qDebug("names[%s] = %d", (const char*)s, val); | ||
449 | } | ||
450 | count = idx->getint(this); | ||
451 | qDebug("Join count %d", count); | ||
452 | if (count > 0) | ||
453 | { | ||
454 | nojoins = count+2; | ||
455 | joins = new UInt32[count+2]; | ||
456 | joins[0] = 0; | ||
457 | joins[count+1] = currentpage.length(); | ||
458 | for (int i = 1; i < count+1; ++i) | ||
459 | { | ||
460 | joins[i] = idx->getint(this); | ||
461 | } | ||
462 | } | ||
463 | } | ||
464 | else | ||
465 | { | ||
466 | while (c != EOF) | ||
467 | { | ||
468 | QString s(""); | ||
469 | while (1) | ||
470 | { | ||
471 | c = idx->getch(this); | ||
472 | if (c == 10 || c == EOF) break; | ||
473 | s += c; | ||
474 | } | ||
475 | //qDebug("%s", (const char*)s); | ||
476 | if (count > 0) | ||
477 | { | ||
478 | --count; | ||
479 | int sp = s.findRev(' '); | ||
480 | QString l = s.left(sp); | ||
481 | int val = s.right(s.length()-sp).toInt(); | ||
482 | switch (phase) | ||
483 | { | ||
484 | case 4: | ||
485 | //qDebug("Join %d is at offset %d", i, val); | ||
486 | joins[i++] = val; | ||
487 | break; | ||
488 | case 3: | ||
489 | //qDebug("Name %s is at offset %d", (const char*)l.mid(1,l.length()-2), val+m_pagedetails[cp].pagestart); | ||
490 | names[l.mid(1,l.length()-2)] = val; | ||
491 | break; | ||
492 | case 1: | ||
493 | //qDebug("%s:%d [%d]", (const char*)l, val, i); | ||
494 | if (val >= 0) | ||
495 | { | ||
496 | tags[i++] = tags[val]+l; | ||
497 | } | ||
498 | else | ||
499 | { | ||
500 | tags[i++] = l; | ||
501 | } | ||
502 | //qDebug("TAG:%s", (const char*)tags[i-1]); | ||
503 | break; | ||
504 | case 2: | ||
505 | paras[i++] = ParaRef(QString(l).toInt(), val); | ||
506 | //qDebug("Para:%u - %u (%s)", QString(l).toInt(), val, (const char*)s); | ||
507 | break; | ||
508 | default: | ||
509 | qDebug("%s:%d", (const char*)l, val); | ||
510 | break; | ||
511 | } | ||
512 | } | ||
513 | else | ||
514 | { | ||
515 | QString key = "[tags "; | ||
516 | if (s.left(key.length()) == key) | ||
517 | { | ||
518 | phase = 1; | ||
519 | i = 0; | ||
520 | count = s.mid(key.length(),s.length()-key.length()-1).toInt(); | ||
521 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
522 | tags = new QString[count]; | ||
523 | } | ||
524 | key = "[paragraphs "; | ||
525 | if (s.left(key.length()) == key) | ||
526 | { | ||
527 | phase = 2; | ||
528 | i = 0; | ||
529 | count = s.mid(key.length(),s.length()-key.length()-1).toInt(); | ||
530 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
531 | paras = new ParaRef[count]; | ||
532 | noparas = count; | ||
533 | } | ||
534 | key = "[names "; | ||
535 | if (s.left(key.length()) == key) | ||
536 | { | ||
537 | phase = 3; | ||
538 | count = s.mid(key.length(),s.length()-key.length()-1).toInt(); | ||
539 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
540 | } | ||
541 | key = "[joins "; | ||
542 | if (s.left(key.length()) == key) | ||
543 | { | ||
544 | phase = 4; | ||
545 | count = s.mid(key.length(),s.length()-key.length()-1).toInt(); | ||
546 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
547 | nojoins = count+2; | ||
548 | i = 1; | ||
549 | joins = new UInt32[count+2]; | ||
550 | joins[0] = 0; | ||
551 | joins[count+1] = currentpage.length(); | ||
552 | qDebug("%s:%s:%d", (const char*)key, (const char*)s, count); | ||
553 | } | ||
554 | qDebug("ZC:%s", (const char*)s); | ||
555 | } | ||
556 | } | ||
557 | } | ||
558 | // for (int i = 0; i < nojoins; ++i) qDebug("JOINS:%u %u", i, joins[i]); | ||
559 | delete idx; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | bool CReb::findanchor(const QString& _info) | ||
564 | { | ||
565 | QMap<QString, int>::Iterator iter = names.find(_info); | ||
566 | if (iter != names.end()) | ||
567 | { | ||
568 | locate(iter.data()+m_pagedetails[currentpage.pageno()].pagestart); | ||
569 | return true; | ||
570 | } | ||
571 | return false; | ||
572 | } | ||
573 | |||
574 | #ifdef USEQPE | ||
575 | void CReb::suspend() | ||
576 | { | ||
577 | CExpander::suspend(fin); | ||
578 | } | ||
579 | void CReb::unsuspend() | ||
580 | { | ||
581 | CExpander::unsuspend(fin); | ||
582 | } | ||
583 | #endif | ||
584 | |||
585 | #ifndef __STATIC | ||
586 | extern "C" | ||
587 | { | ||
588 | CExpander* newcodec() { return new CReb; } | ||
589 | } | ||
590 | #endif | ||
591 | |||
592 | void CReb::startpage(UInt32 pgno) | ||
593 | { | ||
594 | Page_detail rs = m_pagedetails[pgno]; | ||
595 | unsuspend(); | ||
596 | readindex(pgno); | ||
597 | currentpage.startpage(page2pos(pgno), pgno, ((rs.flags & 8) != 0), rs.len); | ||
598 | } | ||
599 | |||
600 | void CReb::startpage(UInt32 _cp, bool _isCompressed, UInt32 _len) | ||
601 | { | ||
602 | unsuspend(); | ||
603 | readindex(_cp); | ||
604 | currentpage.startpage(page2pos(_cp), _cp, _isCompressed, _len); | ||
605 | } | ||
606 | |||
607 | void RBPage::initpage(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len) | ||
608 | { | ||
609 | filepos = pos; | ||
610 | m_pageno = _cp; | ||
611 | m_Compressed = _isCompressed; | ||
612 | m_pagelen = _len; | ||
613 | currentchunk = 0; | ||
614 | pageoffset = 0; | ||
615 | |||
616 | if (chunklist != NULL) delete [] chunklist; | ||
617 | |||
618 | fseek(fin, filepos, SEEK_SET); | ||
619 | if (m_Compressed) | ||
620 | { | ||
621 | fread(&nochunks, 1, sizeof(nochunks), fin); | ||
622 | fread(&m_pagelen, 1, sizeof(m_pagelen), fin); | ||
623 | chunklist = new UInt32[nochunks]; | ||
624 | fread(chunklist, nochunks, 4, fin); | ||
625 | } | ||
626 | else | ||
627 | { | ||
628 | chunklist = NULL; | ||
629 | nochunks = (_len+m_blocksize-1)/m_blocksize; | ||
630 | } | ||
631 | m_startoff = 0; | ||
632 | m_endoff = m_pagelen; | ||
633 | chunkpos = ftell(fin); | ||
634 | qDebug("Compressed:%u Expanded:%u", _len, m_pagelen); | ||
635 | } | ||
636 | |||
637 | void RBPage::startpage(UInt32 pos, UInt32 _cp, bool _isCompressed, UInt32 _len) | ||
638 | { | ||
639 | initpage(pos, _cp, _isCompressed, _len); | ||
640 | readchunk(); | ||
641 | } | ||
642 | |||
643 | int CReb::getch() | ||
644 | { | ||
645 | if (tagoffset < tagstring.length()) | ||
646 | return tagstring[tagoffset++].unicode(); | ||
647 | else | ||
648 | return currentpage.getch(this); | ||
649 | } | ||
650 | |||
651 | int RBPage::getch(CReb* parent) | ||
652 | { | ||
653 | if (chunkoffset >= chunklen) | ||
654 | { | ||
655 | if (++currentchunk >= nochunks) | ||
656 | { | ||
657 | --currentchunk; | ||
658 | return EOF; | ||
659 | } | ||
660 | pageoffset += chunklen; | ||
661 | parent->unsuspend(); | ||
662 | readchunk(); | ||
663 | } | ||
664 | if (offset() == m_endoff) return EOF; | ||
665 | return chunk[chunkoffset++]; | ||
666 | } | ||
667 | |||
668 | unsigned short int RBPage::getuint(CReb* parent) | ||
669 | { | ||
670 | unsigned short int ret = 0; | ||
671 | char *buffer = (char*)(&ret); | ||
672 | for (int i = 0; i < 2; ++i) | ||
673 | { | ||
674 | int ch = getch(parent); | ||
675 | if (ch == EOF) return 0; | ||
676 | buffer[i] = ch; | ||
677 | } | ||
678 | return ret; | ||
679 | } | ||
680 | |||
681 | int RBPage::getint(CReb* parent) | ||
682 | { | ||
683 | int ret = 0; | ||
684 | char *buffer = (char*)(&ret); | ||
685 | for (int i = 0; i < 4; ++i) | ||
686 | { | ||
687 | int ch = getch(parent); | ||
688 | if (ch == EOF) return 0; | ||
689 | buffer[i] = ch; | ||
690 | } | ||
691 | return ret; | ||
692 | } | ||
693 | |||
694 | void RBPage::readchunk() | ||
695 | { | ||
696 | if (m_Compressed) | ||
697 | { | ||
698 | chunkoffset = 0; | ||
699 | fseek(fin, chunkpos, SEEK_SET); | ||
700 | UInt8* inbuf = new UInt8[chunklist[currentchunk]]; | ||
701 | fread(inbuf, 1, chunklist[currentchunk], fin); | ||
702 | chunklen = (*m_decompress)(inbuf, chunklist[currentchunk], chunk, m_blocksize); | ||
703 | delete [] inbuf; | ||
704 | chunkpos = ftell(fin); | ||
705 | } | ||
706 | else | ||
707 | { | ||
708 | chunkoffset = 0; | ||
709 | chunklen = m_blocksize; | ||
710 | if (m_blocksize*(currentchunk+1) > m_pagelen) | ||
711 | { | ||
712 | chunklen = m_pagelen - currentchunk*m_blocksize; | ||
713 | } | ||
714 | fseek(fin, chunkpos, SEEK_SET); | ||
715 | chunklen = fread(chunk, 1, chunklen, fin); | ||
716 | chunkpos = ftell(fin); | ||
717 | } | ||
718 | } | ||
719 | |||
720 | void RBPage::setoffset(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len, UInt32 _offset) | ||
721 | { | ||
722 | if (m_pageno != _cp) | ||
723 | { | ||
724 | initpage(pos, _cp, _isCompressed, _len); | ||
725 | } | ||
726 | else | ||
727 | { | ||
728 | if (m_Compressed) | ||
729 | { | ||
730 | chunkpos = filepos + sizeof(nochunks) + sizeof(m_pagelen) + 4*nochunks; | ||
731 | } | ||
732 | else | ||
733 | { | ||
734 | chunkpos = filepos; | ||
735 | } | ||
736 | } | ||
737 | |||
738 | currentchunk = _offset/m_blocksize; | ||
739 | pageoffset = m_blocksize*currentchunk; | ||
740 | if (m_Compressed) | ||
741 | { | ||
742 | for (int i = 0; i < currentchunk; ++i) | ||
743 | { | ||
744 | chunkpos += chunklist[i]; | ||
745 | } | ||
746 | } | ||
747 | else | ||
748 | { | ||
749 | chunkpos += pageoffset; | ||
750 | } | ||
751 | readchunk(); | ||
752 | chunkoffset = _offset - pageoffset; | ||
753 | } | ||
754 | |||
755 | void CReb::start2endSection() | ||
756 | { | ||
757 | if (m_pagedetails != NULL) | ||
758 | { | ||
759 | if (nojoins > 0) | ||
760 | { | ||
761 | //UInt32 jl = binarychop<UInt32>(joins, nojoins, currentpage.offset()); | ||
762 | |||
763 | UInt32 jl = 0,jh = nojoins-1,jm = (jl+jh)/2; | ||
764 | while (jh > jl+1) | ||
765 | { | ||
766 | if (joins[jm] > currentpage.offset()) | ||
767 | { | ||
768 | jh = jm; | ||
769 | } | ||
770 | else | ||
771 | { | ||
772 | jl = jm; | ||
773 | } | ||
774 | jm = (jl+jh)/2; | ||
775 | } | ||
776 | |||
777 | currentpage.m_startoff = joins[jl]; | ||
778 | currentpage.m_endoff = joins[jl+1]-1; | ||
779 | //currentpage.m_endoff = joins[jh]-1; | ||
780 | } | ||
781 | m_currentstart = m_pagedetails[currentpage.pageno()].pagestart+currentpage.m_startoff; | ||
782 | m_currentend = m_pagedetails[currentpage.pageno()].pagestart+currentpage.m_endoff; | ||
783 | } | ||
784 | else | ||
785 | { | ||
786 | m_currentstart = m_currentend = 0; | ||
787 | } | ||
788 | qDebug("s2e:[%u, %u, %u]", m_currentstart, locate(), m_currentend); | ||
789 | } | ||
diff --git a/noncore/apps/opie-reader/Reb.h b/noncore/apps/opie-reader/Reb.h new file mode 100644 index 0000000..f268eb0 --- a/dev/null +++ b/noncore/apps/opie-reader/Reb.h | |||
@@ -0,0 +1,157 @@ | |||
1 | #ifndef __REB_H | ||
2 | #define __REB_H | ||
3 | #include <stdio.h> | ||
4 | #include <zlib.h> | ||
5 | #include <sys/stat.h> | ||
6 | #ifdef USEQPE | ||
7 | #include <qpe/global.h> | ||
8 | #endif | ||
9 | #include <qmap.h> | ||
10 | |||
11 | #include "CExpander.h" | ||
12 | #include <zlib.h> | ||
13 | |||
14 | #ifdef _WINDOWS | ||
15 | #include <winsock.h> | ||
16 | #endif | ||
17 | |||
18 | #include "mytypes.h" | ||
19 | |||
20 | /* | ||
21 | struct Reb_Segment | ||
22 | { | ||
23 | UInt32 len, page, flags; | ||
24 | Reb_Segment(UInt32 _len = 0, UInt32 _page = 0, UInt32 _flags = 0) | ||
25 | : | ||
26 | len(_len), page(_page), flags(_flags) | ||
27 | {} | ||
28 | }; | ||
29 | */ | ||
30 | |||
31 | class CReb; | ||
32 | |||
33 | class RBPage | ||
34 | { | ||
35 | UInt32 filepos; | ||
36 | UInt32 pageoffset; | ||
37 | UInt32 nochunks, currentchunk, chunkpos, chunklen, chunkoffset; | ||
38 | UInt32 m_pagelen, m_blocksize; | ||
39 | bool m_Compressed; | ||
40 | void readchunk(); | ||
41 | UInt32* chunklist; | ||
42 | UInt8* chunk; | ||
43 | FILE* fin; | ||
44 | UInt32 m_pageno; | ||
45 | void initpage(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len); | ||
46 | size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
47 | public: | ||
48 | RBPage() : pageoffset(0), nochunks(0), currentchunk(0), chunkpos(0), chunkoffset(0), m_pagelen(0), m_Compressed(false), chunklist(NULL), chunk(NULL) {} | ||
49 | ~RBPage() | ||
50 | { | ||
51 | if (chunk != NULL) delete [] chunk; | ||
52 | if (chunklist != NULL) delete [] chunklist; | ||
53 | } | ||
54 | int getch(CReb*); | ||
55 | unsigned short int getuint(CReb*); | ||
56 | int getint(CReb*); | ||
57 | void startpage(UInt32, UInt32, bool, UInt32); | ||
58 | UInt32 pageno() { return m_pageno; } | ||
59 | UInt32 offset() { return pageoffset+chunkoffset; } | ||
60 | void setoffset(UInt32, size_t, bool, UInt32, UInt32); | ||
61 | void init(FILE* _f, UInt32 _bs, size_t (*_decompress)(UInt8*, size_t, UInt8*, size_t)) | ||
62 | { | ||
63 | fin = _f; | ||
64 | m_blocksize = _bs; | ||
65 | chunk = new UInt8[m_blocksize]; | ||
66 | m_decompress = _decompress; | ||
67 | } | ||
68 | UInt32 length() { return m_pagelen; } | ||
69 | UInt32 m_startoff, m_endoff; | ||
70 | }; | ||
71 | |||
72 | struct Page_detail | ||
73 | { | ||
74 | UInt32 pagestart, len, flags; | ||
75 | Page_detail(UInt32 _ps = 0, UInt32 _l = 0, UInt32 _f = 0) | ||
76 | : | ||
77 | pagestart(_ps), len(_l), flags(_f) | ||
78 | { | ||
79 | } | ||
80 | }; | ||
81 | |||
82 | struct ParaRef | ||
83 | { | ||
84 | int pos, tag; | ||
85 | ParaRef(int _pos = 0, int _tag = 0) : pos(_pos), tag(_tag) | ||
86 | { | ||
87 | //qDebug("New PARAREF:%d, %d", pos, tag); | ||
88 | } | ||
89 | }; | ||
90 | |||
91 | class CReb : public CExpander | ||
92 | { | ||
93 | //friend class RBPage; | ||
94 | size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
95 | RBPage currentpage; | ||
96 | UInt32 nopages, m_homepage, m_blocksize; | ||
97 | |||
98 | QMap<QString, UInt32> m_index; | ||
99 | |||
100 | size_t file_length, text_length; | ||
101 | UInt32 toc; | ||
102 | FILE* fin; | ||
103 | void home(); | ||
104 | void startpage(UInt32); | ||
105 | void startpage(UInt32, bool, UInt32); | ||
106 | void readchunk(); | ||
107 | QString tagstring; | ||
108 | UInt32 tagoffset; | ||
109 | UInt32 pagelength(UInt32); | ||
110 | QImage* getPicture(const QString& ref); | ||
111 | UInt32 page2pos(UInt32); | ||
112 | //UInt32 m_pagelen; | ||
113 | UInt32* m_indexpages; | ||
114 | Page_detail* m_pagedetails; | ||
115 | // void UnZip(size_t bsize); | ||
116 | QMap<QString, int> names; | ||
117 | QString* tags; | ||
118 | ParaRef* paras; | ||
119 | UInt32* joins; | ||
120 | UInt32 nojoins; | ||
121 | UInt32 noparas; | ||
122 | bool m_binary; | ||
123 | void readindex(UInt32); | ||
124 | public: | ||
125 | bool findanchor(const QString& _info); | ||
126 | QString about() { return QString("REB codec (c) Tim Wentford"); } | ||
127 | bool getFile(const QString& href, const QString& nm); | ||
128 | void start2endSection(); | ||
129 | void sizes(unsigned long& _file, unsigned long& _text) | ||
130 | { | ||
131 | _file = file_length; | ||
132 | _text = text_length; | ||
133 | } | ||
134 | bool hasrandomaccess() { return true; } | ||
135 | virtual ~CReb(); | ||
136 | CReb(); | ||
137 | int OpenFile(const char *src); | ||
138 | int getch(); | ||
139 | unsigned int locate(); | ||
140 | void locate(unsigned int n); | ||
141 | CList<Bkmk>* getbkmklist(); | ||
142 | MarkupType PreferredMarkup() | ||
143 | { | ||
144 | return cCHM; | ||
145 | } | ||
146 | #ifdef USEQPE | ||
147 | void suspend(); | ||
148 | void unsuspend(); | ||
149 | #else | ||
150 | void suspend() {} | ||
151 | void unsuspend() {} | ||
152 | #endif | ||
153 | }; | ||
154 | |||
155 | #endif | ||
156 | |||
157 | |||
diff --git a/noncore/apps/opie-reader/RebCodec/.cvsignore b/noncore/apps/opie-reader/RebCodec/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/RebCodec/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/RebCodec/RebCodec.pro b/noncore/apps/opie-reader/RebCodec/RebCodec.pro new file mode 100644 index 0000000..2d6410a --- a/dev/null +++ b/noncore/apps/opie-reader/RebCodec/RebCodec.pro | |||
@@ -0,0 +1,21 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = Reb.h | ||
6 | |||
7 | SOURCES = Reb.cpp \ | ||
8 | decompress.cpp | ||
9 | |||
10 | |||
11 | INTERFACES= | ||
12 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | ||
13 | TARGET = Reb | ||
14 | LIBS += -L$(OPIEDIR)/lib -lreader_codec | ||
15 | |||
16 | |||
17 | INCLUDEPATH+= $(OPIEDIR)/include | ||
18 | DEPENDPATH += $(OPIEDIR)/include | ||
19 | |||
20 | include( $(OPIEDIR)/include.pro ) | ||
21 | |||
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h index 8e23c6f..4b7ff4b 100644 --- a/noncore/apps/opie-reader/StyleConsts.h +++ b/noncore/apps/opie-reader/StyleConsts.h | |||
@@ -29,50 +29,53 @@ struct pmstore | |||
29 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) | 29 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) |
30 | { | 30 | { |
31 | graphic = new GraphicLink(p, isLnk, tgt); | 31 | graphic = new GraphicLink(p, isLnk, tgt); |
32 | } | 32 | } |
33 | ~pmstore(); | 33 | ~pmstore(); |
34 | }; | 34 | }; |
35 | 35 | ||
36 | enum EalignmentType | 36 | enum EalignmentType |
37 | { | 37 | { |
38 | m_AlignLeft, | 38 | m_AlignLeft, |
39 | m_AlignRight, | 39 | m_AlignRight, |
40 | m_AlignCentre, | 40 | m_AlignCentre, |
41 | m_AlignJustify | 41 | m_AlignJustify, |
42 | m_AlignNone | ||
42 | }; | 43 | }; |
43 | 44 | ||
44 | class CBasicStyle | 45 | class CBasicStyle |
45 | { | 46 | { |
46 | friend class CStyle; | 47 | friend class CStyle; |
47 | bool m_bold, | 48 | bool m_bold, |
48 | m_italic; | 49 | m_italic; |
50 | unsigned long m_table; | ||
49 | int m_fontsize; | 51 | int m_fontsize; |
50 | EalignmentType m_align; | 52 | EalignmentType m_align; |
51 | unsigned char red, green, blue; | 53 | unsigned char red, green, blue; |
52 | unsigned char bred, bgreen, bblue; | 54 | unsigned char bred, bgreen, bblue; |
53 | unsigned char pred, pgreen, pblue; | 55 | unsigned char pred, pgreen, pblue; |
54 | unsigned long data; | 56 | unsigned long data; |
55 | unsigned long offset; | 57 | unsigned long offset; |
56 | bool isLink; | 58 | bool isLink; |
57 | // bool isVisited; | 59 | // bool isVisited; |
58 | bool m_underline; | 60 | bool m_underline; |
59 | bool m_strikethru; | 61 | bool m_strikethru; |
60 | bool m_monospaced; | 62 | bool m_monospaced; |
61 | unsigned char m_leftmargin, m_rightmargin; | 63 | unsigned char m_leftmargin, m_rightmargin; |
62 | signed char m_extraspace; | 64 | signed char m_extraspace; |
63 | signed char m_voffset; | 65 | signed char m_voffset; |
64 | CBasicStyle() | 66 | CBasicStyle() |
65 | { | 67 | { |
66 | unset(); | 68 | unset(); |
69 | m_table = 0xffffffff; | ||
67 | } | 70 | } |
68 | bool operator!=(const CBasicStyle& rhs) | 71 | bool operator!=(const CBasicStyle& rhs) |
69 | { | 72 | { |
70 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); | 73 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); |
71 | } | 74 | } |
72 | void unset() | 75 | void unset() |
73 | { | 76 | { |
74 | m_bold = false; | 77 | m_bold = false; |
75 | m_italic = false; | 78 | m_italic = false; |
76 | m_fontsize = 0; | 79 | m_fontsize = 0; |
77 | m_align = m_AlignLeft; | 80 | m_align = m_AlignLeft; |
78 | red = green = blue = 0; | 81 | red = green = blue = 0; |
@@ -137,24 +140,27 @@ class CStyle | |||
137 | void setBackground(unsigned char r, unsigned char g, unsigned char b) | 140 | void setBackground(unsigned char r, unsigned char g, unsigned char b) |
138 | { | 141 | { |
139 | sty.bred = r; | 142 | sty.bred = r; |
140 | sty.bgreen = g; | 143 | sty.bgreen = g; |
141 | sty.bblue = b; | 144 | sty.bblue = b; |
142 | } | 145 | } |
143 | CStyle() : graphic(NULL) {} | 146 | CStyle() : graphic(NULL) {} |
144 | ~CStyle(); | 147 | ~CStyle(); |
145 | // CStyle(CStyle&); | 148 | // CStyle(CStyle&); |
146 | CStyle(const CStyle&); | 149 | CStyle(const CStyle&); |
147 | CStyle& operator=(const CStyle&); | 150 | CStyle& operator=(const CStyle&); |
148 | void unset(); | 151 | void unset(); |
152 | bool isTable() const { return (sty.m_table != 0xffffffff); } | ||
153 | void setTable(unsigned long _b) { sty.m_table = _b; } | ||
154 | unsigned long getTable() { return sty.m_table; } | ||
149 | bool isPicture() const { return (graphic != NULL); } | 155 | bool isPicture() const { return (graphic != NULL); } |
150 | bool canScale() const { return graphic->m_isScaleable; } | 156 | bool canScale() const { return graphic->m_isScaleable; } |
151 | void clearPicture(); | 157 | void clearPicture(); |
152 | void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0); | 158 | void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0); |
153 | QImage* getPicture() | 159 | QImage* getPicture() |
154 | { | 160 | { |
155 | QImage* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL); | 161 | QImage* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL); |
156 | return pm; | 162 | return pm; |
157 | } | 163 | } |
158 | void setUnderline() { sty.m_underline = true; } | 164 | void setUnderline() { sty.m_underline = true; } |
159 | void unsetUnderline() { sty.m_underline = false; } | 165 | void unsetUnderline() { sty.m_underline = false; } |
160 | bool isUnderline() { return sty.m_underline; } | 166 | bool isUnderline() { return sty.m_underline; } |
@@ -178,24 +184,28 @@ class CStyle | |||
178 | void setRightJustify() | 184 | void setRightJustify() |
179 | { | 185 | { |
180 | sty.m_align = m_AlignRight; | 186 | sty.m_align = m_AlignRight; |
181 | } | 187 | } |
182 | void setCentreJustify() | 188 | void setCentreJustify() |
183 | { | 189 | { |
184 | sty.m_align = m_AlignCentre; | 190 | sty.m_align = m_AlignCentre; |
185 | } | 191 | } |
186 | void setFullJustify() | 192 | void setFullJustify() |
187 | { | 193 | { |
188 | sty.m_align = m_AlignJustify; | 194 | sty.m_align = m_AlignJustify; |
189 | } | 195 | } |
196 | void setNoJustify() | ||
197 | { | ||
198 | sty.m_align = m_AlignNone; | ||
199 | } | ||
190 | StyleType getJustify() | 200 | StyleType getJustify() |
191 | { | 201 | { |
192 | return sty.m_align; | 202 | return sty.m_align; |
193 | } | 203 | } |
194 | 204 | ||
195 | void setFontSize(int _fs) | 205 | void setFontSize(int _fs) |
196 | { | 206 | { |
197 | sty.m_fontsize = _fs; | 207 | sty.m_fontsize = _fs; |
198 | } | 208 | } |
199 | int getFontSize() const | 209 | int getFontSize() const |
200 | { | 210 | { |
201 | return sty.m_fontsize; | 211 | return sty.m_fontsize; |
diff --git a/noncore/apps/opie-reader/SubAlloc.h b/noncore/apps/opie-reader/SubAlloc.h new file mode 100644 index 0000000..ded2b73 --- a/dev/null +++ b/noncore/apps/opie-reader/SubAlloc.h | |||
@@ -0,0 +1,201 @@ | |||
1 | /**************************************************************************** | ||
2 | * This file is part of PPMd project * | ||
3 | * Written and distributed to public domain by Dmitry Shkarin 1997, * | ||
4 | * 1999-2001 * | ||
5 | * Contents: memory allocation routines * | ||
6 | ****************************************************************************/ | ||
7 | |||
8 | enum { UNIT_SIZE=12, N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4, | ||
9 | N_INDEXES=N1+N2+N3+N4 }; | ||
10 | |||
11 | #pragma pack(1) | ||
12 | struct BLK_NODE { | ||
13 | DWORD Stamp; | ||
14 | BLK_NODE* next; | ||
15 | BOOL avail() const { return (next != NULL); } | ||
16 | void link(BLK_NODE* p) { p->next=next; next=p; } | ||
17 | void unlink() { next=next->next; } | ||
18 | void* remove() { | ||
19 | BLK_NODE* p=next; unlink(); | ||
20 | Stamp--; return p; | ||
21 | } | ||
22 | inline void insert(void* pv,int NU); | ||
23 | } BList[N_INDEXES]; | ||
24 | struct MEM_BLK: public BLK_NODE { DWORD NU; } _PACK_ATTR; | ||
25 | #pragma pack() | ||
26 | |||
27 | static BYTE Indx2Units[N_INDEXES], Units2Indx[128]; // constants | ||
28 | static DWORD GlueCount, SubAllocatorSize=0; | ||
29 | static BYTE* HeapStart, * pText, * UnitsStart, * LoUnit, * HiUnit; | ||
30 | |||
31 | inline void PrefetchData(void* Addr) | ||
32 | { | ||
33 | #if defined(_USE_PREFETCHING) | ||
34 | BYTE PrefetchByte = *(volatile BYTE*) Addr; | ||
35 | #endif /* defined(_USE_PREFETCHING) */ | ||
36 | } | ||
37 | inline void BLK_NODE::insert(void* pv,int NU) { | ||
38 | MEM_BLK* p=(MEM_BLK*) pv; link(p); | ||
39 | p->Stamp=~0UL; p->NU=NU; | ||
40 | Stamp++; | ||
41 | } | ||
42 | inline UINT U2B(UINT NU) { return 8*NU+4*NU; } | ||
43 | inline void SplitBlock(void* pv,UINT OldIndx,UINT NewIndx) | ||
44 | { | ||
45 | UINT i, k, UDiff=Indx2Units[OldIndx]-Indx2Units[NewIndx]; | ||
46 | BYTE* p=((BYTE*) pv)+U2B(Indx2Units[NewIndx]); | ||
47 | if (Indx2Units[i=Units2Indx[UDiff-1]] != UDiff) { | ||
48 | k=Indx2Units[--i]; BList[i].insert(p,k); | ||
49 | p += U2B(k); UDiff -= k; | ||
50 | } | ||
51 | BList[Units2Indx[UDiff-1]].insert(p,UDiff); | ||
52 | } | ||
53 | DWORD _STDCALL GetUsedMemory() | ||
54 | { | ||
55 | DWORD i, RetVal=SubAllocatorSize-(HiUnit-LoUnit)-(UnitsStart-pText); | ||
56 | for (i=0;i < N_INDEXES;i++) | ||
57 | RetVal -= UNIT_SIZE*Indx2Units[i]*BList[i].Stamp; | ||
58 | return RetVal; | ||
59 | } | ||
60 | void _STDCALL StopSubAllocator() { | ||
61 | if ( SubAllocatorSize ) { | ||
62 | SubAllocatorSize=0; delete[] HeapStart; | ||
63 | } | ||
64 | } | ||
65 | BOOL _STDCALL StartSubAllocator(UINT SASize) | ||
66 | { | ||
67 | DWORD t=SASize << 19U; | ||
68 | if (SubAllocatorSize == t) return TRUE; | ||
69 | StopSubAllocator(); | ||
70 | if ((HeapStart=new BYTE[t]) == NULL) return FALSE; | ||
71 | SubAllocatorSize=t; return TRUE; | ||
72 | } | ||
73 | static inline void InitSubAllocator() | ||
74 | { | ||
75 | memset(BList,0,sizeof(BList)); | ||
76 | HiUnit=(pText=HeapStart)+SubAllocatorSize; | ||
77 | UINT Diff=UNIT_SIZE*(SubAllocatorSize/8/UNIT_SIZE*7); | ||
78 | LoUnit=UnitsStart=HiUnit-Diff; GlueCount=0; | ||
79 | } | ||
80 | static void GlueFreeBlocks() | ||
81 | { | ||
82 | UINT i, k, sz; | ||
83 | MEM_BLK s0, * p, * p0, * p1; | ||
84 | if (LoUnit != HiUnit) *LoUnit=0; | ||
85 | for (i=0, (p0=&s0)->next=NULL;i < N_INDEXES;i++) | ||
86 | while ( BList[i].avail() ) { | ||
87 | p=(MEM_BLK*) BList[i].remove(); | ||
88 | if ( !p->NU ) continue; | ||
89 | while ((p1=p+p->NU)->Stamp == ~0UL) { | ||
90 | p->NU += p1->NU; p1->NU=0; | ||
91 | } | ||
92 | p0->link(p); p0=p; | ||
93 | } | ||
94 | while ( s0.avail() ) { | ||
95 | p=(MEM_BLK*) s0.remove(); sz=p->NU; | ||
96 | if ( !sz ) continue; | ||
97 | for ( ;sz > 128;sz -= 128, p += 128) | ||
98 | BList[N_INDEXES-1].insert(p,128); | ||
99 | if (Indx2Units[i=Units2Indx[sz-1]] != sz) { | ||
100 | k=sz-Indx2Units[--i]; BList[k-1].insert(p+(sz-k),k); | ||
101 | } | ||
102 | BList[i].insert(p,Indx2Units[i]); | ||
103 | } | ||
104 | GlueCount=1 << 13; | ||
105 | } | ||
106 | static void* _STDCALL AllocUnitsRare(UINT indx) | ||
107 | { | ||
108 | UINT i=indx; | ||
109 | if ( !GlueCount ) { | ||
110 | GlueFreeBlocks(); | ||
111 | if ( BList[i].avail() ) return BList[i].remove(); | ||
112 | } | ||
113 | do { | ||
114 | if (++i == N_INDEXES) { | ||
115 | GlueCount--; i=U2B(Indx2Units[indx]); | ||
116 | return (UnitsStart-pText > i)?(UnitsStart -= i):(NULL); | ||
117 | } | ||
118 | } while ( !BList[i].avail() ); | ||
119 | void* RetVal=BList[i].remove(); SplitBlock(RetVal,i,indx); | ||
120 | return RetVal; | ||
121 | } | ||
122 | inline void* AllocUnits(UINT NU) | ||
123 | { | ||
124 | UINT indx=Units2Indx[NU-1]; | ||
125 | if ( BList[indx].avail() ) return BList[indx].remove(); | ||
126 | void* RetVal=LoUnit; LoUnit += U2B(Indx2Units[indx]); | ||
127 | if (LoUnit <= HiUnit) return RetVal; | ||
128 | LoUnit -= U2B(Indx2Units[indx]); return AllocUnitsRare(indx); | ||
129 | } | ||
130 | inline void* AllocContext() | ||
131 | { | ||
132 | if (HiUnit != LoUnit) return (HiUnit -= UNIT_SIZE); | ||
133 | else if ( BList->avail() ) return BList->remove(); | ||
134 | else return AllocUnitsRare(0); | ||
135 | } | ||
136 | inline void UnitsCpy(void* Dest,void* Src,UINT NU) | ||
137 | { | ||
138 | DWORD* p1=(DWORD*) Dest, * p2=(DWORD*) Src; | ||
139 | do { | ||
140 | p1[0]=p2[0]; p1[1]=p2[1]; | ||
141 | p1[2]=p2[2]; | ||
142 | p1 += 3; p2 += 3; | ||
143 | } while ( --NU ); | ||
144 | } | ||
145 | inline void* ExpandUnits(void* OldPtr,UINT OldNU) | ||
146 | { | ||
147 | UINT i0=Units2Indx[OldNU-1], i1=Units2Indx[OldNU-1+1]; | ||
148 | if (i0 == i1) return OldPtr; | ||
149 | void* ptr=AllocUnits(OldNU+1); | ||
150 | if ( ptr ) { | ||
151 | UnitsCpy(ptr,OldPtr,OldNU); BList[i0].insert(OldPtr,OldNU); | ||
152 | } | ||
153 | return ptr; | ||
154 | } | ||
155 | inline void* ShrinkUnits(void* OldPtr,UINT OldNU,UINT NewNU) | ||
156 | { | ||
157 | UINT i0=Units2Indx[OldNU-1], i1=Units2Indx[NewNU-1]; | ||
158 | if (i0 == i1) return OldPtr; | ||
159 | if ( BList[i1].avail() ) { | ||
160 | void* ptr=BList[i1].remove(); UnitsCpy(ptr,OldPtr,NewNU); | ||
161 | BList[i0].insert(OldPtr,Indx2Units[i0]); | ||
162 | return ptr; | ||
163 | } else { | ||
164 | SplitBlock(OldPtr,i0,i1); return OldPtr; | ||
165 | } | ||
166 | } | ||
167 | inline void FreeUnits(void* ptr,UINT NU) { | ||
168 | UINT indx=Units2Indx[NU-1]; | ||
169 | BList[indx].insert(ptr,Indx2Units[indx]); | ||
170 | } | ||
171 | inline void SpecialFreeUnit(void* ptr) | ||
172 | { | ||
173 | if ((BYTE*) ptr != UnitsStart) BList->insert(ptr,1); | ||
174 | else { *(DWORD*) ptr=~0UL; UnitsStart += UNIT_SIZE; } | ||
175 | } | ||
176 | inline void* MoveUnitsUp(void* OldPtr,UINT NU) | ||
177 | { | ||
178 | UINT indx=Units2Indx[NU-1]; | ||
179 | if ((BYTE*) OldPtr > UnitsStart+16*1024 || (BLK_NODE*) OldPtr > BList[indx].next) | ||
180 | return OldPtr; | ||
181 | void* ptr=BList[indx].remove(); | ||
182 | UnitsCpy(ptr,OldPtr,NU); NU=Indx2Units[indx]; | ||
183 | if ((BYTE*) OldPtr != UnitsStart) BList[indx].insert(OldPtr,NU); | ||
184 | else UnitsStart += U2B(NU); | ||
185 | return ptr; | ||
186 | } | ||
187 | static inline void ExpandTextArea() | ||
188 | { | ||
189 | BLK_NODE* p; | ||
190 | UINT Count[N_INDEXES]; memset(Count,0,sizeof(Count)); | ||
191 | while ((p=(BLK_NODE*) UnitsStart)->Stamp == ~0UL) { | ||
192 | MEM_BLK* pm=(MEM_BLK*) p; UnitsStart=(BYTE*) (pm+pm->NU); | ||
193 | Count[Units2Indx[pm->NU-1]]++; pm->Stamp=0; | ||
194 | } | ||
195 | for (UINT i=0;i < N_INDEXES;i++) | ||
196 | for (p=BList+i;Count[i] != 0;p=p->next) | ||
197 | while ( !p->next->Stamp ) { | ||
198 | p->unlink(); BList[i].Stamp--; | ||
199 | if ( !--Count[i] ) break; | ||
200 | } | ||
201 | } | ||
diff --git a/noncore/apps/opie-reader/TableDialog.cpp b/noncore/apps/opie-reader/TableDialog.cpp new file mode 100644 index 0000000..b67d534 --- a/dev/null +++ b/noncore/apps/opie-reader/TableDialog.cpp | |||
@@ -0,0 +1,17 @@ | |||
1 | #include "TableDialog.h" | ||
2 | |||
3 | CTableDialog::CTableDialog(const QFont& f, const QString& tabtext, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) | ||
4 | { | ||
5 | setCaption("Table View"); | ||
6 | QVBoxLayout *tmp = new QVBoxLayout(this); | ||
7 | QTextView* qtv = new QTextView(this); | ||
8 | qtv->setFont(f); | ||
9 | tmp->addWidget(qtv); | ||
10 | qtv->setText(tabtext); | ||
11 | if (fs) showMaximized(); | ||
12 | else if (parent != NULL) | ||
13 | { | ||
14 | resize(parent->size()); | ||
15 | move(parent->pos()); | ||
16 | } | ||
17 | } | ||
diff --git a/noncore/apps/opie-reader/TableDialog.h b/noncore/apps/opie-reader/TableDialog.h new file mode 100644 index 0000000..2257a81 --- a/dev/null +++ b/noncore/apps/opie-reader/TableDialog.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef __TABLEDIALOG_H | ||
2 | #define __TABLEDIALOG_H | ||
3 | |||
4 | #include <qdialog.h> | ||
5 | #include <qtextview.h> | ||
6 | #include <qlayout.h> | ||
7 | |||
8 | class CTableDialog : public QDialog | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | #ifndef USEQPE | ||
12 | void keyPressEvent(QKeyEvent* e) | ||
13 | { | ||
14 | switch (e->key()) | ||
15 | { | ||
16 | case Key_Escape: | ||
17 | e->accept(); | ||
18 | reject(); | ||
19 | break; | ||
20 | case Key_Space: | ||
21 | case Key_Return: | ||
22 | e->accept(); | ||
23 | accept(); | ||
24 | break; | ||
25 | default: | ||
26 | QWidget::keyPressEvent(e); | ||
27 | } | ||
28 | } | ||
29 | #endif | ||
30 | public: | ||
31 | CTableDialog(const QFont& f, const QString& tabtext, bool fs = true, QWidget* parent = 0, const char* name = 0); | ||
32 | ~CTableDialog() {} | ||
33 | }; | ||
34 | #endif // CPREFS_H | ||
diff --git a/noncore/apps/opie-reader/ToolbarPrefs.h b/noncore/apps/opie-reader/ToolbarPrefs.h index 0bdae6b..9df8940 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.h +++ b/noncore/apps/opie-reader/ToolbarPrefs.h | |||
@@ -1,39 +1,38 @@ | |||
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 | |||
11 | #include <qvariant.h> | 12 | #include <qvariant.h> |
12 | #include <qwidget.h> | 13 | #include <qwidget.h> |
13 | #include <qtabdialog.h> | 14 | #include <qtabdialog.h> |
14 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
15 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
16 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
17 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
18 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
19 | #ifdef USEQPE | 20 | #ifdef USEQPE |
20 | #include <qpe/menubutton.h> | 21 | #include <qpe/menubutton.h> |
21 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
22 | #else | 23 | #else |
23 | #include "preferences.h" | 24 | #include "preferences.h" |
24 | #endif | 25 | #endif |
25 | //#ifdef OPIE | ||
26 | #define USECOMBO | 26 | #define USECOMBO |
27 | //#endif | ||
28 | 27 | ||
29 | class QVBoxLayout; | 28 | class QVBoxLayout; |
30 | class QHBoxLayout; | 29 | class QHBoxLayout; |
31 | class QGridLayout; | 30 | class QGridLayout; |
32 | //class QCheckBox; | 31 | //class QCheckBox; |
33 | class QLabel; | 32 | class QLabel; |
34 | //class QSpinBox; | 33 | //class QSpinBox; |
35 | /* | 34 | /* |
36 | class CBarPrefs1 : public QWidget | 35 | class CBarPrefs1 : public QWidget |
37 | { | 36 | { |
38 | Q_OBJECT | 37 | Q_OBJECT |
39 | 38 | ||
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h index 199c7da..40b0f0a 100644 --- a/noncore/apps/opie-reader/ZText.h +++ b/noncore/apps/opie-reader/ZText.h | |||
@@ -1,17 +1,21 @@ | |||
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 | #ifdef USEQPE | ||
7 | #include <qpe/global.h> | ||
8 | #endif | ||
9 | |||
6 | #include "CExpander.h" | 10 | #include "CExpander.h" |
7 | 11 | ||
8 | class Text: public CExpander { | 12 | class Text: public CExpander { |
9 | gzFile file; | 13 | gzFile file; |
10 | unsigned long fsize; | 14 | unsigned long fsize; |
11 | public: | 15 | public: |
12 | void suspend() | 16 | void suspend() |
13 | { | 17 | { |
14 | #ifdef USEQPE | 18 | #ifdef USEQPE |
15 | if (!bSuspended) | 19 | if (!bSuspended) |
16 | { | 20 | { |
17 | bSuspended = true; | 21 | bSuspended = true; |
@@ -22,32 +26,37 @@ public: | |||
22 | } | 26 | } |
23 | #endif | 27 | #endif |
24 | } | 28 | } |
25 | void unsuspend() | 29 | void unsuspend() |
26 | { | 30 | { |
27 | #ifdef USEQPE | 31 | #ifdef USEQPE |
28 | if (bSuspended) | 32 | if (bSuspended) |
29 | { | 33 | { |
30 | bSuspended = false; | 34 | bSuspended = false; |
31 | if (sustime != ((time_t)-1)) | 35 | if (sustime != ((time_t)-1)) |
32 | { | 36 | { |
33 | int delay = time(NULL) - sustime; | 37 | int delay = time(NULL) - sustime; |
34 | if (delay < 10) sleep(10-delay); | 38 | if (delay < 10) |
39 | { | ||
40 | Global::statusMessage("Stalling"); | ||
41 | sleep(10-delay); | ||
42 | } | ||
35 | } | 43 | } |
36 | file = gzopen(fname, "rb"); | 44 | file = gzopen(fname, "rb"); |
37 | for (int i = 0; file == NULL && i < 5; i++) | 45 | for (int i = 0; file == NULL && i < 5; i++) |
38 | { | 46 | { |
47 | Global::statusMessage("Stalling"); | ||
39 | sleep(5); | 48 | sleep(5); |
40 | file = gzopen(fname, "rb"); | 49 | file = gzopen(fname, "rb"); |
41 | } | 50 | } |
42 | if (file == NULL) | 51 | if (file == NULL) |
43 | { | 52 | { |
44 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 53 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
45 | exit(0); | 54 | exit(0); |
46 | } | 55 | } |
47 | suspos = gzseek(file, suspos, SEEK_SET); | 56 | suspos = gzseek(file, suspos, SEEK_SET); |
48 | } | 57 | } |
49 | #endif | 58 | #endif |
50 | } | 59 | } |
51 | Text() : file(NULL) {}; | 60 | Text() : file(NULL) {}; |
52 | virtual ~Text() | 61 | virtual ~Text() |
53 | { | 62 | { |
diff --git a/noncore/apps/opie-reader/arith.h b/noncore/apps/opie-reader/arith.h index 19ca646..59b2ea9 100644 --- a/noncore/apps/opie-reader/arith.h +++ b/noncore/apps/opie-reader/arith.h | |||
@@ -1,34 +1,32 @@ | |||
1 | /* | 1 | /* |
2 | * Encodage & décodage arithmétique | 2 | * Encodage & décodage arithmétique |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef ARITH_H | 5 | #ifndef ARITH_H |
6 | 6 | ||
7 | #define ARITH_H | 7 | #define ARITH_H |
8 | 8 | ||
9 | #include "utypes.h" | 9 | #include "utypes.h" |
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | 11 | ||
12 | class ppm_expander; | ||
13 | |||
12 | class PPM_ReadBuf | 14 | class PPM_ReadBuf |
13 | { | 15 | { |
14 | FILE *my_file_in; | 16 | FILE *my_file_in; |
17 | ppm_expander* parent; | ||
15 | public: | 18 | public: |
16 | PPM_ReadBuf(FILE* f) : my_file_in(f) {} | 19 | PPM_ReadBuf(FILE* f, ppm_expander* _parent) : my_file_in(f), parent(_parent) {} |
17 | UINT readbuf(UCHAR *buf,UINT len) | 20 | UINT readbuf(UCHAR *buf,UINT len); |
18 | { | ||
19 | UINT len1; | ||
20 | len1=fread(buf,1,len,my_file_in); | ||
21 | return len1; | ||
22 | } | ||
23 | }; | 21 | }; |
24 | 22 | ||
25 | class ArithClass | 23 | class ArithClass |
26 | { | 24 | { |
27 | 25 | ||
28 | UCHAR *ainbuf; | 26 | UCHAR *ainbuf; |
29 | UCHAR *apinbuf,*aendinbuf; | 27 | UCHAR *apinbuf,*aendinbuf; |
30 | UINT ainbufsize; | 28 | UINT ainbufsize; |
31 | USHORT avalue,alow,ahigh; | 29 | USHORT avalue,alow,ahigh; |
32 | PPM_ReadBuf* areadbuf; | 30 | PPM_ReadBuf* areadbuf; |
33 | UCHAR abitcnt; | 31 | UCHAR abitcnt; |
34 | USHORT abitbuf; | 32 | USHORT abitbuf; |
diff --git a/noncore/apps/opie-reader/arrierego.cpp b/noncore/apps/opie-reader/arrierego.cpp new file mode 100644 index 0000000..be2a3fa --- a/dev/null +++ b/noncore/apps/opie-reader/arrierego.cpp | |||
@@ -0,0 +1,188 @@ | |||
1 | #ifdef USENEF | ||
2 | #include <qimage.h> | ||
3 | #include "arrierego.h" | ||
4 | |||
5 | struct CArriere_dataRecord | ||
6 | { | ||
7 | UInt16 uid; | ||
8 | UInt16 nParagraphs; | ||
9 | UInt32 size; | ||
10 | UInt8 type; | ||
11 | UInt8 reserved; | ||
12 | }; | ||
13 | |||
14 | int CArriere::HeaderSize() | ||
15 | { | ||
16 | return 10; | ||
17 | } | ||
18 | |||
19 | void CArriere::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) | ||
20 | { | ||
21 | CArriere_dataRecord thishdr; | ||
22 | unsuspend(); | ||
23 | fread(&thishdr, 1, HeaderSize(), fin); | ||
24 | uid = ntohs(thishdr.uid); | ||
25 | nParagraphs = ntohs(thishdr.nParagraphs); | ||
26 | size = ntohl(thishdr.size); | ||
27 | type = thishdr.type; | ||
28 | reserved = thishdr.reserved; | ||
29 | // qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", uid, nParagraphs, size, (unsigned int)type, (unsigned int)reserved); | ||
30 | // for (int i = 0; i < sizeof(thishdr); i++) | ||
31 | //printf("%d %x\n", i, (int)(((char *)(&thishdr))[i])); | ||
32 | } | ||
33 | |||
34 | bool CArriere::CorrectDecoder() | ||
35 | { | ||
36 | char * type = (char*)(&(head.type)); | ||
37 | for (int i = 0; i < 8; ++i) qDebug("%c", type[i]); | ||
38 | return (memcmp(&head.type, "ArriereG", 8) == 0); | ||
39 | } | ||
40 | |||
41 | int CArriere::bgetch() | ||
42 | { | ||
43 | int ch = EOF; | ||
44 | if (bufferpos >= buffercontent) | ||
45 | { | ||
46 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) | ||
47 | { | ||
48 | return EOF; | ||
49 | } | ||
50 | if (isEndOfSection(bufferrec)) | ||
51 | { | ||
52 | return EOF; | ||
53 | } | ||
54 | if (!expand(bufferrec+1)) | ||
55 | { | ||
56 | return EOF; | ||
57 | } | ||
58 | mystyle.unset(); | ||
59 | if (m_ParaOffsets[m_nextParaIndex] == 0) | ||
60 | { | ||
61 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) | ||
62 | { | ||
63 | m_nextParaIndex++; | ||
64 | } | ||
65 | } | ||
66 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | ||
67 | } | ||
68 | if (bufferpos == m_nextPara) | ||
69 | { | ||
70 | while (bufferpos == m_nextPara) | ||
71 | { | ||
72 | m_nextParaIndex++; | ||
73 | if (m_nextParaIndex == m_nParas) | ||
74 | { | ||
75 | m_nextPara = -1; | ||
76 | } | ||
77 | else | ||
78 | { | ||
79 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | ||
80 | } | ||
81 | } | ||
82 | mystyle.unset(); | ||
83 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | ||
84 | if (m_lastBreak == locate()) | ||
85 | { | ||
86 | currentpos++; | ||
87 | ch = expandedtextbuffer[bufferpos++]; | ||
88 | } | ||
89 | else | ||
90 | { | ||
91 | ch = 10; | ||
92 | } | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | currentpos++; | ||
97 | ch = expandedtextbuffer[bufferpos++]; | ||
98 | } | ||
99 | return ch; | ||
100 | } | ||
101 | |||
102 | tchar CArriere::getch(bool fast) | ||
103 | { | ||
104 | mystyle.clearPicture(); | ||
105 | return getch_base(fast); | ||
106 | } | ||
107 | |||
108 | /* | ||
109 | void CArriere::setlink(QString& fn, const QString& wrd) | ||
110 | { | ||
111 | fn = wrd; | ||
112 | } | ||
113 | */ | ||
114 | |||
115 | QImage* CArriere::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) | ||
116 | { | ||
117 | QByteArray arr; | ||
118 | arr.assign((const char*)imgbuffer, imgsize); | ||
119 | |||
120 | QImage* qimage = new QImage(arr); | ||
121 | |||
122 | return qimage; | ||
123 | } | ||
124 | |||
125 | void CArriere::start2endSection() | ||
126 | { | ||
127 | m_currentstart = NEFstartSection(); | ||
128 | m_currentend = NEFendSection(); | ||
129 | } | ||
130 | |||
131 | unsigned long CArriere::NEFstartSection() | ||
132 | { | ||
133 | //inefficient - Should calc start/end of section on entry to section? | ||
134 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
135 | UInt32 thishdr_size; | ||
136 | UInt8 thishdr_type, thishdr_reserved; | ||
137 | unsigned long textlength = currentpos-bufferpos; | ||
138 | for (UInt16 recptr = bufferrec-1; recptr >= 1; recptr--) | ||
139 | { | ||
140 | gotorecordnumber(recptr); | ||
141 | //qDebug("recptr:%u", recptr); | ||
142 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
143 | if (thishdr_type < 2) | ||
144 | { | ||
145 | if ((thishdr_reserved && continuation_bit) == 0) break; | ||
146 | textlength -= thishdr_size; | ||
147 | //qDebug("Textlength:%u, reserved:%u, recptr:%u", textlength, thishdr_reserved, recptr); | ||
148 | } | ||
149 | } | ||
150 | return textlength; | ||
151 | } | ||
152 | |||
153 | unsigned long CArriere::NEFendSection() | ||
154 | { | ||
155 | //inefficient - Should calc start/end of section on entry to section? | ||
156 | unsigned long textlength = currentpos-bufferpos+buffercontent; | ||
157 | gotorecordnumber(bufferrec); | ||
158 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
159 | UInt32 thishdr_size; | ||
160 | UInt8 thishdr_type, thishdr_reserved; | ||
161 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
162 | if ((thishdr_reserved && continuation_bit) != 0) | ||
163 | { | ||
164 | for (UInt16 recptr = bufferrec+1; recptr < ntohs(head.recordList.numRecords); recptr++) | ||
165 | { | ||
166 | gotorecordnumber(recptr); | ||
167 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
168 | UInt32 thishdr_size; | ||
169 | UInt8 thishdr_type, thishdr_reserved; | ||
170 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
171 | //qDebug("recptr %u bufferrec %u type %u m_reserved %u", recptr, bufferrec, typ | ||
172 | if (thishdr_type < 2) | ||
173 | { | ||
174 | textlength += thishdr_size; | ||
175 | if ((thishdr_reserved && continuation_bit) == 0) break; | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | return textlength; | ||
180 | } | ||
181 | |||
182 | #ifndef __STATIC | ||
183 | extern "C" | ||
184 | { | ||
185 | CExpander* newcodec() { return new CArriere; } | ||
186 | } | ||
187 | #endif | ||
188 | #endif | ||
diff --git a/noncore/apps/opie-reader/arrierego.h b/noncore/apps/opie-reader/arrierego.h new file mode 100644 index 0000000..5d6e2d0 --- a/dev/null +++ b/noncore/apps/opie-reader/arrierego.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #if (!defined(__ARRIEREGO_H)) && defined(USENEF) | ||
2 | #define __ARRIEREGO_H | ||
3 | #include "plucker_base.h" | ||
4 | |||
5 | #ifdef LOCALPICTURES | ||
6 | class QScrollView; | ||
7 | class QWidget; | ||
8 | #endif | ||
9 | |||
10 | class CArriere : public CPlucker_base | ||
11 | { | ||
12 | protected: | ||
13 | bool isEndOfSection(int thisrec) | ||
14 | { | ||
15 | return !m_bufferisreserved; | ||
16 | } | ||
17 | unsigned long NEFstartSection(); | ||
18 | unsigned long NEFendSection(); | ||
19 | void setbuffersize() | ||
20 | { | ||
21 | compressedbuffersize = buffersize = 64*1024; | ||
22 | } | ||
23 | void GetHeader(UInt16&, UInt16&, UInt32&, UInt8&, UInt8&); | ||
24 | int HeaderSize(); | ||
25 | int bgetch(); | ||
26 | tchar getch(bool); | ||
27 | |||
28 | bool CorrectDecoder(); | ||
29 | // void setlink(QString&, const QString&); | ||
30 | QImage* imagefromdata(UInt8*, UInt32); | ||
31 | unsigned char m_reserved; | ||
32 | public: | ||
33 | void start2endSection(); | ||
34 | QString about() { return CPlucker_base::about()+QString("\nArriereGo codec (c) Tim Wentford"); } | ||
35 | }; | ||
36 | |||
37 | #endif | ||
diff --git a/noncore/apps/opie-reader/cbkmkselector.h b/noncore/apps/opie-reader/cbkmkselector.h index 42951e5..ec0c6e8 100644 --- a/noncore/apps/opie-reader/cbkmkselector.h +++ b/noncore/apps/opie-reader/cbkmkselector.h | |||
@@ -1,43 +1,89 @@ | |||
1 | #include <qwidget.h> | 1 | #include <qwidget.h> |
2 | #include <qlistbox.h> | 2 | #include <qlistbox.h> |
3 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
4 | #include <qlayout.h> | 4 | #include <qlayout.h> |
5 | 5 | ||
6 | class CBkmkSelectorItem : public QListBoxText | ||
7 | { | ||
8 | int m_ref; | ||
9 | public: | ||
10 | CBkmkSelectorItem(const QString& _t, int ref) : QListBoxText(_t), m_ref(ref) | ||
11 | { | ||
12 | } | ||
13 | int reference() { return m_ref; } | ||
14 | }; | ||
15 | |||
6 | class CBkmkSelector : public QWidget | 16 | class CBkmkSelector : public QWidget |
7 | { | 17 | { |
8 | 18 | ||
9 | Q_OBJECT | 19 | Q_OBJECT |
10 | 20 | ||
11 | QListBox* bkmkselector; | 21 | QListBox* bkmkselector; |
12 | QPushButton* exitButton; | 22 | QPushButton* exitButton; |
13 | 23 | /* | |
24 | void keyPressEvent ( QKeyEvent * e ) | ||
25 | { | ||
26 | if ((e->key() == Key_Return) || (e->key() == Key_Space)) | ||
27 | { | ||
28 | emit selected(reinterpret_cast<CBkmkSelectorItem*>(bkmkselector->item(bkmkselector->currentItem()))->reference()); | ||
29 | e->accept(); | ||
30 | } | ||
31 | else | ||
32 | { | ||
33 | e->ignore(); | ||
34 | } | ||
35 | } | ||
36 | */ | ||
14 | signals: | 37 | signals: |
15 | void selected(int i); | 38 | void selected(int i); |
16 | void cancelled(); | 39 | void cancelled(); |
17 | private slots: | 40 | private slots: |
18 | void slotSelected(QListBoxItem* t) { emit selected(bkmkselector->index(t)); } | 41 | void slotSelected(QListBoxItem* t) |
19 | void slotSelected(int t) { emit selected(t); } | 42 | { |
43 | if (t != NULL) | ||
44 | { | ||
45 | emit selected(reinterpret_cast<CBkmkSelectorItem*>(t)->reference()); | ||
46 | } | ||
47 | } | ||
48 | //void slotSelected(int t) { emit selected(t); } | ||
20 | void slotCancel() { emit cancelled(); } | 49 | void slotCancel() { emit cancelled(); } |
50 | void slotSort() | ||
51 | { | ||
52 | bkmkselector->sort(); | ||
53 | #ifdef USEQPE | ||
54 | setCurrentItem(bkmkselector->currentItem()); | ||
55 | #endif | ||
56 | } | ||
21 | public: | 57 | public: |
22 | CBkmkSelector( QWidget *parent=0, const char *name=0, WFlags f = 0) : | 58 | CBkmkSelector( QWidget *parent=0, const char *name=0, WFlags f = 0) : |
23 | QWidget(parent, name, f) | 59 | QWidget(parent, name, f) |
24 | { | 60 | { |
25 | 61 | ||
26 | // QFont f("unifont", 16); | 62 | // QFont f("unifont", 16); |
27 | // setFont( f ); | 63 | // setFont( f ); |
28 | 64 | ||
29 | QVBoxLayout* grid = new QVBoxLayout(this); | 65 | QVBoxLayout* grid = new QVBoxLayout(this); |
30 | bkmkselector = new QListBox(this, "Bookmarks"); | 66 | QHBoxLayout* hgrid = new QHBoxLayout(); |
31 | exitButton = new QPushButton("Cancel", this); | 67 | bkmkselector = new QListBox(this, tr("Bookmarks")); |
32 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); | 68 | QPushButton* _sort = new QPushButton(tr("Sort"), this); |
69 | connect(_sort, SIGNAL(clicked()), this, SLOT( slotSort() ) ); | ||
70 | exitButton = new QPushButton(tr("Cancel"), this); | ||
71 | // connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) ); | ||
33 | connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); | 72 | connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); |
73 | connect(bkmkselector, SIGNAL( returnPressed(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) ); | ||
34 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); | 74 | connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); |
35 | grid->addWidget(bkmkselector,1); | 75 | grid->addWidget(bkmkselector,1); |
36 | grid->addWidget(exitButton); | 76 | grid->addLayout(hgrid); |
77 | hgrid->addWidget(_sort); | ||
78 | hgrid->addWidget(exitButton); | ||
37 | } | 79 | } |
38 | void clear() { bkmkselector->clear(); } | 80 | void clear() { bkmkselector->clear(); } |
39 | void insertItem(const QString& item) { bkmkselector->insertItem(item); } | 81 | void insertItem(const QString& _item, int ref) |
82 | { | ||
83 | CBkmkSelectorItem* item = new CBkmkSelectorItem(_item, ref); | ||
84 | bkmkselector->insertItem(item); | ||
85 | } | ||
40 | QString text(int index) const { return bkmkselector->text(index); } | 86 | QString text(int index) const { return bkmkselector->text(index); } |
41 | void setText(const QString& _l) { exitButton->setText(_l); } | 87 | void setText(const QString& _l) { exitButton->setText(_l); } |
88 | void setCurrentItem(int _i) { bkmkselector->setCurrentItem(_i); } | ||
42 | }; | 89 | }; |
43 | |||
diff --git a/noncore/apps/opie-reader/config.in b/noncore/apps/opie-reader/config.in index 9f80a93..04ff2f1 100644 --- a/noncore/apps/opie-reader/config.in +++ b/noncore/apps/opie-reader/config.in | |||
@@ -1,4 +1,8 @@ | |||
1 | config OPIE-READER | 1 | config OPIE-READER |
2 | boolean "opie-reader (E-Text reader)" | 2 | boolean "opie-reader (E-Text reader)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI |
5 | |||
6 | source noncore/apps/opie-reader/FliteDyn/config.in | ||
7 | source noncore/apps/opie-reader/FliteDyn16/config.in | ||
8 | |||
diff --git a/noncore/apps/opie-reader/decompress.cpp b/noncore/apps/opie-reader/decompress.cpp new file mode 100644 index 0000000..9bfec49 --- a/dev/null +++ b/noncore/apps/opie-reader/decompress.cpp | |||
@@ -0,0 +1,95 @@ | |||
1 | #include <string.h> | ||
2 | #include "decompress.h" | ||
3 | #include <zlib.h> | ||
4 | #include <stdlib.h> | ||
5 | |||
6 | size_t UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | ||
7 | { | ||
8 | z_stream zstream; | ||
9 | memset(&zstream,sizeof(zstream),0); | ||
10 | zstream.next_in = compressedbuffer; | ||
11 | zstream.next_out = tgtbuffer; | ||
12 | zstream.avail_out = bsize; | ||
13 | zstream.avail_in = reclen; | ||
14 | |||
15 | int keylen = 0; | ||
16 | |||
17 | zstream.zalloc = Z_NULL; | ||
18 | zstream.zfree = Z_NULL; | ||
19 | zstream.opaque = Z_NULL; | ||
20 | |||
21 | // printf("Initialising\n"); | ||
22 | |||
23 | inflateInit(&zstream); | ||
24 | int err = 0; | ||
25 | do { | ||
26 | if ( zstream.avail_in == 0 && 0 < keylen ) { | ||
27 | zstream.next_in = compressedbuffer + keylen; | ||
28 | zstream.avail_in = reclen - keylen; | ||
29 | keylen = 0; | ||
30 | } | ||
31 | zstream.next_out = tgtbuffer; | ||
32 | zstream.avail_out = bsize; | ||
33 | |||
34 | err = inflate( &zstream, Z_SYNC_FLUSH ); | ||
35 | |||
36 | ////qDebug("err:%d - %u", err, zstream.avail_in); | ||
37 | |||
38 | } while ( err == Z_OK ); | ||
39 | |||
40 | inflateEnd(&zstream); | ||
41 | return zstream.total_out; | ||
42 | } | ||
43 | |||
44 | #if defined(__STATIC) && defined(USENEF) | ||
45 | #include "Model.h" | ||
46 | size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t) | ||
47 | { | ||
48 | if (strcmp(_s, "PluckerDecompress3") == 0) | ||
49 | { | ||
50 | return PluckerDecompress3; | ||
51 | } | ||
52 | if (strcmp(_s, "PluckerDecompress4") == 0) | ||
53 | { | ||
54 | return PluckerDecompress4; | ||
55 | } | ||
56 | if (strcmp(_s, "RebDecompress") == 0) | ||
57 | { | ||
58 | return RebDecompress; | ||
59 | } | ||
60 | return NULL; | ||
61 | } | ||
62 | #else | ||
63 | |||
64 | #include "qfileinfo.h" | ||
65 | |||
66 | #include <dlfcn.h> | ||
67 | |||
68 | size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t) | ||
69 | { | ||
70 | #ifdef USEQPE | ||
71 | #ifdef OPIE | ||
72 | QString codecpath(getenv("OPIEDIR")); | ||
73 | #else | ||
74 | QString codecpath(getenv("QTDIR")); | ||
75 | #endif | ||
76 | codecpath += "/plugins/reader/support/libpluckerdecompress.so"; | ||
77 | #else | ||
78 | QString codecpath(getenv("READERDIR")); | ||
79 | codecpath += "/support/libpluckerdecompress.so"; | ||
80 | #endif | ||
81 | qDebug("Codec:%s", (const char*)codecpath); | ||
82 | if (QFile::exists(codecpath)) | ||
83 | { | ||
84 | qDebug("Codec:%s", (const char*)codecpath); | ||
85 | void* handle = dlopen(codecpath, RTLD_LAZY); | ||
86 | if (handle == 0) | ||
87 | { | ||
88 | qDebug("Can't find codec:%s", dlerror()); | ||
89 | return NULL; | ||
90 | } | ||
91 | return (size_t (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); | ||
92 | } | ||
93 | return NULL; | ||
94 | } | ||
95 | #endif | ||
diff --git a/noncore/apps/opie-reader/decompress.h b/noncore/apps/opie-reader/decompress.h new file mode 100644 index 0000000..400685f --- a/dev/null +++ b/noncore/apps/opie-reader/decompress.h | |||
@@ -0,0 +1,5 @@ | |||
1 | #include "mytypes.h" | ||
2 | |||
3 | size_t UnZip(UInt8* compressedbuffer,size_t reclen,UInt8* tgtbuffer,size_t bsize); | ||
4 | |||
5 | size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t); | ||
diff --git a/noncore/apps/opie-reader/ebookcodec.h b/noncore/apps/opie-reader/ebookcodec.h index f6e2daf..4229fb9 100644 --- a/noncore/apps/opie-reader/ebookcodec.h +++ b/noncore/apps/opie-reader/ebookcodec.h | |||
@@ -1,38 +1,47 @@ | |||
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 | #ifdef USEQPE | 6 | #ifdef USEQPE |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | #include "util.h" | ||
11 | |||
12 | #ifndef __STATIC | 10 | #ifndef __STATIC |
13 | #include <dlfcn.h> | 11 | #include <dlfcn.h> |
14 | class ebookcodec : public CExpander_Interface | 12 | class ebookcodec : public CExpander_Interface |
15 | { | 13 | { |
16 | CExpander *codec; | 14 | CExpander *codec; |
17 | void *handle; | 15 | void *handle; |
18 | int status; | 16 | int status; |
19 | public: | 17 | public: |
18 | QString getTableAsHtml(unsigned long loc) { return codec->getTableAsHtml(loc); } | ||
20 | QString about() | 19 | QString about() |
21 | { | 20 | { |
22 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); | 21 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); |
23 | } | 22 | } |
24 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) | 23 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) |
25 | { | 24 | { |
26 | QString codecpath(QTReaderUtil::getPluginPath()); | 25 | #ifdef USEQPE |
26 | #ifdef OPIE | ||
27 | QString codecpath(getenv("OPIEDIR")); | ||
28 | #else | ||
29 | QString codecpath(getenv("QTDIR")); | ||
30 | #endif | ||
31 | codecpath += "/plugins/reader/codecs/"; | ||
32 | #else | ||
33 | QString codecpath(getenv("READERDIR")); | ||
34 | codecpath += "/codecs/"; | ||
35 | #endif | ||
27 | codecpath += _s; | 36 | codecpath += _s; |
28 | if (QFile::exists(codecpath)) | 37 | if (QFile::exists(codecpath)) |
29 | { | 38 | { |
30 | qDebug("Codec:%s", (const char*)codecpath); | 39 | qDebug("Codec:%s", (const char*)codecpath); |
31 | handle = dlopen(codecpath, RTLD_LAZY); | 40 | handle = dlopen(codecpath, RTLD_LAZY); |
32 | if (handle == 0) | 41 | if (handle == 0) |
33 | { | 42 | { |
34 | /* | 43 | /* |
35 | QString wrn(dlerror()); | 44 | QString wrn(dlerror()); |
36 | QString fmt; | 45 | QString fmt; |
37 | while (wrn.length() > 10) | 46 | while (wrn.length() > 10) |
38 | { | 47 | { |
@@ -104,15 +113,19 @@ class ebookcodec : public CExpander_Interface | |||
104 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } | 113 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } |
105 | void setContinuous(bool _b) { codec->setContinuous(_b); } | 114 | void setContinuous(bool _b) { codec->setContinuous(_b); } |
106 | void setwidth(int w) { codec->setwidth(w); } | 115 | void setwidth(int w) { codec->setwidth(w); } |
107 | unsigned long startSection() { return codec->startSection(); } | 116 | unsigned long startSection() { return codec->startSection(); } |
108 | unsigned long endSection() { return codec->endSection(); } | 117 | unsigned long endSection() { return codec->endSection(); } |
109 | int openfile(const char *src) | 118 | int openfile(const char *src) |
110 | { | 119 | { |
111 | //qDebug("ebook openfile:%s", src); | 120 | //qDebug("ebook openfile:%s", src); |
112 | return (status != 0) ? status : codec->openfile(src); | 121 | return (status != 0) ? status : codec->openfile(src); |
113 | } | 122 | } |
114 | int getwidth() { return codec->getwidth(); } | 123 | int getwidth() { return codec->getwidth(); } |
115 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } | 124 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } |
116 | bool getFile(const QString& href) { return codec->getFile(href); } | 125 | bool getFile(const QString& href, const QString& nm) { return codec->getFile(href, nm); } |
126 | bool findanchor(const QString& nm) | ||
127 | { | ||
128 | return codec->findanchor(nm); | ||
129 | } | ||
117 | }; | 130 | }; |
118 | #endif | 131 | #endif |
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp index 2291c85..c8c371a 100644 --- a/noncore/apps/opie-reader/fileBrowser.cpp +++ b/noncore/apps/opie-reader/fileBrowser.cpp | |||
@@ -46,25 +46,25 @@ fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, boo | |||
46 | buttonShowHidden->setOn( false ); | 46 | buttonShowHidden->setOn( false ); |
47 | 47 | ||
48 | dirLabel = new QLabel(this, "DirLabel"); | 48 | dirLabel = new QLabel(this, "DirLabel"); |
49 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); | 49 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); |
50 | dirLabel->setText(currentDir.canonicalPath()); | 50 | dirLabel->setText(currentDir.canonicalPath()); |
51 | 51 | ||
52 | ListView = new QtrListView( this, "ListView" ); | 52 | ListView = new QtrListView( this, "ListView" ); |
53 | ListView->addColumn( tr( "Name" ) ); | 53 | ListView->addColumn( tr( "Name" ) ); |
54 | ListView->setSorting( 2, FALSE); | 54 | ListView->setSorting( 2, FALSE); |
55 | ListView->addColumn( tr( "Size" ) ); | 55 | ListView->addColumn( tr( "Size" ) ); |
56 | ListView->setSelectionMode(QListView::Single); | 56 | ListView->setSelectionMode(QListView::Single); |
57 | ListView->setAllColumnsShowFocus( TRUE ); | 57 | ListView->setAllColumnsShowFocus( TRUE ); |
58 | ListView->setColumnWidthMode(0, QListView::Manual); | 58 | ListView->setColumnWidthMode(0, ((modal) ? QListView::Manual : QListView::Maximum)); |
59 | ListView->setColumnWidthMode(1, QListView::Manual); | 59 | ListView->setColumnWidthMode(1, QListView::Manual); |
60 | 60 | ||
61 | // signals and slots connections | 61 | // signals and slots connections |
62 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); | 62 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); |
63 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); | 63 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); |
64 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 64 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
65 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 65 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
66 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 66 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
67 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 67 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
68 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); | 68 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); |
69 | 69 | ||
70 | QVBoxLayout* grid = new QVBoxLayout(this); | 70 | QVBoxLayout* grid = new QVBoxLayout(this); |
diff --git a/noncore/apps/opie-reader/flitecmd.cpp b/noncore/apps/opie-reader/flitecmd.cpp new file mode 100644 index 0000000..bb7e303 --- a/dev/null +++ b/noncore/apps/opie-reader/flitecmd.cpp | |||
@@ -0,0 +1,43 @@ | |||
1 | #include <unistd.h> | ||
2 | #include <sys/types.h> | ||
3 | #include <sys/wait.h> | ||
4 | #include <errno.h> | ||
5 | #include "flitecmd.h" | ||
6 | |||
7 | void CFliteCmd::output(const QString& txt) | ||
8 | { | ||
9 | pid_t pid; | ||
10 | if ((pid = fork()) <0) | ||
11 | { | ||
12 | qDebug("No memory"); | ||
13 | } | ||
14 | else if (pid == 0) | ||
15 | { | ||
16 | execlp("flite", "flite", "-t", (const char*)txt, NULL); | ||
17 | _exit(127); | ||
18 | qDebug("Can't find flite"); | ||
19 | } | ||
20 | else | ||
21 | { | ||
22 | int status; | ||
23 | while (waitpid(pid, &status, 0) < 0) | ||
24 | { | ||
25 | if (errno != EINTR) | ||
26 | { | ||
27 | qDebug("Error from flite"); | ||
28 | break; | ||
29 | } | ||
30 | } | ||
31 | qDebug("flite status:%d", status); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | QString CFliteCmd::about() | ||
36 | { | ||
37 | return QString("FliteCmd output codec (c) Tim Wentford\n"); | ||
38 | } | ||
39 | |||
40 | extern "C" | ||
41 | { | ||
42 | COutput* newcodec() { return new CFliteCmd; } | ||
43 | } | ||
diff --git a/noncore/apps/opie-reader/flitecmd.h b/noncore/apps/opie-reader/flitecmd.h new file mode 100644 index 0000000..10f9710 --- a/dev/null +++ b/noncore/apps/opie-reader/flitecmd.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #include "outputcodec.h" | ||
2 | |||
3 | class CFliteCmd : public COutput | ||
4 | { | ||
5 | public: | ||
6 | CFliteCmd() {} | ||
7 | ~CFliteCmd() {} | ||
8 | QString about(); | ||
9 | void output(const QString& _o); | ||
10 | }; | ||
diff --git a/noncore/apps/opie-reader/flitedyn.cpp b/noncore/apps/opie-reader/flitedyn.cpp new file mode 100644 index 0000000..c268cd4 --- a/dev/null +++ b/noncore/apps/opie-reader/flitedyn.cpp | |||
@@ -0,0 +1,29 @@ | |||
1 | #include "flitedyn.h" | ||
2 | |||
3 | cst_voice *CFliteDyn::m_voice = NULL; | ||
4 | |||
5 | CFliteDyn::CFliteDyn() | ||
6 | { | ||
7 | if (m_voice == NULL) | ||
8 | { | ||
9 | qDebug("Constucting flite"); | ||
10 | flite_init(); | ||
11 | m_voice = register_cmu_us_kal(); | ||
12 | } | ||
13 | } | ||
14 | |||
15 | QString CFliteDyn::about() | ||
16 | { | ||
17 | return QString("FliteDyn output codec (c) Tim Wentford\n"); | ||
18 | } | ||
19 | |||
20 | void CFliteDyn::output(const QString& _o) | ||
21 | { | ||
22 | float tm = flite_text_to_speech((const char*)_o, m_voice, "play"); | ||
23 | qDebug("Produced %g seconds of speech", tm); | ||
24 | } | ||
25 | |||
26 | extern "C" | ||
27 | { | ||
28 | COutput* newcodec() { return new CFliteDyn; } | ||
29 | } | ||
diff --git a/noncore/apps/opie-reader/flitedyn.h b/noncore/apps/opie-reader/flitedyn.h new file mode 100644 index 0000000..4455048 --- a/dev/null +++ b/noncore/apps/opie-reader/flitedyn.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #include "outputcodec.h" | ||
2 | extern "C" | ||
3 | { | ||
4 | #include <flite.h> | ||
5 | cst_voice *register_cmu_us_kal(); | ||
6 | } | ||
7 | |||
8 | class CFliteDyn : public COutput | ||
9 | { | ||
10 | static cst_voice *m_voice; | ||
11 | public: | ||
12 | CFliteDyn(); | ||
13 | ~CFliteDyn() {} | ||
14 | QString about(); | ||
15 | void output(const QString& _o); | ||
16 | }; | ||
diff --git a/noncore/apps/opie-reader/iSilo.cpp b/noncore/apps/opie-reader/iSilo.cpp index 5f14b96..1f727fe 100644 --- a/noncore/apps/opie-reader/iSilo.cpp +++ b/noncore/apps/opie-reader/iSilo.cpp | |||
@@ -1,16 +1,16 @@ | |||
1 | #include "iSilo.h" | 1 | #include "iSilo.h" |
2 | #ifdef _WINDOWS | 2 | #ifdef _WINDOWS |
3 | #include <winsock.h> | 3 | #include <winsock.h> |
4 | #endif | 4 | #endif |
5 | u_int8_t *rodata = (u_int8_t *) | 5 | u_int8_t *rodata = (u_int8_t *) |
6 | "\x10\x11\x12\x00\x08\x07\x09\x06\x0a\x05\x0b\x04\x0c\x03\x0d\x02\x0e\x01\x0f"; | 6 | "\x10\x11\x12\x00\x08\x07\x09\x06\x0a\x05\x0b\x04\x0c\x03\x0d\x02\x0e\x01\x0f"; |
7 | 7 | ||
8 | u_int16_t *rsize_min = (u_int16_t *) | 8 | u_int16_t *rsize_min = (u_int16_t *) |
9 | "\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0d" | 9 | "\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0d" |
10 | "\x00\x0f\x00\x11\x00\x13\x00\x17\x00\x1b\x00\x1f\x00\x23\x00\x2b\x00\x33\x00" | 10 | "\x00\x0f\x00\x11\x00\x13\x00\x17\x00\x1b\x00\x1f\x00\x23\x00\x2b\x00\x33\x00" |
11 | "\x3b\x00\x43\x00\x53\x00\x63\x00\x73\x00\x83\x00\xa3\x00\xc3\x00\xe3\x00\x02" | 11 | "\x3b\x00\x43\x00\x53\x00\x63\x00\x73\x00\x83\x00\xa3\x00\xc3\x00\xe3\x00\x02" |
12 | "\x01"; | 12 | "\x01"; |
13 | 13 | ||
14 | u_int8_t *rsize_delta = (u_int8_t *) | 14 | u_int8_t *rsize_delta = (u_int8_t *) |
15 | "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03" | 15 | "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03" |
16 | "\x03\x04\x04\x04\x04\x05\x05\x05\x05\x00"; | 16 | "\x03\x04\x04\x04\x04\x05\x05\x05\x05\x00"; |
@@ -285,24 +285,25 @@ bool iSilo::reset_trees() | |||
285 | } | 285 | } |
286 | u_int32_t iSilo::get_bits(int num) { | 286 | u_int32_t iSilo::get_bits(int num) { |
287 | int i, r; | 287 | int i, r; |
288 | u_int32_t result = 0; | 288 | u_int32_t result = 0; |
289 | 289 | ||
290 | if (num == 0) { | 290 | if (num == 0) { |
291 | pos = 0; | 291 | pos = 0; |
292 | return(0); | 292 | return(0); |
293 | } | 293 | } |
294 | 294 | ||
295 | for (i = 0; i < num; i++) { | 295 | for (i = 0; i < num; i++) { |
296 | if (pos == 0) { | 296 | if (pos == 0) { |
297 | unsuspend(); | ||
297 | r = fread(buf, sizeof(u_int32_t), 256, fin); | 298 | r = fread(buf, sizeof(u_int32_t), 256, fin); |
298 | if (r <= 0) { | 299 | if (r <= 0) { |
299 | qDebug("ERROR: Unexpected end of file"); | 300 | qDebug("ERROR: Unexpected end of file"); |
300 | exit(-1); /* FIXME */ | 301 | exit(-1); /* FIXME */ |
301 | } | 302 | } |
302 | pos = 32*256; | 303 | pos = 32*256; |
303 | } | 304 | } |
304 | 305 | ||
305 | pos--; | 306 | pos--; |
306 | result <<= 1; | 307 | result <<= 1; |
307 | result |= (ntohl(buf[255 - (pos/32)]) >> (31-(pos % 32))) & 1; | 308 | result |= (ntohl(buf[255 - (pos/32)]) >> (31-(pos % 32))) & 1; |
308 | } | 309 | } |
@@ -552,30 +553,30 @@ void iSilo::read_attr() | |||
552 | } | 553 | } |
553 | if (attr_rec >= attr_start && attr_rec < attr_end) | 554 | if (attr_rec >= attr_start && attr_rec < attr_end) |
554 | { | 555 | { |
555 | gotorecordnumber(attr_rec); | 556 | gotorecordnumber(attr_rec); |
556 | fread(buffer, 1, 4, fin); | 557 | fread(buffer, 1, 4, fin); |
557 | fread(&attr_num, sizeof(attr_num), 1, fin); | 558 | fread(&attr_num, sizeof(attr_num), 1, fin); |
558 | attr_num = ntohs(attr_num)+1; | 559 | attr_num = ntohs(attr_num)+1; |
559 | attr = new s_attrib[attr_num]; | 560 | attr = new s_attrib[attr_num]; |
560 | for (int j = 0; j < attr_num; j++) | 561 | for (int j = 0; j < attr_num; j++) |
561 | { | 562 | { |
562 | fread(&attr[j].offset, 2, 1, fin); | 563 | fread(&attr[j].offset, 2, 1, fin); |
563 | attr[j].offset = htons(attr[j].offset); | 564 | attr[j].offset = htons(attr[j].offset); |
564 | } | 565 | } |
565 | #ifdef _WINDOWS | 566 | #ifdef _WINDOWS |
566 | for (j = 0; j < attr_num; j++) | 567 | for (j = 0; j < attr_num; j++) |
567 | #else | 568 | #else |
568 | for (int j = 0; j < attr_num; j++) | 569 | for (int j = 0; j < attr_num; j++) |
569 | #endif | 570 | #endif |
570 | { | 571 | { |
571 | fread(&attr[j].value, 2, 1, fin); | 572 | fread(&attr[j].value, 2, 1, fin); |
572 | if (attr[j].offset < last_pos) | 573 | if (attr[j].offset < last_pos) |
573 | { | 574 | { |
574 | pos_hi++; | 575 | pos_hi++; |
575 | } | 576 | } |
576 | 577 | ||
577 | if ((attr[j].offset == last_pos) && (attr[j].value == last_value)) | 578 | if ((attr[j].offset == last_pos) && (attr[j].value == last_value)) |
578 | { | 579 | { |
579 | pos_hi++; | 580 | pos_hi++; |
580 | } | 581 | } |
581 | 582 | ||
diff --git a/noncore/apps/opie-reader/linktype.h b/noncore/apps/opie-reader/linktype.h index 23c24ac..a23d345 100644 --- a/noncore/apps/opie-reader/linktype.h +++ b/noncore/apps/opie-reader/linktype.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef __LINKTYPE_H | 1 | #ifndef __LINKTYPE_H |
2 | #define __LINKTYPE_H | 2 | #define __LINKTYPE_H |
3 | 3 | ||
4 | typedef unsigned int linkType; | 4 | typedef unsigned int linkType; |
5 | const linkType eNone = 0, eLink = 1, ePicture = 2, eFile = 4; | 5 | const linkType eNone = 0, eLink = 1, ePicture = 2, eFile = 4, eTable = 8; |
6 | 6 | ||
7 | #endif | 7 | #endif |
diff --git a/noncore/apps/opie-reader/main.cpp b/noncore/apps/opie-reader/main.cpp index af276da..2be6045 100644 --- a/noncore/apps/opie-reader/main.cpp +++ b/noncore/apps/opie-reader/main.cpp | |||
@@ -1,12 +1,13 @@ | |||
1 | |||
1 | #ifdef USEQPE | 2 | #ifdef USEQPE |
2 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
3 | #else | 4 | #else |
4 | #include <qapplication.h> | 5 | #include <qapplication.h> |
5 | #endif | 6 | #endif |
6 | #include "QTReaderApp.h" | 7 | #include "QTReaderApp.h" |
7 | 8 | ||
8 | #include "signal.h" | 9 | #include "signal.h" |
9 | #include "stdio.h" | 10 | #include "stdio.h" |
10 | #include "time.h" | 11 | #include "time.h" |
11 | 12 | ||
12 | 13 | ||
diff --git a/noncore/apps/opie-reader/mytypes.h b/noncore/apps/opie-reader/mytypes.h new file mode 100644 index 0000000..ea60db3 --- a/dev/null +++ b/noncore/apps/opie-reader/mytypes.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __MYTYPES_H__ | ||
2 | #define __MYTYPES_H__ | ||
3 | typedef unsigned char UInt8; | ||
4 | typedef unsigned short UInt16; | ||
5 | typedef signed short Int16; | ||
6 | typedef unsigned long UInt32; | ||
7 | #endif | ||
8 | |||
diff --git a/noncore/apps/opie-reader/opie-reader.pro b/noncore/apps/opie-reader/opie-reader.pro index 170f7fa..47980e1 100644 --- a/noncore/apps/opie-reader/opie-reader.pro +++ b/noncore/apps/opie-reader/opie-reader.pro | |||
@@ -1,16 +1,24 @@ | |||
1 | TEMPLATE = subdirs | 1 | TEMPLATE = subdirs |
2 | SUBDIRS = pluckerbaselib \ | 2 | SUBDIRS = pluckerbaselib \ |
3 | codeclib \ | 3 | codeclib \ |
4 | pdblib \ | 4 | pdblib \ |
5 | PluckerCodec \ | 5 | PluckerCodec \ |
6 | AportisCodec \ | 6 | AportisCodec \ |
7 | CHM \ | 7 | CHM \ |
8 | HTMLFilter \ | 8 | HTMLFilter \ |
9 | WeaselCodec \ | 9 | WeaselCodec \ |
10 | iSiloCodec \ | 10 | iSiloCodec \ |
11 | ppmsCodec \ | 11 | ppmsCodec \ |
12 | FliteCmd \ | ||
13 | pluckerdecompress \ | ||
14 | ArriereCodec \ | ||
15 | RebCodec \ | ||
12 | reader | 16 | reader |
13 | 17 | ||
18 | # these are added only built if enabled in "make menuconfig" | ||
19 | # FliteDyn | ||
20 | # FliteDyn16 | ||
21 | |||
14 | include( $(OPIEDIR)/include.pro ) | 22 | include( $(OPIEDIR)/include.pro ) |
15 | 23 | ||
16 | 24 | ||
diff --git a/noncore/apps/opie-reader/outputcodec.h b/noncore/apps/opie-reader/outputcodec.h new file mode 100644 index 0000000..727575c --- a/dev/null +++ b/noncore/apps/opie-reader/outputcodec.h | |||
@@ -0,0 +1,84 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <qfileinfo.h> | ||
3 | #include <qdir.h> | ||
4 | |||
5 | #ifdef USEQPE | ||
6 | #include <qpe/global.h> | ||
7 | #endif | ||
8 | |||
9 | class COutput | ||
10 | { | ||
11 | public: | ||
12 | virtual ~COutput() {} | ||
13 | virtual void output(const QString&) = 0; | ||
14 | virtual QString about() = 0; | ||
15 | }; | ||
16 | |||
17 | #ifndef __STATIC | ||
18 | #include <dlfcn.h> | ||
19 | class outputcodec : public COutput | ||
20 | { | ||
21 | COutput *codec; | ||
22 | void *handle; | ||
23 | int status; | ||
24 | public: | ||
25 | void output(const QString& q) { codec->output(q); } | ||
26 | QString about() | ||
27 | { | ||
28 | return QString("Plug-in output codec interface (c) Tim Wentford\n")+codec->about(); | ||
29 | } | ||
30 | outputcodec(const QString& _s) : codec(NULL), handle(NULL), status(-1) | ||
31 | { | ||
32 | #ifdef USEQPE | ||
33 | #ifdef OPIE | ||
34 | QString codecpath(getenv("OPIEDIR")); | ||
35 | #else | ||
36 | QString codecpath(getenv("QTDIR")); | ||
37 | #endif | ||
38 | codecpath += "/plugins/reader/outcodecs/lib"; | ||
39 | #else | ||
40 | QString codecpath(getenv("READERDIR")); | ||
41 | codecpath += "/outcodecs/lib"; | ||
42 | #endif | ||
43 | codecpath += _s; | ||
44 | codecpath += ".so"; | ||
45 | if (QFile::exists(codecpath)) | ||
46 | { | ||
47 | qDebug("Codec:%s", (const char*)codecpath); | ||
48 | handle = dlopen(codecpath, RTLD_LAZY); | ||
49 | if (handle == 0) | ||
50 | { | ||
51 | qDebug("Can't find codec:%s", dlerror()); | ||
52 | status = -10; | ||
53 | return; | ||
54 | } | ||
55 | COutput* (*newcodec)(); | ||
56 | newcodec = (COutput* (*)())dlsym(handle, "newcodec"); | ||
57 | if (newcodec == NULL) | ||
58 | { | ||
59 | qDebug("Can't find newcodec"); | ||
60 | status = -20; | ||
61 | return; | ||
62 | } | ||
63 | codec = (*newcodec)(); | ||
64 | status = 0; | ||
65 | } | ||
66 | else | ||
67 | { | ||
68 | qDebug("Can't find codec:%s", (const char*)codecpath); | ||
69 | } | ||
70 | if (codec == NULL) | ||
71 | { | ||
72 | qDebug("Can't do newcodec"); | ||
73 | status = -30; | ||
74 | return; | ||
75 | } | ||
76 | } | ||
77 | virtual ~outputcodec() | ||
78 | { | ||
79 | if (codec != NULL) delete codec; | ||
80 | if (handle != NULL) dlclose(handle); | ||
81 | } | ||
82 | int getStatus() { return status; } | ||
83 | }; | ||
84 | #endif | ||
diff --git a/noncore/apps/opie-reader/pdb.cpp b/noncore/apps/opie-reader/pdb.cpp index 6719af4..a13b33d 100644 --- a/noncore/apps/opie-reader/pdb.cpp +++ b/noncore/apps/opie-reader/pdb.cpp | |||
@@ -1,18 +1,17 @@ | |||
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 | |||
7 | #ifdef USEQPE | 6 | #ifdef USEQPE |
8 | void Cpdb::suspend() | 7 | void Cpdb::suspend() |
9 | { | 8 | { |
10 | CExpander::suspend(fin); | 9 | CExpander::suspend(fin); |
11 | } | 10 | } |
12 | void Cpdb::unsuspend() | 11 | void Cpdb::unsuspend() |
13 | { | 12 | { |
14 | CExpander::unsuspend(fin); | 13 | CExpander::unsuspend(fin); |
15 | } | 14 | } |
16 | #endif | 15 | #endif |
17 | 16 | ||
18 | Cpdb::~Cpdb() | 17 | Cpdb::~Cpdb() |
@@ -28,39 +27,41 @@ Cpdb::~Cpdb() | |||
28 | 27 | ||
29 | size_t Cpdb::recordpos(int n) | 28 | size_t Cpdb::recordpos(int n) |
30 | { | 29 | { |
31 | UInt16 mxn = ntohs(head.recordList.numRecords); | 30 | UInt16 mxn = ntohs(head.recordList.numRecords); |
32 | if (n >= mxn) | 31 | if (n >= mxn) |
33 | { | 32 | { |
34 | return file_length; | 33 | return file_length; |
35 | } | 34 | } |
36 | else | 35 | else |
37 | { | 36 | { |
38 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); | 37 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); |
39 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; | 38 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; |
39 | unsuspend(); | ||
40 | fseek(fin, dataoffset, SEEK_SET); | 40 | fseek(fin, dataoffset, SEEK_SET); |
41 | RecordListType hdr; | 41 | RecordListType hdr; |
42 | fread(&hdr, 1, sizeof(hdr), fin); | 42 | fread(&hdr, 1, sizeof(hdr), fin); |
43 | return ntohl(hdr.nextRecordListID); | 43 | return ntohl(hdr.nextRecordListID); |
44 | } | 44 | } |
45 | 45 | ||
46 | } | 46 | } |
47 | 47 | ||
48 | size_t Cpdb::recordlength(int n) | 48 | size_t Cpdb::recordlength(int n) |
49 | { | 49 | { |
50 | return recordpos(n+1)-recordpos(n); | 50 | return recordpos(n+1)-recordpos(n); |
51 | } | 51 | } |
52 | 52 | ||
53 | void Cpdb::gotorecordnumber(int n) | 53 | void Cpdb::gotorecordnumber(int n) |
54 | { | 54 | { |
55 | unsuspend(); | ||
55 | fseek(fin, recordpos(n), SEEK_SET); | 56 | fseek(fin, recordpos(n), SEEK_SET); |
56 | } | 57 | } |
57 | 58 | ||
58 | bool Cpdb::openpdbfile(const char *src) | 59 | bool Cpdb::openpdbfile(const char *src) |
59 | { | 60 | { |
60 | //qDebug("cpdb openfile:%s", src); | 61 | //qDebug("cpdb openfile:%s", src); |
61 | 62 | ||
62 | // printf("In openfile\n"); | 63 | // printf("In openfile\n"); |
63 | // printf("closing fin:%x\n",fin); | 64 | // printf("closing fin:%x\n",fin); |
64 | if (fin != NULL) fclose(fin); | 65 | if (fin != NULL) fclose(fin); |
65 | // printf("opening fin\n"); | 66 | // printf("opening fin\n"); |
66 | fin = fopen(src,"rb"); | 67 | fin = fopen(src,"rb"); |
@@ -73,17 +74,17 @@ bool Cpdb::openpdbfile(const char *src) | |||
73 | // just holds the first few chars of the file | 74 | // just holds the first few chars of the file |
74 | //char buf[0x100]; | 75 | //char buf[0x100]; |
75 | struct stat _stat; | 76 | struct stat _stat; |
76 | stat(src,&_stat); | 77 | stat(src,&_stat); |
77 | file_length = _stat.st_size; | 78 | file_length = _stat.st_size; |
78 | // fseek(fin,0,SEEK_END); | 79 | // fseek(fin,0,SEEK_END); |
79 | // file_length = ftell(fin); | 80 | // file_length = ftell(fin); |
80 | 81 | ||
81 | fseek(fin,0,SEEK_SET); | 82 | fseek(fin,0,SEEK_SET); |
82 | 83 | ||
83 | fread(&head, 1, sizeof(head), fin); | 84 | fread(&head, 1, sizeof(head), fin); |
84 | 85 | ||
85 | qDebug("Database name:%s", head.name); | 86 | //qDebug("Database name:%s", head.name); |
86 | qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); | 87 | //qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); |
87 | 88 | ||
88 | return true; | 89 | return true; |
89 | } | 90 | } |
diff --git a/noncore/apps/opie-reader/pdb.h b/noncore/apps/opie-reader/pdb.h index 7458919..a0abd1b 100644 --- a/noncore/apps/opie-reader/pdb.h +++ b/noncore/apps/opie-reader/pdb.h | |||
@@ -6,31 +6,29 @@ | |||
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 | |||
18 | #include "CExpander.h" | 19 | #include "CExpander.h" |
19 | 20 | ||
20 | /* Normal Palm typedefs */ | 21 | /* Normal Palm typedefs */ |
21 | typedef unsigned char UInt8; | 22 | #include "mytypes.h" |
22 | typedef unsigned short UInt16; | ||
23 | typedef signed short Int16; | ||
24 | typedef unsigned long UInt32; | ||
25 | typedef UInt32 LocalID; | 23 | typedef UInt32 LocalID; |
26 | 24 | ||
27 | /* Max length of DB name */ | 25 | /* Max length of DB name */ |
28 | #define dmDBNameLength 0x20 | 26 | #define dmDBNameLength 0x20 |
29 | 27 | ||
30 | 28 | ||
31 | /************************************************************ | 29 | /************************************************************ |
32 | * Structure of a Record entry | 30 | * Structure of a Record entry |
33 | *************************************************************/ | 31 | *************************************************************/ |
34 | typedef struct { | 32 | typedef struct { |
35 | LocalID localChunkID; // local chunkID of a record | 33 | LocalID localChunkID; // local chunkID of a record |
36 | UInt8 attributes; // record attributes; | 34 | UInt8 attributes; // record attributes; |
@@ -83,18 +81,21 @@ class Cpdb : public CExpander | |||
83 | size_t file_length; | 81 | size_t file_length; |
84 | FILE* fin; | 82 | FILE* fin; |
85 | size_t recordpos(int); | 83 | size_t recordpos(int); |
86 | size_t recordlength(int); | 84 | size_t recordlength(int); |
87 | void gotorecordnumber(int); | 85 | void gotorecordnumber(int); |
88 | DatabaseHdrType head; | 86 | DatabaseHdrType head; |
89 | bool openpdbfile(const char* src); | 87 | bool openpdbfile(const char* src); |
90 | Cpdb() : fin(NULL) {} | 88 | Cpdb() : fin(NULL) {} |
91 | ~Cpdb(); | 89 | ~Cpdb(); |
92 | #ifdef USEQPE | 90 | #ifdef USEQPE |
93 | void suspend(); | 91 | void suspend(); |
94 | void unsuspend(); | 92 | void unsuspend(); |
93 | #else | ||
94 | void suspend() {} | ||
95 | void unsuspend() {} | ||
95 | #endif | 96 | #endif |
96 | public: | 97 | public: |
97 | virtual void sizes(unsigned long& _file, unsigned long& _text) = 0; | 98 | virtual void sizes(unsigned long& _file, unsigned long& _text) = 0; |
98 | }; | 99 | }; |
99 | #endif | 100 | #endif |
100 | 101 | ||
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp index d7d538f..51c7fa7 100644 --- a/noncore/apps/opie-reader/plucker_base.cpp +++ b/noncore/apps/opie-reader/plucker_base.cpp | |||
@@ -1,57 +1,57 @@ | |||
1 | #include "usenef.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 /* USEQPE */ | 7 | #endif /* USEQPE */ |
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 | #endif /* USEQPE */ | 13 | #endif /* USEQPE */ |
15 | #include <qclipboard.h> | 14 | #include <qclipboard.h> |
16 | #ifndef USEQPE | 15 | #ifndef USEQPE |
17 | #include <qapplication.h> | 16 | #include <qapplication.h> |
18 | #else /* USEQPE */ | 17 | #else /* USEQPE */ |
19 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
20 | #endif /* USEQPE */ | 19 | #endif /* USEQPE */ |
21 | #include <qimage.h> | 20 | #include <qimage.h> |
22 | 21 | ||
23 | #include "plucker_base.h" | 22 | #include "plucker_base.h" |
24 | #include "Aportis.h" | 23 | #include "Aportis.h" |
25 | #include "hrule.h" | 24 | #include "hrule.h" |
26 | #include "util.h" | 25 | #include "decompress.h" |
27 | 26 | ||
28 | const UInt8 CPlucker_base::continuation_bit = 1; | 27 | const UInt8 CPlucker_base::continuation_bit = 1; |
29 | 28 | ||
30 | CPlucker_base::CPlucker_base() : | 29 | CPlucker_base::CPlucker_base() : |
31 | #ifdef LOCALPICTURES | 30 | #ifdef LOCALPICTURES |
32 | m_viewer(NULL), | 31 | m_viewer(NULL), |
33 | m_picture(NULL), | 32 | m_picture(NULL), |
34 | #endif | 33 | #endif |
35 | expandedtextbuffer(NULL), | 34 | expandedtextbuffer(NULL), |
36 | compressedtextbuffer(NULL), | 35 | compressedtextbuffer(NULL), |
37 | bufferrec(-1), | 36 | bufferrec(-1), |
38 | m_offset(0) | 37 | m_offset(0) |
39 | //, urls(NULL) | 38 | //, urls(NULL) |
40 | { /*printf("constructing:%x\n",fin);*/ } | 39 | { /*printf("constructing:%x\n",fin);*/ } |
41 | 40 | ||
42 | 41 | ||
43 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) | 42 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) |
44 | { | 43 | { |
45 | if (type%2 == 0) | 44 | unsuspend(); |
45 | if ((type%2 == 0) && (type != 14)) | ||
46 | { | 46 | { |
47 | fread(buffer, reclen, sizeof(char), fin); | 47 | fread(buffer, reclen, sizeof(char), fin); |
48 | } | 48 | } |
49 | else | 49 | else |
50 | { | 50 | { |
51 | UInt8* readbuffer = NULL; | 51 | UInt8* readbuffer = NULL; |
52 | if (reclen > compressedbuffersize) | 52 | if (reclen > compressedbuffersize) |
53 | { | 53 | { |
54 | readbuffer = new UInt8[reclen]; | 54 | readbuffer = new UInt8[reclen]; |
55 | } | 55 | } |
56 | else | 56 | else |
57 | { | 57 | { |
@@ -296,25 +296,25 @@ void CPlucker_base::locate(unsigned int n) | |||
296 | thisrec++; | 296 | thisrec++; |
297 | locpos += bs; | 297 | locpos += bs; |
298 | gotorecordnumber(thisrec); | 298 | gotorecordnumber(thisrec); |
299 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 299 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
300 | if (thishdr_type < 2) | 300 | if (thishdr_type < 2) |
301 | { | 301 | { |
302 | bs = thishdr_size; | 302 | bs = thishdr_size; |
303 | } | 303 | } |
304 | else | 304 | else |
305 | { | 305 | { |
306 | bs = 0; | 306 | bs = 0; |
307 | } | 307 | } |
308 | } while (locpos + bs <= n); | 308 | } while (locpos + bs < n); |
309 | 309 | ||
310 | // qDebug("Time(2): %u", clock()-start); | 310 | // qDebug("Time(2): %u", clock()-start); |
311 | /* | 311 | /* |
312 | if (recptr != thisrec) | 312 | if (recptr != thisrec) |
313 | { | 313 | { |
314 | qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); | 314 | qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); |
315 | UInt16 thishdr_uid, thishdr_nParagraphs; | 315 | UInt16 thishdr_uid, thishdr_nParagraphs; |
316 | UInt32 thishdr_size = buffercontent; | 316 | UInt32 thishdr_size = buffercontent; |
317 | UInt8 thishdr_type, thishdr_reserved; | 317 | UInt8 thishdr_type, thishdr_reserved; |
318 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 318 | for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
319 | { | 319 | { |
320 | gotorecordnumber(recptr); | 320 | gotorecordnumber(recptr); |
@@ -403,25 +403,25 @@ bool CPlucker_base::expand(int thisrec) | |||
403 | m_nextPara = m_ParaOffsets[0]; | 403 | m_nextPara = m_ParaOffsets[0]; |
404 | //qDebug("First offset = %u", m_nextPara); | 404 | //qDebug("First offset = %u", m_nextPara); |
405 | m_nextParaIndex = 0; | 405 | m_nextParaIndex = 0; |
406 | } | 406 | } |
407 | else | 407 | else |
408 | { | 408 | { |
409 | m_nextPara = -1; | 409 | m_nextPara = -1; |
410 | } | 410 | } |
411 | bufferpos = 0; | 411 | bufferpos = 0; |
412 | //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); | 412 | //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); |
413 | return true; | 413 | return true; |
414 | } | 414 | } |
415 | 415 | /* | |
416 | void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | 416 | void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) |
417 | { | 417 | { |
418 | z_stream zstream; | 418 | z_stream zstream; |
419 | memset(&zstream,sizeof(zstream),0); | 419 | memset(&zstream,sizeof(zstream),0); |
420 | zstream.next_in = compressedbuffer; | 420 | zstream.next_in = compressedbuffer; |
421 | zstream.next_out = tgtbuffer; | 421 | zstream.next_out = tgtbuffer; |
422 | zstream.avail_out = bsize; | 422 | zstream.avail_out = bsize; |
423 | zstream.avail_in = reclen; | 423 | zstream.avail_in = reclen; |
424 | 424 | ||
425 | int keylen = 0; | 425 | int keylen = 0; |
426 | 426 | ||
427 | zstream.zalloc = Z_NULL; | 427 | zstream.zalloc = Z_NULL; |
@@ -440,26 +440,26 @@ void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff | |||
440 | } | 440 | } |
441 | zstream.next_out = tgtbuffer; | 441 | zstream.next_out = tgtbuffer; |
442 | zstream.avail_out = bsize; | 442 | zstream.avail_out = bsize; |
443 | 443 | ||
444 | err = inflate( &zstream, Z_SYNC_FLUSH ); | 444 | err = inflate( &zstream, Z_SYNC_FLUSH ); |
445 | 445 | ||
446 | ////qDebug("err:%d - %u", err, zstream.avail_in); | 446 | ////qDebug("err:%d - %u", err, zstream.avail_in); |
447 | 447 | ||
448 | } while ( err == Z_OK ); | 448 | } while ( err == Z_OK ); |
449 | 449 | ||
450 | inflateEnd(&zstream); | 450 | inflateEnd(&zstream); |
451 | } | 451 | } |
452 | 452 | */ | |
453 | void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) | 453 | size_t CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) |
454 | { | 454 | { |
455 | // UInt16 headerSize; | 455 | // UInt16 headerSize; |
456 | UInt16 docSize; | 456 | UInt16 docSize; |
457 | UInt16 i; | 457 | UInt16 i; |
458 | UInt16 j; | 458 | UInt16 j; |
459 | UInt16 k; | 459 | UInt16 k; |
460 | 460 | ||
461 | UInt8 *inBuf = compressedbuffer; | 461 | UInt8 *inBuf = compressedbuffer; |
462 | UInt8 *outBuf = tgtbuffer; | 462 | UInt8 *outBuf = tgtbuffer; |
463 | 463 | ||
464 | // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph ); | 464 | // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph ); |
465 | docSize = reclen; | 465 | docSize = reclen; |
@@ -492,24 +492,25 @@ void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff | |||
492 | m = ( c & 0x3fff ) >> COUNT_BITS; | 492 | m = ( c & 0x3fff ) >> COUNT_BITS; |
493 | n = c & ( ( 1 << COUNT_BITS ) - 1 ); | 493 | n = c & ( ( 1 << COUNT_BITS ) - 1 ); |
494 | n += 2; | 494 | n += 2; |
495 | 495 | ||
496 | do { | 496 | do { |
497 | outBuf[ i ] = outBuf[ i - m ]; | 497 | outBuf[ i ] = outBuf[ i - m ]; |
498 | i++; | 498 | i++; |
499 | } while ( 0 < n-- ); | 499 | } while ( 0 < n-- ); |
500 | } | 500 | } |
501 | } | 501 | } |
502 | k += bsize; | 502 | k += bsize; |
503 | } | 503 | } |
504 | return i; | ||
504 | } | 505 | } |
505 | 506 | ||
506 | void CPlucker_base::home() | 507 | void CPlucker_base::home() |
507 | { | 508 | { |
508 | currentpos = 0; | 509 | currentpos = 0; |
509 | expand(1); | 510 | expand(1); |
510 | } | 511 | } |
511 | 512 | ||
512 | CList<Bkmk>* CPlucker_base::getbkmklist() | 513 | CList<Bkmk>* CPlucker_base::getbkmklist() |
513 | { | 514 | { |
514 | /* | 515 | /* |
515 | UInt16 thishdr_uid, thishdr_nParagraphs; | 516 | UInt16 thishdr_uid, thishdr_nParagraphs; |
@@ -1047,27 +1048,181 @@ linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& | |||
1047 | { | 1048 | { |
1048 | m_nextPara = -1; | 1049 | m_nextPara = -1; |
1049 | } | 1050 | } |
1050 | else | 1051 | else |
1051 | { | 1052 | { |
1052 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 1053 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
1053 | } | 1054 | } |
1054 | } | 1055 | } |
1055 | */ | 1056 | */ |
1056 | } | 1057 | } |
1057 | return eLink; | 1058 | return eLink; |
1058 | } | 1059 | } |
1060 | QString CPlucker_base::getTableAsHtml(unsigned long tgt) | ||
1061 | { | ||
1062 | qDebug("CPlucker_base::getTableAsHtml:%u", tgt); | ||
1063 | size_t reclen; | ||
1064 | UInt16 thisrec = finduid(tgt); | ||
1065 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); | ||
1066 | reclen = recordlength(thisrec); | ||
1067 | gotorecordnumber(thisrec); | ||
1068 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
1069 | UInt32 thishdr_size; | ||
1070 | UInt8 thishdr_type, thishdr_reserved; | ||
1071 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
1072 | qDebug("Found a table of type:%u", thishdr_type); | ||
1073 | reclen -= HeaderSize(); | ||
1074 | UInt32 imgsize = thishdr_size; | ||
1075 | UInt8* imgbuffer = new UInt8[imgsize]; | ||
1076 | Expand(reclen, thishdr_type, imgbuffer, imgsize); | ||
1077 | |||
1078 | QString ret; | ||
1079 | |||
1080 | UInt16 size, columns, rows; | ||
1081 | UInt8 depth, border; | ||
1082 | UInt32 borderColour, linkColour; | ||
1083 | UInt8* dp(imgbuffer); | ||
1084 | |||
1085 | memcpy(&size, dp, sizeof(size)); | ||
1086 | size = ntohs(size); | ||
1087 | dp += sizeof(size); | ||
1088 | memcpy(&columns, dp, sizeof(columns)); | ||
1089 | columns = ntohs(columns); | ||
1090 | dp += sizeof(columns); | ||
1091 | memcpy(&rows, dp, sizeof(rows)); | ||
1092 | rows = ntohs(rows); | ||
1093 | dp += sizeof(rows); | ||
1094 | qDebug("Rows:%u Cols:%u", rows, columns); | ||
1095 | |||
1096 | memcpy(&depth, dp, sizeof(depth)); | ||
1097 | dp += sizeof(depth); | ||
1098 | memcpy(&border, dp, sizeof(border)); | ||
1099 | dp += sizeof(border); | ||
1100 | |||
1101 | qDebug("Depth:%u, Border:%u", depth, border); | ||
1102 | |||
1103 | memcpy(&borderColour, dp, sizeof(borderColour)); | ||
1104 | dp += sizeof(borderColour); | ||
1105 | memcpy(&linkColour, dp, sizeof(linkColour)); | ||
1106 | dp += sizeof(linkColour); | ||
1107 | |||
1108 | qDebug("Colours: border:%x, link:%x", borderColour, linkColour); | ||
1109 | |||
1110 | if (border) | ||
1111 | { | ||
1112 | ret = "<table border>"; | ||
1113 | } | ||
1114 | else | ||
1115 | { | ||
1116 | ret = "<table>"; | ||
1117 | } | ||
1118 | bool firstrow = true; | ||
1119 | bool firstcol = true; | ||
1120 | while (dp < imgbuffer+imgsize) | ||
1121 | { | ||
1122 | UInt8 ch = *dp++; | ||
1123 | if (ch == 0x00) | ||
1124 | { | ||
1125 | ch = *dp++; | ||
1126 | if (ch == 0x90) | ||
1127 | { | ||
1128 | if (firstrow) | ||
1129 | { | ||
1130 | ret += "<tr>"; | ||
1131 | firstrow = false; | ||
1132 | firstcol = true; | ||
1133 | } | ||
1134 | else | ||
1135 | { | ||
1136 | ret += "</tr><tr>"; | ||
1137 | } | ||
1138 | } | ||
1139 | else if (ch == 0x97) | ||
1140 | { | ||
1141 | if (firstcol) | ||
1142 | { | ||
1143 | ret += "<td"; | ||
1144 | firstcol = false; | ||
1145 | } | ||
1146 | else | ||
1147 | { | ||
1148 | ret += "</td><td"; | ||
1149 | } | ||
1150 | UInt8 align; | ||
1151 | UInt16 imgid; | ||
1152 | UInt8 cols, rows; | ||
1153 | UInt16 len; | ||
1154 | memcpy(&align, dp, sizeof(align)); | ||
1155 | dp += sizeof(align); | ||
1156 | memcpy(&imgid, dp, sizeof(imgid)); | ||
1157 | dp += sizeof(imgid); | ||
1158 | imgid = ntohs(imgid); | ||
1159 | memcpy(&cols, dp, sizeof(cols)); | ||
1160 | dp += sizeof(cols); | ||
1161 | memcpy(&rows, dp, sizeof(rows)); | ||
1162 | dp += sizeof(rows); | ||
1163 | memcpy(&len, dp, sizeof(len)); | ||
1164 | dp += sizeof(len); | ||
1165 | len = ntohs(len); | ||
1166 | switch (align) | ||
1167 | { | ||
1168 | case 1: | ||
1169 | ret += " align=right"; | ||
1170 | break; | ||
1171 | case 2: | ||
1172 | ret += " align=center"; | ||
1173 | break; | ||
1174 | case 3: | ||
1175 | ret += " align=justify"; | ||
1176 | break; | ||
1177 | case 0: | ||
1178 | break; | ||
1179 | default: | ||
1180 | qDebug("Unknown table cell alignment:%u", align); | ||
1181 | } | ||
1182 | if (cols != 1) | ||
1183 | { | ||
1184 | QString num; | ||
1185 | num.setNum(cols); | ||
1186 | ret += " colspan="; | ||
1187 | ret += num; | ||
1188 | } | ||
1189 | if (rows != 1) | ||
1190 | { | ||
1191 | QString num; | ||
1192 | num.setNum(rows); | ||
1193 | ret += " rowspan="; | ||
1194 | ret += num; | ||
1195 | } | ||
1196 | ret += ">"; | ||
1197 | } | ||
1198 | else | ||
1199 | { | ||
1200 | dp += (ch & 7); | ||
1201 | } | ||
1202 | } | ||
1203 | else | ||
1204 | { | ||
1205 | ret += QChar(ch); | ||
1206 | } | ||
1207 | } | ||
1208 | |||
1209 | ret += "</td></tr></table>"; | ||
1210 | delete [] imgbuffer; | ||
1211 | return ret; | ||
1212 | } | ||
1059 | 1213 | ||
1060 | tchar CPlucker_base::getch_base(bool fast) | 1214 | tchar CPlucker_base::getch_base(bool fast) |
1061 | { | 1215 | { |
1216 | mystyle.setTable(0xffffffff); | ||
1062 | int ch = bgetch(); | 1217 | int ch = bgetch(); |
1063 | while (ch == 0) | 1218 | while (ch == 0) |
1064 | { | 1219 | { |
1065 | ch = bgetch(); | 1220 | ch = bgetch(); |
1066 | ////qDebug("Function:%x", ch); | 1221 | ////qDebug("Function:%x", ch); |
1067 | switch (ch) | 1222 | switch (ch) |
1068 | { | 1223 | { |
1069 | case 0x38: | 1224 | case 0x38: |
1070 | // //qDebug("Break:%u", locate()); | 1225 | // //qDebug("Break:%u", locate()); |
1071 | if (m_lastBreak == locate()) | 1226 | if (m_lastBreak == locate()) |
1072 | { | 1227 | { |
1073 | ch = bgetch(); | 1228 | ch = bgetch(); |
@@ -1110,28 +1265,24 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1110 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 1265 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
1111 | { | 1266 | { |
1112 | if (*it == ln) | 1267 | if (*it == ln) |
1113 | { | 1268 | { |
1114 | hasseen = true; | 1269 | hasseen = true; |
1115 | break; | 1270 | break; |
1116 | } | 1271 | } |
1117 | } | 1272 | } |
1118 | if (hasseen) | 1273 | if (hasseen) |
1119 | { | 1274 | { |
1120 | mystyle.setStrikethru(); | 1275 | mystyle.setStrikethru(); |
1121 | } | 1276 | } |
1122 | else | ||
1123 | { | ||
1124 | mystyle.setUnderline(); | ||
1125 | } | ||
1126 | mystyle.setOffset(m_offset); | 1277 | mystyle.setOffset(m_offset); |
1127 | m_offset = 0; | 1278 | m_offset = 0; |
1128 | ch = bgetch(); | 1279 | ch = bgetch(); |
1129 | } | 1280 | } |
1130 | break; | 1281 | break; |
1131 | case 0x08: | 1282 | case 0x08: |
1132 | ch = bgetch(); | 1283 | ch = bgetch(); |
1133 | // mystyle.setColour(0, 0, 0); | 1284 | // mystyle.setColour(0, 0, 0); |
1134 | mystyle.unsetUnderline(); | 1285 | mystyle.unsetUnderline(); |
1135 | mystyle.unsetStrikethru(); | 1286 | mystyle.unsetStrikethru(); |
1136 | mystyle.setLink(false); | 1287 | mystyle.setLink(false); |
1137 | mystyle.setData(0); | 1288 | mystyle.setData(0); |
@@ -1320,24 +1471,33 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1320 | for (int i = 0; i < tlen; i++) bgetch(); | 1471 | for (int i = 0; i < tlen; i++) bgetch(); |
1321 | //qDebug("Function 83"); | 1472 | //qDebug("Function 83"); |
1322 | } | 1473 | } |
1323 | break; | 1474 | break; |
1324 | case 0x9a: | 1475 | case 0x9a: |
1325 | { | 1476 | { |
1326 | m_offset = 255*bgetch(); | 1477 | m_offset = 255*bgetch(); |
1327 | m_offset += bgetch(); | 1478 | m_offset += bgetch(); |
1328 | qDebug("Found offset:%u", m_offset); | 1479 | qDebug("Found offset:%u", m_offset); |
1329 | ch = bgetch(); | 1480 | ch = bgetch(); |
1330 | } | 1481 | } |
1331 | break; | 1482 | break; |
1483 | case 0x92: | ||
1484 | { | ||
1485 | ch = bgetch(); | ||
1486 | ch <<= 8; | ||
1487 | ch |= (tchar)bgetch(); | ||
1488 | mystyle.setTable(ch); | ||
1489 | ch = 0x16e5; | ||
1490 | } | ||
1491 | break; | ||
1332 | case 0x85: | 1492 | case 0x85: |
1333 | default: | 1493 | default: |
1334 | qDebug("Function:%x NOT IMPLEMENTED", ch); | 1494 | qDebug("Function:%x NOT IMPLEMENTED", ch); |
1335 | { | 1495 | { |
1336 | int skip = ch & 7; | 1496 | int skip = ch & 7; |
1337 | for (int i = 0; i < skip; i++) | 1497 | for (int i = 0; i < skip; i++) |
1338 | { | 1498 | { |
1339 | ch = bgetch(); | 1499 | ch = bgetch(); |
1340 | //qDebug("Arg %d, %d", i, ch); | 1500 | //qDebug("Arg %d, %d", i, ch); |
1341 | } | 1501 | } |
1342 | ch = bgetch(); | 1502 | ch = bgetch(); |
1343 | } | 1503 | } |
@@ -1348,61 +1508,21 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1348 | { | 1508 | { |
1349 | while (ch == ' ') | 1509 | while (ch == ' ') |
1350 | { | 1510 | { |
1351 | ch = getch(false); | 1511 | ch = getch(false); |
1352 | } | 1512 | } |
1353 | } | 1513 | } |
1354 | 1514 | ||
1355 | m_lastIsBreak = (ch == 10); | 1515 | m_lastIsBreak = (ch == 10); |
1356 | 1516 | ||
1357 | return (ch == EOF) ? UEOF : ch; | 1517 | return (ch == EOF) ? UEOF : ch; |
1358 | } | 1518 | } |
1359 | 1519 | ||
1360 | #if defined(__STATIC) && defined(USENEF) | ||
1361 | #include "Model.h" | ||
1362 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | ||
1363 | { | ||
1364 | if (_s == "PluckerDecompress3") | ||
1365 | { | ||
1366 | return PluckerDecompress3; | ||
1367 | } | ||
1368 | if (_s == "PluckerDecompress4") | ||
1369 | { | ||
1370 | return PluckerDecompress4; | ||
1371 | } | ||
1372 | return NULL; | ||
1373 | } | ||
1374 | #else | ||
1375 | |||
1376 | #include "qfileinfo.h" | ||
1377 | |||
1378 | #include <dlfcn.h> | ||
1379 | |||
1380 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | ||
1381 | { | ||
1382 | QString codecpath(QTReaderUtil::getPluginPath("support")); | ||
1383 | codecpath += "/libpluckerdecompress.so"; | ||
1384 | qDebug("Codec:%s", (const char*)codecpath); | ||
1385 | if (QFile::exists(codecpath)) | ||
1386 | { | ||
1387 | qDebug("Codec:%s", (const char*)codecpath); | ||
1388 | void* handle = dlopen(codecpath, RTLD_LAZY); | ||
1389 | if (handle == 0) | ||
1390 | { | ||
1391 | qDebug("Can't find codec:%s", dlerror()); | ||
1392 | return NULL; | ||
1393 | } | ||
1394 | return (void (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); | ||
1395 | } | ||
1396 | return NULL; | ||
1397 | } | ||
1398 | #endif | ||
1399 | |||
1400 | QString CPlucker_base::about() | 1520 | QString CPlucker_base::about() |
1401 | { | 1521 | { |
1402 | QString abt = "Plucker base codec (c) Tim Wentford"; | 1522 | QString abt = "Plucker base codec (c) Tim Wentford"; |
1403 | if (m_decompress != UnDoc && m_decompress != UnZip) | 1523 | if (m_decompress != UnDoc && m_decompress != UnZip) |
1404 | { | 1524 | { |
1405 | abt += "\nSpecial decompression (c) Tim Wentford"; | 1525 | abt += "\nSpecial decompression (c) Tim Wentford (ppmd by Dmitry Shkarin"; |
1406 | } | 1526 | } |
1407 | return abt; | 1527 | return abt; |
1408 | } | 1528 | } |
diff --git a/noncore/apps/opie-reader/plucker_base.h b/noncore/apps/opie-reader/plucker_base.h index 8d74cc2..2b57986 100644 --- a/noncore/apps/opie-reader/plucker_base.h +++ b/noncore/apps/opie-reader/plucker_base.h | |||
@@ -57,29 +57,29 @@ protected: | |||
57 | UInt32 compressedbuffersize; | 57 | UInt32 compressedbuffersize; |
58 | UInt32 buffercontent; | 58 | UInt32 buffercontent; |
59 | UInt8* expandedtextbuffer; | 59 | UInt8* expandedtextbuffer; |
60 | UInt8* compressedtextbuffer; | 60 | UInt8* compressedtextbuffer; |
61 | // char* urls; | 61 | // char* urls; |
62 | // size_t urlsize; | 62 | // size_t urlsize; |
63 | size_t bufferpos; | 63 | size_t bufferpos; |
64 | int bufferrec; | 64 | int bufferrec; |
65 | CPlucker_record0 hdr0; | 65 | CPlucker_record0 hdr0; |
66 | bool m_bufferisreserved; | 66 | bool m_bufferisreserved; |
67 | size_t currentpos; | 67 | size_t currentpos; |
68 | bool expand(int); | 68 | bool expand(int); |
69 | static void UnZip(UInt8*, size_t, UInt8*, size_t); | 69 | //static void UnZip(UInt8*, size_t, UInt8*, size_t); |
70 | static void UnDoc(UInt8*, size_t, UInt8*, size_t); | 70 | static size_t UnDoc(UInt8*, size_t, UInt8*, size_t); |
71 | |||
72 | size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
71 | 73 | ||
72 | void (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
73 | void (*getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t); | ||
74 | #ifdef LOCALPICTURES | 74 | #ifdef LOCALPICTURES |
75 | void showimg(UInt16 tgt); | 75 | void showimg(UInt16 tgt); |
76 | #endif | 76 | #endif |
77 | QImage* getimg(UInt16 tgt); | 77 | QImage* getimg(UInt16 tgt); |
78 | QImage* expandimg(UInt16 tgt, bool border=false); | 78 | QImage* expandimg(UInt16 tgt, bool border=false); |
79 | void home(); | 79 | void home(); |
80 | virtual int bgetch() = 0; | 80 | virtual int bgetch() = 0; |
81 | CNavigation m_nav; | 81 | CNavigation m_nav; |
82 | public: | 82 | public: |
83 | QString about(); | 83 | QString about(); |
84 | QImage* getPicture(unsigned long tgt); | 84 | QImage* getPicture(unsigned long tgt); |
85 | void sizes(unsigned long& _file, unsigned long& _text); | 85 | void sizes(unsigned long& _file, unsigned long& _text); |
@@ -101,15 +101,16 @@ protected: | |||
101 | } | 101 | } |
102 | void saveposn(size_t posn) { m_nav.saveposn(posn); } | 102 | void saveposn(size_t posn) { m_nav.saveposn(posn); } |
103 | void writeposn(size_t posn) { m_nav.writeposn(posn); } | 103 | void writeposn(size_t posn) { m_nav.writeposn(posn); } |
104 | linkType forward(size_t& loc) { return (m_nav.forward(loc)) ? eLink : eNone; } | 104 | linkType forward(size_t& loc) { return (m_nav.forward(loc)) ? eLink : eNone; } |
105 | linkType back(size_t& loc) { return (m_nav.back(loc)) ? eLink : eNone; } | 105 | linkType back(size_t& loc) { return (m_nav.back(loc)) ? eLink : eNone; } |
106 | bool hasnavigation() { return true; } | 106 | bool hasnavigation() { return true; } |
107 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); | 107 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); |
108 | void putSaveData(unsigned char*& src, unsigned short& srclen); | 108 | void putSaveData(unsigned char*& src, unsigned short& srclen); |
109 | 109 | ||
110 | virtual bool CorrectDecoder() = 0; | 110 | virtual bool CorrectDecoder() = 0; |
111 | // virtual void setlink(QString&, const QString&) = 0; | 111 | // virtual void setlink(QString&, const QString&) = 0; |
112 | virtual QImage* imagefromdata(UInt8*, UInt32) = 0; | 112 | virtual QImage* imagefromdata(UInt8*, UInt32) = 0; |
113 | QString getTableAsHtml(unsigned long loc); | ||
113 | }; | 114 | }; |
114 | 115 | ||
115 | #endif | 116 | #endif |
diff --git a/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro b/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro index a66dc44..0212d84 100644 --- a/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro +++ b/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro | |||
@@ -1,18 +1,19 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = 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 | decompress.cpp | ||
9 | 10 | ||
10 | INTERFACES= | 11 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/lib | 12 | DESTDIR = $(OPIEDIR)/lib |
12 | TARGET = reader_pluckerbase | 13 | TARGET = reader_pluckerbase |
13 | LIBS += -ldl | 14 | LIBS += -ldl |
14 | 15 | ||
15 | INCLUDEPATH+= $(OPIEDIR)/include | 16 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= $(OPIEDIR)/include | 17 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 18 | ||
18 | include( $(OPIEDIR)/include.pro ) | 19 | include( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/pluckerdecompress/.cvsignore b/noncore/apps/opie-reader/pluckerdecompress/.cvsignore new file mode 100644 index 0000000..1810ee0 --- a/dev/null +++ b/noncore/apps/opie-reader/pluckerdecompress/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | config.in | ||
3 | moc_* | ||
4 | .moc | ||
5 | .obj | ||
diff --git a/noncore/apps/opie-reader/pluckerdecompress/pluckerdecompress.pro b/noncore/apps/opie-reader/pluckerdecompress/pluckerdecompress.pro new file mode 100644 index 0000000..c1b7686 --- a/dev/null +++ b/noncore/apps/opie-reader/pluckerdecompress/pluckerdecompress.pro | |||
@@ -0,0 +1,17 @@ | |||
1 | DEFINES += OPIE USEQPE | ||
2 | VPATH = .. | ||
3 | TEMPLATE= lib | ||
4 | CONFIG = qt warn_on release dll | ||
5 | HEADERS = CSource.h Model.h Coder.h SubAlloc.h | ||
6 | |||
7 | SOURCES = Model.cpp | ||
8 | |||
9 | |||
10 | INTERFACES= | ||
11 | DESTDIR = $(OPIEDIR)/plugins/reader/support | ||
12 | TARGET = pluckerdecompress | ||
13 | |||
14 | INCLUDEPATH+= $(OPIEDIR)/include | ||
15 | DEPENDPATH += $(OPIEDIR)/include | ||
16 | |||
17 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/apps/opie-reader/ppm_expander.cpp b/noncore/apps/opie-reader/ppm_expander.cpp index 2a4318b..61ef90e 100644 --- a/noncore/apps/opie-reader/ppm_expander.cpp +++ b/noncore/apps/opie-reader/ppm_expander.cpp | |||
@@ -29,25 +29,25 @@ char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; | |||
29 | ppm_expander::~ppm_expander() { | 29 | ppm_expander::~ppm_expander() { |
30 | if (needppmend) ppm.PPM_End(); | 30 | if (needppmend) ppm.PPM_End(); |
31 | ppm.arith.Arith_DecodeEnd(); | 31 | ppm.arith.Arith_DecodeEnd(); |
32 | if (buf_in!=NULL) delete [] buf_in; | 32 | if (buf_in!=NULL) delete [] buf_in; |
33 | if (buf_out!=NULL) delete [] buf_out; | 33 | if (buf_out!=NULL) delete [] buf_out; |
34 | if (my_read_buf != NULL) delete my_read_buf; | 34 | if (my_read_buf != NULL) delete my_read_buf; |
35 | if (my_file_in != NULL) fclose(my_file_in); | 35 | if (my_file_in != NULL) fclose(my_file_in); |
36 | } | 36 | } |
37 | 37 | ||
38 | int ppm_expander::OpenFile(const char* infile) | 38 | int ppm_expander::OpenFile(const char* infile) |
39 | { | 39 | { |
40 | my_file_in=fopen(infile,"rb"); | 40 | my_file_in=fopen(infile,"rb"); |
41 | my_read_buf = new PPM_ReadBuf(my_file_in); | 41 | my_read_buf = new PPM_ReadBuf(my_file_in, this); |
42 | return home(); | 42 | return home(); |
43 | } | 43 | } |
44 | 44 | ||
45 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) | 45 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) |
46 | { | 46 | { |
47 | struct stat _stat; | 47 | struct stat _stat; |
48 | fstat(fileno(my_file_in),&_stat); | 48 | fstat(fileno(my_file_in),&_stat); |
49 | file = _stat.st_size; | 49 | file = _stat.st_size; |
50 | text = numblocks*blocksize; | 50 | text = numblocks*blocksize; |
51 | } | 51 | } |
52 | 52 | ||
53 | int ppm_expander::home() | 53 | int ppm_expander::home() |
@@ -98,18 +98,27 @@ int ppm_expander::getch() { | |||
98 | if (curblock >= numblocks) return EOF; | 98 | if (curblock >= numblocks) return EOF; |
99 | int c=ppm.PPM_Decode(); | 99 | int c=ppm.PPM_Decode(); |
100 | if (c == SYM_EOF) | 100 | if (c == SYM_EOF) |
101 | { | 101 | { |
102 | if (++curblock >= numblocks) return EOF; | 102 | if (++curblock >= numblocks) return EOF; |
103 | locate(curblock,0); | 103 | locate(curblock,0); |
104 | c = ppm.PPM_Decode(); | 104 | c = ppm.PPM_Decode(); |
105 | } | 105 | } |
106 | outbytes++; | 106 | outbytes++; |
107 | return (c==SYM_EOF) ? EOF : c; | 107 | return (c==SYM_EOF) ? EOF : c; |
108 | } | 108 | } |
109 | 109 | ||
110 | UINT PPM_ReadBuf::readbuf(UCHAR *buf,UINT len) | ||
111 | { | ||
112 | UINT len1; | ||
113 | parent->unsuspend(); | ||
114 | len1=fread(buf,1,len,my_file_in); | ||
115 | return len1; | ||
116 | } | ||
117 | |||
118 | |||
110 | #ifndef __STATIC | 119 | #ifndef __STATIC |
111 | extern "C" | 120 | extern "C" |
112 | { | 121 | { |
113 | CExpander* newcodec() { return new ppm_expander; } | 122 | CExpander* newcodec() { return new ppm_expander; } |
114 | } | 123 | } |
115 | #endif | 124 | #endif |
diff --git a/noncore/apps/opie-reader/ppm_expander.h b/noncore/apps/opie-reader/ppm_expander.h index ccc89c2..c5f8a17 100644 --- a/noncore/apps/opie-reader/ppm_expander.h +++ b/noncore/apps/opie-reader/ppm_expander.h | |||
@@ -1,23 +1,23 @@ | |||
1 | #ifndef __ppm_expander_h | 1 | #ifndef __ppm_expander_h |
2 | #define __ppm_expander_h | 2 | #define __ppm_expander_h |
3 | 3 | ||
4 | #include "CExpander.h" | 4 | #include "CExpander.h" |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | 6 | ||
7 | 7 | ||
8 | #include "utypes.h" | 8 | #include "utypes.h" |
9 | #include "ppm.h" | 9 | #include "ppm.h" |
10 | #include "arith.h" | ||
11 | 10 | ||
11 | class PPM_ReadBuf; | ||
12 | 12 | ||
13 | #define SYM_EOF 256 | 13 | #define SYM_EOF 256 |
14 | 14 | ||
15 | class ppm_expander : public CExpander { | 15 | class ppm_expander : public CExpander { |
16 | UCHAR *buf_in,*buf_out; | 16 | UCHAR *buf_in,*buf_out; |
17 | unsigned int bufsize; | 17 | unsigned int bufsize; |
18 | unsigned int outbytes; | 18 | unsigned int outbytes; |
19 | unsigned long blocksize; | 19 | unsigned long blocksize; |
20 | unsigned short numblocks; | 20 | unsigned short numblocks; |
21 | unsigned short curblock; | 21 | unsigned short curblock; |
22 | unsigned short maxnode; | 22 | unsigned short maxnode; |
23 | bool needppmend; | 23 | bool needppmend; |
@@ -27,24 +27,27 @@ class ppm_expander : public CExpander { | |||
27 | ppm_worker ppm; | 27 | ppm_worker ppm; |
28 | public: | 28 | public: |
29 | 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"); } |
30 | #ifdef USEQPE | 30 | #ifdef USEQPE |
31 | void suspend() | 31 | void suspend() |
32 | { | 32 | { |
33 | CExpander::suspend(my_file_in); | 33 | CExpander::suspend(my_file_in); |
34 | } | 34 | } |
35 | void unsuspend() | 35 | void unsuspend() |
36 | { | 36 | { |
37 | CExpander::unsuspend(my_file_in); | 37 | CExpander::unsuspend(my_file_in); |
38 | } | 38 | } |
39 | #else | ||
40 | void suspend() {} | ||
41 | void unsuspend() {} | ||
39 | #endif | 42 | #endif |
40 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) | 43 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) |
41 | { | 44 | { |
42 | bufsize = 1024; | 45 | bufsize = 1024; |
43 | buf_in = new UCHAR[bufsize]; | 46 | buf_in = new UCHAR[bufsize]; |
44 | buf_out = new UCHAR[bufsize]; | 47 | buf_out = new UCHAR[bufsize]; |
45 | outbytes = 0; | 48 | outbytes = 0; |
46 | } | 49 | } |
47 | int OpenFile(const char* infile); | 50 | int OpenFile(const char* infile); |
48 | int getch(); | 51 | int getch(); |
49 | void locate(unsigned short block, unsigned int n); | 52 | void locate(unsigned short block, unsigned int n); |
50 | virtual ~ppm_expander(); | 53 | virtual ~ppm_expander(); |
diff --git a/noncore/apps/opie-reader/preferences.cpp b/noncore/apps/opie-reader/preferences.cpp index 0f59a22..67960ed 100755 --- a/noncore/apps/opie-reader/preferences.cpp +++ b/noncore/apps/opie-reader/preferences.cpp | |||
@@ -1,12 +1,13 @@ | |||
1 | |||
1 | #ifndef USEQPE | 2 | #ifndef USEQPE |
2 | 3 | ||
3 | #include "preferences.h" | 4 | #include "preferences.h" |
4 | 5 | ||
5 | #include <qfile.h> | 6 | #include <qfile.h> |
6 | #include <qtextstream.h> | 7 | #include <qtextstream.h> |
7 | 8 | ||
8 | Config::Config(const QString& _fn) : fname(_fn) | 9 | Config::Config(const QString& _fn) : fname(_fn) |
9 | { | 10 | { |
10 | // qDebug("Config::Config:%s", (const char*)fname); | 11 | // qDebug("Config::Config:%s", (const char*)fname); |
11 | QFile fl(fname); | 12 | QFile fl(fname); |
12 | if (fl.open(IO_ReadOnly)) | 13 | if (fl.open(IO_ReadOnly)) |
diff --git a/noncore/apps/opie-reader/preferences.h b/noncore/apps/opie-reader/preferences.h index aeb2a84..39959d4 100644 --- a/noncore/apps/opie-reader/preferences.h +++ b/noncore/apps/opie-reader/preferences.h | |||
@@ -1,26 +1,26 @@ | |||
1 | #ifndef USEQPE | 1 | #ifndef USEQPE |
2 | #ifndef __PREFERENCES_H | 2 | #ifndef __PREFERENCES_H |
3 | #define __PREFERENCES_H | 3 | #define __PREFERENCES_H |
4 | 4 | ||
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | 7 | ||
8 | class Config | 8 | class Config |
9 | { | 9 | { |
10 | QMap<QString, QString> values; | 10 | QMap<QString, QString> values; |
11 | QString fname; | 11 | QString fname; |
12 | public: | 12 | public: |
13 | Config(const QString& fname); | 13 | Config(const QString& fname); |
14 | ~Config(); | 14 | ~Config(); |
15 | void setGroup(const QString& s) { } | 15 | void setGroup(const QString& s) { } |
16 | QString readEntry(const QString&, const QString&); | 16 | QString readEntry(const QString&, const QString&); |
17 | bool readBoolEntry(const QString&, const bool); | 17 | bool readBoolEntry(const QString&, const bool); |
18 | int readNumEntry(const QString&, const int); | 18 | int readNumEntry(const QString&, const int); |
19 | 19 | ||
20 | void writeEntry(const QString&, const QString&); | 20 | void writeEntry(const QString&, const QString&); |
21 | void writeEntry(const QString&, const bool); | 21 | void writeEntry(const QString&, const bool); |
22 | void writeEntry(const QString&, const int); | 22 | void writeEntry(const QString&, const int); |
23 | }; | 23 | }; |
24 | 24 | ||
25 | #endif // PREFERENCES | 25 | #endif // PREFERENCES |
26 | #endif | 26 | #endif |
diff --git a/noncore/apps/opie-reader/reader.staticpro b/noncore/apps/opie-reader/reader.staticpro deleted file mode 100644 index 78ea8fb..0000000 --- a/noncore/apps/opie-reader/reader.staticpro +++ b/dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_off debug | ||
3 | HEADERS = Aportis.h \ | ||
4 | Bkmks.h \ | ||
5 | BuffDoc.h \ | ||
6 | ButtonPrefs.h \ | ||
7 | CAnnoEdit.h \ | ||
8 | CBuffer.h \ | ||
9 | CDrawBuffer.h \ | ||
10 | CEncoding.h \ | ||
11 | CEncoding_tables.h \ | ||
12 | CExpander.h \ | ||
13 | CFilter.h \ | ||
14 | CloseDialog.h \ | ||
15 | Filedata.h \ | ||
16 | FixedFont.h \ | ||
17 | FontControl.h \ | ||
18 | GraphicWin.h \ | ||
19 | Markups.h \ | ||
20 | Navigation.h \ | ||
21 | Palm2QImage.h \ | ||
22 | Prefs.h \ | ||
23 | QFloatBar.h \ | ||
24 | QTReader.h \ | ||
25 | QTReaderApp.h \ | ||
26 | QtrListView.h \ | ||
27 | Queue.h \ | ||
28 | StyleConsts.h \ | ||
29 | ToolbarPrefs.h \ | ||
30 | URLDialog.h \ | ||
31 | ZText.h \ | ||
32 | arith.h \ | ||
33 | cbkmkselector.h \ | ||
34 | config.h \ | ||
35 | fileBrowser.h \ | ||
36 | infowin.h \ | ||
37 | linktype.h \ | ||
38 | my_list.h \ | ||
39 | names.h \ | ||
40 | QSTATICREADERINC/opie.h \ | ||
41 | pdb.h \ | ||
42 | plucker_base.h \ | ||
43 | plucker.h \ | ||
44 | ppm.h \ | ||
45 | ppm_expander.h \ | ||
46 | preferences.h \ | ||
47 | QSTATICREADERINC/static.h \ | ||
48 | usenef.h \ | ||
49 | QSTATICREADERINC/useqpe.h \ | ||
50 | ustring.h \ | ||
51 | utypes.h \ | ||
52 | version.h \ | ||
53 | ztxt.h | ||
54 | |||
55 | SOURCES = Aportis.cpp \ | ||
56 | Bkmks.cpp \ | ||
57 | BuffDoc.cpp \ | ||
58 | ButtonPrefs.cpp \ | ||
59 | CAnnoEdit.cpp \ | ||
60 | CBuffer.cpp \ | ||
61 | CDrawBuffer.cpp \ | ||
62 | CEncoding.cpp \ | ||
63 | CEncoding_tables.cpp \ | ||
64 | CExpander.cpp \ | ||
65 | CFilter.cpp \ | ||
66 | CHM.cpp \ | ||
67 | CRegExp.cpp \ | ||
68 | CloseDialog.cpp \ | ||
69 | FontControl.cpp \ | ||
70 | GraphicWin.cpp \ | ||
71 | Navigation.cpp \ | ||
72 | Palm2QImage.cpp \ | ||
73 | Prefs.cpp \ | ||
74 | QTReader.cpp \ | ||
75 | QTReaderApp.cpp \ | ||
76 | QtrListView.cpp \ | ||
77 | StyleConsts.cpp \ | ||
78 | ToolbarPrefs.cpp \ | ||
79 | URLDialog.cpp \ | ||
80 | arith_d.cpp \ | ||
81 | chm_lib.c \ | ||
82 | fileBrowser.cpp \ | ||
83 | hrule.cpp \ | ||
84 | infowin.cpp \ | ||
85 | iSilo.cpp \ | ||
86 | lzx.c \ | ||
87 | main.cpp \ | ||
88 | orkey.cpp \ | ||
89 | pdb.cpp \ | ||
90 | plucker.cpp \ | ||
91 | plucker_base.cpp \ | ||
92 | ppm.cpp \ | ||
93 | ppm_expander.cpp \ | ||
94 | preferences.cpp \ | ||
95 | striphtml.cpp \ | ||
96 | util.cpp \ | ||
97 | version.cpp \ | ||
98 | ztxt.cpp | ||
99 | |||
100 | INTERFACES= | ||
101 | DESTDIR = QSTATICREADEROBJS | ||
102 | INCLUDEPATH+= QSTATICREADERINC | ||
103 | DEPENDPATH+= QSTATICREADERINC | ||
104 | OBJECTS_DIR = QSTATICREADEROBJS | ||
105 | MOC_DIR = QSTATICREADERMOCS | ||
106 | TARGET = uqtreader | ||
107 | #LIBS += -lqpe | ||
108 | |||
diff --git a/noncore/apps/opie-reader/reader.staticzpro b/noncore/apps/opie-reader/reader.staticzpro deleted file mode 100644 index 861eb88..0000000 --- a/noncore/apps/opie-reader/reader.staticzpro +++ b/dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on release | ||
3 | HEADERS = Aportis.h \ | ||
4 | Bkmks.h \ | ||
5 | BuffDoc.h \ | ||
6 | ButtonPrefs.h \ | ||
7 | CAnnoEdit.h \ | ||
8 | CBuffer.h \ | ||
9 | CDrawBuffer.h \ | ||
10 | CEncoding.h \ | ||
11 | CEncoding_tables.h \ | ||
12 | CExpander.h \ | ||
13 | CFilter.h \ | ||
14 | CloseDialog.h \ | ||
15 | Filedata.h \ | ||
16 | FixedFont.h \ | ||
17 | FontControl.h \ | ||
18 | GraphicWin.h \ | ||
19 | Markups.h \ | ||
20 | Navigation.h \ | ||
21 | Palm2QImage.h \ | ||
22 | Prefs.h \ | ||
23 | QFloatBar.h \ | ||
24 | QTReader.h \ | ||
25 | QTReaderApp.h \ | ||
26 | QtrListView.h \ | ||
27 | Queue.h \ | ||
28 | StateData.h \ | ||
29 | StyleConsts.h \ | ||
30 | ToolbarPrefs.h \ | ||
31 | URLDialog.h \ | ||
32 | ZText.h \ | ||
33 | arith.h \ | ||
34 | cbkmkselector.h \ | ||
35 | config.h \ | ||
36 | fileBrowser.h \ | ||
37 | infowin.h \ | ||
38 | linktype.h \ | ||
39 | my_list.h \ | ||
40 | names.h \ | ||
41 | ZSTATICREADERINC/opie.h \ | ||
42 | pdb.h \ | ||
43 | plucker_base.h \ | ||
44 | plucker.h \ | ||
45 | ppm.h \ | ||
46 | ppm_expander.h \ | ||
47 | preferences.h \ | ||
48 | ZSTATICREADERINC/static.h \ | ||
49 | usenef.h \ | ||
50 | ZSTATICREADERINC/useqpe.h \ | ||
51 | ustring.h \ | ||
52 | utypes.h \ | ||
53 | version.h \ | ||
54 | ztxt.h | ||
55 | |||
56 | SOURCES = Aportis.cpp \ | ||
57 | Bkmks.cpp \ | ||
58 | BuffDoc.cpp \ | ||
59 | ButtonPrefs.cpp \ | ||
60 | CAnnoEdit.cpp \ | ||
61 | CBuffer.cpp \ | ||
62 | CDrawBuffer.cpp \ | ||
63 | CEncoding.cpp \ | ||
64 | CEncoding_tables.cpp \ | ||
65 | CExpander.cpp \ | ||
66 | CFilter.cpp \ | ||
67 | CHM.cpp \ | ||
68 | CRegExp.cpp \ | ||
69 | CloseDialog.cpp \ | ||
70 | FontControl.cpp \ | ||
71 | GraphicWin.cpp \ | ||
72 | Navigation.cpp \ | ||
73 | Palm2QImage.cpp \ | ||
74 | Prefs.cpp \ | ||
75 | QTReader.cpp \ | ||
76 | QTReaderApp.cpp \ | ||
77 | QtrListView.cpp \ | ||
78 | StyleConsts.cpp \ | ||
79 | ToolbarPrefs.cpp \ | ||
80 | URLDialog.cpp \ | ||
81 | arith_d.cpp \ | ||
82 | chm_lib.c \ | ||
83 | fileBrowser.cpp \ | ||
84 | hrule.cpp \ | ||
85 | infowin.cpp \ | ||
86 | iSilo.cpp \ | ||
87 | lzx.c \ | ||
88 | main.cpp \ | ||
89 | orkey.cpp \ | ||
90 | pdb.cpp \ | ||
91 | plucker.cpp \ | ||
92 | plucker_base.cpp \ | ||
93 | ppm.cpp \ | ||
94 | ppm_expander.cpp \ | ||
95 | striphtml.cpp \ | ||
96 | util.cpp \ | ||
97 | version.cpp \ | ||
98 | ztxt.cpp | ||
99 | |||
100 | INTERFACES= | ||
101 | DESTDIR = ZSTATICREADEROBJS | ||
102 | INCLUDEPATH+= ZSTATICREADERINC | ||
103 | DEPENDPATH+= ZSTATICREADERINC | ||
104 | OBJECTS_DIR = ZSTATICREADEROBJS | ||
105 | MOC_DIR = ZSTATICREADERMOCS | ||
106 | TARGET = uqtreader | ||
107 | LIBS += -lqpe | ||
108 | |||
diff --git a/noncore/apps/opie-reader/reader/reader.pro b/noncore/apps/opie-reader/reader/reader.pro index 6349ea7..dc6a5dd 100644 --- a/noncore/apps/opie-reader/reader/reader.pro +++ b/noncore/apps/opie-reader/reader/reader.pro | |||
@@ -21,62 +21,63 @@ HEADERS = Aportis.h \ | |||
21 | Markups.h \ | 21 | Markups.h \ |
22 | Navigation.h \ | 22 | Navigation.h \ |
23 | Palm2QImage.h \ | 23 | Palm2QImage.h \ |
24 | Prefs.h \ | 24 | Prefs.h \ |
25 | PPMd.h \ | 25 | PPMd.h \ |
26 | PPMdType.h \ | 26 | PPMdType.h \ |
27 | QFloatBar.h \ | 27 | QFloatBar.h \ |
28 | QTReader.h \ | 28 | QTReader.h \ |
29 | QTReaderApp.h \ | 29 | QTReaderApp.h \ |
30 | QtrListView.h \ | 30 | QtrListView.h \ |
31 | Queue.h \ | 31 | Queue.h \ |
32 | StyleConsts.h \ | 32 | StyleConsts.h \ |
33 | TableDialog.h \ | ||
33 | ToolbarPrefs.h \ | 34 | ToolbarPrefs.h \ |
34 | URLDialog.h \ | 35 | URLDialog.h \ |
35 | ZText.h \ | 36 | ZText.h \ |
36 | arith.h \ | 37 | arith.h \ |
37 | cbkmkselector.h \ | 38 | cbkmkselector.h \ |
38 | config.h \ | 39 | config.h \ |
39 | fileBrowser.h \ | 40 | fileBrowser.h \ |
40 | infowin.h \ | 41 | infowin.h \ |
41 | linktype.h \ | 42 | linktype.h \ |
42 | my_list.h \ | 43 | my_list.h \ |
43 | names.h \ | 44 | names.h \ |
44 | pdb.h \ | 45 | pdb.h \ |
45 | plucker.h \ | 46 | plucker.h \ |
46 | plucker_base.h \ | 47 | plucker_base.h \ |
47 | ppm.h \ | 48 | ppm.h \ |
48 | ppm_expander.h \ | 49 | ppm_expander.h \ |
49 | usenef.h \ | ||
50 | ustring.h \ | 50 | ustring.h \ |
51 | util.h \ | 51 | util.h \ |
52 | utypes.h \ | 52 | utypes.h \ |
53 | version.h \ | 53 | version.h \ |
54 | ztxt.h | 54 | ztxt.h |
55 | 55 | ||
56 | SOURCES = BuffDoc.cpp \ | 56 | SOURCES = BuffDoc.cpp \ |
57 | ButtonPrefs.cpp \ | 57 | ButtonPrefs.cpp \ |
58 | CAnnoEdit.cpp \ | 58 | CAnnoEdit.cpp \ |
59 | CDrawBuffer.cpp \ | 59 | CDrawBuffer.cpp \ |
60 | CEncoding.cpp \ | 60 | CEncoding.cpp \ |
61 | CEncoding_tables.cpp \ | 61 | CEncoding_tables.cpp \ |
62 | CFilter.cpp \ | 62 | CFilter.cpp \ |
63 | CRegExp.cpp \ | 63 | CRegExp.cpp \ |
64 | CloseDialog.cpp \ | 64 | CloseDialog.cpp \ |
65 | FontControl.cpp \ | 65 | FontControl.cpp \ |
66 | GraphicWin.cpp \ | 66 | GraphicWin.cpp \ |
67 | Prefs.cpp \ | 67 | Prefs.cpp \ |
68 | QTReader.cpp \ | 68 | QTReader.cpp \ |
69 | QTReaderApp.cpp \ | 69 | QTReaderApp.cpp \ |
70 | QtrListView.cpp \ | 70 | QtrListView.cpp \ |
71 | TableDialog.cpp \ | ||
71 | ToolbarPrefs.cpp \ | 72 | ToolbarPrefs.cpp \ |
72 | URLDialog.cpp \ | 73 | URLDialog.cpp \ |
73 | fileBrowser.cpp \ | 74 | fileBrowser.cpp \ |
74 | infowin.cpp \ | 75 | infowin.cpp \ |
75 | main.cpp \ | 76 | main.cpp \ |
76 | orkey.cpp \ | 77 | orkey.cpp \ |
77 | util.cpp \ | 78 | util.cpp \ |
78 | version.cpp | 79 | version.cpp |
79 | 80 | ||
80 | INTERFACES= | 81 | INTERFACES= |
81 | DESTDIR = $(OPIEDIR)/bin | 82 | DESTDIR = $(OPIEDIR)/bin |
82 | INCLUDEPATH+= $(OPIEDIR)/include | 83 | INCLUDEPATH+= $(OPIEDIR)/include |
diff --git a/noncore/apps/opie-reader/setn.sh b/noncore/apps/opie-reader/setn.sh deleted file mode 100644 index ad9409f..0000000 --- a/noncore/apps/opie-reader/setn.sh +++ b/dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | #export QPEDIR=/opt/Qtopia | ||
18 | export QTDIR=/home/tim/nevyos/qt-embedded-free-3.1.1 | ||
19 | export PATH=$QTDIR/bin:$OLDPATH | ||
20 | export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++ | ||
21 | export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH | ||
22 | |||
23 | #PS1="[${cyan}\T$NC][${RED}Laptop${NC}]\W> " | ||
24 | #PS1="[${RED}NevyOS${NC}]\W> " | ||
25 | PS1="[NevyOS]\W> " | ||
26 | |||
27 | echo -e \\n${RED}NevyOS${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/seto.sh b/noncore/apps/opie-reader/seto.sh deleted file mode 100644 index c1d1dd1..0000000 --- a/noncore/apps/opie-reader/seto.sh +++ b/dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | export QPEDIR=/opt/Qtopia/opie | ||
18 | export QTDIR=/opt/Qtopia/opie | ||
19 | export PATH=$QTDIR/bin:/usr/local/arm/3.3/bin:$OLDPATH | ||
20 | export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-opie-g++ | ||
21 | #export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH | ||
22 | |||
23 | PS1="[Opie]\W> " | ||
24 | |||
25 | echo -e \\n${RED}Opie${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/setqt.sh b/noncore/apps/opie-reader/setqt.sh deleted file mode 100644 index 1b7e7b7..0000000 --- a/noncore/apps/opie-reader/setqt.sh +++ b/dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | #export QPEDIR=/opt/Qtopia | ||
18 | export QTDIR=/usr/lib/qt3 | ||
19 | export PATH=$QTDIR/bin:$OLDPATH | ||
20 | #export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++ | ||
21 | |||
22 | export READERDIR=/home/tim/uqtreader | ||
23 | export LD_LIBRARY_PATH=$READERDIR/lib:$OLD_LD_LIBRARY_PATH | ||
24 | |||
25 | |||
26 | #PS1="[${cyan}\T$NC][${RED}Laptop${NC}]\W> " | ||
27 | #PS1="[${RED}NevyOS${NC}]\W> " | ||
28 | PS1="[QT]\W> " | ||
29 | |||
30 | echo -e \\n${RED}QT${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/setws.sh b/noncore/apps/opie-reader/setws.sh deleted file mode 100644 index 61aeccb..0000000 --- a/noncore/apps/opie-reader/setws.sh +++ b/dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | export QPEDIR=/opt/Qtopia | ||
18 | export QTDIR=/opt/Qtopia | ||
19 | export PATH=$QTDIR/bin:$OLDPATH | ||
20 | export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++ | ||
21 | export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH | ||
22 | |||
23 | #PS1="[${cyan}\T$NC][${RED}Laptop${NC}]\W> " | ||
24 | #PS1="[${RED}Laptop${NC}]\W> " | ||
25 | PS1="[Laptop]\W> " | ||
26 | |||
27 | echo -e \\n${RED}Laptop${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/setz.sh b/noncore/apps/opie-reader/setz.sh deleted file mode 100644 index e2fa4cd..0000000 --- a/noncore/apps/opie-reader/setz.sh +++ b/dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | red='\e[0;31m' | ||
2 | RED='\e[1;31m' | ||
3 | blue='\e[0;34m' | ||
4 | BLUE='\e[1;34m' | ||
5 | cyan='\e[0;36m' | ||
6 | CYAN='\e[1;36m' | ||
7 | NC='\e[0m' # No Color | ||
8 | |||
9 | if test -z $OLDPATH; then | ||
10 | export OLDPATH=$PATH | ||
11 | fi | ||
12 | |||
13 | if test -z $OLD_LD_LIBRARY_PATH; then | ||
14 | export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | ||
15 | fi | ||
16 | |||
17 | export QPEDIR=/opt/Qtopia/sharp | ||
18 | export QTDIR=/opt/Qtopia/sharp | ||
19 | export PATH=$QTDIR/bin:/usr/local/arm/bin:$OLDPATH | ||
20 | export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-sharp-g++ | ||
21 | export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH | ||
22 | |||
23 | PS1="[Zaurus]\W> " | ||
24 | |||
25 | echo -e \\n${RED}Zaurus${NC} environment configured\\n | ||
diff --git a/noncore/apps/opie-reader/striphtml.cpp b/noncore/apps/opie-reader/striphtml.cpp index e86402b..c434dbb 100644 --- a/noncore/apps/opie-reader/striphtml.cpp +++ b/noncore/apps/opie-reader/striphtml.cpp | |||
@@ -1,23 +1,22 @@ | |||
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 | #ifdef USEQPE | 5 | #ifdef USEQPE |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #endif | 7 | #endif |
8 | #include "CDrawBuffer.h" | 8 | #include "CDrawBuffer.h" |
9 | #include "striphtml.h" | 9 | #include "striphtml.h" |
10 | #include "hrule.h" | 10 | #include "hrule.h" |
11 | #include "util.h" | ||
12 | 11 | ||
13 | #include <qregexp.h> | 12 | #include <qregexp.h> |
14 | #include <qimage.h> | 13 | #include <qimage.h> |
15 | #include <qpixmap.h> | 14 | #include <qpixmap.h> |
16 | //#include <qprogressdialog.h> | 15 | //#include <qprogressdialog.h> |
17 | //#include <qapplication.h> | 16 | //#include <qapplication.h> |
18 | 17 | ||
19 | static unsigned char h2i(unsigned char c) | 18 | static unsigned char h2i(unsigned char c) |
20 | { | 19 | { |
21 | unsigned char ret = 0; | 20 | unsigned char ret = 0; |
22 | if ('0' <= c && c <= '9') | 21 | if ('0' <= c && c <= '9') |
23 | { | 22 | { |
@@ -81,33 +80,41 @@ void striphtml::skipblock(const QString& _ent) | |||
81 | while (ch != '<' && ch != UEOF) | 80 | while (ch != '<' && ch != UEOF) |
82 | { | 81 | { |
83 | mygetch(ch, dummy, pos); | 82 | mygetch(ch, dummy, pos); |
84 | } | 83 | } |
85 | 84 | ||
86 | ch = skip_ws(); | 85 | ch = skip_ws(); |
87 | 86 | ||
88 | ent = getname(ch, " >").lower(); | 87 | ent = getname(ch, " >").lower(); |
89 | qDebug("Skipblock:%s", (const char*)ent); | 88 | qDebug("Skipblock:%s", (const char*)ent); |
90 | } while (ent != _ent && ch != UEOF); | 89 | } while (ent != _ent && ch != UEOF); |
91 | } | 90 | } |
92 | 91 | ||
93 | void striphtml::locate(unsigned int n) | 92 | void striphtml::reset() |
94 | { | 93 | { |
95 | m_inblock = false; | 94 | m_inblock = false; |
96 | text_q = ""; | 95 | text_q = ""; |
96 | q = ""; | ||
97 | tablenesteddepth = 0; | ||
97 | forcecentre = false; | 98 | forcecentre = false; |
98 | ignorespace = false; | 99 | ignorespace = false; |
100 | indent = 0; | ||
99 | while (!stylestack.isEmpty()) stylestack.pop(); | 101 | while (!stylestack.isEmpty()) stylestack.pop(); |
100 | currentstyle.unset(); | 102 | currentstyle.unset(); |
103 | } | ||
104 | |||
105 | void striphtml::locate(unsigned int n) | ||
106 | { | ||
101 | qDebug("striphtml:locating:%u", n); | 107 | qDebug("striphtml:locating:%u", n); |
108 | reset(); | ||
102 | parent->locate(n); | 109 | parent->locate(n); |
103 | } | 110 | } |
104 | 111 | ||
105 | int striphtml::getpara(CBuffer& buff, unsigned long& startpos) | 112 | int striphtml::getpara(CBuffer& buff, unsigned long& startpos) |
106 | { | 113 | { |
107 | tchar ch; | 114 | tchar ch; |
108 | CStyle sty; | 115 | CStyle sty; |
109 | unsigned long pos; | 116 | unsigned long pos; |
110 | int i = 0; | 117 | int i = 0; |
111 | parent->getch(ch, sty, startpos); | 118 | parent->getch(ch, sty, startpos); |
112 | pos = startpos; | 119 | pos = startpos; |
113 | while (1) | 120 | while (1) |
@@ -224,24 +231,31 @@ QString striphtml::dehtml(const QString& _info) | |||
224 | } | 231 | } |
225 | } | 232 | } |
226 | } | 233 | } |
227 | info += ch; | 234 | info += ch; |
228 | } | 235 | } |
229 | return info; | 236 | return info; |
230 | } | 237 | } |
231 | 238 | ||
232 | bool striphtml::findanchor(const QString& _info) | 239 | bool striphtml::findanchor(const QString& _info) |
233 | { | 240 | { |
234 | // QProgressDialog dlg("Finding link...", QString::null, 0, NULL, "progress", true); | 241 | // QProgressDialog dlg("Finding link...", QString::null, 0, NULL, "progress", true); |
235 | // QProgressBar dlg(0); | 242 | // QProgressBar dlg(0); |
243 | if (parent->findanchor(_info)) | ||
244 | { | ||
245 | reset(); | ||
246 | return true; | ||
247 | } | ||
248 | qDebug("Using html find"); | ||
249 | parent->locate(parent->startSection()); | ||
236 | #if defined(USEQPE) || defined(_WINDOWS) | 250 | #if defined(USEQPE) || defined(_WINDOWS) |
237 | QString info; | 251 | QString info; |
238 | for (int i = 0; i < _info.length(); i++) | 252 | for (int i = 0; i < _info.length(); i++) |
239 | { | 253 | { |
240 | tchar ch = _info[i]; | 254 | tchar ch = _info[i]; |
241 | if (QString(".^$[]*+?").find(ch) != -1) | 255 | if (QString(".^$[]*+?").find(ch) != -1) |
242 | { | 256 | { |
243 | info += '\\'; | 257 | info += '\\'; |
244 | } | 258 | } |
245 | info += ch; | 259 | info += ch; |
246 | } | 260 | } |
247 | #else | 261 | #else |
@@ -286,41 +300,51 @@ bool striphtml::findanchor(const QString& _info) | |||
286 | qDebug("Found"); | 300 | qDebug("Found"); |
287 | ret = true; | 301 | ret = true; |
288 | } | 302 | } |
289 | else | 303 | else |
290 | { | 304 | { |
291 | locate(startpos); | 305 | locate(startpos); |
292 | qDebug("Not found"); | 306 | qDebug("Not found"); |
293 | ret = false; | 307 | ret = false; |
294 | } | 308 | } |
295 | return ret; | 309 | return ret; |
296 | } | 310 | } |
297 | 311 | ||
298 | striphtml::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) | 312 | striphtml::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), tablenesteddepth(0) |
299 | { | 313 | { |
300 | href2filepos = new QMap<QString, unsigned long>; | 314 | href2filepos = new QMap<QString, unsigned long>; |
301 | id2href = new QMap<unsigned long, QString>; | 315 | id2href = new QMap<unsigned long, QString>; |
302 | } | 316 | } |
303 | 317 | ||
304 | striphtml::~striphtml() | 318 | striphtml::~striphtml() |
305 | { | 319 | { |
306 | if (entmap != NULL) delete entmap; | 320 | if (entmap != NULL) delete entmap; |
307 | delete href2filepos; | 321 | delete href2filepos; |
308 | delete id2href; | 322 | delete id2href; |
309 | } | 323 | } |
310 | 324 | ||
311 | void striphtml::initentmap() | 325 | void striphtml::initentmap() |
312 | { | 326 | { |
313 | entmap = new QMap<QString, tchar>; | 327 | entmap = new QMap<QString, tchar>; |
314 | QString fname(QTReaderUtil::getPluginPath("data")); | 328 | #ifdef USEQPE |
329 | #ifdef OPIE | ||
330 | QString fname(getenv("OPIEDIR")); | ||
331 | #else | ||
332 | QString fname(getenv("QTDIR")); | ||
333 | #endif | ||
334 | fname += "/plugins/reader/data"; | ||
335 | #else | ||
336 | QString fname(getenv("READERDIR")); | ||
337 | fname += "/data"; | ||
338 | #endif | ||
315 | QFileInfo fi; | 339 | QFileInfo fi; |
316 | fi.setFile(fname, "HTMLentities"); | 340 | fi.setFile(fname, "HTMLentities"); |
317 | if (fi.exists()) | 341 | if (fi.exists()) |
318 | { | 342 | { |
319 | fname = fi.absFilePath(); | 343 | fname = fi.absFilePath(); |
320 | 344 | ||
321 | QFile fl(fname); | 345 | QFile fl(fname); |
322 | if (fl.open(IO_ReadOnly)) | 346 | if (fl.open(IO_ReadOnly)) |
323 | { | 347 | { |
324 | QTextStream t(&fl); | 348 | QTextStream t(&fl); |
325 | QString key, value; | 349 | QString key, value; |
326 | while (!t.eof()) | 350 | while (!t.eof()) |
@@ -403,24 +427,30 @@ QString striphtml::getattr(tchar& ch) | |||
403 | CStyle sty; | 427 | CStyle sty; |
404 | unsigned long pos; | 428 | unsigned long pos; |
405 | if (ch == ' ') ch = skip_ws(); | 429 | if (ch == ' ') ch = skip_ws(); |
406 | if (ch == '=') | 430 | if (ch == '=') |
407 | { | 431 | { |
408 | ch = skip_ws(); | 432 | ch = skip_ws(); |
409 | if (ch == '"') | 433 | if (ch == '"') |
410 | { | 434 | { |
411 | mygetch(ch, sty, pos); | 435 | mygetch(ch, sty, pos); |
412 | ref = getname(ch, "\""); | 436 | ref = getname(ch, "\""); |
413 | ch = skip_ws(); | 437 | ch = skip_ws(); |
414 | } | 438 | } |
439 | else if (ch == '\'') | ||
440 | { | ||
441 | mygetch(ch, sty, pos); | ||
442 | ref = getname(ch, "\'"); | ||
443 | ch = skip_ws(); | ||
444 | } | ||
415 | else | 445 | else |
416 | { | 446 | { |
417 | ref = getname(ch, " >"); | 447 | ref = getname(ch, " >"); |
418 | if (ch == ' ') ch = skip_ws(); | 448 | if (ch == ' ') ch = skip_ws(); |
419 | } | 449 | } |
420 | } | 450 | } |
421 | return ref; | 451 | return ref; |
422 | } | 452 | } |
423 | 453 | ||
424 | linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm) | 454 | linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm) |
425 | { | 455 | { |
426 | #if defined(USEQPE) || defined(_WINDOWS) | 456 | #if defined(USEQPE) || defined(_WINDOWS) |
@@ -469,45 +499,49 @@ linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& | |||
469 | } | 499 | } |
470 | else | 500 | else |
471 | { | 501 | { |
472 | file = dehtml(href); | 502 | file = dehtml(href); |
473 | } | 503 | } |
474 | 504 | ||
475 | qDebug("File:%s", (const char*)file); | 505 | qDebug("File:%s", (const char*)file); |
476 | qDebug("Name:%s", (const char*)name); | 506 | qDebug("Name:%s", (const char*)name); |
477 | 507 | ||
478 | 508 | ||
479 | if (file.isEmpty()) | 509 | if (file.isEmpty()) |
480 | { | 510 | { |
511 | if (parent->findanchor(name)) | ||
512 | { | ||
513 | reset(); | ||
514 | return eLink; | ||
515 | } | ||
481 | fpit = href2filepos->find(name); | 516 | fpit = href2filepos->find(name); |
482 | if (fpit != href2filepos->end()) | 517 | if (fpit != href2filepos->end()) |
483 | { | 518 | { |
484 | locate(*fpit); | 519 | locate(*fpit); |
485 | return eLink; | 520 | return eLink; |
486 | } | 521 | } |
487 | else | 522 | else |
488 | { | 523 | { |
489 | // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\""; | 524 | // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\""; |
490 | qDebug("Do a search for:%s", (const char*)name); | 525 | qDebug("Do a search for:%s", (const char*)name); |
491 | parent->locate(0); | ||
492 | findanchor(name); | 526 | findanchor(name); |
493 | return eLink; | 527 | return eLink; |
494 | } | 528 | } |
495 | } | 529 | } |
496 | else | 530 | else |
497 | // if (href.find('#') == -1) | 531 | // if (href.find('#') == -1) |
498 | { | 532 | { |
499 | if (m_bchm) | 533 | if (m_bchm) |
500 | { | 534 | { |
501 | w = "/"+file; | 535 | w = file; |
502 | nm = name; | 536 | nm = name; |
503 | return eFile; | 537 | return eFile; |
504 | } | 538 | } |
505 | else | 539 | else |
506 | { | 540 | { |
507 | QFileInfo f(currentfile); | 541 | QFileInfo f(currentfile); |
508 | QFileInfo f1(f.dir(true), file); | 542 | QFileInfo f1(f.dir(true), file); |
509 | if (f1.exists()) | 543 | if (f1.exists()) |
510 | { | 544 | { |
511 | w = f1.absFilePath(); | 545 | w = f1.absFilePath(); |
512 | nm = name; | 546 | nm = name; |
513 | } | 547 | } |
@@ -555,67 +589,94 @@ void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
555 | parent->getch(ch, sty, pos); | 589 | parent->getch(ch, sty, pos); |
556 | if (ch == '<') | 590 | if (ch == '<') |
557 | { | 591 | { |
558 | m_inblock = true; | 592 | m_inblock = true; |
559 | } | 593 | } |
560 | if (ch == '>') | 594 | if (ch == '>') |
561 | { | 595 | { |
562 | m_inblock = false; | 596 | m_inblock = false; |
563 | } | 597 | } |
564 | } | 598 | } |
565 | if (ch == 10 && !isPre) | 599 | if (ch == 10 && !isPre) |
566 | { | 600 | { |
601 | #ifdef REMOVE_LF_BEFORE_ENDTAG | ||
602 | parent->getch(ch, sty, pos); | ||
603 | if (ch == '<') | ||
604 | { | ||
605 | parent->getch(ch, sty, pos); | ||
606 | if (ch == '/') | ||
607 | { | ||
608 | ch = '<'; | ||
609 | text_q += '/'; | ||
610 | } | ||
611 | else | ||
612 | { | ||
613 | text_q += '<'; | ||
614 | text_q += ch; | ||
615 | ch = ' '; | ||
616 | } | ||
617 | } | ||
618 | else | ||
619 | { | ||
620 | text_q += ch; | ||
621 | ch = ' '; | ||
622 | } | ||
623 | #else | ||
567 | ch = ' '; | 624 | ch = ' '; |
625 | #endif | ||
568 | } | 626 | } |
569 | } | 627 | } |
570 | 628 | ||
571 | void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos) | 629 | void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos) |
572 | { | 630 | { |
573 | /* | 631 | /* |
574 | int count = 0; | 632 | int count = 0; |
575 | for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter) | 633 | for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter) |
576 | { | 634 | { |
577 | count++; | 635 | count++; |
578 | } | 636 | } |
579 | qDebug("Currently have %u styles", count); | 637 | qDebug("Currently have %u styles", count); |
580 | */ | 638 | */ |
581 | if (stylestack.isEmpty()) | 639 | if (stylestack.isEmpty()) |
582 | { | 640 | { |
583 | currentstyle.unset(); | 641 | currentstyle.unset(); |
584 | } | 642 | } |
585 | else | 643 | else |
586 | { | 644 | { |
587 | qDebug("Using stack style"); | ||
588 | currentstyle = stylestack.first(); | 645 | currentstyle = stylestack.first(); |
589 | } | 646 | } |
590 | if (forcecentre) | 647 | if (forcecentre) |
591 | { | 648 | { |
592 | currentstyle.setCentreJustify(); | 649 | currentstyle.setCentreJustify(); |
593 | } | 650 | } |
594 | if (ch == ' ') ch = skip_ws(); | 651 | if (ch == ' ') ch = skip_ws(); |
595 | while (ch != '>' && ch != UEOF) | 652 | while (ch != '>' && ch != UEOF) |
596 | { | 653 | { |
597 | QString ent = getname(ch, " =>").lower(); | 654 | QString ent = getname(ch, " =>").lower(); |
598 | QString attr = getattr(ch).lower(); | 655 | QString attr = getattr(ch).lower(); |
599 | //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 656 | //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
600 | if (ent == "align") | 657 | if (ent == "align") |
601 | { | 658 | { |
602 | if (attr == "center") | 659 | if (attr == "center") |
603 | { | 660 | { |
604 | currentstyle.setCentreJustify(); | 661 | currentstyle.setCentreJustify(); |
605 | } | 662 | } |
606 | if (attr == "right") | 663 | if (attr == "right") |
607 | { | 664 | { |
608 | currentstyle.setRightJustify(); | 665 | currentstyle.setRightJustify(); |
609 | } | 666 | } |
667 | if (attr == "justify") | ||
668 | { | ||
669 | currentstyle.setFullJustify(); | ||
670 | } | ||
610 | } | 671 | } |
611 | if (ent == "id") | 672 | if (ent == "id") |
612 | { | 673 | { |
613 | (*href2filepos)[attr] = pos; | 674 | (*href2filepos)[attr] = pos; |
614 | } | 675 | } |
615 | if (ent == "bgcolor") | 676 | if (ent == "bgcolor") |
616 | { | 677 | { |
617 | qDebug("Got paper colour:%s", (const char*)attr); | 678 | qDebug("Got paper colour:%s", (const char*)attr); |
618 | unsigned char r,g,b; | 679 | unsigned char r,g,b; |
619 | parse_color(attr, r, g, b); | 680 | parse_color(attr, r, g, b); |
620 | currentstyle.setPaper(r, g, b); | 681 | currentstyle.setPaper(r, g, b); |
621 | } | 682 | } |
@@ -645,52 +706,51 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
645 | unsigned char g = q[4].unicode(); | 706 | unsigned char g = q[4].unicode(); |
646 | unsigned char b = q[5].unicode(); | 707 | unsigned char b = q[5].unicode(); |
647 | ch = '#'; | 708 | ch = '#'; |
648 | //qDebug("html:hrule<%u, %u>", w, h); | 709 | //qDebug("html:hrule<%u, %u>", w, h); |
649 | currentstyle.setPicture(false, hRule(w,h,r,g,b)); | 710 | currentstyle.setPicture(false, hRule(w,h,r,g,b)); |
650 | q = q.right(q.length()-6); | 711 | q = q.right(q.length()-6); |
651 | } | 712 | } |
652 | else | 713 | else |
653 | { | 714 | { |
654 | q = q.right(q.length()-1); | 715 | q = q.right(q.length()-1); |
655 | } | 716 | } |
656 | sty = currentstyle; | 717 | sty = currentstyle; |
718 | lastch = ch; | ||
657 | return; | 719 | return; |
658 | } | 720 | } |
659 | do | 721 | do |
660 | { | 722 | { |
661 | unsigned long npos; | 723 | unsigned long npos; |
662 | CStyle dummy; | 724 | CStyle dummy; |
663 | mygetch(ch, dummy, pos); | 725 | mygetch(ch, dummy, pos); |
664 | // if (ch == 10 && !isPre) ch = ' '; | ||
665 | while (ch == '<' && ch != UEOF) | 726 | while (ch == '<' && ch != UEOF) |
666 | { | 727 | { |
667 | ch = skip_ws(); | 728 | ch = skip_ws(); |
668 | |||
669 | QString ent = getname(ch, " >").lower(); | 729 | QString ent = getname(ch, " >").lower(); |
670 | 730 | ||
671 | // qDebug("Entity:%s", (const char*)ent); | 731 | // qDebug("Entity:%s", (const char*)ent); |
672 | 732 | ||
673 | if (ent == "a"/* || ent == "reference"*/) | 733 | if (ent == "a"/* || ent == "reference"*/) |
674 | { | 734 | { |
675 | if (ch == ' ') ch = skip_ws(); | 735 | if (ch == ' ') ch = skip_ws(); |
676 | bool fileposfound = false; | 736 | bool fileposfound = false; |
677 | bool ishref = false; | 737 | bool ishref = false; |
678 | unsigned int filepos = 0; | 738 | unsigned int filepos = 0; |
679 | QString ref, name; | 739 | QString ref, name; |
680 | while (ch != '>' && ch != UEOF) | 740 | while (ch != '>' && ch != UEOF) |
681 | { | 741 | { |
682 | QString ent = getname(ch, " =>").lower(); | 742 | QString ent = getname(ch, " =>").lower(); |
683 | QString attr = getattr(ch); | 743 | QString attr = getattr(ch); |
684 | qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 744 | //qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
685 | if (ent == "name") | 745 | if (ent == "name") |
686 | { | 746 | { |
687 | name = attr; | 747 | name = attr; |
688 | } | 748 | } |
689 | if (ent == "onclick") | 749 | if (ent == "onclick") |
690 | { | 750 | { |
691 | int st = attr.find('\''); | 751 | int st = attr.find('\''); |
692 | int nd = attr.findRev('\''); | 752 | int nd = attr.findRev('\''); |
693 | ref = attr.mid(st+1, nd-st-1); | 753 | ref = attr.mid(st+1, nd-st-1); |
694 | ishref = true; | 754 | ishref = true; |
695 | qDebug("Onclick:%s", (const char*)ref); | 755 | qDebug("Onclick:%s", (const char*)ref); |
696 | } | 756 | } |
@@ -703,25 +763,25 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
703 | { | 763 | { |
704 | filepos = attr.toUInt(&fileposfound); | 764 | filepos = attr.toUInt(&fileposfound); |
705 | if (ref.isEmpty()) | 765 | if (ref.isEmpty()) |
706 | { | 766 | { |
707 | ishref = true; | 767 | ishref = true; |
708 | ref = attr; | 768 | ref = attr; |
709 | } | 769 | } |
710 | } | 770 | } |
711 | if (ent == "title") | 771 | if (ent == "title") |
712 | { | 772 | { |
713 | text_q = attr + "</a><p>"; | 773 | text_q = attr + "</a><p>"; |
714 | } | 774 | } |
715 | qDebug("<a %s=%s>", (const char*)ent, (const char*)ref); | 775 | //qDebug("<a %s=%s>", (const char*)ent, (const char*)ref); |
716 | } | 776 | } |
717 | if (ishref) | 777 | if (ishref) |
718 | { | 778 | { |
719 | currentstyle.setColour(0,0,255); | 779 | currentstyle.setColour(0,0,255); |
720 | currentstyle.setLink(true); | 780 | currentstyle.setLink(true); |
721 | currentstyle.setData(currentid); | 781 | currentstyle.setData(currentid); |
722 | if (!text_q.isEmpty()) | 782 | if (!text_q.isEmpty()) |
723 | { | 783 | { |
724 | currentstyle.setBold(); | 784 | currentstyle.setBold(); |
725 | currentstyle.setCentreJustify(); | 785 | currentstyle.setCentreJustify(); |
726 | } | 786 | } |
727 | (*id2href)[currentid] = ref; | 787 | (*id2href)[currentid] = ref; |
@@ -738,26 +798,27 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
738 | (*href2filepos)[name] = pos; | 798 | (*href2filepos)[name] = pos; |
739 | } | 799 | } |
740 | } | 800 | } |
741 | else if (ent == "p") | 801 | else if (ent == "p") |
742 | { | 802 | { |
743 | parse_paragraph(currentstyle, ch, pos); | 803 | parse_paragraph(currentstyle, ch, pos); |
744 | currentstyle.setExtraSpace(3); | 804 | currentstyle.setExtraSpace(3); |
745 | continue; | 805 | continue; |
746 | } | 806 | } |
747 | else if (ent == "div") | 807 | else if (ent == "div") |
748 | { | 808 | { |
749 | parse_paragraph(currentstyle, ch, pos); | 809 | parse_paragraph(currentstyle, ch, pos); |
750 | stylestack.push_front(currentstyle); | 810 | stylestack.push_front(currentstyle); |
751 | //indent = 0; | 811 | currentstyle.setExtraSpace(16); |
812 | //indent = 0; | ||
752 | continue; | 813 | continue; |
753 | } | 814 | } |
754 | else if (ent == "sup") | 815 | else if (ent == "sup") |
755 | { | 816 | { |
756 | currentstyle.setVOffset(-1); | 817 | currentstyle.setVOffset(-1); |
757 | } | 818 | } |
758 | else if (ent == "sup") | 819 | else if (ent == "sup") |
759 | { | 820 | { |
760 | currentstyle.setVOffset(1); | 821 | currentstyle.setVOffset(1); |
761 | } | 822 | } |
762 | else if (ent == "/sup" || ent == "/sub") | 823 | else if (ent == "/sup" || ent == "/sub") |
763 | { | 824 | { |
@@ -791,54 +852,58 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
791 | { | 852 | { |
792 | if (ch != '>') ch = skip_ws_end(); | 853 | if (ch != '>') ch = skip_ws_end(); |
793 | currentstyle.setBackground(255, 255, 255); | 854 | currentstyle.setBackground(255, 255, 255); |
794 | currentstyle.setColour(0, 0, 0); | 855 | currentstyle.setColour(0, 0, 0); |
795 | if (!stylestack.isEmpty()) | 856 | if (!stylestack.isEmpty()) |
796 | { | 857 | { |
797 | stylestack.pop(); | 858 | stylestack.pop(); |
798 | } | 859 | } |
799 | } | 860 | } |
800 | else if (ent == "pre") | 861 | else if (ent == "pre") |
801 | { | 862 | { |
802 | isPre = true; | 863 | isPre = true; |
864 | currentstyle.setNoJustify(); | ||
803 | currentstyle.setMono(); | 865 | currentstyle.setMono(); |
804 | } | 866 | } |
805 | else if (ent == "tt") | 867 | else if (ent == "tt") |
806 | { | 868 | { |
807 | currentstyle.setMono(); | 869 | currentstyle.setMono(); |
808 | } | 870 | } |
809 | else if (ent == "b" || ent == "strong") | 871 | else if (ent == "b" || ent == "strong") |
810 | { | 872 | { |
811 | currentstyle.setBold(); | 873 | currentstyle.setBold(); |
812 | } | 874 | } |
813 | else if (ent == "u") | 875 | else if (ent == "u") |
814 | { | 876 | { |
815 | currentstyle.setUnderline(); | 877 | currentstyle.setUnderline(); |
816 | } | 878 | } |
817 | else if (ent == "/u") | 879 | else if (ent == "/u") |
818 | { | 880 | { |
819 | currentstyle.unsetUnderline(); | 881 | currentstyle.unsetUnderline(); |
820 | } | 882 | } |
821 | else if (ent == "blockquote") | 883 | else if (ent == "blockquote") |
822 | { | 884 | { |
823 | if (ch != '>') ch = skip_ws_end(); | 885 | if (ch != '>') ch = skip_ws_end(); |
824 | ch = 10; | 886 | ch = 10; |
887 | currentstyle.setExtraSpace(0); | ||
825 | currentstyle.setLeftMargin(30); | 888 | currentstyle.setLeftMargin(30); |
826 | currentstyle.setRightMargin(30); | 889 | currentstyle.setRightMargin(30); |
827 | continue; | 890 | continue; |
828 | } | 891 | } |
829 | else if (ent == "br" || ent == "br/") | 892 | else if (ent == "br" || ent == "br/") |
830 | { | 893 | { |
831 | if (ch != '>') ch = skip_ws_end(); | 894 | if (ch != '>') ch = skip_ws_end(); |
832 | ch = 10; | 895 | ch = 10; |
896 | currentstyle.setExtraSpace(0); | ||
897 | lastch = 0; | ||
833 | continue; | 898 | continue; |
834 | } | 899 | } |
835 | else if (ent == "mbp:pagebreak") | 900 | else if (ent == "mbp:pagebreak") |
836 | { | 901 | { |
837 | /* | 902 | /* |
838 | if (ch != '>') ch = skip_ws_end(pos); | 903 | if (ch != '>') ch = skip_ws_end(pos); |
839 | q += 10; | 904 | q += 10; |
840 | q += QChar(UEOF); | 905 | q += QChar(UEOF); |
841 | ch = 10; | 906 | ch = 10; |
842 | continue; | 907 | continue; |
843 | */ | 908 | */ |
844 | ch = 6; | 909 | ch = 6; |
@@ -852,24 +917,25 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
852 | currentstyle.setCentreJustify(); | 917 | currentstyle.setCentreJustify(); |
853 | ch = 10; | 918 | ch = 10; |
854 | continue; | 919 | continue; |
855 | } | 920 | } |
856 | else if (ent == "/center") | 921 | else if (ent == "/center") |
857 | { | 922 | { |
858 | qDebug("unsetting centre"); | 923 | qDebug("unsetting centre"); |
859 | forcecentre = false; | 924 | forcecentre = false; |
860 | } | 925 | } |
861 | else if (ent == "li") | 926 | else if (ent == "li") |
862 | { | 927 | { |
863 | if (ch != '>') ch = skip_ws_end(); | 928 | if (ch != '>') ch = skip_ws_end(); |
929 | lastch = 0; | ||
864 | ch = 10; | 930 | ch = 10; |
865 | if (m_listtype[indent % m_cmaxdepth] == 1) | 931 | if (m_listtype[indent % m_cmaxdepth] == 1) |
866 | { | 932 | { |
867 | q.setNum(m_ctr[indent % m_cmaxdepth]++); | 933 | q.setNum(m_ctr[indent % m_cmaxdepth]++); |
868 | } | 934 | } |
869 | else | 935 | else |
870 | { | 936 | { |
871 | q += QChar(8226); | 937 | q += QChar(8226); |
872 | } | 938 | } |
873 | q += ' '; | 939 | q += ' '; |
874 | currentstyle.setLeftMargin(6*indent); | 940 | currentstyle.setLeftMargin(6*indent); |
875 | qDebug("Setting indent:%d", indent); | 941 | qDebug("Setting indent:%d", indent); |
@@ -909,62 +975,66 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
909 | else if (ent == "/small") | 975 | else if (ent == "/small") |
910 | { | 976 | { |
911 | currentstyle.setFontSize(0); | 977 | currentstyle.setFontSize(0); |
912 | } | 978 | } |
913 | else if (ent == "big") | 979 | else if (ent == "big") |
914 | { | 980 | { |
915 | currentstyle.setFontSize(2); | 981 | currentstyle.setFontSize(2); |
916 | } | 982 | } |
917 | else if (ent == "/big") | 983 | else if (ent == "/big") |
918 | { | 984 | { |
919 | currentstyle.setFontSize(0); | 985 | currentstyle.setFontSize(0); |
920 | } | 986 | } |
987 | else if (ent[0] == '/' && ent[1] == 'h' && ent.length() == 3 && QString("123456789").find(ent[2]) != -1) | ||
988 | { | ||
989 | parse_paragraph(currentstyle, ch, pos); | ||
990 | currentstyle.setExtraSpace(3); | ||
991 | continue; | ||
992 | } | ||
921 | else if (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1) | 993 | else if (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1) |
922 | { | 994 | { |
923 | indent = 0; | 995 | indent = 0; |
924 | if (ent[1] == '1') | 996 | if (ent[1] == '1') |
925 | { | 997 | { |
926 | parse_paragraph(currentstyle, ch, pos); | 998 | parse_paragraph(currentstyle, ch, pos); |
927 | currentstyle.setFontSize(3); | 999 | currentstyle.setFontSize(3); |
928 | currentstyle.setExtraSpace(8); | 1000 | currentstyle.setExtraSpace(8); |
929 | currentstyle.setBold(); | 1001 | currentstyle.setBold(); |
930 | // currentstyle.setExtraSpace(10); | 1002 | // currentstyle.setExtraSpace(10); |
931 | continue; | ||
932 | } | 1003 | } |
933 | else if (ent[1] == '2') | 1004 | else if (ent[1] == '2') |
934 | { | 1005 | { |
935 | parse_paragraph(currentstyle, ch, pos); | 1006 | parse_paragraph(currentstyle, ch, pos); |
936 | currentstyle.setFontSize(2); | 1007 | currentstyle.setFontSize(2); |
937 | currentstyle.setExtraSpace(6); | 1008 | currentstyle.setExtraSpace(6); |
938 | currentstyle.setBold(); | 1009 | currentstyle.setBold(); |
939 | // currentstyle.setExtraSpace(10); | 1010 | // currentstyle.setExtraSpace(10); |
940 | continue; | ||
941 | } | 1011 | } |
942 | else if (ent[1] == '3') | 1012 | else if (ent[1] == '3') |
943 | { | 1013 | { |
944 | parse_paragraph(currentstyle, ch, pos); | 1014 | parse_paragraph(currentstyle, ch, pos); |
945 | currentstyle.setFontSize(1); | 1015 | currentstyle.setFontSize(1); |
946 | currentstyle.setExtraSpace(4); | 1016 | currentstyle.setExtraSpace(4); |
947 | currentstyle.setBold(); | 1017 | currentstyle.setBold(); |
948 | // currentstyle.setExtraSpace(10); | 1018 | // currentstyle.setExtraSpace(10); |
949 | continue; | ||
950 | } | 1019 | } |
951 | else | 1020 | else |
952 | { | 1021 | { |
953 | parse_paragraph(currentstyle, ch, pos); | 1022 | parse_paragraph(currentstyle, ch, pos); |
954 | currentstyle.setExtraSpace(4); | 1023 | currentstyle.setExtraSpace(4); |
955 | currentstyle.setBold(); | 1024 | currentstyle.setBold(); |
956 | // currentstyle.setExtraSpace(10); | 1025 | // currentstyle.setExtraSpace(10); |
957 | continue; | ||
958 | } | 1026 | } |
1027 | ch = 10; | ||
1028 | continue; | ||
959 | } | 1029 | } |
960 | 1030 | ||
961 | 1031 | ||
962 | else if (ent == "/a") | 1032 | else if (ent == "/a") |
963 | { | 1033 | { |
964 | currentstyle.setColour(0,0,0); | 1034 | currentstyle.setColour(0,0,0); |
965 | currentstyle.setLink(false); | 1035 | currentstyle.setLink(false); |
966 | } | 1036 | } |
967 | else if (ent == "/pre") | 1037 | else if (ent == "/pre") |
968 | { | 1038 | { |
969 | currentstyle.unsetMono(); | 1039 | currentstyle.unsetMono(); |
970 | isPre = false; | 1040 | isPre = false; |
@@ -1038,108 +1108,150 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
1038 | if (!stylestack.isEmpty()) | 1108 | if (!stylestack.isEmpty()) |
1039 | { | 1109 | { |
1040 | stylestack.pop(); | 1110 | stylestack.pop(); |
1041 | } | 1111 | } |
1042 | // ch = 10; | 1112 | // ch = 10; |
1043 | continue; | 1113 | continue; |
1044 | } | 1114 | } |
1045 | */ | 1115 | */ |
1046 | else if (ent[0] == '/' && ent.length() == 3 && ent[1] == 'h' && QString("123456789").find(ent[2]) != -1) | 1116 | else if (ent[0] == '/' && ent.length() == 3 && ent[1] == 'h' && QString("123456789").find(ent[2]) != -1) |
1047 | { | 1117 | { |
1048 | currentstyle.unset(); | 1118 | currentstyle.unset(); |
1049 | if (ch != '>') ch = skip_ws_end(); | 1119 | if (ch != '>') ch = skip_ws_end(); |
1050 | ch = 10; | 1120 | //ch = 10; |
1051 | continue; | 1121 | //continue; |
1052 | } | 1122 | } |
1053 | |||
1054 | |||
1055 | |||
1056 | else if (ent == "table" || ent == "/table") | 1123 | else if (ent == "table" || ent == "/table") |
1057 | { | 1124 | { |
1058 | currentstyle.unset(); | 1125 | currentstyle.unset(); |
1059 | ignorespace = (ent == "table"); | 1126 | ignorespace = (ent == "table"); |
1127 | if (ent == "table") | ||
1128 | { | ||
1129 | if (tablenesteddepth++ == 0) currentstyle.setTable(pos); | ||
1130 | } | ||
1131 | else | ||
1132 | { | ||
1133 | if (--tablenesteddepth <= 0) | ||
1134 | { | ||
1135 | tablenesteddepth = 0; | ||
1136 | currentstyle.setTable(0xffffffff); | ||
1137 | } | ||
1138 | } | ||
1060 | if (ch == ' ') ch = skip_ws(); | 1139 | if (ch == ' ') ch = skip_ws(); |
1061 | while (ch != '>' && ch != UEOF) | 1140 | while (ch != '>' && ch != UEOF) |
1062 | { | 1141 | { |
1063 | QString ent = getname(ch, " =>").lower(); | 1142 | QString ent = getname(ch, " =>").lower(); |
1064 | QString attr = getattr(ch); | 1143 | QString attr = getattr(ch); |
1065 | qDebug("<table>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 1144 | qDebug("<table>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
1066 | } | 1145 | } |
1067 | if (ch != '>') ch = skip_ws_end(); | 1146 | if (ch != '>') ch = skip_ws_end(); |
1068 | 1147 | ||
1148 | currentstyle.setLeftMargin(6*tablenesteddepth); | ||
1149 | |||
1150 | |||
1151 | lastch = 0; // Anything but 10 | ||
1069 | ch = 10; | 1152 | ch = 10; |
1070 | q += '-'; | 1153 | q += '-'; |
1071 | q += QChar(parent->getwidth()); | 1154 | q += QChar(parent->getwidth()); |
1072 | q += 2; | 1155 | q += 3; |
1073 | q += '\0'; | 1156 | q += '\0'; |
1074 | q += '\0'; | 1157 | q += '\0'; |
1075 | q += '\0'; | 1158 | q += '\0'; |
1076 | continue; | 1159 | continue; |
1077 | } | 1160 | } |
1078 | else if (ent == "hr") | 1161 | else if (ent == "hr") |
1079 | { | 1162 | { |
1163 | //bool isPageBreak = false; | ||
1080 | if (ch == ' ') ch = skip_ws(); | 1164 | if (ch == ' ') ch = skip_ws(); |
1081 | // if (stylestack.isEmpty()) | ||
1082 | // { | ||
1083 | currentstyle.unset(); | ||
1084 | // } | ||
1085 | /* | ||
1086 | else | ||
1087 | { | ||
1088 | qDebug("Using stack style"); | ||
1089 | currentstyle = stylestack.first(); | ||
1090 | } | ||
1091 | */ | ||
1092 | unsigned char red = 0, green = 0, blue = 0; | 1165 | unsigned char red = 0, green = 0, blue = 0; |
1093 | while (ch != '>' && ch != UEOF) | 1166 | while (ch != '>' && ch != UEOF) |
1094 | { | 1167 | { |
1095 | QString ent = getname(ch, " =>").lower(); | 1168 | QString ent = getname(ch, " =>").lower(); |
1096 | QString attr = getattr(ch); | 1169 | QString attr = getattr(ch); |
1097 | if (ent == "color") | 1170 | if (ent == "color") |
1098 | { | 1171 | { |
1099 | parse_color(attr, red, green, blue); | 1172 | parse_color(attr, red, green, blue); |
1100 | } | 1173 | } |
1174 | /* | ||
1175 | if (ent == "size") | ||
1176 | { | ||
1177 | if (attr == "0") | ||
1178 | { | ||
1179 | isPageBreak = true; | ||
1180 | } | ||
1181 | } | ||
1182 | */ | ||
1101 | qDebug("<hr>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 1183 | qDebug("<hr>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
1102 | } | 1184 | } |
1103 | if (ch != '>') ch = skip_ws_end(); | 1185 | if (ch != '>') ch = skip_ws_end(); |
1104 | ch = 10; | 1186 | /* |
1105 | q += '-'; | 1187 | if (isPageBreak) |
1106 | q += QChar(parent->getwidth()); | 1188 | { |
1107 | q += 3; | 1189 | ch = UEOF; |
1108 | q += red; | 1190 | } |
1109 | q += green; | 1191 | else |
1110 | q += blue; | 1192 | { |
1193 | */ | ||
1194 | // if (stylestack.isEmpty()) | ||
1195 | // { | ||
1196 | currentstyle.unset(); | ||
1197 | // } | ||
1198 | /* | ||
1199 | else | ||
1200 | { | ||
1201 | qDebug("Using stack style"); | ||
1202 | currentstyle = stylestack.first(); | ||
1203 | } | ||
1204 | */ | ||
1205 | lastch = 0; //Anything but 10 or ' ' | ||
1206 | ch = 10; | ||
1207 | q += '-'; | ||
1208 | q += QChar(parent->getwidth()); | ||
1209 | q += 3; | ||
1210 | q += red; | ||
1211 | q += green; | ||
1212 | q += blue; | ||
1213 | |||
1111 | continue; | 1214 | continue; |
1112 | } | 1215 | } |
1113 | 1216 | ||
1114 | 1217 | ||
1115 | 1218 | ||
1116 | else if (ent == "img") | 1219 | else if (ent == "img") |
1117 | { | 1220 | { |
1118 | if (ch == ' ') ch = skip_ws(); | 1221 | if (ch == ' ') ch = skip_ws(); |
1119 | while (ch != '>' && ch != UEOF) | 1222 | while (ch != '>' && ch != UEOF) |
1120 | { | 1223 | { |
1121 | QString ent = getname(ch, " =>").lower(); | 1224 | QString ent = getname(ch, " =>").lower(); |
1122 | QString attr = getattr(ch); | 1225 | QString attr = getattr(ch); |
1123 | qDebug("<img>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 1226 | qDebug("<img>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
1124 | if (ent == "src") | 1227 | if (ent == "src") |
1125 | { | 1228 | { |
1229 | /* | ||
1126 | if (m_bchm) | 1230 | if (m_bchm) |
1127 | { | 1231 | { |
1128 | QImage* img = parent->getPicture(attr); | 1232 | QImage* img = parent->getPicture(attr); |
1129 | if (img != NULL) | 1233 | if (img != NULL) |
1130 | { | 1234 | { |
1131 | currentstyle.setPicture(true, img); | 1235 | currentstyle.setPicture(true, img); |
1132 | } | 1236 | } |
1133 | } | 1237 | } |
1238 | */ | ||
1239 | |||
1240 | |||
1241 | QImage* img = parent->getPicture(attr); | ||
1242 | if (img != NULL) | ||
1243 | { | ||
1244 | currentstyle.setPicture(true, img); | ||
1245 | } | ||
1134 | else | 1246 | else |
1135 | { | 1247 | { |
1136 | QFileInfo f(currentfile); | 1248 | QFileInfo f(currentfile); |
1137 | QFileInfo f1(f.dir(true), attr); | 1249 | QFileInfo f1(f.dir(true), attr); |
1138 | QPixmap pm; | 1250 | QPixmap pm; |
1139 | if (pm.load(f1.absFilePath())) | 1251 | if (pm.load(f1.absFilePath())) |
1140 | { | 1252 | { |
1141 | QImage* img = new QImage(pm.convertToImage()); | 1253 | QImage* img = new QImage(pm.convertToImage()); |
1142 | currentstyle.setPicture(true, img); | 1254 | currentstyle.setPicture(true, img); |
1143 | } | 1255 | } |
1144 | } | 1256 | } |
1145 | } | 1257 | } |
@@ -1163,44 +1275,55 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
1163 | ch = '#'; | 1275 | ch = '#'; |
1164 | break; | 1276 | break; |
1165 | } | 1277 | } |
1166 | else if (ent.left(2) == "dc") | 1278 | else if (ent.left(2) == "dc") |
1167 | { | 1279 | { |
1168 | QString nd("/"); | 1280 | QString nd("/"); |
1169 | skipblock(nd+ent); | 1281 | skipblock(nd+ent); |
1170 | } | 1282 | } |
1171 | else if (ent == "metadata") | 1283 | else if (ent == "metadata") |
1172 | { | 1284 | { |
1173 | // skipblock("/metadata"); | 1285 | // skipblock("/metadata"); |
1174 | } | 1286 | } |
1287 | else if (ent == "title") | ||
1288 | { | ||
1289 | skipblock("/title"); | ||
1290 | } | ||
1291 | else if (ent == "head") | ||
1292 | { | ||
1293 | skipblock("/head"); | ||
1294 | } | ||
1175 | /* | 1295 | /* |
1176 | else if (ent == "metadata") | 1296 | else if (ent == "metadata") |
1177 | { | 1297 | { |
1178 | currentstyle.setFontSize(-2); | 1298 | currentstyle.setFontSize(-2); |
1179 | } | 1299 | } |
1180 | else if (ent == "/metadata") | 1300 | else if (ent == "/metadata") |
1181 | { | 1301 | { |
1182 | currentstyle.unset(); | 1302 | currentstyle.unset(); |
1183 | ch = 10; | 1303 | ch = 10; |
1184 | continue; | 1304 | continue; |
1185 | } | 1305 | } |
1186 | */ | 1306 | */ |
1187 | else | 1307 | else |
1188 | { | 1308 | { |
1189 | if (ent[0] != '/') | 1309 | if (ent[0] != '/') |
1190 | qDebug("Not handling:%s", (const char*)ent); | 1310 | qDebug("Not handling:%s", (const char*)ent); |
1191 | } | 1311 | } |
1192 | 1312 | ||
1193 | if (ch != '>') ch = skip_ws_end(); | 1313 | if (ch != '>') ch = skip_ws_end(); |
1194 | mygetch(ch, dummy, npos); | 1314 | if (ent[0] == '/') |
1315 | mygetch(ch, dummy, pos); | ||
1316 | else | ||
1317 | mygetch(ch, dummy, npos); | ||
1195 | } | 1318 | } |
1196 | if (ch == '&') | 1319 | if (ch == '&') |
1197 | { | 1320 | { |
1198 | mygetch(ch, dummy, npos); | 1321 | mygetch(ch, dummy, npos); |
1199 | if (ch == '#') | 1322 | if (ch == '#') |
1200 | { | 1323 | { |
1201 | int id = 0; | 1324 | int id = 0; |
1202 | mygetch(ch, dummy, npos); | 1325 | mygetch(ch, dummy, npos); |
1203 | while (ch != ';' && ch != UEOF) | 1326 | while (ch != ';' && ch != UEOF) |
1204 | { | 1327 | { |
1205 | id = 10*id+ch-'0'; | 1328 | id = 10*id+ch-'0'; |
1206 | mygetch(ch, dummy, npos); | 1329 | mygetch(ch, dummy, npos); |
@@ -1225,24 +1348,67 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
1225 | #endif | 1348 | #endif |
1226 | if (it != entmap->end()) | 1349 | if (it != entmap->end()) |
1227 | { | 1350 | { |
1228 | ch = *it; | 1351 | ch = *it; |
1229 | } | 1352 | } |
1230 | else | 1353 | else |
1231 | { | 1354 | { |
1232 | ch = '.'; | 1355 | ch = '.'; |
1233 | } | 1356 | } |
1234 | } | 1357 | } |
1235 | } | 1358 | } |
1236 | // sty = (dummy == ucFontBase) ? currentstyle : dummy; | 1359 | // sty = (dummy == ucFontBase) ? currentstyle : dummy; |
1360 | if (lastch == 10 && ch == 10 && sty.getExtraSpace() > currentstyle.getExtraSpace()) | ||
1361 | { | ||
1362 | currentstyle.setExtraSpace(sty.getExtraSpace()); | ||
1363 | } | ||
1237 | sty = currentstyle; | 1364 | sty = currentstyle; |
1238 | } | 1365 | } |
1239 | while (!isPre && (lastch == ' ' || lastch == 10 || ignorespace) && ch == ' '); | 1366 | while (!isPre && (((lastch == ' ' || lastch == 10 || ignorespace) && ch == ' ') || ((ch == 10) && (lastch == 10)))); |
1240 | // lastch = ch; | 1367 | // lastch = ch; |
1241 | lastch = ch; | 1368 | lastch = ch; |
1242 | return; | 1369 | return; |
1243 | } | 1370 | } |
1244 | 1371 | ||
1372 | QString striphtml::getTableAsHtml(unsigned long loc) | ||
1373 | { | ||
1374 | qDebug("striphtml::getTableAsHtml"); | ||
1375 | QString ret; | ||
1376 | tchar ch(0); | ||
1377 | CStyle sty; | ||
1378 | unsigned long pos; | ||
1379 | locate(loc); | ||
1380 | int endpos(0); | ||
1381 | QString endmarker("</table>"); | ||
1382 | QString startmarker("<table"); | ||
1383 | int startpos(0); | ||
1384 | int depth(0); | ||
1385 | while (ch != UEOF) | ||
1386 | { | ||
1387 | parent->getch(ch, sty, pos); | ||
1388 | QChar qc(ch); | ||
1389 | ret += qc; | ||
1390 | if (qc.lower() == endmarker[endpos]) | ||
1391 | { | ||
1392 | if ((++endpos >= endmarker.length()) && (--depth <= 0)) break; | ||
1393 | } | ||
1394 | else | ||
1395 | { | ||
1396 | endpos = 0; | ||
1397 | } | ||
1398 | if (qc.lower() == startmarker[startpos]) | ||
1399 | { | ||
1400 | if (++startpos >= startmarker.length()) ++depth; | ||
1401 | } | ||
1402 | else | ||
1403 | { | ||
1404 | startpos = 0; | ||
1405 | } | ||
1406 | } | ||
1407 | return ret; | ||
1408 | } | ||
1409 | |||
1410 | |||
1245 | extern "C" | 1411 | extern "C" |
1246 | { | 1412 | { |
1247 | CFilter* newfilter(const QString& s) { return new striphtml(s); } | 1413 | CFilter* newfilter(const QString& s) { return new striphtml(s); } |
1248 | } | 1414 | } |
diff --git a/noncore/apps/opie-reader/striphtml.h b/noncore/apps/opie-reader/striphtml.h index 42e2b7e..b1f7c0a 100644 --- a/noncore/apps/opie-reader/striphtml.h +++ b/noncore/apps/opie-reader/striphtml.h | |||
@@ -1,25 +1,27 @@ | |||
1 | #ifndef __STRIPHTML_H | 1 | #ifndef __STRIPHTML_H |
2 | #define __STRIPHTML_H | 2 | #define __STRIPHTML_H |
3 | 3 | ||
4 | #include "CFilter.h" | 4 | #include "CFilter.h" |
5 | #include "Navigation.h" | 5 | #include "Navigation.h" |
6 | #include "CBuffer.h" | 6 | #include "CBuffer.h" |
7 | #include "CExpander.h" | 7 | #include "CExpander.h" |
8 | #include "my_list.h" | 8 | #include "my_list.h" |
9 | 9 | ||
10 | class striphtml : public CFilter | 10 | class striphtml : public CFilter |
11 | { | 11 | { |
12 | void reset(); | ||
12 | bool ignorespace; | 13 | bool ignorespace; |
13 | bool m_bchm; | 14 | bool m_bchm; |
15 | int tablenesteddepth; | ||
14 | CList<CStyle> stylestack; | 16 | CList<CStyle> stylestack; |
15 | static CNavigation_base<htmlmark> m_nav; | 17 | static CNavigation_base<htmlmark> m_nav; |
16 | QMap<QString, tchar>* entmap; | 18 | QMap<QString, tchar>* entmap; |
17 | CStyle currentstyle; | 19 | CStyle currentstyle; |
18 | bool isPre; | 20 | bool isPre; |
19 | unsigned short skip_ws(); | 21 | unsigned short skip_ws(); |
20 | unsigned short skip_ws_end(); | 22 | unsigned short skip_ws_end(); |
21 | unsigned short skip_ws_end(unsigned long&); | 23 | unsigned short skip_ws_end(unsigned long&); |
22 | unsigned short parse_m(); | 24 | unsigned short parse_m(); |
23 | QMap<QString, unsigned long>* href2filepos; | 25 | QMap<QString, unsigned long>* href2filepos; |
24 | QMap<unsigned long, QString>* id2href; | 26 | QMap<unsigned long, QString>* id2href; |
25 | unsigned long currentid; | 27 | unsigned long currentid; |
@@ -80,14 +82,15 @@ class striphtml : public CFilter | |||
80 | } | 82 | } |
81 | } | 83 | } |
82 | else | 84 | else |
83 | { | 85 | { |
84 | f = m.filename(); | 86 | f = m.filename(); |
85 | } | 87 | } |
86 | loc = m.posn(); | 88 | loc = m.posn(); |
87 | return ret; | 89 | return ret; |
88 | } | 90 | } |
89 | bool hasnavigation() { return true; } | 91 | bool hasnavigation() { return true; } |
90 | virtual void locate(unsigned int n); | 92 | virtual void locate(unsigned int n); |
91 | void setchm(bool _b) { m_bchm = _b; } | 93 | void setchm(bool _b) { m_bchm = _b; } |
94 | QString getTableAsHtml(unsigned long loc); | ||
92 | }; | 95 | }; |
93 | #endif | 96 | #endif |
diff --git a/noncore/apps/opie-reader/update-gcc3.sh b/noncore/apps/opie-reader/update-gcc3.sh deleted file mode 100755 index f604e42..0000000 --- a/noncore/apps/opie-reader/update-gcc3.sh +++ b/dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | touch infowin.cpp | ||
3 | for f in *lib.omak; do make -f $f; done | ||
4 | for f in *.omak; do make -f $f; done | ||
5 | for f in *.omak; do make -f $f; done | ||
6 | cp /home/tim/codecreader/opie-reader.desktop $QTDIR/apps/Applications/ | ||
7 | cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/ | ||
8 | cp /home/tim/codecreader/opie-pics/* $QTDIR/pics/opie-reader/ | ||
9 | cp HTMLentities $QTDIR/plugins/reader/data/ | ||
10 | rm $QTDIR/help/html/*reader*.html | ||
11 | cp /home/tim/codecreader/help/*.html $QTDIR/help/html/ | ||
12 | rm $QTDIR/help/html/*reader*.html | ||
13 | cp /home/tim/codecreader/help/*.html $QTDIR/help/html/ | ||
14 | rm -f $QTDIR/lib/libreader*.so | ||
15 | rm -f $QTDIR/lib/libreader*.so.1 | ||
16 | for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done | ||
17 | rm -f $QTDIR/lib/libreader*.so.1.* | ||
18 | |||
19 | /home/tim/bin/zstrip.sh $QTDIR/bin/reader | ||
20 | for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done | ||
21 | |||
22 | for SUBDIR in codecs support filters | ||
23 | do | ||
24 | CDIR=$QTDIR/plugins/reader/$SUBDIR | ||
25 | rm -f $CDIR/*.so | ||
26 | for f in $CDIR/*.1.0.0 ; do mv -f $f $CDIR/`basename $f .1.0.0` ; done | ||
27 | rm -f $CDIR/*.so.* | ||
28 | for f in $CDIR/*.so ; do /home/tim/bin/zstrip.sh $f ; done | ||
29 | done | ||
30 | rm -f opie-reader-gcc3_*.ipk | ||
31 | rm -f full/opie-reader-gcc3_*.ipk | ||
32 | rm -f partial/opie-reader-gcc3_*.ipk | ||
33 | mkipks opie-reader-gcc3.control | ||
34 | cp opie-reader-gcc3_*.ipk full/ | ||
35 | for f in opie-reader-gcc3_*.ipk | ||
36 | do | ||
37 | cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
38 | done | ||
39 | rm $QTDIR/plugins/reader/support/libpluckerdecompress.so | ||
40 | rm $QTDIR/plugins/reader/codecs/libArriereGo.so | ||
41 | rm $QTDIR/plugins/reader/codecs/libNEF.so | ||
42 | mkipks opie-reader-gcc3.control | ||
43 | cp opie-reader-gcc3_*.ipk partial/ | ||
44 | for f in opie-reader-gcc3_*.ipk | ||
45 | do | ||
46 | cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
47 | done | ||
diff --git a/noncore/apps/opie-reader/update-opie.sh b/noncore/apps/opie-reader/update-opie.sh deleted file mode 100755 index 261ef46..0000000 --- a/noncore/apps/opie-reader/update-opie.sh +++ b/dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | touch infowin.cpp | ||
3 | for f in *lib.zmak; do make -f $f; done | ||
4 | for f in *.zmak; do make -f $f; done | ||
5 | for f in *.zmak; do make -f $f; done | ||
6 | cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/ | ||
7 | cp /home/tim/codecreader/opie-pics/* $QTDIR/pics/opie-reader/ | ||
8 | cp HTMLentities $QTDIR/plugins/reader/data/ | ||
9 | rm $QTDIR/help/html/*reader*.html | ||
10 | cp /home/tim/codecreader/help/*.html $QTDIR/help/html/ | ||
11 | rm -f $QTDIR/lib/libreader*.so | ||
12 | rm -f $QTDIR/lib/libreader*.so.1 | ||
13 | for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done | ||
14 | rm -f $QTDIR/lib/libreader*.so.1.* | ||
15 | |||
16 | /home/tim/bin/zstrip.sh $QTDIR/bin/uqtreader | ||
17 | rm -f $QTDIR/bin/reader | ||
18 | mv $QTDIR/bin/uqtreader $QTDIR/bin/reader | ||
19 | for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done | ||
20 | for SUBDIR in codecs support filters | ||
21 | do | ||
22 | CDIR=$QTDIR/plugins/reader/$SUBDIR | ||
23 | rm -f $CDIR/*.so | ||
24 | for f in $CDIR/*.1.0.0 ; do mv -f $f $CDIR/`basename $f .1.0.0` ; done | ||
25 | rm -f $CDIR/*.so.* | ||
26 | for f in $CDIR/*.so ; do zstrip.sh $f ; done | ||
27 | done | ||
28 | rm -f opie-reader-opie_*.ipk | ||
29 | rm -f full/opie-reader-opie_*.ipk | ||
30 | rm -f partial/opie-reader-opie_*.ipk | ||
31 | mkipks opie-reader-opie.control | ||
32 | cp opie-reader-opie_*.ipk full/ | ||
33 | for f in opie-reader-opie_*.ipk | ||
34 | do | ||
35 | cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
36 | done | ||
37 | rm $QTDIR/plugins/reader/support/libpluckerdecompress.so | ||
38 | rm $QTDIR/plugins/reader/codecs/libArriereGo.so | ||
39 | rm $QTDIR/plugins/reader/codecs/libNEF.so | ||
40 | mkipks opie-reader-opie.control | ||
41 | cp opie-reader-opie_*.ipk partial/ | ||
42 | for f in opie-reader-opie_*.ipk | ||
43 | do | ||
44 | cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
45 | done | ||
diff --git a/noncore/apps/opie-reader/update.sh b/noncore/apps/opie-reader/update.sh deleted file mode 100755 index 61b8a5e..0000000 --- a/noncore/apps/opie-reader/update.sh +++ b/dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | touch infowin.cpp | ||
3 | for f in *lib.zmak; do make -f $f; done | ||
4 | for f in *.zmak; do make -f $f; done | ||
5 | for f in *.zmak; do make -f $f; done | ||
6 | cp /home/tim/codecreader/uqtreader*.desktop /opt/Qtopia/apps/Applications/ | ||
7 | cp /home/tim/codecreader/pics/* /opt/Qtopia/pics/opie-reader/ | ||
8 | cp /home/tim/codecreader/uqtreader*.desktop $QTDIR/apps/Applications/ | ||
9 | cp /home/tim/codecreader/opie-reader.desktop $QTDIR/apps/Applications/ | ||
10 | cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/ | ||
11 | cp HTMLentities $QTDIR/plugins/reader/data/ | ||
12 | rm $QTDIR/help/html/*reader*.html | ||
13 | cp /home/tim/codecreader/help/*.html $QTDIR/help/html/ | ||
14 | rm -f $QTDIR/lib/libreader*.so | ||
15 | rm -f $QTDIR/lib/libreader*.so.1 | ||
16 | for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done | ||
17 | rm -f $QTDIR/lib/libreader*.so.1.* | ||
18 | |||
19 | /home/tim/bin/zstrip.sh $QTDIR/bin/uqtreader | ||
20 | for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done | ||
21 | |||
22 | for SUBDIR in codecs support filters | ||
23 | do | ||
24 | CDIR=$QTDIR/plugins/reader/$SUBDIR | ||
25 | rm -f $CDIR/*.so | ||
26 | for f in $CDIR/*.1.0.0 ; do mv -f $f $CDIR/`basename $f .1.0.0` ; done | ||
27 | rm -f $CDIR/*.so.* | ||
28 | for f in $CDIR/*.so ; do /home/tim/bin/zstrip.sh $f ; done | ||
29 | done | ||
30 | rm -f opie-reader_*.ipk | ||
31 | rm -f full/opie-reader_*.ipk | ||
32 | rm -f partial/opie-reader_*.ipk | ||
33 | mkipks opie-reader.control | ||
34 | cp opie-reader_*.ipk full/ | ||
35 | for f in opie-reader_*.ipk | ||
36 | do | ||
37 | cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
38 | done | ||
39 | rm $QTDIR/plugins/reader/support/libpluckerdecompress.so | ||
40 | rm $QTDIR/plugins/reader/codecs/libArriereGo.so | ||
41 | rm $QTDIR/plugins/reader/codecs/libNEF.so | ||
42 | mkipks opie-reader.control | ||
43 | cp opie-reader_*.ipk partial/ | ||
44 | for f in opie-reader_*.ipk | ||
45 | do | ||
46 | cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk | ||
47 | done | ||
diff --git a/noncore/apps/opie-reader/usenef.h b/noncore/apps/opie-reader/usenef.h deleted file mode 100644 index 57898cb..0000000 --- a/noncore/apps/opie-reader/usenef.h +++ b/dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #ifndef __USENEF_H | ||
2 | #define __USENEF_H | ||
3 | |||
4 | //#define USENEF | ||
5 | |||
6 | #endif | ||
diff --git a/noncore/apps/opie-reader/util.cpp b/noncore/apps/opie-reader/util.cpp index a736f8b..2ca1cc8 100644 --- a/noncore/apps/opie-reader/util.cpp +++ b/noncore/apps/opie-reader/util.cpp | |||
@@ -1,36 +1,45 @@ | |||
1 | #include "util.h" | 1 | #include "util.h" |
2 | #include <limits.h> | ||
2 | 3 | ||
3 | QString filesize(unsigned long l) | 4 | QString filesize(unsigned long l) |
4 | { | 5 | { |
5 | char units[] = { 'K', 'M', 'G' }; | 6 | char units[] = { 'K', 'M', 'G' }; |
6 | int iu = 0; | 7 | int iu = 0; |
7 | while (l > 999 && iu < sizeof(units)) | 8 | while (l > 999 && iu < sizeof(units)) |
8 | { | 9 | { |
9 | l = (l+512)/1024; | 10 | l = (l+512)/1024; |
10 | iu++; | 11 | iu++; |
11 | } | 12 | } |
12 | QString ret = QString::number(l); | 13 | QString ret = QString::number(l); |
13 | if (iu != 0) | 14 | if (iu != 0) |
14 | { | 15 | { |
15 | ret += QChar(units[iu-1]); | 16 | ret += QChar(units[iu-1]); |
16 | } | 17 | } |
17 | return ret; | 18 | return ret; |
18 | } | 19 | } |
19 | 20 | ||
20 | QString percent(unsigned long pos, unsigned long len) | 21 | QString percent(unsigned long pos, unsigned long len) |
21 | { | 22 | { |
22 | unsigned long permil = 0; | 23 | unsigned long permil = 0; |
23 | if (len != 0) | 24 | if (len != 0) |
24 | { | 25 | { |
25 | permil = (1000*pos+len/2)/len; | 26 | if (pos > UINT_MAX/1000) |
27 | { | ||
28 | unsigned long l1 = (len+500)/1000; | ||
29 | permil = (pos+l1/2)/l1; | ||
30 | } | ||
31 | else | ||
32 | { | ||
33 | permil = (1000*pos+len/2)/len; | ||
34 | } | ||
26 | } | 35 | } |
27 | unsigned long percen = permil/10; | 36 | unsigned long percen = permil/10; |
28 | unsigned long frac = permil - 10*percen; | 37 | unsigned long frac = permil - 10*percen; |
29 | return QString::number(percen) + "." + QString::number(frac); | 38 | return QString::number(percen) + "." + QString::number(frac); |
30 | } | 39 | } |
31 | 40 | ||
32 | QString fmt(unsigned long pos, unsigned long len) | 41 | QString fmt(unsigned long pos, unsigned long len) |
33 | { | 42 | { |
34 | QString ret = filesize(pos) + "/" + filesize(len) + " : " + percent(pos,len) +"%"; | 43 | QString ret = filesize(pos) + "/" + filesize(len) + " : " + percent(pos,len) +"%"; |
35 | return ret; | 44 | return ret; |
36 | } | 45 | } |
diff --git a/noncore/apps/opie-reader/util.h b/noncore/apps/opie-reader/util.h index f831ead..3964b5e 100644 --- a/noncore/apps/opie-reader/util.h +++ b/noncore/apps/opie-reader/util.h | |||
@@ -1,57 +1,9 @@ | |||
1 | #ifndef __UTIL_H | 1 | #ifndef __UTIL_H |
2 | #define __UTIL_H | 2 | #define __UTIL_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qdir.h> | ||
6 | #include <stdlib.h> | ||
7 | 5 | ||
8 | QString filesize(unsigned long l); | 6 | QString filesize(unsigned long l); |
9 | QString percent(unsigned long pos, unsigned long len); | 7 | QString percent(unsigned long pos, unsigned long len); |
10 | QString fmt(unsigned long pos, unsigned long len); | 8 | QString fmt(unsigned long pos, unsigned long len); |
11 | |||
12 | /** | ||
13 | * class with utility inline function(s) | ||
14 | * (in contrast to global functions they become available by just | ||
15 | * including util.h) | ||
16 | */ | ||
17 | class QTReaderUtil | ||
18 | { | ||
19 | public: | ||
20 | |||
21 | /** | ||
22 | * searches for a specific direcory inside OpieReader installation | ||
23 | * | ||
24 | * @param subdir name of sub directory inside installation directory which is needed | ||
25 | * @return full path name including that sub directory | ||
26 | * | ||
27 | * search order is (on all platforms): | ||
28 | * - OPIEDIR | ||
29 | * - QTDIR | ||
30 | * - READERDIR | ||
31 | */ | ||
32 | static QString getPluginPath( const char *subdir = "codecs/" ) | ||
33 | { | ||
34 | QString dirname; | ||
35 | dirname = getenv("OPIEDIR"); | ||
36 | dirname += "/plugins/reader/"; | ||
37 | dirname += subdir; | ||
38 | if (QDir(dirname).exists()) | ||
39 | return dirname; | ||
40 | |||
41 | dirname = getenv("QTDIR"); | ||
42 | dirname += "/plugins/reader/"; | ||
43 | dirname += subdir; | ||
44 | if (QDir(dirname).exists()) | ||
45 | return dirname; | ||
46 | |||
47 | dirname = getenv("READERDIR"); | ||
48 | dirname += "/"; | ||
49 | dirname += subdir; | ||
50 | if (QDir(dirname).exists()) | ||
51 | return dirname; | ||
52 | |||
53 | return ""; | ||
54 | } | ||
55 | }; | ||
56 | |||
57 | #endif | 9 | #endif |
diff --git a/noncore/apps/opie-reader/version.cpp b/noncore/apps/opie-reader/version.cpp index 9d92abe..aafb3d8 100644 --- a/noncore/apps/opie-reader/version.cpp +++ b/noncore/apps/opie-reader/version.cpp | |||
@@ -1,29 +1,62 @@ | |||
1 | #include "version.h" | 1 | #include "version.h" |
2 | #include "names.h" | 2 | #include "names.h" |
3 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
4 | 4 | ||
5 | bool CheckVersion(int& major, int& bkmktype, char& minor) | 5 | #include <qmultilineedit.h> |
6 | #include <qlayout.h> | ||
7 | #include <qtextview.h> | ||
8 | class versionbox : public QDialog | ||
9 | { | ||
10 | public: | ||
11 | versionbox(const QString& txt, QWidget* parent = NULL) : QDialog(parent, NULL, true) | ||
12 | { | ||
13 | setCaption(tr( "New Features" )); | ||
14 | QVBoxLayout* v = new QVBoxLayout(this); | ||
15 | /* | ||
16 | QMultiLineEdit* box = new QMultiLineEdit(this); | ||
17 | v->addWidget(box); | ||
18 | box->setReadOnly(true); | ||
19 | box->setWordWrap(QMultiLineEdit::WidgetWidth); | ||
20 | box->setText(txt); | ||
21 | */ | ||
22 | QTextView* box = new QTextView(this); | ||
23 | v->addWidget(box); | ||
24 | box->setText(txt); | ||
25 | #ifdef USEQPE | ||
26 | showMaximized(); | ||
27 | #endif | ||
28 | } | ||
29 | }; | ||
30 | |||
31 | bool CheckVersion(int& major, int& bkmktype, char& minor, QWidget* pnt) | ||
6 | { | 32 | { |
7 | if ( | 33 | if ( |
8 | (major != MAJOR) | 34 | (major != MAJOR) |
9 | || | 35 | || |
10 | (bkmktype != BKMKTYPE) | 36 | (bkmktype != BKMKTYPE) |
11 | || | 37 | || |
12 | (minor != MINOR) | 38 | (minor != MINOR) |
13 | ) | 39 | ) |
14 | { | 40 | { |
15 | major = MAJOR; | 41 | major = MAJOR; |
16 | bkmktype = BKMKTYPE; | 42 | bkmktype = BKMKTYPE; |
17 | minor = MINOR; | 43 | minor = MINOR; |
18 | 44 | versionbox v( | |
19 | QMessageBox::warning(NULL, PROGNAME, | 45 | "<h2>New Features</h2>" |
20 | "New Features in this version\n\n\n" | 46 | "<h3>Support for custom version of rbmake</h3>" |
21 | "Relative margin settings\n" | 47 | "<h3>Mini scrollbar now acts more like a QT scrollbar.</h3>" |
22 | "Cyrillic hyphenation"); | 48 | "<p>The handle can be dragged to jump to a \"random\" location and tapping to either side of the handle does page up/down</p>" |
49 | "<p>Line up/down is done by tapping in the margins to either end of the scroll bar (left/right margins for a horizontal scrollbar, top/bottom for a vertical scrollbar).</p>" | ||
50 | "<p>The toolbar now stays hidden if you hide it.</p>" | ||
51 | "<p>Better support for tables. Tapping on a table brings up a table viewer. The inline display of the linearised table can be toggled using the Inline Table option" | ||
52 | , | ||
53 | pnt | ||
54 | ); | ||
55 | v.exec(); | ||
23 | return true; | 56 | return true; |
24 | } | 57 | } |
25 | else | 58 | else |
26 | { | 59 | { |
27 | return false; | 60 | return false; |
28 | } | 61 | } |
29 | } | 62 | } |
diff --git a/noncore/apps/opie-reader/version.h b/noncore/apps/opie-reader/version.h index dcf0692..486d152 100644 --- a/noncore/apps/opie-reader/version.h +++ b/noncore/apps/opie-reader/version.h | |||
@@ -1,9 +1,9 @@ | |||
1 | #ifndef __VERSION_H | 1 | #ifndef __VERSION_H |
2 | #define __VERSION_H | 2 | #define __VERSION_H |
3 | 3 | ||
4 | #define MAJOR 0 | 4 | #define MAJOR 0 |
5 | #define BKMKTYPE 7 | 5 | #define BKMKTYPE 7 |
6 | #define MINOR 'g' | 6 | #define MINOR 'i' |
7 | #define RELEASE_TYPE "beta" | 7 | #define RELEASE_TYPE "beta" |
8 | 8 | ||
9 | #endif | 9 | #endif |
diff --git a/noncore/apps/opie-reader/ztxt.cpp b/noncore/apps/opie-reader/ztxt.cpp index 35db05e..e04eaa0 100644 --- a/noncore/apps/opie-reader/ztxt.cpp +++ b/noncore/apps/opie-reader/ztxt.cpp | |||
@@ -58,24 +58,25 @@ int ztxt::getch() | |||
58 | } | 58 | } |
59 | 59 | ||
60 | unsigned int ztxt::locate() | 60 | unsigned int ztxt::locate() |
61 | { | 61 | { |
62 | return currentpos; | 62 | return currentpos; |
63 | } | 63 | } |
64 | 64 | ||
65 | void ztxt::locate(unsigned int n) | 65 | void ztxt::locate(unsigned int n) |
66 | { | 66 | { |
67 | 67 | ||
68 | if (hasrandomaccess()) | 68 | if (hasrandomaccess()) |
69 | { | 69 | { |
70 | unsuspend(); | ||
70 | bufferrec = n / ntohs(hdr0.recordSize) + 1; | 71 | bufferrec = n / ntohs(hdr0.recordSize) + 1; |
71 | if (bufferrec == 1) | 72 | if (bufferrec == 1) |
72 | { | 73 | { |
73 | inflateEnd(&zstream); | 74 | inflateEnd(&zstream); |
74 | } | 75 | } |
75 | size_t reclen = recordlength(bufferrec); | 76 | size_t reclen = recordlength(bufferrec); |
76 | if (reclen == 0) return; | 77 | if (reclen == 0) return; |
77 | gotorecordnumber(bufferrec); | 78 | gotorecordnumber(bufferrec); |
78 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 79 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
79 | 80 | ||
80 | zstream.next_in = compressedtextbuffer; | 81 | zstream.next_in = compressedtextbuffer; |
81 | zstream.next_out = expandedtextbuffer; | 82 | zstream.next_out = expandedtextbuffer; |
@@ -98,24 +99,25 @@ void ztxt::locate(unsigned int n) | |||
98 | currentpos = n - n % ntohs(hdr0.recordSize); | 99 | currentpos = n - n % ntohs(hdr0.recordSize); |
99 | while (currentpos < n) getch(); | 100 | while (currentpos < n) getch(); |
100 | } | 101 | } |
101 | else | 102 | else |
102 | { | 103 | { |
103 | home(); | 104 | home(); |
104 | while (currentpos < n && getch() != EOF); | 105 | while (currentpos < n && getch() != EOF); |
105 | } | 106 | } |
106 | } | 107 | } |
107 | 108 | ||
108 | void ztxt::home() | 109 | void ztxt::home() |
109 | { | 110 | { |
111 | unsuspend(); | ||
110 | if (bInit) | 112 | if (bInit) |
111 | { | 113 | { |
112 | inflateEnd(&zstream); | 114 | inflateEnd(&zstream); |
113 | } | 115 | } |
114 | bInit = true; | 116 | bInit = true; |
115 | size_t reclen = recordlength(1); | 117 | size_t reclen = recordlength(1); |
116 | gotorecordnumber(1); | 118 | gotorecordnumber(1); |
117 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 119 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
118 | 120 | ||
119 | zstream.next_in = compressedtextbuffer; | 121 | zstream.next_in = compressedtextbuffer; |
120 | zstream.next_out = expandedtextbuffer; | 122 | zstream.next_out = expandedtextbuffer; |
121 | zstream.avail_out = buffersize; | 123 | zstream.avail_out = buffersize; |
@@ -138,24 +140,25 @@ void ztxt::home() | |||
138 | //printf("buffercontent:%u\n", buffercontent); | 140 | //printf("buffercontent:%u\n", buffercontent); |
139 | } | 141 | } |
140 | 142 | ||
141 | CList<Bkmk>* ztxt::getbkmklist() | 143 | CList<Bkmk>* ztxt::getbkmklist() |
142 | { | 144 | { |
143 | UInt16 recno = ntohs(hdr0.bookmarkRecord); | 145 | UInt16 recno = ntohs(hdr0.bookmarkRecord); |
144 | 146 | ||
145 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); | 147 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); |
146 | 148 | ||
147 | if (recno == 0) return NULL; | 149 | if (recno == 0) return NULL; |
148 | 150 | ||
149 | CList<Bkmk>* t = new CList<Bkmk>; | 151 | CList<Bkmk>* t = new CList<Bkmk>; |
152 | unsuspend(); | ||
150 | size_t cur = ftell(fin); | 153 | size_t cur = ftell(fin); |
151 | gotorecordnumber(recno); | 154 | gotorecordnumber(recno); |
152 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) | 155 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) |
153 | { | 156 | { |
154 | zTXTbkmk bkmk; | 157 | zTXTbkmk bkmk; |
155 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; | 158 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; |
156 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); | 159 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); |
157 | tchar title[MAX_BMRK_LENGTH]; | 160 | tchar title[MAX_BMRK_LENGTH]; |
158 | for (int j = 0; j < MAX_BMRK_LENGTH; j++) | 161 | for (int j = 0; j < MAX_BMRK_LENGTH; j++) |
159 | { | 162 | { |
160 | title[j] = bkmk.title[j]; | 163 | title[j] = bkmk.title[j]; |
161 | } | 164 | } |