Diffstat (limited to 'noncore/apps/opie-reader/BuffDoc.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/BuffDoc.cpp | 55 |
1 files changed, 53 insertions, 2 deletions
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,12 +1,11 @@ | |||
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 | ||
@@ -18,12 +17,13 @@ | |||
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; |
@@ -57,12 +57,24 @@ void BuffDoc::locate(unsigned int n) | |||
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; |
@@ -632,12 +644,19 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
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; |
@@ -652,13 +671,23 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
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(); |
@@ -703,6 +732,28 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
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 | } | ||