summaryrefslogtreecommitdiff
authorpohly <pohly>2005-05-05 14:39:33 (UTC)
committer pohly <pohly>2005-05-05 14:39:33 (UTC)
commit39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (unidiff)
tree96e66fdc18dca4d4ab8611133e072f57dea224b9
parent279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff)
downloadopie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.zip
opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.gz
opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.bz2
new opie-reader sources with support for ArriereGo, Reb input and flite output plugins
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Aportis.cpp8
-rw-r--r--noncore/apps/opie-reader/ArriereCodec/.cvsignore5
-rw-r--r--noncore/apps/opie-reader/ArriereCodec/ArriereCodec.pro16
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp55
-rw-r--r--noncore/apps/opie-reader/BuffDoc.h25
-rw-r--r--noncore/apps/opie-reader/ButtonPrefs.cpp4
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.cpp25
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.h2
-rw-r--r--noncore/apps/opie-reader/CEncoding.h15
-rw-r--r--noncore/apps/opie-reader/CExpander.cpp10
-rw-r--r--noncore/apps/opie-reader/CExpander.h14
-rw-r--r--noncore/apps/opie-reader/CFilter.cpp54
-rw-r--r--noncore/apps/opie-reader/CFilter.h55
-rw-r--r--noncore/apps/opie-reader/CHM.cpp35
-rw-r--r--noncore/apps/opie-reader/CHM.h2
-rw-r--r--noncore/apps/opie-reader/CRegExp.cpp170
-rw-r--r--noncore/apps/opie-reader/CSource.h62
-rw-r--r--noncore/apps/opie-reader/Coder.h113
-rw-r--r--noncore/apps/opie-reader/FliteCmd/.cvsignore5
-rw-r--r--noncore/apps/opie-reader/FliteCmd/FliteCmd.pro18
-rw-r--r--noncore/apps/opie-reader/FliteDyn/.cvsignore5
-rw-r--r--noncore/apps/opie-reader/FliteDyn/FliteDyn.pro18
-rw-r--r--noncore/apps/opie-reader/FliteDyn16/.cvsignore5
-rw-r--r--noncore/apps/opie-reader/FliteDyn16/FliteDyn16.pro18
-rw-r--r--noncore/apps/opie-reader/FontControl.cpp1
-rw-r--r--noncore/apps/opie-reader/FontControl.h2
-rw-r--r--noncore/apps/opie-reader/Model.cpp721
-rw-r--r--noncore/apps/opie-reader/Model.h11
-rw-r--r--noncore/apps/opie-reader/Palm2QImage.cpp1
-rw-r--r--noncore/apps/opie-reader/Prefs.cpp127
-rw-r--r--noncore/apps/opie-reader/Prefs.h75
-rw-r--r--noncore/apps/opie-reader/QTReader.cpp1301
-rw-r--r--noncore/apps/opie-reader/QTReader.h96
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp246
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.h13
-rw-r--r--noncore/apps/opie-reader/Reb.cpp789
-rw-r--r--noncore/apps/opie-reader/Reb.h157
-rw-r--r--noncore/apps/opie-reader/RebCodec/.cvsignore5
-rw-r--r--noncore/apps/opie-reader/RebCodec/RebCodec.pro21
-rw-r--r--noncore/apps/opie-reader/StyleConsts.h12
-rw-r--r--noncore/apps/opie-reader/SubAlloc.h201
-rw-r--r--noncore/apps/opie-reader/TableDialog.cpp17
-rw-r--r--noncore/apps/opie-reader/TableDialog.h34
-rw-r--r--noncore/apps/opie-reader/ToolbarPrefs.h3
-rw-r--r--noncore/apps/opie-reader/ZText.h15
-rw-r--r--noncore/apps/opie-reader/arith.h12
-rw-r--r--noncore/apps/opie-reader/arrierego.cpp188
-rw-r--r--noncore/apps/opie-reader/arrierego.h37
-rw-r--r--noncore/apps/opie-reader/cbkmkselector.h64
-rw-r--r--noncore/apps/opie-reader/config.in4
-rw-r--r--noncore/apps/opie-reader/decompress.cpp95
-rw-r--r--noncore/apps/opie-reader/decompress.h5
-rw-r--r--noncore/apps/opie-reader/ebookcodec.h21
-rw-r--r--noncore/apps/opie-reader/fileBrowser.cpp2
-rw-r--r--noncore/apps/opie-reader/flitecmd.cpp43
-rw-r--r--noncore/apps/opie-reader/flitecmd.h10
-rw-r--r--noncore/apps/opie-reader/flitedyn.cpp29
-rw-r--r--noncore/apps/opie-reader/flitedyn.h16
-rw-r--r--noncore/apps/opie-reader/iSilo.cpp17
-rw-r--r--noncore/apps/opie-reader/linktype.h2
-rw-r--r--noncore/apps/opie-reader/main.cpp1
-rw-r--r--noncore/apps/opie-reader/mytypes.h8
-rw-r--r--noncore/apps/opie-reader/opie-reader.pro8
-rw-r--r--noncore/apps/opie-reader/outputcodec.h84
-rw-r--r--noncore/apps/opie-reader/pdb.cpp7
-rw-r--r--noncore/apps/opie-reader/pdb.h9
-rw-r--r--noncore/apps/opie-reader/plucker_base.cpp224
-rw-r--r--noncore/apps/opie-reader/plucker_base.h9
-rw-r--r--noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro3
-rw-r--r--noncore/apps/opie-reader/pluckerdecompress/.cvsignore5
-rw-r--r--noncore/apps/opie-reader/pluckerdecompress/pluckerdecompress.pro17
-rw-r--r--noncore/apps/opie-reader/ppm_expander.cpp11
-rw-r--r--noncore/apps/opie-reader/ppm_expander.h5
-rwxr-xr-xnoncore/apps/opie-reader/preferences.cpp1
-rw-r--r--noncore/apps/opie-reader/preferences.h50
-rw-r--r--noncore/apps/opie-reader/reader.staticpro108
-rw-r--r--noncore/apps/opie-reader/reader.staticzpro108
-rw-r--r--noncore/apps/opie-reader/reader/reader.pro3
-rw-r--r--noncore/apps/opie-reader/setn.sh27
-rw-r--r--noncore/apps/opie-reader/seto.sh25
-rw-r--r--noncore/apps/opie-reader/setqt.sh30
-rw-r--r--noncore/apps/opie-reader/setws.sh27
-rw-r--r--noncore/apps/opie-reader/setz.sh25
-rw-r--r--noncore/apps/opie-reader/striphtml.cpp252
-rw-r--r--noncore/apps/opie-reader/striphtml.h3
-rwxr-xr-xnoncore/apps/opie-reader/update-gcc3.sh47
-rwxr-xr-xnoncore/apps/opie-reader/update-opie.sh45
-rwxr-xr-xnoncore/apps/opie-reader/update.sh47
-rw-r--r--noncore/apps/opie-reader/usenef.h6
-rw-r--r--noncore/apps/opie-reader/util.cpp11
-rw-r--r--noncore/apps/opie-reader/util.h48
-rw-r--r--noncore/apps/opie-reader/version.cpp45
-rw-r--r--noncore/apps/opie-reader/version.h2
-rw-r--r--noncore/apps/opie-reader/ztxt.cpp3
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
@@ -56,2 +56,3 @@ CList<Bkmk>* Aportis::getbkmklist()
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);
@@ -248,2 +249,3 @@ int Aportis::getch()
248 { 249 {
250unsuspend();
249 int c = getc(fin); 251 int c = getc(fin);
@@ -265,2 +267,3 @@ int Aportis::getch()
265 // take a char from the input buffer 267 // take a char from the input buffer
268unsuspend();
266 c = getc(fin); 269 c = getc(fin);
@@ -322,3 +325,3 @@ unsigned int Aportis::GetBS(unsigned int bn)
322 WORD fs; 325 WORD fs;
323 326unsuspend();
324 fseek(fin, 0x56 + 8*bn, SEEK_SET); 327 fseek(fin, 0x56 + 8*bn, SEEK_SET);
@@ -345,2 +348,3 @@ unsigned int Aportis::locate()
345 { 348 {
349unsuspend();
346 size_t cur = ftell(fin); 350 size_t cur = ftell(fin);
@@ -403,2 +407,3 @@ bool Aportis::refreshbuffer()
403 unsigned char t[3]; 407 unsigned char t[3];
408 unsuspend();
404 fread(t,1,3,fin); 409 fread(t,1,3,fin);
@@ -432,2 +437,3 @@ QImage* Aportis::getPicture(unsigned long tgt)
432{ 437{
438unsuspend();
433 unsigned short tgtrec = tgt+mobiimagerec; 439 unsigned short tgtrec = tgt+mobiimagerec;
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 @@
1Makefile
2config.in
3moc_*
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 @@
1DEFINES += OPIE USEQPE
2VPATH = ..
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
12LIBS += -L$(OPIEDIR)/lib -lreader_pdb -lreader_pluckerbase -lreader_codec
13
14 INCLUDEPATH+= $(OPIEDIR)/include
15DEPENDPATH += $(OPIEDIR)/include
16DEFINES += 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
@@ -5,3 +5,2 @@
5 5
6#include "usenef.h"
7#include "BuffDoc.h" 6#include "BuffDoc.h"
@@ -23,2 +22,3 @@
23#include "iSilo.h" 22#include "iSilo.h"
23#include "Reb.h"
24#endif 24#endif
@@ -62,2 +62,14 @@ void BuffDoc::locate(unsigned int n)
62 62
63void 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
63static bool isletter(unsigned short c) 75static bool isletter(unsigned short c)
@@ -637,2 +649,9 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
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;
@@ -657,3 +676,13 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
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");
@@ -708 +737,23 @@ QString BuffDoc::about()
708} 737}
738
739int 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
@@ -49,6 +49,4 @@ class BuffDoc
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
@@ -97,2 +95,13 @@ class BuffDoc
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); }
@@ -101,2 +110,3 @@ class BuffDoc
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; }
@@ -131,2 +141,3 @@ class BuffDoc
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); }
@@ -135,6 +146,10 @@ class BuffDoc
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 }
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
@@ -154,2 +154,6 @@ CButtonPrefs::CButtonPrefs( QMap<orKey, int>* _kmap, QWidget* parent, const cha
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);
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
@@ -366,2 +366,3 @@ int CDrawBuffer::offset(int scwidth, unsigned short _lborder, unsigned short _rb
366 case m_AlignLeft: 366 case m_AlignLeft:
367 case m_AlignNone:
367 currentx = _lborder + leftMargin(); 368 currentx = _lborder + leftMargin();
@@ -486,3 +487,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
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
@@ -660,3 +661,3 @@ CStyle CDrawBuffer::firststyle()
660 661
661linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img) 662linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img, size_t& tabletgt)
662{ 663{
@@ -692,2 +693,7 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, siz
692 } 693 }
694 if (currentstyle.isTable())
695 {
696 tabletgt = currentstyle.getTable();
697 ret |= eTable;
698 }
693 return ret; 699 return ret;
@@ -718,3 +724,3 @@ void CDrawBuffer::resize(int availht)
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; )
@@ -758,2 +764,13 @@ void CDrawBuffer::resize(int availht)
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 }
@@ -774,3 +791,3 @@ void CDrawBuffer::resize(int availht)
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();
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
@@ -80,3 +80,3 @@ class CDrawBuffer : public CBuffer
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);
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
@@ -14,2 +14,7 @@ class CEncoding : public CCharacterSource
14public: 14public:
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) {}
@@ -18,3 +23,6 @@ public:
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); }
@@ -27,5 +35,4 @@ public:
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};
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,2 +1,5 @@
1#include "CExpander.h" 1#include "CExpander.h"
2#ifdef USEQPE
3#include <qpe/global.h>
4#endif
2 5
@@ -72,3 +75,7 @@ void CExpander::unsuspend(FILE*& fin)
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");
@@ -76,2 +83,3 @@ void CExpander::unsuspend(FILE*& fin)
76 { 83 {
84 Global::statusMessage("Stalling");
77 sleep(5); 85 sleep(5);
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
@@ -26,2 +26,3 @@ class CCharacterSource
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;
@@ -38,4 +39,5 @@ class CCharacterSource
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};
@@ -85,3 +87,5 @@ class CExpander_Interface
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};
@@ -145,3 +149,7 @@ class CExpander : public CExpander_Interface
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};
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
@@ -4,2 +4,3 @@
4#include <qdir.h> 4#include <qdir.h>
5
5#ifdef USEQPE 6#ifdef USEQPE
@@ -10,3 +11,2 @@
10#include "hrule.h" 11#include "hrule.h"
11#include "util.h"
12 12
@@ -667,4 +667,13 @@ ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NU
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;
@@ -694,3 +703,3 @@ ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NU
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);
@@ -815 +824,38 @@ void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos)
815} 824}
825
826void 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
855void 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
@@ -21,2 +21,3 @@ class CFilter_IFace : public CCharacterSource
21 virtual CCharacterSource* getparent() = 0; 21 virtual CCharacterSource* getparent() = 0;
22 virtual unsigned long startSection() = 0;
22}; 23};
@@ -28,2 +29,7 @@ class CFilter : public CFilter_IFace
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)
@@ -52,3 +58,4 @@ class CFilter : public CFilter_IFace
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};
@@ -78,2 +85,6 @@ class CFilterChain
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)
@@ -86,2 +97,8 @@ class CFilterChain
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)
@@ -405,2 +422,7 @@ class ExternFilter : public CFilter_IFace
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); }
@@ -413,3 +435,6 @@ class ExternFilter : public CFilter_IFace
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); }
@@ -425,4 +450,5 @@ class ExternFilter : public CFilter_IFace
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};
@@ -473,2 +499,25 @@ class setfg : public CFilter
473 499
500class 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
513class 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
@@ -7,2 +7,5 @@
7#include <qpixmap.h> 7#include <qpixmap.h>
8#ifdef USEQPE
9#include <qpe/global.h>
10#endif
8 11
@@ -51,3 +54,3 @@ CHM::~CHM() {
51 54
52void CHM::suspend() { 55void CHM::suspend() {
53#ifdef USEQPE 56#ifdef USEQPE
@@ -57,3 +60,3 @@ void CHM::suspend() {
57 chmFile = NULL; 60 chmFile = NULL;
58 sustime = time(NULL); 61 sustime = time(NULL);
59#endif 62#endif
@@ -61,3 +64,3 @@ void CHM::suspend() {
61 64
62void CHM::unsuspend() { 65void CHM::unsuspend() {
63#ifdef USEQPE 66#ifdef USEQPE
@@ -67,6 +70,10 @@ void CHM::unsuspend() {
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);
@@ -79,3 +86,3 @@ void CHM::unsuspend() {
79 //suspos = gzseek(file, suspos, SEEK_SET); 86 //suspos = gzseek(file, suspos, SEEK_SET);
80 } 87 }
81#endif 88#endif
@@ -88,2 +95,3 @@ void CHM::addContent(QString content) {
88void CHM::FillHomeContent() { 95void CHM::FillHomeContent() {
96unsuspend();
89 if (chmHHCPath != "") { 97 if (chmHHCPath != "") {
@@ -164,2 +172,3 @@ bool CHM::FillBuffer()
164{ 172{
173unsuspend();
165 bool bRetVal = false; 174 bool bRetVal = false;
@@ -198,2 +207,3 @@ bool CHM::FillBuffer()
198bool CHM::FillContent() { 207bool CHM::FillContent() {
208unsuspend();
199 bool bRetVal = false; 209 bool bRetVal = false;
@@ -241,3 +251,4 @@ bool CHM::FillContent() {
241 251
242bool CHM::getFile(const QString& href) { 252bool 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);
@@ -321,7 +332,7 @@ int CHM::getch() {
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;
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
@@ -58,3 +58,3 @@ public:
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);
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
@@ -63,7 +63,7 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
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 {
@@ -87,8 +87,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
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 {
@@ -99,8 +99,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
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);
@@ -113,8 +113,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
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 {
@@ -122,16 +122,16 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
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;
@@ -139,8 +139,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
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++)
@@ -159,8 +159,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
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;
@@ -195,8 +195,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
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 {
@@ -230,14 +230,14 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
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 }
@@ -268,8 +268,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
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)
@@ -290,8 +290,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
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 {
@@ -299,16 +299,16 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
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;
@@ -316,8 +316,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
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++)
@@ -384,8 +384,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
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)
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
4class CInfo
5{
6 public:
7 virtual unsigned long size() = 0;
8};
9
10class CSource : public CInfo
11{
12 public:
13 virtual int get() = 0;
14};
15
16class CSink : public CInfo
17{
18 public:
19 virtual void put(unsigned char c) = 0;
20};
21
22class 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
41class 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
10typedef unsigned int uint;
11typedef unsigned char uc;
12
13#define DO(n) for (int _=0; _<n; _++)
14#define TOP (1<<24)
15#define BOT (1<<16)
16
17
18class 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
26public:
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
59static struct SUBRANGE {
60 DWORD LowCount, HighCount, scale;
61} SubRange;
62enum { TOP=1 << 24, BOT=1 << 15 };
63static DWORD low, code, range;
64
65inline 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}
76inline void ariEncodeSymbol()
77{
78 low += SubRange.LowCount*(range /= SubRange.scale);
79 range *= SubRange.HighCount-SubRange.LowCount;
80}
81inline 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}
103inline UINT ariGetCurrentCount() {
104 return (code-low)/(range /= SubRange.scale);
105}
106inline UINT ariGetCurrentShiftCount(UINT SHIFT) {
107 return (code-low)/(range >>= SHIFT);
108}
109inline 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 @@
1Makefile
2config.in
3moc_*
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 @@
1DEFINES += OPIE USEQPE
2VPATH = ..
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
16DEPENDPATH += $(OPIEDIR)/include
17
18include( $(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 @@
1Makefile
2config.in
3moc_*
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 @@
1DEFINES += OPIE USEQPE
2VPATH = ..
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
13LIBS += -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
16DEPENDPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include
17
18include( $(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 @@
1Makefile
2config.in
3moc_*
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 @@
1DEFINES += OPIE USEQPE
2VPATH = ..
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
13LIBS += -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
16DEPENDPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include
17
18include( $(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,2 +1,3 @@
1#include <qfontdatabase.h> 1#include <qfontdatabase.h>
2
2#include "FontControl.h" 3#include "FontControl.h"
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
@@ -63,3 +63,3 @@ class FontControl
63 } 63 }
64 return m_fontsizes[tgt]; 64 return tgt >= 0 ? m_fontsizes[tgt] : 12;
65 } 65 }
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
13enum { 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)
17static 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;
31static 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
56static BYTE NS2BSIndx[256], QTable[260]; // constants
57static PPM_CONTEXT::STATE* FoundState; // found next state transition
58static int InitEsc, OrderFall, RunLength, InitRL, MaxOrder;
59static BYTE CharMask[256], NumMasked, PrevSuccess, EscCount, PrintCount;
60static WORD BinSumm[25][64]; // binary SEE-contexts
61static MR_METHOD MRMethod;
62
63inline 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}
74inline 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}
79struct PPMD_STARTUP { inline PPMD_STARTUP(); } PPMd_StartUp;
80inline 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}
99static 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 }
120static 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}
134void 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))
150PPM_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 {
162REMOVE: 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}
183PPM_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}
202static 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}
237static PPM_CONTEXT* _FASTCALL CreateSuccessors(BOOL Skip,PPM_CONTEXT::STATE* p,
238 PPM_CONTEXT* pc);
239static 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) {
250FROZEN: 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); }
262LOOP_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}
279void 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}
316static 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 }
339LOOP_ENTRY:
340 if (p->Successor != UpBranch) {
341 pc=p->Successor; break;
342 }
343 *pps++ = p;
344 } while ( pc->Suffix );
345NO_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}
367static 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;
435RESTART_MODEL:
436 RestoreModelRare(pc1,MinContext,FSuccessor);
437}
438// Tabulated escapes for exponential symbol distribution
439static 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))
441inline 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}
458inline 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}
475inline 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}
483inline 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}
510inline 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}
534inline 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}
540inline 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}
556inline 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;
570SYMBOL_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}
579inline 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}
602inline void ClearMask(CInfo* EncodedFile, CInfo* DecodedFile)
603{
604 EscCount=1; memset(CharMask,0,sizeof(CharMask));
605 // if (++PrintCount == 0) PrintInfo(DecodedFile,EncodedFile);
606}
607void _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 }
635STOP_ENCODING:
636 ARI_FLUSH_ENCODER(EncodedFile); //PrintInfo(DecodedFile,EncodedFile);
637}
638void _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 }
664STOP_DECODING:
665 // PrintInfo(DecodedFile,EncodedFile);
666 return;
667}
668
669
670
671#include "PPMd.h"
672#include "CSource.h"
673
674size_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
703extern "C"
704{
705
706size_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
711size_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
716size_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
4extern "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,2 +1,3 @@
1/* -*- mode: c; indent-tabs-mode: nil; -*- */ 1/* -*- mode: c; indent-tabs-mode: nil; -*- */
2
2#include <stdio.h> 3#include <stdio.h>
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
@@ -10,2 +10,4 @@
10 10
11#include <stdlib.h>
12
11#include <qcheckbox.h> 13#include <qcheckbox.h>
@@ -20,2 +22,3 @@
20#include <qlineedit.h> 22#include <qlineedit.h>
23#include <qdir.h>
21#ifdef USECOMBO 24#ifdef USECOMBO
@@ -104,2 +107,7 @@ CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl )
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 /*
@@ -564,2 +572,5 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl )
564 572
573 QCheckBox* outcodec = new QCheckBox( bg );
574 outcodec->setText( tr( "Output" ) );
575
565} 576}
@@ -595,2 +606,5 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl )
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);
@@ -606,29 +620,51 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl )
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
652CMiscPrefs::~CMiscPrefs()
653{
654 // no need to delete child widgets, Qt does it all for us
655}
656
657CScrollPrefs::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 );
@@ -641,31 +677,55 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl )
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
670CMiscPrefs::~CMiscPrefs() 730CScrollPrefs::~CScrollPrefs()
671{ 731{
@@ -674,2 +734,3 @@ CMiscPrefs::~CMiscPrefs()
674 734
735
675CPrefs::CPrefs( int w, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) 736CPrefs::CPrefs( int w, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true)
@@ -680,2 +741,3 @@ CPrefs::CPrefs( int w, bool fs, QWidget* parent, const char* name) : QDialog(par
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);
@@ -686,2 +748,3 @@ CPrefs::CPrefs( int w, bool fs, QWidget* parent, const char* name) : QDialog(par
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"));
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
@@ -63,2 +63,4 @@ public:
63 // QCheckBox* Negative; 63 // QCheckBox* Negative;
64 QCheckBox* InlineTables;
65 QCheckBox* Underlinelinks;
64}; 66};
@@ -100,2 +102,3 @@ public:
100 QCheckBox* Continuous; 102 QCheckBox* Continuous;
103 QCheckBox* DoubleBuffer;
101protected: 104protected:
@@ -118,4 +121,21 @@ public:
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
132class CScrollPrefs : public QWidget
133{
134
135public:
136
137 friend class CPrefs;
138
139 CScrollPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
140 ~CScrollPrefs();
121 141
@@ -124,5 +144,5 @@ public:
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
@@ -133,3 +153,3 @@ class QListViewItem;
133 153
134class CButtonPrefs : public QWidget 154sclass CButtonPrefs : public QWidget
135{ 155{
@@ -191,3 +211,3 @@ Q_OBJECT
191 CMiscPrefs* misc; 211 CMiscPrefs* misc;
192 // CButtonPrefs* button; 212 CScrollPrefs* scroll;
193 CInterPrefs* inter; 213 CInterPrefs* inter;
@@ -223,3 +243,5 @@ Q_OBJECT
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(); }
@@ -248,3 +270,5 @@ Q_OBJECT
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); }
@@ -275,3 +299,3 @@ Q_OBJECT
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); }
@@ -279,3 +303,3 @@ Q_OBJECT
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); }
@@ -283,3 +307,3 @@ Q_OBJECT
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(); }
@@ -302,3 +326,2 @@ Q_OBJECT
302 326
303
304#ifdef USECOMBO 327#ifdef USECOMBO
@@ -319,2 +342,22 @@ Q_OBJECT
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(); }
@@ -325,2 +368,4 @@ Q_OBJECT
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(); }
@@ -373,12 +418,12 @@ Q_OBJECT
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};
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
@@ -34,3 +34,6 @@ const int _SBARHEIGHT = 3;
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
@@ -40,2 +43,3 @@ 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 };
@@ -51,5 +55,5 @@ tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>'
51 55
52
53QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : 56QTReader::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),
@@ -91,12 +95,8 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
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}
@@ -119,3 +119,3 @@ QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *nam
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);
@@ -140,3 +140,4 @@ 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;
@@ -156,10 +157,12 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
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();
@@ -167,12 +170,154 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
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 }
@@ -297,3 +442,3 @@ void QTReader::goForward()
297 442
298linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img) 443linkType 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{
@@ -342,3 +487,3 @@ linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t
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}
@@ -356,2 +501,34 @@ void QTReader::suspend()
356 501
502void 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
357void QTReader::setTwoTouch(bool _b) 534void QTReader::setTwoTouch(bool _b)
@@ -364,3 +541,2 @@ void QTReader::setContinuous(bool _b)
364{ 541{
365 buffdoc.unsuspend();
366 buffdoc.setContinuous(m_continuousDocument = _b); 542 buffdoc.setContinuous(m_continuousDocument = _b);
@@ -457,3 +633,3 @@ void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouse
457 { 633 {
458 qDebug("Selecteed:%s", (const char*)wrd); 634 qDebug("Selected:%s", (const char*)wrd);
459 if (m_twotouch) 635 if (m_twotouch)
@@ -470,12 +646,41 @@ void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouse
470 646
471void QTReader::mouseReleaseEvent( QMouseEvent* _e ) 647#ifdef USETIMER
648void 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 }
@@ -483,187 +688,294 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
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
694void 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
754void 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 }
@@ -674,3 +986,3 @@ 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();
@@ -682,3 +994,10 @@ void QTReader::focusOutEvent(QFocusEvent* e)
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;
@@ -719,3 +1038,2 @@ void QTReader::NavUp()
719{ 1038{
720 buffdoc.unsuspend();
721 if (buffdoc.hasnavigation()) 1039 if (buffdoc.hasnavigation())
@@ -739,3 +1057,2 @@ void QTReader::NavDown()
739{ 1057{
740 buffdoc.unsuspend();
741 if (buffdoc.hasnavigation()) 1058 if (buffdoc.hasnavigation())
@@ -764,4 +1081,3 @@ void QTReader::zoomin()
764 setfont(); 1081 setfont();
765 locate(pagelocate()); 1082 refresh();
766 repaint();
767 setautoscroll(sc); 1083 setautoscroll(sc);
@@ -777,4 +1093,3 @@ void QTReader::zoomout()
777 setfont(); 1093 setfont();
778 locate(pagelocate()); 1094 refresh();
779 repaint();
780 setautoscroll(sc); 1095 setautoscroll(sc);
@@ -811,4 +1126,3 @@ void QTReader::keyPressEvent(QKeyEvent* e)
811{ 1126{
812 buffdoc.unsuspend(); 1127
813
814 //((QTReaderApp*)parent()->parent())->handlekey(e); 1128 //((QTReaderApp*)parent()->parent())->handlekey(e);
@@ -908,2 +1222,3 @@ void QTReader::setautoscroll(bool _sc)
908{ 1222{
1223 m_outofdate = true;
909 if (_sc == m_autoScroll) return; 1224 if (_sc == m_autoScroll) return;
@@ -929,2 +1244,5 @@ void QTReader::setautoscroll(bool _sc)
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;
@@ -949,3 +1267,2 @@ bool QTReader::getline(CDrawBuffer *buff)
949{ 1267{
950 buffdoc.unsuspend();
951 bool bRet; 1268 bool bRet;
@@ -1067,20 +1384,2 @@ void QTReader::doinplacescroll()
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;
@@ -1101,3 +1400,2 @@ void QTReader::doinplacescroll()
1101#endif 1400#endif
1102 //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll);
1103 emit SetScrollState(m_autoScroll); 1401 emit SetScrollState(m_autoScroll);
@@ -1496,5 +1794,16 @@ 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}
@@ -1559,24 +1868,28 @@ void QTReader::redrawall()
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 }
@@ -1584,10 +1897,16 @@ void QTReader::redrawall()
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 }
@@ -1602,6 +1921,32 @@ void QTReader::drawFonts()
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()))
@@ -1613,3 +1958,5 @@ void QTReader::drawFonts()
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);
@@ -1653,59 +2000,2 @@ void QTReader::drawFonts()
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();
@@ -1930,3 +2220,2 @@ void QTReader::init()
1930{ 2220{
1931 buffdoc.unsuspend();
1932 setBackgroundColor( m_bg ); 2221 setBackgroundColor( m_bg );
@@ -1937,2 +2226,6 @@ void QTReader::init()
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);
@@ -1946,6 +2239,11 @@ 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
@@ -1984,5 +2282,43 @@ void QTReader::printIt()
1984 2282
1985void QTReader::paintEvent( QPaintEvent * ) 2283void 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}
@@ -2018,5 +2354,14 @@ int main( int argc, tchar **argv )
2018 2354
2355bool 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/*
2019bool QTReader::locate(unsigned long n) { 2365bool QTReader::locate(unsigned long n) {
2020 //printf("Locate\n"); 2366 //printf("Locate\n");
2021 buffdoc.unsuspend();
2022 buffdoc.locate(n); 2367 buffdoc.locate(n);
@@ -2025,2 +2370,3 @@ bool QTReader::locate(unsigned long n) {
2025 fillbuffer(); 2370 fillbuffer();
2371 m_outofdate = true;
2026// // qDebug("&Buffer filled"); 2372// // qDebug("&Buffer filled");
@@ -2031,3 +2377,3 @@ bool QTReader::locate(unsigned long n) {
2031} 2377}
2032 2378*/
2033unsigned int QTReader::screenlines() 2379unsigned int QTReader::screenlines()
@@ -2041,3 +2387,2 @@ 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);
@@ -2065,2 +2410,8 @@ bool QTReader::fillbuffer(int reuse, int ht, int newht)
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++;
@@ -2068,7 +2419,10 @@ bool QTReader::fillbuffer(int reuse, int ht, int newht)
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 }
@@ -2103,3 +2457,2 @@ void QTReader::dopagedn()
2103// qDebug("HEIGHT(2):%d", m_lastheight); 2457// qDebug("HEIGHT(2):%d", m_lastheight);
2104 buffdoc.unsuspend();
2105 ResetScroll(); 2458 ResetScroll();
@@ -2152,4 +2505,6 @@ bool QTReader::synch(size_t start, size_t end)
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 }
@@ -2160,3 +2515,2 @@ void QTReader::dopageup(unsigned int target)
2160{ 2515{
2161 buffdoc.unsuspend();
2162 ResetScroll(); 2516 ResetScroll();
@@ -2164,4 +2518,4 @@ void QTReader::dopageup(unsigned int target)
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;
@@ -2182,2 +2536,3 @@ void QTReader::dopageup(unsigned int target)
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());
@@ -2189,11 +2544,11 @@ void QTReader::dopageup(unsigned int target)
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 }
@@ -2295,4 +2650,5 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
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 {
@@ -2318,4 +2674,2 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
2318 qDebug("buffdoc.openfile done"); 2674 qDebug("buffdoc.openfile done");
2319 locate(lcn);
2320 qDebug("buffdoc.locate done");
2321 } 2675 }
@@ -2323,2 +2677,4 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
2323 qDebug("Updated"); 2677 qDebug("Updated");
2678 bDoUpdates = true;
2679 locate(lcn);
2324 return bRC; 2680 return bRC;
@@ -2360,2 +2716,3 @@ void QTReader::lineDown()
2360 mylastpos = locate(); 2716 mylastpos = locate();
2717 m_outofdate = true;
2361 update(); 2718 update();
@@ -2574,12 +2931,17 @@ MarkupType QTReader::PreferredMarkup()
2574} 2931}
2575#ifdef DOUBLEBUFFER 2932
2576void QTReader::resizeEvent( QResizeEvent * p ) 2933void 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 }
@@ -2607,10 +2969,10 @@ void QTReader::resizeEvent( QResizeEvent * p )
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
@@ -2618,14 +2980,8 @@ 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;
@@ -2650,13 +3006,27 @@ void QTReader::setrotated(bool sfs)
2650 qDebug("Right margin:%u", m_right_border ); 3006 qDebug("Right margin:%u", m_right_border );
3007 */
2651} 3008}
2652 3009
2653void QTReader::drawBackground() 3010void 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)
@@ -2665,5 +3035,12 @@ void QTReader::drawBackground()
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 }
@@ -2672,12 +3049,10 @@ void QTReader::drawBackground()
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 }
@@ -2690,5 +3065,12 @@ void QTReader::drawBackground()
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 }
@@ -2698,3 +3080,3 @@ void QTReader::drawBackground()
2698 } 3080 }
2699 // dbp->setBackgroundMode(OpaqueMode); 3081 // p->setBackgroundMode(OpaqueMode);
2700 } 3082 }
@@ -2761,3 +3143,8 @@ 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}
@@ -2899,3 +3286,3 @@ void QTReader::gotoLink()
2899 { 3286 {
2900 if (!buffdoc.getFile(href)) 3287 if (!buffdoc.getFile(href, nm))
2901 { 3288 {
@@ -2907,2 +3294,3 @@ void QTReader::gotoLink()
2907 fillbuffer(); 3294 fillbuffer();
3295 m_outofdate = true;
2908 update(); 3296 update();
@@ -2915,3 +3303,5 @@ void QTReader::gotoLink()
2915 { 3303 {
3304 buffdoc.resetPos();
2916 fillbuffer(); 3305 fillbuffer();
3306 m_outofdate = true;
2917 update(); 3307 update();
@@ -2932,2 +3322,3 @@ void QTReader::gotoLink()
2932 fillbuffer(); 3322 fillbuffer();
3323 m_outofdate = true;
2933 update(); 3324 update();
@@ -2951,5 +3342,5 @@ void QTReader::gotoLink()
2951 emit OnURLSelected(href, tgt); 3342 emit OnURLSelected(href, tgt);
3343 refresh();
2952 } 3344 }
2953 } 3345 }
2954 locate(pagelocate());
2955 } 3346 }
@@ -2962,2 +3353,3 @@ void QTReader::refresh(bool full)
2962{ 3353{
3354 qDebug("Refreshing");
2963 int h, w; 3355 int h, w;
@@ -2983,3 +3375,118 @@ void QTReader::refresh(bool full)
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
3382CFilterChain* 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
3438void 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
3465bool 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
3478bool 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
@@ -20,12 +20,10 @@ class QImage;
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
27class QPainter; 24class QPainter;
28#endif 25class COutput;
29 26
30class CStyle; 27class CStyle;
28#define USETIMER
31 29
@@ -35,6 +33,11 @@ class QTReader : public QWidget
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);
@@ -76,7 +79,5 @@ class QTReader : public QWidget
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();
@@ -97,2 +98,3 @@ class QTReader : public QWidget
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
@@ -108,2 +110,3 @@ public:
108 QString about(); 110 QString about();
111 void readAloud();
109 CList<Bkmk>* Bkmklist() { return pBkmklist; } 112 CList<Bkmk>* Bkmklist() { return pBkmklist; }
@@ -155,3 +158,3 @@ public:
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 /*
@@ -227,56 +230,8 @@ public:
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
281private slots: 233private slots:
234#ifdef USETIMER
235 void actionDrag();
236#endif
282 void dopageup(); 237 void dopageup();
@@ -290,5 +245,5 @@ private slots:
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*);
@@ -302,2 +257,3 @@ private slots:
302 void init(); 257 void init();
258 void mouseMoveEvent( QMouseEvent* );
303 void mousePressEvent( QMouseEvent* ); 259 void mousePressEvent( QMouseEvent* );
@@ -307,2 +263,5 @@ private slots:
307 void setfont(); 263 void setfont();
264 bool m_doubleBuffered;
265
266 void setDoubleBuffer(bool _b);
308 //myoutput stuff 267 //myoutput stuff
@@ -313,3 +272,3 @@ private slots:
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;
@@ -324,4 +283,4 @@ private slots:
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;
@@ -332,2 +291,3 @@ private slots:
332 public: 291 public:
292 bool doOutput(const QString& wrd);
333 void setDoUpdates(bool b) { bDoUpdates = b; } 293 void setDoUpdates(bool b) { bDoUpdates = b; }
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
@@ -19,2 +19,3 @@
19**********************************************************************/ 19**********************************************************************/
20
20#include <qregexp.h> 21#include <qregexp.h>
@@ -68,2 +69,3 @@
68#include <qfontdatabase.h> 69#include <qfontdatabase.h>
70
69#ifdef USEQPE 71#ifdef USEQPE
@@ -71,3 +73,4 @@
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>
@@ -78,2 +81,5 @@ using namespace Opie::Ui;
78#else 81#else
82#include "fileBrowser.h"
83#endif
84#else
79#include "qfiledialog.h" 85#include "qfiledialog.h"
@@ -90,3 +96,3 @@ using namespace Opie::Ui;
90 96
91bool CheckVersion(int&, int&, char&); 97bool CheckVersion(int&, int&, char&, QWidget*);
92 98
@@ -155,7 +161,5 @@ void QTReaderApp::listBkmkFiles()
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
@@ -179,4 +183,3 @@ void QTReaderApp::listBkmkFiles()
179 { 183 {
180 bkmkselector->insertItem(de->d_name); 184 bkmkselector->insertItem(de->d_name, cnt++);
181 cnt++;
182 } 185 }
@@ -204,3 +207,3 @@ void QTReaderApp::hidetoolbars()
204 207
205#ifdef USEQPE 208#if defined(USEQPE)
206 menubar->hide(); 209 menubar->hide();
@@ -335,3 +338,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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);
@@ -342,3 +345,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
342 345
343#ifdef USEQPE 346#if defined(USEQPE)
344 QPopupMenu* tmp = new QPopupMenu(mb); 347 QPopupMenu* tmp = new QPopupMenu(mb);
@@ -438,2 +441,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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);
@@ -458,2 +464,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -473,2 +480,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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
@@ -502,4 +511,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -508,2 +519,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -518,2 +530,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
518 m_doClipboard = config.readBoolEntry( "Clipboard", false); 530 m_doClipboard = config.readBoolEntry( "Clipboard", false);
531 m_doOutput = config.readBoolEntry( "OutputTgt", false);
519 /* 532 /*
@@ -844,2 +857,14 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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
@@ -974,2 +999,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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())
@@ -1034,4 +1060,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
1034 } 1060 }
1035 reader->bDoUpdates = true; 1061 // reader->bDoUpdates = true;
1036 reader->update(); 1062 // reader->update();
1037 config.setGroup("Version"); 1063 config.setGroup("Version");
@@ -1040,3 +1066,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 {
@@ -1067,3 +1093,3 @@ void QTReaderApp::addtoolbars(Config* config)
1067 { 1093 {
1068#ifdef USEQPE 1094#if defined(USEQPE)
1069 if (fileBar != menubar) 1095 if (fileBar != menubar)
@@ -1095,3 +1121,3 @@ void QTReaderApp::addtoolbars(Config* config)
1095 { 1121 {
1096#ifdef USEQPE 1122#if defined(USEQPE)
1097 if ((navBar == fileBar) && (fileBar == menubar)) 1123 if ((navBar == fileBar) && (fileBar == menubar))
@@ -1134,3 +1160,3 @@ void QTReaderApp::addtoolbars(Config* config)
1134 { 1160 {
1135#ifdef USEQPE 1161#if defined(USEQPE)
1136 if ((viewBar == fileBar) && (fileBar == menubar)) 1162 if ((viewBar == fileBar) && (fileBar == menubar))
@@ -1166,3 +1192,3 @@ void QTReaderApp::addtoolbars(Config* config)
1166 { 1192 {
1167#ifdef USEQPE 1193#if defined(USEQPE)
1168 if ((markBar == fileBar) && (fileBar == menubar)) 1194 if ((markBar == fileBar) && (fileBar == menubar))
@@ -1235,3 +1261,3 @@ QToolBar* QTReaderApp::filebar()
1235 { 1261 {
1236#ifdef USEQPE 1262#if defined(USEQPE)
1237 case cesSingle: 1263 case cesSingle:
@@ -1719,3 +1745,2 @@ void QTReaderApp::setrotated(bool sfs)
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 }
@@ -1735,5 +1760,4 @@ void QTReaderApp::setrotated(bool sfs)
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}
@@ -1930,3 +1954,3 @@ void QTReaderApp::fileOpen2()
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 }
@@ -1953,3 +1977,3 @@ QString QTReaderApp::usefilebrowser()
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;
@@ -2005,2 +2029,3 @@ void QTReaderApp::showprefs()
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);
@@ -2017,2 +2042,3 @@ void QTReaderApp::showprefs()
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);
@@ -2058,2 +2084,3 @@ void QTReaderApp::showprefs()
2058 prefwin->Continuous(reader->m_continuousDocument); 2084 prefwin->Continuous(reader->m_continuousDocument);
2085 prefwin->DoubleBuffer(reader->m_doubleBuffered);
2059 2086
@@ -2072,2 +2099,3 @@ void QTReaderApp::showprefs()
2072 prefwin->miscclipboard(m_doClipboard); 2099 prefwin->miscclipboard(m_doClipboard);
2100 prefwin->miscoutput(m_doOutput);
2073 2101
@@ -2087,2 +2115,4 @@ void QTReaderApp::showprefs()
2087 2115
2116 prefwin->outcodec(reader->m_outputName);
2117
2088 if (prefwin->exec()) 2118 if (prefwin->exec())
@@ -2091,2 +2121,4 @@ void QTReaderApp::showprefs()
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();
@@ -2109,2 +2141,3 @@ void QTReaderApp::showprefs()
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();
@@ -2151,2 +2184,3 @@ void QTReaderApp::showprefs()
2151 reader->setContinuous(prefwin->Continuous()); 2184 reader->setContinuous(prefwin->Continuous());
2185 reader->setDoubleBuffer(prefwin->DoubleBuffer());
2152 2186
@@ -2164,2 +2198,3 @@ void QTReaderApp::showprefs()
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();
@@ -2185,2 +2220,11 @@ void QTReaderApp::showprefs()
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;
@@ -2292,8 +2336,32 @@ void QTReaderApp::showinfo()
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);
@@ -2744,3 +2812,3 @@ void QTReaderApp::search()
2744 2812
2745void QTReaderApp::openFile( const QString &f ) 2813void QTReaderApp::openFile( const QString &f, unsigned int loc )
2746{ 2814{
@@ -2767,3 +2835,3 @@ void QTReaderApp::openFile( const QString &f )
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);
@@ -2808,3 +2876,3 @@ void QTReaderApp::handlekey(QKeyEvent* e)
2808 case Key_Escape: 2876 case Key_Escape:
2809 // qDebug("escape event"); 2877 qDebug("escape event");
2810 if (m_disableesckey) 2878 if (m_disableesckey)
@@ -2893,16 +2961,13 @@ void QTReaderApp::handlekey(QKeyEvent* e)
2893 2961
2894#ifdef NEWFULLSCREEN 2962#if defined(USEQPE) && defined(USENEWFULLSCREEN)
2895void QTReaderApp::enableFullscreen() 2963void 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
2903void 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 }
@@ -2910,8 +2975,12 @@ void QTReaderApp::resizeEvent(QResizeEvent *)
2910 2975
2911void QTReaderApp::focusInEvent(QFocusEvent*) 2976void 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 }
@@ -2926,3 +2995,3 @@ void QTReaderApp::showEditTools()
2926 { 2995 {
2927#ifdef USEQPE 2996#if defined(USEQPE)
2928 if (menubar != NULL) menubar->hide(); 2997 if (menubar != NULL) menubar->hide();
@@ -2946,8 +3015,4 @@ void QTReaderApp::showEditTools()
2946 //showNormal(); 3015 //showNormal();
2947#ifdef NEWFULLSCREEN
2948 enableFullscreen();
2949#else
2950 showFullScreen(); 3016 showFullScreen();
2951#endif 3017 }
2952 }
2953 else 3018 else
@@ -2972,3 +3037,3 @@ void QTReaderApp::showEditTools()
2972 { 3037 {
2973#ifdef USEQPE 3038#if defined(USEQPE)
2974 menubar->show(); 3039 menubar->show();
@@ -3006,3 +3071,3 @@ void QTReaderApp::showEditTools()
3006 //qDebug("sm"); 3071 //qDebug("sm");
3007#ifdef USEQPE 3072#if defined(USEQPE) && !defined(SIMPAD)
3008 showMaximized(); 3073 showMaximized();
@@ -3019,3 +3084,3 @@ void QTReaderApp::showEditTools()
3019 // qDebug("ref"); 3084 // qDebug("ref");
3020 reader->refresh(true); 3085 //reader->refresh(true);
3021 // qDebug("done"); 3086 // qDebug("done");
@@ -3176,3 +3241,3 @@ void QTReaderApp::do_delmark()
3176 3241
3177bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) 3242bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel)
3178{ 3243{
@@ -3184,2 +3249,3 @@ bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
3184 int cnt = 0; 3249 int cnt = 0;
3250 int slt = -1;
3185 if (plist != NULL) 3251 if (plist != NULL)
@@ -3188,9 +3254,17 @@ bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
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 }
@@ -3201,2 +3275,3 @@ bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
3201 editorStack->raiseWidget( bkmkselector ); 3275 editorStack->raiseWidget( bkmkselector );
3276 if (slt != -1) bkmkselector->setCurrentItem(slt);
3202 return true; 3277 return true;
@@ -3240,5 +3315,4 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
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
@@ -3250,2 +3324,4 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
3250 bk->value(0); 3324 bk->value(0);
3325 reader->m_lastposn = 0;
3326 openFile(fn);
3251 } 3327 }
@@ -3255,2 +3331,3 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
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);
@@ -3263,3 +3340,2 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
3263 // showEditTools(); 3340 // showEditTools();
3264 reader->locate(bk->value());
3265 } 3341 }
@@ -3368,3 +3444,3 @@ void QTReaderApp::gotobkmk(int ind)
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");
@@ -3705,5 +3781,6 @@ void QTReaderApp::do_autogen(const QString& regText)
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;
@@ -3724,2 +3801,10 @@ void QTReaderApp::do_autogen(const QString& regText)
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 }
@@ -4034,2 +4119,6 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2,
4034 4119
4120 if (m_doOutput && reader->checkoutput())
4121 {
4122 reader->doOutput(wrd);
4123 }
4035 if (m_doClipboard) 4124 if (m_doClipboard)
@@ -4118,3 +4207,3 @@ void QTReaderApp::doAction(QKeyEvent* e)
4118 { 4207 {
4119#ifdef USEQPE 4208#if defined(USEQPE)
4120 menubar->hide(); 4209 menubar->hide();
@@ -4129,3 +4218,3 @@ void QTReaderApp::doAction(QKeyEvent* e)
4129 { 4218 {
4130#ifdef USEQPE 4219#if defined(USEQPE)
4131 menubar->show(); 4220 menubar->show();
@@ -4342,2 +4431,3 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
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 );
@@ -4367,2 +4457,3 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
4367 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); 4457 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
4458 config.writeEntry( "OutputCodec", reader->m_outputName);
4368 } 4459 }
@@ -4398,2 +4489,3 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
4398 config.writeEntry( "Clipboard", m_doClipboard); 4489 config.writeEntry( "Clipboard", m_doClipboard);
4490 config.writeEntry( "OutputTgt", m_doOutput);
4399 /* 4491 /*
@@ -4412,3 +4504,5 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
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 );
@@ -4418,2 +4512,3 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
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 );
@@ -4521,2 +4616,3 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
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 );
@@ -4576,3 +4672,5 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
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 );
@@ -4581,2 +4679,3 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
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 );
@@ -4591,2 +4690,3 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
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
@@ -4597,2 +4697,4 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
4597 reader->setTwoTouch(m_twoTouch); 4697 reader->setTwoTouch(m_twoTouch);
4698
4699 reader->m_outputName = config.readEntry( "OutputCodec", reader->m_outputName);
4598 4700
@@ -4639,4 +4741,3 @@ bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs)
4639 4741
4640 bkmkselector->insertItem(fi->fileName()); 4742 bkmkselector->insertItem(fi->fileName(), cnt++);
4641 cnt++;
4642 4743
@@ -4665,4 +4766,3 @@ bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs)
4665 { 4766 {
4666 bkmkselector->insertItem(de->d_name); 4767 bkmkselector->insertItem(de->d_name, cnt++);
4667 cnt++;
4668 } 4768 }
@@ -4737,2 +4837,4 @@ void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt)
4737 } 4837 }
4838 QString msg = "External URL\n" + href;
4839 QMessageBox::information(this, PROGNAME, msg);
4738#else 4840#else
@@ -4903,3 +5005,3 @@ void QTReaderApp::forceopen(const QString& filename)
4903 */ 5005 */
4904 if (!filename.isEmpty()) 5006 if (!filename.isEmpty() && QFileInfo(filename).exists())
4905 { 5007 {
@@ -4920,2 +5022,6 @@ void QTReaderApp::forceopen(const QString& filename)
4920 } 5022 }
5023 else
5024 {
5025 OnURLSelected(filename, 0);
5026 }
4921} 5027}
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
@@ -177,3 +177,3 @@ class QTReaderApp : public QMainWindow
177 void suspend(); 177 void suspend();
178 void openFile( const QString & ); 178 void openFile( const QString &, unsigned int loc = 0 );
179 179
@@ -188,6 +188,6 @@ class QTReaderApp : public QMainWindow
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
@@ -210,2 +210,3 @@ class QTReaderApp : public QMainWindow
210 bool m_doDictionary; 210 bool m_doDictionary;
211 bool m_doOutput;
211 bool m_doClipboard; 212 bool m_doClipboard;
@@ -390,3 +391,3 @@ private slots:
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();
@@ -423,3 +424,3 @@ private slots:
423// QPEToolBar /* *menu,*/ *fileBar; 424// QPEToolBar /* *menu,*/ *fileBar;
424#ifdef USEQPE 425#if defined(USEQPE)
425 QToolBar *menubar; 426 QToolBar *menubar;
@@ -427,3 +428,3 @@ private slots:
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;
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
16template<class T>
17UInt32 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
35template<class T, class D>
36UInt32 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
56CReb::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
63CReb::~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
73unsigned int CReb::locate()
74{
75 return m_pagedetails[currentpage.pageno()].pagestart+currentpage.offset();
76}
77
78void 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
143bool 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
160QImage* 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
181CList<Bkmk>* CReb::getbkmklist() { return NULL; }
182
183void CReb::home()
184{
185 startpage(m_homepage);
186}
187
188int 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
352UInt32 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
360UInt32 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
371void 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
563bool 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
575void CReb::suspend()
576{
577 CExpander::suspend(fin);
578}
579void CReb::unsuspend()
580{
581 CExpander::unsuspend(fin);
582}
583#endif
584
585#ifndef __STATIC
586extern "C"
587{
588 CExpander* newcodec() { return new CReb; }
589}
590#endif
591
592void 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
600void CReb::startpage(UInt32 _cp, bool _isCompressed, UInt32 _len)
601{
602 unsuspend();
603 readindex(_cp);
604 currentpage.startpage(page2pos(_cp), _cp, _isCompressed, _len);
605}
606
607void 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
637void RBPage::startpage(UInt32 pos, UInt32 _cp, bool _isCompressed, UInt32 _len)
638{
639 initpage(pos, _cp, _isCompressed, _len);
640 readchunk();
641}
642
643int CReb::getch()
644{
645 if (tagoffset < tagstring.length())
646 return tagstring[tagoffset++].unicode();
647 else
648 return currentpage.getch(this);
649}
650
651int 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
668unsigned 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
681int 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
694void 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
720void 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
755void 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/*
21struct 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
31class CReb;
32
33class 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
72struct 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
82struct 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
91class 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);
124public:
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 @@
1Makefile
2config.in
3moc_*
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 @@
1DEFINES += OPIE USEQPE
2VPATH = ..
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
14LIBS += -L$(OPIEDIR)/lib -lreader_codec
15
16
17 INCLUDEPATH+= $(OPIEDIR)/include
18DEPENDPATH += $(OPIEDIR)/include
19
20include( $(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
@@ -40,3 +40,4 @@ enum EalignmentType
40 m_AlignCentre, 40 m_AlignCentre,
41 m_AlignJustify 41 m_AlignJustify,
42 m_AlignNone
42}; 43};
@@ -48,2 +49,3 @@ class CBasicStyle
48 m_italic; 49 m_italic;
50 unsigned long m_table;
49 int m_fontsize; 51 int m_fontsize;
@@ -66,2 +68,3 @@ class CBasicStyle
66 unset(); 68 unset();
69 m_table = 0xffffffff;
67 } 70 }
@@ -148,2 +151,5 @@ class 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); }
@@ -189,2 +195,6 @@ class CStyle
189 } 195 }
196 void setNoJustify()
197 {
198 sty.m_align = m_AlignNone;
199 }
190 StyleType getJustify() 200 StyleType getJustify()
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
8enum { 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)
12struct 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];
24struct MEM_BLK: public BLK_NODE { DWORD NU; } _PACK_ATTR;
25#pragma pack()
26
27static BYTE Indx2Units[N_INDEXES], Units2Indx[128]; // constants
28static DWORD GlueCount, SubAllocatorSize=0;
29static BYTE* HeapStart, * pText, * UnitsStart, * LoUnit, * HiUnit;
30
31inline void PrefetchData(void* Addr)
32{
33#if defined(_USE_PREFETCHING)
34 BYTE PrefetchByte = *(volatile BYTE*) Addr;
35#endif /* defined(_USE_PREFETCHING) */
36}
37inline 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}
42inline UINT U2B(UINT NU) { return 8*NU+4*NU; }
43inline 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}
53DWORD _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}
60void _STDCALL StopSubAllocator() {
61 if ( SubAllocatorSize ) {
62 SubAllocatorSize=0; delete[] HeapStart;
63 }
64}
65BOOL _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}
73static 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}
80static 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}
106static 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}
122inline 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}
130inline 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}
136inline 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}
145inline 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}
155inline 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}
167inline void FreeUnits(void* ptr,UINT NU) {
168 UINT indx=Units2Indx[NU-1];
169 BList[indx].insert(ptr,Indx2Units[indx]);
170}
171inline void SpecialFreeUnit(void* ptr)
172{
173 if ((BYTE*) ptr != UnitsStart) BList->insert(ptr,1);
174 else { *(DWORD*) ptr=~0UL; UnitsStart += UNIT_SIZE; }
175}
176inline 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}
187static 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
3CTableDialog::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
8class CTableDialog : public QDialog
9{
10Q_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
@@ -10,2 +10,3 @@
10#define CTOOLBARPREFS_H 10#define CTOOLBARPREFS_H
11
11#include <qvariant.h> 12#include <qvariant.h>
@@ -24,5 +25,3 @@
24#endif 25#endif
25//#ifdef OPIE
26#define USECOMBO 26#define USECOMBO
27//#endif
28 27
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
@@ -5,2 +5,6 @@
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"
@@ -33,3 +37,7 @@ public:
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 }
@@ -37,6 +45,7 @@ public:
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)
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
@@ -11,2 +11,4 @@
11 11
12class ppm_expander;
13
12class PPM_ReadBuf 14class PPM_ReadBuf
@@ -14,10 +16,6 @@ class PPM_ReadBuf
14 FILE *my_file_in; 16 FILE *my_file_in;
17 ppm_expander* parent;
15public: 18public:
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};
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
5struct CArriere_dataRecord
6{
7 UInt16 uid;
8 UInt16 nParagraphs;
9 UInt32 size;
10 UInt8 type;
11 UInt8 reserved;
12};
13
14int CArriere::HeaderSize()
15{
16 return 10;
17}
18
19void 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
34bool 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
41int 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
102tchar CArriere::getch(bool fast)
103{
104 mystyle.clearPicture();
105 return getch_base(fast);
106}
107
108/*
109void CArriere::setlink(QString& fn, const QString& wrd)
110{
111 fn = wrd;
112}
113*/
114
115QImage* 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
125void CArriere::start2endSection()
126{
127 m_currentstart = NEFstartSection();
128 m_currentend = NEFendSection();
129}
130
131unsigned 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
153unsigned 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
183extern "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
6class QScrollView;
7class QWidget;
8#endif
9
10class CArriere : public CPlucker_base
11{
12protected:
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;
32public:
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
@@ -5,2 +5,12 @@
5 5
6class 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
6class CBkmkSelector : public QWidget 16class CBkmkSelector : public QWidget
@@ -12,3 +22,16 @@ class CBkmkSelector : public QWidget
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 */
14signals: 37signals:
@@ -17,5 +40,18 @@ signals:
17private slots: 40private 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 }
21public: 57public:
@@ -29,15 +65,25 @@ public:
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
@@ -4 +4,5 @@
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
6size_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"
46size_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
68size_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
3size_t UnZip(UInt8* compressedbuffer,size_t reclen,UInt8* tgtbuffer,size_t bsize);
4
5size_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
@@ -9,4 +9,2 @@
9 9
10#include "util.h"
11
12#ifndef __STATIC 10#ifndef __STATIC
@@ -19,2 +17,3 @@ class ebookcodec : public CExpander_Interface
19 public: 17 public:
18 QString getTableAsHtml(unsigned long loc) { return codec->getTableAsHtml(loc); }
20 QString about() 19 QString about()
@@ -25,3 +24,13 @@ class ebookcodec : public CExpander_Interface
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;
@@ -115,3 +124,7 @@ class ebookcodec : public CExpander_Interface
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};
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
@@ -57,3 +57,3 @@ fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, boo
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);
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
7void 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
35QString CFliteCmd::about()
36{
37 return QString("FliteCmd output codec (c) Tim Wentford\n");
38}
39
40extern "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
3class 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
3cst_voice *CFliteDyn::m_voice = NULL;
4
5CFliteDyn::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
15QString CFliteDyn::about()
16{
17 return QString("FliteDyn output codec (c) Tim Wentford\n");
18}
19
20void 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
26extern "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"
2extern "C"
3{
4#include <flite.h>
5 cst_voice *register_cmu_us_kal();
6}
7
8class 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,5 +1,5 @@
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
5u_int8_t *rodata = (u_int8_t *) 5u_int8_t *rodata = (u_int8_t *)
@@ -296,2 +296,3 @@ u_int32_t iSilo::get_bits(int num) {
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);
@@ -563,8 +564,8 @@ void iSilo::read_attr()
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 {
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
@@ -4,3 +4,3 @@
4typedef unsigned int linkType; 4typedef unsigned int linkType;
5const linkType eNone = 0, eLink = 1, ePicture = 2, eFile = 4; 5const linkType eNone = 0, eLink = 1, ePicture = 2, eFile = 4, eTable = 8;
6 6
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 +1,2 @@
1
1#ifdef USEQPE 2#ifdef USEQPE
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__
3typedef unsigned char UInt8;
4typedef unsigned short UInt16;
5typedef signed short Int16;
6typedef 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
@@ -11,4 +11,12 @@ SUBDIRS = pluckerbaselib \
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
14include( $(OPIEDIR)/include.pro ) 22include( $(OPIEDIR)/include.pro )
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
9class 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>
19class 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
@@ -5,3 +5,2 @@
5 5
6
7#ifdef USEQPE 6#ifdef USEQPE
@@ -39,2 +38,3 @@ size_t Cpdb::recordpos(int n)
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);
@@ -54,2 +54,3 @@ void Cpdb::gotorecordnumber(int n)
54{ 54{
55unsuspend();
55 fseek(fin, recordpos(n), SEEK_SET); 56 fseek(fin, recordpos(n), SEEK_SET);
@@ -84,4 +85,4 @@ bool Cpdb::openpdbfile(const char *src)
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
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
@@ -17,2 +17,3 @@
17#include <stdio.h> 17#include <stdio.h>
18
18#include "CExpander.h" 19#include "CExpander.h"
@@ -20,6 +21,3 @@
20/* Normal Palm typedefs */ 21/* Normal Palm typedefs */
21typedef unsigned char UInt8; 22#include "mytypes.h"
22typedef unsigned short UInt16;
23typedef signed short Int16;
24typedef unsigned long UInt32;
25typedef UInt32 LocalID; 23typedef UInt32 LocalID;
@@ -94,2 +92,5 @@ class Cpdb : public CExpander
94 void unsuspend(); 92 void unsuspend();
93#else
94 void suspend() {}
95 void unsuspend() {}
95#endif 96#endif
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,2 +1 @@
1#include "usenef.h"
2#include <stdio.h> #include <stdio.h>
@@ -25,3 +24,3 @@
25#include "hrule.h" 24#include "hrule.h"
26#include "util.h" 25#include "decompress.h"
27 26
@@ -44,3 +43,4 @@ void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buff
44{ 43{
45 if (type%2 == 0) 44unsuspend();
45 if ((type%2 == 0) && (type != 14))
46 { 46 {
@@ -307,3 +307,3 @@ void CPlucker_base::locate(unsigned int n)
307 } 307 }
308 } while (locpos + bs <= n); 308 } while (locpos + bs < n);
309 309
@@ -414,3 +414,3 @@ bool CPlucker_base::expand(int thisrec)
414} 414}
415 415/*
416void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) 416void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
@@ -451,4 +451,4 @@ void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff
451} 451}
452 452*/
453void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) 453size_t CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
454{ 454{
@@ -503,2 +503,3 @@ void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff
503 } 503 }
504 return i;
504} 505}
@@ -1058,2 +1059,155 @@ linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString&
1058} 1059}
1060QString 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
@@ -1061,2 +1215,3 @@ tchar CPlucker_base::getch_base(bool fast)
1061{ 1215{
1216 mystyle.setTable(0xffffffff);
1062 int ch = bgetch(); 1217 int ch = bgetch();
@@ -1121,6 +1276,2 @@ tchar CPlucker_base::getch_base(bool fast)
1121 } 1276 }
1122 else
1123 {
1124 mystyle.setUnderline();
1125 }
1126 mystyle.setOffset(m_offset); 1277 mystyle.setOffset(m_offset);
@@ -1331,2 +1482,11 @@ tchar CPlucker_base::getch_base(bool fast)
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:
@@ -1359,42 +1519,2 @@ tchar CPlucker_base::getch_base(bool fast)
1359 1519
1360#if defined(__STATIC) && defined(USENEF)
1361#include "Model.h"
1362void (*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
1380void (*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
1400QString CPlucker_base::about() 1520QString CPlucker_base::about()
@@ -1404,3 +1524,3 @@ QString CPlucker_base::about()
1404 { 1524 {
1405 abt += "\nSpecial decompression (c) Tim Wentford"; 1525 abt += "\nSpecial decompression (c) Tim Wentford (ppmd by Dmitry Shkarin";
1406 } 1526 }
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
@@ -68,7 +68,7 @@ protected:
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
@@ -112,2 +112,3 @@ protected:
112 virtual QImage* imagefromdata(UInt8*, UInt32) = 0; 112 virtual QImage* imagefromdata(UInt8*, UInt32) = 0;
113 QString getTableAsHtml(unsigned long loc);
113}; 114};
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
@@ -7,3 +7,4 @@ HEADERS = pdb.h \
7 7
8 SOURCES = plucker_base.cpp 8 SOURCES = plucker_base.cpp \
9 decompress.cpp
9 10
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 @@
1Makefile
2config.in
3moc_*
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 @@
1DEFINES += OPIE USEQPE
2VPATH = ..
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
15DEPENDPATH += $(OPIEDIR)/include
16
17include( $(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
@@ -40,3 +40,3 @@ int ppm_expander::OpenFile(const char* infile)
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();
@@ -109,2 +109,11 @@ int ppm_expander::getch() {
109 109
110UINT 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
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
@@ -9,4 +9,4 @@
9#include "ppm.h" 9#include "ppm.h"
10#include "arith.h"
11 10
11class PPM_ReadBuf;
12 12
@@ -38,2 +38,5 @@ public:
38 } 38 }
39#else
40 void suspend() {}
41 void unsuspend() {}
39#endif 42#endif
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 +1,2 @@
1
1#ifndef USEQPE 2#ifndef USEQPE
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
8class Config 8class 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
104OBJECTS_DIR = QSTATICREADEROBJS
105MOC_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
104OBJECTS_DIR = ZSTATICREADEROBJS
105MOC_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
@@ -32,2 +32,3 @@ HEADERS = Aportis.h \
32 StyleConsts.h \ 32 StyleConsts.h \
33 TableDialog.h \
33 ToolbarPrefs.h \ 34 ToolbarPrefs.h \
@@ -48,3 +49,2 @@ HEADERS = Aportis.h \
48 ppm_expander.h \ 49 ppm_expander.h \
49 usenef.h \
50 ustring.h \ 50 ustring.h \
@@ -70,2 +70,3 @@ SOURCES = BuffDoc.cpp \
70 QtrListView.cpp \ 70 QtrListView.cpp \
71 TableDialog.cpp \
71 ToolbarPrefs.cpp \ 72 ToolbarPrefs.cpp \
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 @@
1red='\e[0;31m'
2RED='\e[1;31m'
3blue='\e[0;34m'
4BLUE='\e[1;34m'
5cyan='\e[0;36m'
6CYAN='\e[1;36m'
7NC='\e[0m' # No Color
8
9if test -z $OLDPATH; then
10 export OLDPATH=$PATH
11fi
12
13if test -z $OLD_LD_LIBRARY_PATH; then
14 export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
15fi
16
17#export QPEDIR=/opt/Qtopia
18export QTDIR=/home/tim/nevyos/qt-embedded-free-3.1.1
19export PATH=$QTDIR/bin:$OLDPATH
20export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++
21export 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> "
25PS1="[NevyOS]\W> "
26
27echo -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 @@
1red='\e[0;31m'
2RED='\e[1;31m'
3blue='\e[0;34m'
4BLUE='\e[1;34m'
5cyan='\e[0;36m'
6CYAN='\e[1;36m'
7NC='\e[0m' # No Color
8
9if test -z $OLDPATH; then
10 export OLDPATH=$PATH
11fi
12
13if test -z $OLD_LD_LIBRARY_PATH; then
14 export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
15fi
16
17export QPEDIR=/opt/Qtopia/opie
18export QTDIR=/opt/Qtopia/opie
19export PATH=$QTDIR/bin:/usr/local/arm/3.3/bin:$OLDPATH
20export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-opie-g++
21#export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH
22
23PS1="[Opie]\W> "
24
25echo -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 @@
1red='\e[0;31m'
2RED='\e[1;31m'
3blue='\e[0;34m'
4BLUE='\e[1;34m'
5cyan='\e[0;36m'
6CYAN='\e[1;36m'
7NC='\e[0m' # No Color
8
9if test -z $OLDPATH; then
10 export OLDPATH=$PATH
11fi
12
13if test -z $OLD_LD_LIBRARY_PATH; then
14 export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
15fi
16
17#export QPEDIR=/opt/Qtopia
18export QTDIR=/usr/lib/qt3
19export PATH=$QTDIR/bin:$OLDPATH
20#export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++
21
22export READERDIR=/home/tim/uqtreader
23export 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> "
28PS1="[QT]\W> "
29
30echo -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 @@
1red='\e[0;31m'
2RED='\e[1;31m'
3blue='\e[0;34m'
4BLUE='\e[1;34m'
5cyan='\e[0;36m'
6CYAN='\e[1;36m'
7NC='\e[0m' # No Color
8
9if test -z $OLDPATH; then
10 export OLDPATH=$PATH
11fi
12
13if test -z $OLD_LD_LIBRARY_PATH; then
14 export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
15fi
16
17export QPEDIR=/opt/Qtopia
18export QTDIR=/opt/Qtopia
19export PATH=$QTDIR/bin:$OLDPATH
20export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++
21export 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> "
25PS1="[Laptop]\W> "
26
27echo -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 @@
1red='\e[0;31m'
2RED='\e[1;31m'
3blue='\e[0;34m'
4BLUE='\e[1;34m'
5cyan='\e[0;36m'
6CYAN='\e[1;36m'
7NC='\e[0m' # No Color
8
9if test -z $OLDPATH; then
10 export OLDPATH=$PATH
11fi
12
13if test -z $OLD_LD_LIBRARY_PATH; then
14 export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
15fi
16
17export QPEDIR=/opt/Qtopia/sharp
18export QTDIR=/opt/Qtopia/sharp
19export PATH=$QTDIR/bin:/usr/local/arm/bin:$OLDPATH
20export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-sharp-g++
21export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH
22
23PS1="[Zaurus]\W> "
24
25echo -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
@@ -10,3 +10,2 @@
10#include "hrule.h" 10#include "hrule.h"
11#include "util.h"
12 11
@@ -92,3 +91,3 @@ void striphtml::skipblock(const QString& _ent)
92 91
93void striphtml::locate(unsigned int n) 92void striphtml::reset()
94{ 93{
@@ -96,7 +95,15 @@ void striphtml::locate(unsigned int n)
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
105void 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);
@@ -235,2 +242,9 @@ bool striphtml::findanchor(const QString& _info)
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)
@@ -297,3 +311,3 @@ bool striphtml::findanchor(const QString& _info)
297 311
298striphtml::striphtml(const QString& _s) : entmap(NULL), isPre(false), currentid(0), lastch(0), currentfile(_s), indent(0), forcecentre(false), m_inblock(false), m_bchm(false), ignorespace(false) 312striphtml::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{
@@ -313,3 +327,13 @@ void striphtml::initentmap()
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;
@@ -414,2 +438,8 @@ QString striphtml::getattr(tchar& ch)
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
@@ -480,2 +510,7 @@ linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString&
480 { 510 {
511 if (parent->findanchor(name))
512 {
513 reset();
514 return eLink;
515 }
481 fpit = href2filepos->find(name); 516 fpit = href2filepos->find(name);
@@ -490,3 +525,2 @@ linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString&
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);
@@ -500,3 +534,3 @@ linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString&
500 { 534 {
501 w = "/"+file; 535 w = file;
502 nm = name; 536 nm = name;
@@ -566,3 +600,27 @@ void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos)
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 }
@@ -586,3 +644,2 @@ void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long p
586 { 644 {
587 qDebug("Using stack style");
588 currentstyle = stylestack.first(); 645 currentstyle = stylestack.first();
@@ -609,2 +666,6 @@ void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long p
609 } 666 }
667 if (attr == "justify")
668 {
669 currentstyle.setFullJustify();
670 }
610 } 671 }
@@ -656,2 +717,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
656 sty = currentstyle; 717 sty = currentstyle;
718 lastch = ch;
657 return; 719 return;
@@ -663,3 +725,2 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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)
@@ -667,3 +728,2 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
667 ch = skip_ws(); 728 ch = skip_ws();
668
669 QString ent = getname(ch, " >").lower(); 729 QString ent = getname(ch, " >").lower();
@@ -683,3 +743,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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")
@@ -714,3 +774,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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 }
@@ -749,4 +809,5 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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;
@@ -802,2 +863,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
802 isPre = true; 863 isPre = true;
864 currentstyle.setNoJustify();
803 currentstyle.setMono(); 865 currentstyle.setMono();
@@ -824,2 +886,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
824 ch = 10; 886 ch = 10;
887 currentstyle.setExtraSpace(0);
825 currentstyle.setLeftMargin(30); 888 currentstyle.setLeftMargin(30);
@@ -832,2 +895,4 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
832 ch = 10; 895 ch = 10;
896 currentstyle.setExtraSpace(0);
897 lastch = 0;
833 continue; 898 continue;
@@ -863,2 +928,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
863 if (ch != '>') ch = skip_ws_end(); 928 if (ch != '>') ch = skip_ws_end();
929 lastch = 0;
864 ch = 10; 930 ch = 10;
@@ -920,2 +986,8 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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)
@@ -930,3 +1002,2 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
930 // currentstyle.setExtraSpace(10); 1002 // currentstyle.setExtraSpace(10);
931 continue;
932 } 1003 }
@@ -939,3 +1010,2 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
939 // currentstyle.setExtraSpace(10); 1010 // currentstyle.setExtraSpace(10);
940 continue;
941 } 1011 }
@@ -948,3 +1018,2 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
948 // currentstyle.setExtraSpace(10); 1018 // currentstyle.setExtraSpace(10);
949 continue;
950 } 1019 }
@@ -956,4 +1025,5 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
956 // currentstyle.setExtraSpace(10); 1025 // currentstyle.setExtraSpace(10);
957 continue;
958 } 1026 }
1027 ch = 10;
1028 continue;
959 } 1029 }
@@ -1049,8 +1119,5 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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")
@@ -1059,2 +1126,14 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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();
@@ -1068,2 +1147,6 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
1068 1147
1148 currentstyle.setLeftMargin(6*tablenesteddepth);
1149
1150
1151 lastch = 0; // Anything but 10
1069 ch = 10; 1152 ch = 10;
@@ -1071,3 +1154,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
1071 q += QChar(parent->getwidth()); 1154 q += QChar(parent->getwidth());
1072 q += 2; 1155 q += 3;
1073 q += '\0'; 1156 q += '\0';
@@ -1079,14 +1162,4 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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;
@@ -1100,2 +1173,11 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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);
@@ -1103,9 +1185,30 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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;
@@ -1125,2 +1228,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
1125 { 1228 {
1229 /*
1126 if (m_bchm) 1230 if (m_bchm)
@@ -1133,2 +1237,10 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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
@@ -1174,2 +1286,10 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
1174 } 1286 }
1287 else if (ent == "title")
1288 {
1289 skipblock("/title");
1290 }
1291 else if (ent == "head")
1292 {
1293 skipblock("/head");
1294 }
1175 /* 1295 /*
@@ -1193,3 +1313,6 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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 }
@@ -1236,5 +1359,9 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
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;
@@ -1244,2 +1371,41 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
1244 1371
1372QString 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
1245extern "C" 1411extern "C"
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
@@ -11,4 +11,6 @@ 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;
@@ -91,2 +93,3 @@ class striphtml : public CFilter
91 void setchm(bool _b) { m_bchm = _b; } 93 void setchm(bool _b) { m_bchm = _b; }
94 QString getTableAsHtml(unsigned long loc);
92}; 95};
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
2touch infowin.cpp
3for f in *lib.omak; do make -f $f; done
4for f in *.omak; do make -f $f; done
5for f in *.omak; do make -f $f; done
6cp /home/tim/codecreader/opie-reader.desktop $QTDIR/apps/Applications/
7cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/
8cp /home/tim/codecreader/opie-pics/* $QTDIR/pics/opie-reader/
9cp HTMLentities $QTDIR/plugins/reader/data/
10rm $QTDIR/help/html/*reader*.html
11cp /home/tim/codecreader/help/*.html $QTDIR/help/html/
12rm $QTDIR/help/html/*reader*.html
13cp /home/tim/codecreader/help/*.html $QTDIR/help/html/
14rm -f $QTDIR/lib/libreader*.so
15rm -f $QTDIR/lib/libreader*.so.1
16for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done
17rm -f $QTDIR/lib/libreader*.so.1.*
18
19/home/tim/bin/zstrip.sh $QTDIR/bin/reader
20for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done
21
22for SUBDIR in codecs support filters
23do
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
29done
30rm -f opie-reader-gcc3_*.ipk
31rm -f full/opie-reader-gcc3_*.ipk
32rm -f partial/opie-reader-gcc3_*.ipk
33mkipks opie-reader-gcc3.control
34cp opie-reader-gcc3_*.ipk full/
35for f in opie-reader-gcc3_*.ipk
36 do
37 cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
38done
39rm $QTDIR/plugins/reader/support/libpluckerdecompress.so
40rm $QTDIR/plugins/reader/codecs/libArriereGo.so
41rm $QTDIR/plugins/reader/codecs/libNEF.so
42mkipks opie-reader-gcc3.control
43cp opie-reader-gcc3_*.ipk partial/
44for f in opie-reader-gcc3_*.ipk
45 do
46 cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
47done
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
2touch infowin.cpp
3for f in *lib.zmak; do make -f $f; done
4for f in *.zmak; do make -f $f; done
5for f in *.zmak; do make -f $f; done
6cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/
7cp /home/tim/codecreader/opie-pics/* $QTDIR/pics/opie-reader/
8cp HTMLentities $QTDIR/plugins/reader/data/
9rm $QTDIR/help/html/*reader*.html
10cp /home/tim/codecreader/help/*.html $QTDIR/help/html/
11rm -f $QTDIR/lib/libreader*.so
12rm -f $QTDIR/lib/libreader*.so.1
13for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done
14rm -f $QTDIR/lib/libreader*.so.1.*
15
16/home/tim/bin/zstrip.sh $QTDIR/bin/uqtreader
17rm -f $QTDIR/bin/reader
18mv $QTDIR/bin/uqtreader $QTDIR/bin/reader
19for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done
20for SUBDIR in codecs support filters
21do
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
27done
28rm -f opie-reader-opie_*.ipk
29rm -f full/opie-reader-opie_*.ipk
30rm -f partial/opie-reader-opie_*.ipk
31mkipks opie-reader-opie.control
32cp opie-reader-opie_*.ipk full/
33for f in opie-reader-opie_*.ipk
34 do
35 cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
36done
37rm $QTDIR/plugins/reader/support/libpluckerdecompress.so
38rm $QTDIR/plugins/reader/codecs/libArriereGo.so
39rm $QTDIR/plugins/reader/codecs/libNEF.so
40mkipks opie-reader-opie.control
41cp opie-reader-opie_*.ipk partial/
42for f in opie-reader-opie_*.ipk
43 do
44 cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
45done
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
2touch infowin.cpp
3for f in *lib.zmak; do make -f $f; done
4for f in *.zmak; do make -f $f; done
5for f in *.zmak; do make -f $f; done
6cp /home/tim/codecreader/uqtreader*.desktop /opt/Qtopia/apps/Applications/
7cp /home/tim/codecreader/pics/* /opt/Qtopia/pics/opie-reader/
8cp /home/tim/codecreader/uqtreader*.desktop $QTDIR/apps/Applications/
9cp /home/tim/codecreader/opie-reader.desktop $QTDIR/apps/Applications/
10cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/
11cp HTMLentities $QTDIR/plugins/reader/data/
12rm $QTDIR/help/html/*reader*.html
13cp /home/tim/codecreader/help/*.html $QTDIR/help/html/
14rm -f $QTDIR/lib/libreader*.so
15rm -f $QTDIR/lib/libreader*.so.1
16for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done
17rm -f $QTDIR/lib/libreader*.so.1.*
18
19/home/tim/bin/zstrip.sh $QTDIR/bin/uqtreader
20for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done
21
22for SUBDIR in codecs support filters
23do
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
29done
30rm -f opie-reader_*.ipk
31rm -f full/opie-reader_*.ipk
32rm -f partial/opie-reader_*.ipk
33mkipks opie-reader.control
34cp opie-reader_*.ipk full/
35for f in opie-reader_*.ipk
36 do
37 cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
38done
39rm $QTDIR/plugins/reader/support/libpluckerdecompress.so
40rm $QTDIR/plugins/reader/codecs/libArriereGo.so
41rm $QTDIR/plugins/reader/codecs/libNEF.so
42mkipks opie-reader.control
43cp opie-reader_*.ipk partial/
44for f in opie-reader_*.ipk
45 do
46 cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
47done
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,2 +1,3 @@
1#include "util.h" 1#include "util.h"
2#include <limits.h>
2 3
@@ -24,3 +25,11 @@ QString percent(unsigned long pos, unsigned long len)
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 }
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
@@ -4,4 +4,2 @@
4#include <qstring.h> 4#include <qstring.h>
5#include <qdir.h>
6#include <stdlib.h>
7 5
@@ -10,48 +8,2 @@ QString percent(unsigned long pos, unsigned long len);
10QString fmt(unsigned long pos, unsigned long len); 8QString 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 */
17class 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
@@ -4,3 +4,29 @@
4 4
5bool CheckVersion(int& major, int& bkmktype, char& minor) 5#include <qmultilineedit.h>
6#include <qlayout.h>
7#include <qtextview.h>
8class versionbox : public QDialog
9{
10public:
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
31bool CheckVersion(int& major, int& bkmktype, char& minor, QWidget* pnt)
6{ 32{
@@ -17,7 +43,14 @@ bool CheckVersion(int& major, int& bkmktype, char& minor)
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;
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
@@ -5,3 +5,3 @@
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"
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
@@ -69,2 +69,3 @@ void ztxt::locate(unsigned int n)
69 { 69 {
70 unsuspend();
70 bufferrec = n / ntohs(hdr0.recordSize) + 1; 71 bufferrec = n / ntohs(hdr0.recordSize) + 1;
@@ -109,2 +110,3 @@ void ztxt::home()
109{ 110{
111unsuspend();
110 if (bInit) 112 if (bInit)
@@ -149,2 +151,3 @@ CList<Bkmk>* ztxt::getbkmklist()
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);