summaryrefslogtreecommitdiff
Side-by-side diff
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()
CList<Bkmk>* t = new CList<Bkmk>;
+ unsuspend();
size_t cur = ftell(fin);
@@ -248,2 +249,3 @@ int Aportis::getch()
{
+unsuspend();
int c = getc(fin);
@@ -265,2 +267,3 @@ int Aportis::getch()
// take a char from the input buffer
+unsuspend();
c = getc(fin);
@@ -322,3 +325,3 @@ unsigned int Aportis::GetBS(unsigned int bn)
WORD fs;
-
+unsuspend();
fseek(fin, 0x56 + 8*bn, SEEK_SET);
@@ -345,2 +348,3 @@ unsigned int Aportis::locate()
{
+unsuspend();
size_t cur = ftell(fin);
@@ -403,2 +407,3 @@ bool Aportis::refreshbuffer()
unsigned char t[3];
+ unsuspend();
fread(t,1,3,fin);
@@ -432,2 +437,3 @@ QImage* Aportis::getPicture(unsigned long tgt)
{
+unsuspend();
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 @@
+Makefile
+config.in
+moc_*
+.moc
+.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 @@
+DEFINES += OPIE USEQPE
+VPATH = ..
+TEMPLATE = lib
+CONFIG = qt warn_on release dll
+HEADERS = arrierego.h
+
+SOURCES = arrierego.cpp
+
+INTERFACES =
+DESTDIR = $(OPIEDIR)/plugins/reader/codecs
+TARGET = ArriereGo
+LIBS += -L$(OPIEDIR)/lib -lreader_pdb -lreader_pluckerbase -lreader_codec
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+DEFINES += USENEF
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp
index 1f0a524..355d14d 100644
--- a/noncore/apps/opie-reader/BuffDoc.cpp
+++ b/noncore/apps/opie-reader/BuffDoc.cpp
@@ -5,3 +5,2 @@
-#include "usenef.h"
#include "BuffDoc.h"
@@ -23,2 +22,3 @@
#include "iSilo.h"
+#include "Reb.h"
#endif
@@ -62,2 +62,14 @@ void BuffDoc::locate(unsigned int n)
+void BuffDoc::resetPos()
+{
+ // //qDebug("BuffDoc:locating:%u",n);
+ lastword.empty();
+ lastsizes[0] = laststartline = exp->locate();
+#ifdef NEWLINEBREAK
+ lastispara = false;
+#else
+ lastispara = false;
+#endif
+}
+
static bool isletter(unsigned short c)
@@ -637,2 +649,9 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
//qDebug("Trying ppms");
+ exp = new CReb;
+ ret = exp->openfile(src);
+ }
+ if (ret != 0)
+ {
+ delete exp;
+ //qDebug("Trying ppms");
exp = new ppm_expander;
@@ -657,3 +676,13 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
#else
- QString codecpath(QTReaderUtil::getPluginPath());
+#ifdef USEQPE
+#ifdef OPIE
+ QString codecpath(getenv("OPIEDIR"));
+#else
+ QString codecpath(getenv("QTDIR"));
+#endif
+ codecpath += "/plugins/reader/codecs";
+#else
+ QString codecpath(getenv("READERDIR"));
+ codecpath += "/codecs";
+#endif
QDir d(codecpath, "*.so");
@@ -708 +737,23 @@ QString BuffDoc::about()
}
+
+int BuffDoc::getsentence(CBuffer& buff)
+{
+ tchar ch;
+ int i = 0;
+ bool intext = false;
+ while ((ch = getch()) != 10 && ch != UEOF)
+ {
+ buff[i++] = ch;
+ if (ch == '"' || ch == '\'' || ch == 0x2018 || ch == 0x2019 ||
+ ch == 0x201a || ch == 0x201b || ch == 0x201c || ch == 0x201d)
+ {
+ intext = !intext;
+ }
+ if (!intext && (ch == '.' || ch == '!' || ch == '?')) break;
+ }
+
+ buff[i] = '\0';
+ if (i == 0 && ch == UEOF) i = -1;
+ laststartline = exp->locate();
+ return i;
+}
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
void suspend() { if (exp != NULL) exp->suspend(); }
- void unsuspend() { if (exp != NULL) exp->unsuspend(); }
#else
void suspend() {}
- void unsuspend() {}
#endif
@@ -97,2 +95,13 @@ class BuffDoc
}
+ /*
+ void rawgetch(tchar& ch, CStyle& sty, unsigned long& pos)
+ {
+ if (exp != NULL)
+ {
+ filt->rawgetch(ch, sty, pos);
+ }
+ else
+ ch = UEOF;
+ }
+ */
void setwidth(int w) { if (exp != NULL) exp->setwidth(w); }
@@ -101,2 +110,3 @@ class BuffDoc
unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); }
+ void resetPos();
unsigned int locate() { return (exp == NULL) ? 0 : laststartline; }
@@ -131,2 +141,3 @@ class BuffDoc
}
+ int getsentence(CBuffer& buff);
void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); }
@@ -135,6 +146,10 @@ class BuffDoc
linkType back(QString& f, size_t& loc) { return filt->back(f, loc); }
- bool hasnavigation() { return filt->hasnavigation(); }
- bool getFile(QString href)
+ bool hasnavigation() { return (exp == NULL) ? false : filt->hasnavigation(); }
+ bool getFile(const QString& href, QString& nm)
+ {
+ return (exp == NULL) ? false : exp->getFile(href, nm);
+ }
+ QString getTableAsHtml(unsigned long loc)
{
- return (exp == NULL) ? false : exp->getFile(href);
+ return (exp != NULL) ? filt->getTableAsHtml(loc) : QString("");
}
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
lo->addWidget(debounce);
+ /*
+ QPushButton* assignClose = new QPushButton("Assign\nCancel", this);
+ lo->addWidget(assignClose);
+ */
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
case m_AlignLeft:
+ case m_AlignNone:
currentx = _lborder + leftMargin();
@@ -486,3 +487,3 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int
#if defined(OPIE) || !defined(USEQPE)
- _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100));
+ _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10/*0*/));
#else
@@ -660,3 +661,3 @@ CStyle CDrawBuffer::firststyle()
-linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img)
+linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img, size_t& tabletgt)
{
@@ -692,2 +693,7 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, siz
}
+ if (currentstyle.isTable())
+ {
+ tabletgt = currentstyle.getTable();
+ ret |= eTable;
+ }
return ret;
@@ -718,3 +724,3 @@ void CDrawBuffer::resize(int availht)
{
-
+ int p_linespacing = 0;
for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; )
@@ -758,2 +764,13 @@ void CDrawBuffer::resize(int availht)
}
+ else
+ {
+ descent = (_style.getPicture()->height()-ascent)/2;
+ ascent = (_style.getPicture()->height()+ascent)/2;
+ }
+ int lineSpacing = ascent+descent;
+ if (lineSpacing > p_linespacing)
+ {
+ p_linespacing = lineSpacing;
+ }
+ extra = 0;
}
@@ -774,3 +791,3 @@ void CDrawBuffer::resize(int availht)
}
- m_showPartial = (m_lineSpacing > t_lineSpacing);
+ m_showPartial = (p_linespacing > t_lineSpacing);
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
// void frig();
- linkType getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*&);
+ linkType getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*&, size_t&);
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
public:
+ virtual QString getTableAsHtml(unsigned long loc)
+ {
+ qDebug("CEncoding::getTableAsHtml()");
+ return parent->getTableAsHtml(loc);
+ }
CEncoding() : parent(NULL) {}
@@ -18,3 +23,6 @@ public:
void locate(unsigned int n) { parent->locate(n); }
- bool findanchor(const QString& nm) { return false; }
+ bool findanchor(const QString& nm)
+ {
+ return parent->findanchor(nm);
+ }
void saveposn(const QString& f, size_t posn) { parent->saveposn(posn); }
@@ -27,5 +35,4 @@ public:
QImage* getPicture(const QString& href) { return parent->getPicture(href); }
- bool getFile(const QString& href) { qDebug("Encoding Get File"); return parent->getFile(href);}
-
-
+ bool getFile(const QString& href, const QString& nm) { qDebug("Encoding Get File"); return parent->getFile(href, nm);}
+ unsigned long startSection() { return parent->startSection(); }
};
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 @@
#include "CExpander.h"
+#ifdef USEQPE
+#include <qpe/global.h>
+#endif
@@ -72,3 +75,7 @@ void CExpander::unsuspend(FILE*& fin)
int delay = time(NULL) - sustime;
- if (delay < 10) sleep(10-delay);
+ if (delay < 10)
+ {
+ Global::statusMessage("Stalling");
+ sleep(10-delay);
+ }
fin = fopen(fname, "rb");
@@ -76,2 +83,3 @@ void CExpander::unsuspend(FILE*& fin)
{
+ Global::statusMessage("Stalling");
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
public:
+ virtual QString getTableAsHtml(unsigned long loc) = 0;
virtual void getch(tchar&, CStyle&, unsigned long&) = 0;
@@ -38,4 +39,5 @@ class CCharacterSource
virtual QImage* getPicture(const QString& href) = 0;
- virtual bool getFile(const QString& href) = 0;
+ virtual bool getFile(const QString& href, const QString& nm) = 0;
virtual QString about() = 0;
+ virtual unsigned long startSection() = 0;
};
@@ -85,3 +87,5 @@ class CExpander_Interface
virtual QImage* getPicture(const QString& href) = 0;
- virtual bool getFile(const QString& href) = 0;
+ virtual bool getFile(const QString& href, const QString& nm) = 0;
+ virtual bool findanchor(const QString& nm) = 0;
+ virtual QString getTableAsHtml(unsigned long loc) { return QString(""); }
};
@@ -145,3 +149,7 @@ class CExpander : public CExpander_Interface
virtual QImage* getPicture(const QString& href) { return NULL; }
- virtual bool getFile(const QString& href) { return false; }
+ virtual bool getFile(const QString& href, const QString& nm) { return false; }
+ virtual bool findanchor(const QString& nm)
+ {
+ return false;
+ }
};
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 @@
#include <qdir.h>
+
#ifdef USEQPE
@@ -10,3 +11,2 @@
#include "hrule.h"
-#include "util.h"
@@ -667,4 +667,13 @@ ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NU
{
- QString filterpath(QTReaderUtil::getPluginPath("filters"));
- filterpath += "/lib";
+#ifdef USEQPE
+#ifdef OPIE
+ QString filterpath(getenv("OPIEDIR"));
+#else
+ QString filterpath(getenv("QTDIR"));
+#endif
+ filterpath += "/plugins/reader/filters/lib";
+#else
+ QString filterpath(getenv("READERDIR"));
+ filterpath += "/filters/lib";
+#endif
filterpath += nm;
@@ -694,3 +703,3 @@ ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NU
{
- qDebug("No filter path");
+ qDebug("No filter path:%s", (const char*)filterpath);
filt = new ErrorFilter(QString("No filter plugins installed:")+nm);
@@ -815 +824,38 @@ void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos)
}
+
+void tableLink::getch(tchar& ch, CStyle& sty, unsigned long& pos)
+{
+ if (offset >= (int)text.length())
+ {
+ offset = -1;
+ sty.setColour(m_r, m_g, m_b);
+ do
+ {
+ parent->getch(ch, sty, pos);
+ }
+ while (sty.isTable());
+ return;
+ }
+ if (offset >= 0)
+ {
+ ch = text[offset++].unicode();
+ return;
+ }
+ parent->getch(ch, sty, pos);
+ if (sty.isTable())
+ {
+ offset = 1;
+ ch = text[0].unicode();
+ m_r = sty.Red(), m_g = sty.Green(), m_b = sty.Blue();
+ sty.setColour(255, 0, 0);
+ }
+ return;
+}
+
+void underlineLink::getch(tchar& ch, CStyle& sty, unsigned long& pos)
+{
+ parent->getch(ch, sty, pos);
+ if (sty.getLink()) sty.setUnderline();
+ //if (isLink && !sty.getLink()) sty.unsetUnderline();
+ //isLink = sty.getLink();
+}
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
virtual CCharacterSource* getparent() = 0;
+ virtual unsigned long startSection() = 0;
};
@@ -28,2 +29,7 @@ class CFilter : public CFilter_IFace
public:
+ virtual QString getTableAsHtml(unsigned long loc)
+ {
+ qDebug("CFilter::getTableAsHtml()");
+ return parent->getTableAsHtml(loc);
+ }
virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm)
@@ -52,3 +58,4 @@ class CFilter : public CFilter_IFace
QImage* getPicture(const QString& href) { return parent->getPicture(href); }
- bool getFile(const QString& href) { return parent->getFile(href); }
+ bool getFile(const QString& href, const QString& nm) { return parent->getFile(href, nm); }
+ virtual unsigned long startSection() { return parent->startSection(); }
};
@@ -78,2 +85,6 @@ class CFilterChain
}
+ QString getTableAsHtml(unsigned long loc)
+ {
+ return front->getTableAsHtml(loc);
+ }
void locate(unsigned int n)
@@ -86,2 +97,8 @@ class CFilterChain
}
+ /*
+ void rawgetch(tchar& ch, CStyle& sty, unsigned long& pos)
+ {
+ encoder->getch(ch, sty, pos);
+ }
+ */
void addfilter(CFilter_IFace* p)
@@ -405,2 +422,7 @@ class ExternFilter : public CFilter_IFace
}
+ QString getTableAsHtml(unsigned long loc)
+ {
+ qDebug("ExternFilter::getTableAsHtml()");
+ return filt->getTableAsHtml(loc);
+ }
void setparent(CCharacterSource* p) { filt->setparent(p); }
@@ -413,3 +435,6 @@ class ExternFilter : public CFilter_IFace
void locate(unsigned int n) { filt->locate(n); }
- bool findanchor(const QString& nm) { return filt->findanchor(nm); }
+ bool findanchor(const QString& nm)
+ {
+ return filt->findanchor(nm);
+ }
void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); }
@@ -425,4 +450,5 @@ class ExternFilter : public CFilter_IFace
QImage* getPicture(const QString& href) { return filt->getPicture(href); }
- bool getFile(const QString& href) { return filt->getFile(href); }
+ bool getFile(const QString& href, const QString& nm) { return filt->getFile(href, nm); }
QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); }
+ unsigned long startSection() { return filt->startSection(); }
};
@@ -473,2 +499,25 @@ class setfg : public CFilter
+class tableLink : public CFilter
+{
+ QString text;
+ int offset;
+ int m_r, m_g, m_b;
+ public:
+ tableLink() : text( "See Table" ), offset(-1)
+ {
+ }
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos);
+ QString about() { return QString("Table link filter (c) Tim Wentford\n")+parent->about(); }
+};
+
+class underlineLink : public CFilter
+{
+ bool isLink;
+ public:
+ underlineLink() : isLink(false) {}
+ ~underlineLink() {}
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos);
+ QString about() { return QString("Link underlining filter (c) Tim Wentford\n")+parent->about(); }
+};
+
#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 @@
#include <qpixmap.h>
+#ifdef USEQPE
+#include <qpe/global.h>
+#endif
@@ -51,3 +54,3 @@ CHM::~CHM() {
-void CHM::suspend() {
+void CHM::suspend() {
#ifdef USEQPE
@@ -57,3 +60,3 @@ void CHM::suspend() {
chmFile = NULL;
- sustime = time(NULL);
+ sustime = time(NULL);
#endif
@@ -61,3 +64,3 @@ void CHM::suspend() {
-void CHM::unsuspend() {
+void CHM::unsuspend() {
#ifdef USEQPE
@@ -67,6 +70,10 @@ void CHM::unsuspend() {
int delay = time(NULL) - sustime;
- if (delay < 10)
- sleep(10-delay);
+ if (delay < 10)
+ {
+ Global::statusMessage("Stalling");
+ sleep(10-delay);
+ }
chmFile = chm_open(fname);
for (int i = 0; chmFile == NULL && i < 5; i++) {
+ Global::statusMessage("Stalling");
sleep(5);
@@ -79,3 +86,3 @@ void CHM::unsuspend() {
//suspos = gzseek(file, suspos, SEEK_SET);
- }
+ }
#endif
@@ -88,2 +95,3 @@ void CHM::addContent(QString content) {
void CHM::FillHomeContent() {
+unsuspend();
if (chmHHCPath != "") {
@@ -164,2 +172,3 @@ bool CHM::FillBuffer()
{
+unsuspend();
bool bRetVal = false;
@@ -198,2 +207,3 @@ bool CHM::FillBuffer()
bool CHM::FillContent() {
+unsuspend();
bool bRetVal = false;
@@ -241,3 +251,4 @@ bool CHM::FillContent() {
-bool CHM::getFile(const QString& href) {
+bool CHM::getFile(const QString& _href, const QString& ) {
+ QString href = "/" + _href;
qDebug("Got:%s", (const char*)href);
@@ -321,7 +332,7 @@ int CHM::getch() {
return EOF;
-#ifdef _WINDOWS
- QChar letter = chmBuffer.at(bufpos++);
-#else
- QChar letter = chmBuffer[bufpos++];
-#endif
+#ifdef _WINDOWS
+ QChar letter = chmBuffer.at(bufpos++);
+#else
+ QChar letter = chmBuffer[bufpos++];
+#endif
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:
}
- bool getFile(const QString& href);
+ bool getFile(const QString& href, const QString& nm);
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)
{
-#ifdef _WINDOWS
- switch (pat.at(p).unicode())
-#else
- switch (pat[p].unicode())
-#endif
+#ifdef _WINDOWS
+ switch (pat.at(p).unicode())
+#else
+ switch (pat[p].unicode())
+#endif
{
@@ -87,8 +87,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
{
- p++;
+ p++;
#ifdef _WINDOWS
- while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9')
-#else
- while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9')
-#endif
+ while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9')
+#else
+ while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9')
+#endif
{
@@ -99,8 +99,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
case '\\' :
- {
+ {
#ifdef _WINDOWS
- tchar c = escapedchar(pat.at(++p).unicode());
-#else
- tchar c = escapedchar(pat[++p].unicode());
-#endif
+ tchar c = escapedchar(pat.at(++p).unicode());
+#else
+ tchar c = escapedchar(pat[++p].unicode());
+#endif
regchar(c, insens);
@@ -113,8 +113,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
bool invert = false;
- tchar c;
+ tchar c;
#ifdef _WINDOWS
- if (pat.at(p+1).unicode() == '^')
-#else
- if (pat[p+1].unicode() == '^')
-#endif
+ if (pat.at(p+1).unicode() == '^')
+#else
+ if (pat[p+1].unicode() == '^')
+#endif
{
@@ -122,16 +122,16 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
invert = true;
- }
+ }
#ifdef _WINDOWS
- while ((c = pat.at(++p).unicode()) != ']')
-#else
- while ((c = pat[++p].unicode()) != ']')
-#endif
+ while ((c = pat.at(++p).unicode()) != ']')
+#else
+ while ((c = pat[++p].unicode()) != ']')
+#endif
{
if (c == '\\')
- {
+ {
#ifdef _WINDOWS
- c = escapedchar(pat.at(++p).unicode());
-#else
- c = escapedchar(pat[++p].unicode());
-#endif
+ c = escapedchar(pat.at(++p).unicode());
+#else
+ c = escapedchar(pat[++p].unicode());
+#endif
if (c == ']') break;
@@ -139,8 +139,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
if (c == '-')
- {
+ {
#ifdef _WINDOWS
- c = pat.at(++p).unicode();
-#else
- c = pat[++p].unicode();
-#endif
+ c = pat.at(++p).unicode();
+#else
+ c = pat[++p].unicode();
+#endif
for (tchar j = clast; j <= c; j++)
@@ -159,8 +159,8 @@ void CRegExpFilt::prepreprocessing(const QString& pat, bool insens)
default :
- {
+ {
#ifdef _WINDOWS
- regchar(pat.at(p).unicode(), insens);
-#else
- regchar(pat[p].unicode(), insens);
-#endif
+ regchar(pat.at(p).unicode(), insens);
+#else
+ regchar(pat[p].unicode(), insens);
+#endif
break;
@@ -195,8 +195,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
qDebug("m is %u", m);
- if (inkeep) keep |= bit[m];
+ if (inkeep) keep |= bit[m];
#ifdef _WINDOWS
- switch (pat.at(p).unicode())
-#else
- switch (pat[p].unicode())
-#endif
+ switch (pat.at(p).unicode())
+#else
+ switch (pat[p].unicode())
+#endif
{
@@ -230,14 +230,14 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
p++;
- int count = 0;
+ int count = 0;
#ifdef _WINDOWS
- while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9')
-#else
- while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9')
-#endif
- {
+ while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9')
+#else
+ while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9')
+#endif
+ {
#ifdef _WINDOWS
- count = 10*count + pat.at(p++).unicode() - '0';
-#else
- count = 10*count + pat[p++].unicode() - '0';
-#endif
+ count = 10*count + pat.at(p++).unicode() - '0';
+#else
+ count = 10*count + pat[p++].unicode() - '0';
+#endif
}
@@ -268,8 +268,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
case '\\' :
- {
+ {
#ifdef _WINDOWS
- tchar c = escapedchar(pat.at(++p).unicode());
-#else
- tchar c = escapedchar(pat[++p].unicode());
-#endif
+ tchar c = escapedchar(pat.at(++p).unicode());
+#else
+ tchar c = escapedchar(pat[++p].unicode());
+#endif
if (insens)
@@ -290,8 +290,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
tchar c, clast;
- bool invert = false;
+ bool invert = false;
#ifdef _WINDOWS
- if (pat.at(p+1).unicode() == '^')
-#else
- if (pat[p+1].unicode() == '^')
-#endif
+ if (pat.at(p+1).unicode() == '^')
+#else
+ if (pat[p+1].unicode() == '^')
+#endif
{
@@ -299,16 +299,16 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
invert = true;
- }
+ }
#ifdef _WINDOWS
- while ((c = pat.at(++p).unicode()) != ']')
-#else
- while ((c = pat[++p].unicode()) != ']')
-#endif
+ while ((c = pat.at(++p).unicode()) != ']')
+#else
+ while ((c = pat[++p].unicode()) != ']')
+#endif
{
if (c == '\\')
- {
+ {
#ifdef _WINDOWS
- c = escapedchar(pat.at(++p).unicode());
-#else
- c = escapedchar(pat[++p].unicode());
-#endif
+ c = escapedchar(pat.at(++p).unicode());
+#else
+ c = escapedchar(pat[++p].unicode());
+#endif
if (c == ']') break;
@@ -316,8 +316,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
if (c == '-')
- {
+ {
#ifdef _WINDOWS
- c = pat.at(++p).unicode();
-#else
- c = pat[++p].unicode();
-#endif
+ c = pat.at(++p).unicode();
+#else
+ c = pat[++p].unicode();
+#endif
for (tchar j = clast; j <= c; j++)
@@ -384,8 +384,8 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens)
default :
- {
+ {
#ifdef _WINDOWS
- tchar c = pat.at(p).unicode();
-#else
- tchar c = pat[p].unicode();
-#endif
+ tchar c = pat.at(p).unicode();
+#else
+ tchar c = pat[p].unicode();
+#endif
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 @@
+#ifndef __CSOURCE_H
+#define __CSOURCE_H
+
+class CInfo
+{
+ public:
+ virtual unsigned long size() = 0;
+};
+
+class CSource : public CInfo
+{
+ public:
+ virtual int get() = 0;
+};
+
+class CSink : public CInfo
+{
+ public:
+ virtual void put(unsigned char c) = 0;
+};
+
+class CMemSource : public CSource
+{
+ unsigned long m_total_size;
+ unsigned long m_current;
+ unsigned char* m_buffer;
+ public:
+ CMemSource(unsigned char* _buffer, unsigned long _size)
+ :
+ m_total_size(_size),
+ m_current(0),
+ m_buffer(_buffer)
+ {}
+ unsigned long size() { return m_current; }
+ int get()
+ {
+ return ((m_current < m_total_size) ? m_buffer[m_current++] : -1);
+ }
+};
+
+class CMemSink : public CSink
+{
+ unsigned long m_total_size;
+ unsigned long m_current;
+ unsigned char* m_buffer;
+ public:
+ CMemSink(unsigned char* _buffer, unsigned long _size)
+ :
+ m_total_size(_size),
+ m_current(0),
+ m_buffer(_buffer)
+ {}
+ unsigned long size() { return m_current; }
+ void put(unsigned char c)
+ {
+ if (m_current < m_total_size)
+ {
+ m_buffer[m_current++] = c;
+ }
+ }
+};
+#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 @@
+#include "CSource.h"
+/****************************************************************************
+ * This file is part of PPMd project *
+ * Contents: 'Carryless rangecoder' by Dmitry Subbotin *
+ * Comments: this implementation is claimed to be a public domain *
+ ****************************************************************************/
+/********************** Original text *************************************
+//////// Carryless rangecoder (c) 1999 by Dmitry Subbotin ////////
+
+typedef unsigned int uint;
+typedef unsigned char uc;
+
+#define DO(n) for (int _=0; _<n; _++)
+#define TOP (1<<24)
+#define BOT (1<<16)
+
+
+class RangeCoder
+{
+ uint low, code, range, passed;
+ FILE *f;
+
+ void OutByte (uc c) { passed++; fputc(c,f); }
+ uc InByte () { passed++; return fgetc(f); }
+
+public:
+
+ uint GetPassed () { return passed; }
+ void StartEncode (FILE *F) { f=F; passed=low=0; range= (uint) -1; }
+ void FinishEncode () { DO(4) OutByte(low>>24), low<<=8; }
+ void StartDecode (FILE *F) { passed=low=code=0; range= (uint) -1;
+ f=F; DO(4) code= code<<8 | InByte();
+ }
+
+ void Encode (uint cumFreq, uint freq, uint totFreq) {
+ assert(cumFreq+freq<totFreq && freq && totFreq<=BOT);
+ low += cumFreq * (range/= totFreq);
+ range*= freq;
+ while ((low ^ low+range)<TOP || range<BOT && ((range= -low & BOT-1),1))
+ OutByte(low>>24), range<<=8, low<<=8;
+ }
+
+ uint GetFreq (uint totFreq) {
+ uint tmp= (code-low) / (range/= totFreq);
+ if (tmp >= totFreq) throw ("Input data corrupt"); // or force it to return
+ return tmp; // a valid value :)
+ }
+
+ void Decode (uint cumFreq, uint freq, uint totFreq) {
+ assert(cumFreq+freq<totFreq && freq && totFreq<=BOT);
+ low += cumFreq*range;
+ range*= freq;
+ while ((low ^ low+range)<TOP || range<BOT && ((range= -low & BOT-1),1))
+ code= code<<8 | InByte(), range<<=8, low<<=8;
+ }
+};
+*****************************************************************************/
+
+static struct SUBRANGE {
+ DWORD LowCount, HighCount, scale;
+} SubRange;
+enum { TOP=1 << 24, BOT=1 << 15 };
+static DWORD low, code, range;
+
+inline void ariInitEncoder()
+{
+ low=0; range=DWORD(-1);
+}
+#define ARI_ENC_NORMALIZE(stream) { \
+ while ((low ^ (low+range)) < TOP || range < BOT && \
+ ((range= -low & (BOT-1)),1)) { \
+ _PPMD_E_PUTC(low >> 24,stream); \
+ range <<= 8; low <<= 8; \
+ } \
+}
+inline void ariEncodeSymbol()
+{
+ low += SubRange.LowCount*(range /= SubRange.scale);
+ range *= SubRange.HighCount-SubRange.LowCount;
+}
+inline void ariShiftEncodeSymbol(UINT SHIFT)
+{
+ low += SubRange.LowCount*(range >>= SHIFT);
+ range *= SubRange.HighCount-SubRange.LowCount;
+}
+#define ARI_FLUSH_ENCODER(stream) { \
+ for (UINT i=0;i < 4;i++) { \
+ _PPMD_E_PUTC(low >> 24,stream); low <<= 8; \
+ } \
+}
+#define ARI_INIT_DECODER(stream) { \
+ low=code=0; range=DWORD(-1); \
+ for (UINT i=0;i < 4;i++) \
+ code=(code << 8) | _PPMD_D_GETC(stream); \
+}
+#define ARI_DEC_NORMALIZE(stream) { \
+ while ((low ^ (low+range)) < TOP || range < BOT && \
+ ((range= -low & (BOT-1)),1)) { \
+ code=(code << 8) | _PPMD_D_GETC(stream); \
+ range <<= 8; low <<= 8; \
+ } \
+}
+inline UINT ariGetCurrentCount() {
+ return (code-low)/(range /= SubRange.scale);
+}
+inline UINT ariGetCurrentShiftCount(UINT SHIFT) {
+ return (code-low)/(range >>= SHIFT);
+}
+inline void ariRemoveSubrange()
+{
+ low += range*SubRange.LowCount;
+ range *= SubRange.HighCount-SubRange.LowCount;
+}
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 @@
+Makefile
+config.in
+moc_*
+.moc
+.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 @@
+DEFINES += OPIE USEQPE
+VPATH = ..
+TEMPLATE = lib
+CONFIG = qt warn_on release dll
+HEADERS = flitecmd.h
+
+SOURCES = flitecmd.cpp
+
+
+INTERFACES =
+DESTDIR = $(OPIEDIR)/plugins/reader/outcodecs
+TARGET = flitecmd
+
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+
+include( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-reader/FliteDyn/.cvsignore b/noncore/apps/opie-reader/FliteDyn/.cvsignore
new file mode 100644
index 0000000..1810ee0
--- a/dev/null
+++ b/noncore/apps/opie-reader/FliteDyn/.cvsignore
@@ -0,0 +1,5 @@
+Makefile
+config.in
+moc_*
+.moc
+.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 @@
+DEFINES += OPIE USEQPE
+VPATH = ..
+TEMPLATE = lib
+CONFIG = qt warn_on release dll
+HEADERS = flitedyn.h
+
+SOURCES = flitedyn.cpp
+
+
+INTERFACES =
+DESTDIR = $(OPIEDIR)/plugins/reader/outcodecs
+TARGET = flitedyn
+LIBS += -L/home/tim/flite/flite-1.2-release/lib -lflite_cmu_us_kal -lflite_usenglish -lflite_cmulex -lflite
+
+INCLUDEPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include
+DEPENDPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include
+
+include( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-reader/FliteDyn16/.cvsignore b/noncore/apps/opie-reader/FliteDyn16/.cvsignore
new file mode 100644
index 0000000..1810ee0
--- a/dev/null
+++ b/noncore/apps/opie-reader/FliteDyn16/.cvsignore
@@ -0,0 +1,5 @@
+Makefile
+config.in
+moc_*
+.moc
+.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 @@
+DEFINES += OPIE USEQPE
+VPATH = ..
+TEMPLATE = lib
+CONFIG = qt warn_on release dll
+HEADERS = flitedyn.h
+
+SOURCES = flitedyn.cpp
+
+
+INTERFACES =
+DESTDIR = $(OPIEDIR)/plugins/reader/outcodecs
+TARGET = flitedyn
+LIBS += -L/home/tim/flite/flite-1.2-release/lib -lflite_cmu_us_kal16 -lflite_usenglish -lflite_cmulex -lflite
+
+INCLUDEPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include
+DEPENDPATH += /home/tim/flite/flite-1.2-release/include $(OPIEDIR)/include
+
+include( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp
index 9bb3bc0..08b8c52 100644
--- a/noncore/apps/opie-reader/FontControl.cpp
+++ b/noncore/apps/opie-reader/FontControl.cpp
@@ -1,2 +1,3 @@
#include <qfontdatabase.h>
+
#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
}
- return m_fontsizes[tgt];
+ return tgt >= 0 ? m_fontsizes[tgt] : 12;
}
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 @@
+/****************************************************************************
+ * This file is part of PPMd project *
+ * Written and distributed to public domain by Dmitry Shkarin 1997, *
+ * 1999-2001 *
+ * Contents: PPMII model description and encoding/decoding routines *
+ ****************************************************************************/
+#include <string.h>
+#include "PPMd.h"
+#pragma hdrstop
+#include "Coder.h"
+#include "SubAlloc.h"
+
+enum { UP_FREQ=5, INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
+ INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124, O_BOUND=9 };
+
+#pragma pack(1)
+static struct SEE2_CONTEXT { // SEE-contexts for PPM-contexts with masked symbols
+ WORD Summ;
+ BYTE Shift, Count;
+ void init(UINT InitVal) { Summ=InitVal << (Shift=PERIOD_BITS-4); Count=7; }
+ UINT getMean() {
+ UINT RetVal=(Summ >> Shift); Summ -= RetVal;
+ return RetVal+(RetVal == 0);
+ }
+ void update() {
+ if (Shift < PERIOD_BITS && --Count == 0) {
+ Summ += Summ; Count=3 << Shift++;
+ }
+ }
+} _PACK_ATTR SEE2Cont[24][32], DummySEE2Cont;
+static struct PPM_CONTEXT { // Notes:
+ BYTE NumStats, Flags; // 1. NumStats & NumMasked contain
+ WORD SummFreq; // number of symbols minus 1
+ struct STATE { // 2. sizeof(WORD) > sizeof(BYTE)
+ BYTE Symbol, Freq; // 3. contexts example:
+ PPM_CONTEXT* Successor; // MaxOrder:
+ } _PACK_ATTR * Stats; // ABCD context
+ PPM_CONTEXT* Suffix; // BCD suffix
+ inline void encodeBinSymbol(int symbol);// BCDE successor
+ inline void encodeSymbol1(int symbol);// other orders:
+ inline void encodeSymbol2(int symbol);// BCD context
+ inline void decodeBinSymbol();// CD suffix
+ inline void decodeSymbol1();// BCDE successor
+ inline void decodeSymbol2();
+ inline void update1(STATE* p);
+ inline void update2(STATE* p);
+ inline SEE2_CONTEXT* makeEscFreq2();
+ void rescale();
+ void refresh(int OldNU,BOOL Scale);
+ PPM_CONTEXT* cutOff(int Order);
+ PPM_CONTEXT* removeBinConts(int Order);
+ STATE& oneState() const { return (STATE&) SummFreq; }
+} _PACK_ATTR* MaxContext;
+#pragma pack()
+
+static BYTE NS2BSIndx[256], QTable[260]; // constants
+static PPM_CONTEXT::STATE* FoundState; // found next state transition
+static int InitEsc, OrderFall, RunLength, InitRL, MaxOrder;
+static BYTE CharMask[256], NumMasked, PrevSuccess, EscCount, PrintCount;
+static WORD BinSumm[25][64]; // binary SEE-contexts
+static MR_METHOD MRMethod;
+
+inline void SWAP(PPM_CONTEXT::STATE& s1,PPM_CONTEXT::STATE& s2)
+{
+ /*
+ WORD t1=(WORD&) s1; PPM_CONTEXT* t2=s1.Successor;
+ (WORD&) s1 = (WORD&) s2; s1.Successor=s2.Successor;
+ (WORD&) s2 = t1; s2.Successor=t2;
+ */
+ PPM_CONTEXT::STATE t = s1;
+ s1 = s2;
+ s2 = t;
+}
+inline void StateCpy(PPM_CONTEXT::STATE& s1,const PPM_CONTEXT::STATE& s2)
+{
+ // (WORD&) s1=(WORD&) s2; s1.Successor=s2.Successor;
+ s1 = s2;
+}
+struct PPMD_STARTUP { inline PPMD_STARTUP(); } PPMd_StartUp;
+inline PPMD_STARTUP::PPMD_STARTUP() // constants initialization
+{
+ UINT i, k, m, Step;
+ for (i=0,k=1;i < N1 ;i++,k += 1) Indx2Units[i]=k;
+ for (k++;i < N1+N2 ;i++,k += 2) Indx2Units[i]=k;
+ for (k++;i < N1+N2+N3 ;i++,k += 3) Indx2Units[i]=k;
+ for (k++;i < N1+N2+N3+N4;i++,k += 4) Indx2Units[i]=k;
+ for (k=i=0;k < 128;k++) {
+ i += (Indx2Units[i] < k+1); Units2Indx[k]=i;
+ }
+ NS2BSIndx[0]=2*0; NS2BSIndx[1]=2*1;
+ memset(NS2BSIndx+2,2*2,9); memset(NS2BSIndx+11,2*3,256-11);
+ for (i=0;i < UP_FREQ;i++) QTable[i]=i;
+ for (m=i=UP_FREQ, k=Step=1;i < 260;i++) {
+ QTable[i]=m;
+ if ( !--k ) { k = ++Step; m++; }
+ }
+ (DWORD&) DummySEE2Cont=PPMdSignature;
+}
+static void _STDCALL StartModelRare(int MaxOrder,MR_METHOD MRMethod)
+{
+ UINT i, k, m;
+ memset(CharMask,0,sizeof(CharMask)); EscCount=PrintCount=1;
+ if (MaxOrder < 2) { // we are in solid mode
+ OrderFall=::MaxOrder;
+ for (PPM_CONTEXT* pc=MaxContext;pc->Suffix != NULL;pc=pc->Suffix)
+ OrderFall--;
+ return;
+ }
+ OrderFall=::MaxOrder=MaxOrder; ::MRMethod=MRMethod;
+ InitSubAllocator();
+ RunLength=InitRL=-((MaxOrder < 12)?MaxOrder:12)-1;
+ MaxContext = (PPM_CONTEXT*) AllocContext();
+ MaxContext->Suffix=NULL;
+ MaxContext->SummFreq=(MaxContext->NumStats=255)+2;
+ MaxContext->Stats = (PPM_CONTEXT::STATE*) AllocUnits(256/2);
+ for (PrevSuccess=i=0;i < 256;i++) {
+ MaxContext->Stats[i].Symbol=i; MaxContext->Stats[i].Freq=1;
+ MaxContext->Stats[i].Successor=NULL;
+ }
+static const WORD InitBinEsc[]={0x3CDD,0x1F3F,0x59BF,0x48F3,0x64A1,0x5ABC,0x6632,0x6051};
+ for (i=m=0;m < 25;m++) {
+ while (QTable[i] == m) i++;
+ for (k=0;k < 8;k++)
+ BinSumm[m][k]=BIN_SCALE-InitBinEsc[k]/(i+1);
+ for (k=8;k < 64;k += 8)
+ memcpy(BinSumm[m]+k,BinSumm[m],8*sizeof(WORD));
+ }
+ for (i=m=0;m < 24;m++) {
+ while (QTable[i+3] == m+3) i++;
+ SEE2Cont[m][0].init(2*i+5);
+ for (k=1;k < 32;k++) SEE2Cont[m][k]=SEE2Cont[m][0];
+ }
+}
+void PPM_CONTEXT::refresh(int OldNU,BOOL Scale)
+{
+ int i=NumStats, EscFreq;
+ STATE* p = Stats = (STATE*) ShrinkUnits(Stats,OldNU,(i+2) >> 1);
+ Flags=(Flags & (0x10+0x04*Scale))+0x08*(p->Symbol >= 0x40);
+ EscFreq=SummFreq-p->Freq;
+ SummFreq = (p->Freq=(p->Freq+Scale) >> Scale);
+ do {
+ EscFreq -= (++p)->Freq;
+ SummFreq += (p->Freq=(p->Freq+Scale) >> Scale);
+ Flags |= 0x08*(p->Symbol >= 0x40);
+ } while ( --i );
+ SummFreq += (EscFreq=(EscFreq+Scale) >> Scale);
+}
+#define P_CALL(F) ( PrefetchData(p->Successor), \
+ p->Successor=p->Successor->F(Order+1))
+PPM_CONTEXT* PPM_CONTEXT::cutOff(int Order)
+{
+ int i, tmp;
+ STATE* p;
+ if ( !NumStats ) {
+ if ((BYTE*) (p=&oneState())->Successor >= UnitsStart) {
+ if (Order < MaxOrder) P_CALL(cutOff);
+ else p->Successor=NULL;
+ if (!p->Successor && Order > O_BOUND)
+ goto REMOVE;
+ return this;
+ } else {
+REMOVE: SpecialFreeUnit(this); return NULL;
+ }
+ }
+ PrefetchData(Stats);
+ Stats = (STATE*) MoveUnitsUp(Stats,tmp=(NumStats+2) >> 1);
+ for (p=Stats+(i=NumStats);p >= Stats;p--)
+ if ((BYTE*) p->Successor < UnitsStart) {
+ p->Successor=NULL; SWAP(*p,Stats[i--]);
+ } else if (Order < MaxOrder) P_CALL(cutOff);
+ else p->Successor=NULL;
+ if (i != NumStats && Order) {
+ NumStats=i; p=Stats;
+ if (i < 0) { FreeUnits(p,tmp); goto REMOVE; }
+ else if (i == 0) {
+ Flags=(Flags & 0x10)+0x08*(p->Symbol >= 0x40);
+ StateCpy(oneState(),*p); FreeUnits(p,tmp);
+ oneState().Freq=(oneState().Freq+11) >> 3;
+ } else refresh(tmp,SummFreq > 16*i);
+ }
+ return this;
+}
+PPM_CONTEXT* PPM_CONTEXT::removeBinConts(int Order)
+{
+ STATE* p;
+ if ( !NumStats ) {
+ p=&oneState();
+ if ((BYTE*) p->Successor >= UnitsStart && Order < MaxOrder)
+ P_CALL(removeBinConts);
+ else p->Successor=NULL;
+ if (!p->Successor && (!Suffix->NumStats || Suffix->Flags == 0xFF)) {
+ FreeUnits(this,1); return NULL;
+ } else return this;
+ }
+ PrefetchData(Stats);
+ for (p=Stats+NumStats;p >= Stats;p--)
+ if ((BYTE*) p->Successor >= UnitsStart && Order < MaxOrder)
+ P_CALL(removeBinConts);
+ else p->Successor=NULL;
+ return this;
+}
+static void RestoreModelRare(PPM_CONTEXT* pc1,PPM_CONTEXT* MinContext,
+ PPM_CONTEXT* FSuccessor)
+{
+ PPM_CONTEXT* pc;
+ PPM_CONTEXT::STATE* p;
+ for (pc=MaxContext, pText=HeapStart;pc != pc1;pc=pc->Suffix)
+ if (--(pc->NumStats) == 0) {
+ pc->Flags=(pc->Flags & 0x10)+0x08*(pc->Stats->Symbol >= 0x40);
+ p=pc->Stats; StateCpy(pc->oneState(),*p);
+ SpecialFreeUnit(p);
+ pc->oneState().Freq=(pc->oneState().Freq+11) >> 3;
+ } else
+ pc->refresh((pc->NumStats+3) >> 1,FALSE);
+ for ( ;pc != MinContext;pc=pc->Suffix)
+ if ( !pc->NumStats )
+ pc->oneState().Freq -= pc->oneState().Freq >> 1;
+ else if ((pc->SummFreq += 4) > 128+4*pc->NumStats)
+ pc->refresh((pc->NumStats+2) >> 1,TRUE);
+ if (MRMethod > MRM_FREEZE) {
+ MaxContext=FSuccessor; GlueCount += !(BList[1].Stamp & 1);
+ } else if (MRMethod == MRM_FREEZE) {
+ while ( MaxContext->Suffix ) MaxContext=MaxContext->Suffix;
+ MaxContext->removeBinConts(0); MRMethod=MR_METHOD(MRMethod+1);
+ GlueCount=0; OrderFall=MaxOrder;
+ } else if (MRMethod == MRM_RESTART || GetUsedMemory() < (SubAllocatorSize >> 1)) {
+ StartModelRare(MaxOrder,MRMethod);
+ EscCount=0; PrintCount=0xFF;
+ } else {
+ while ( MaxContext->Suffix ) MaxContext=MaxContext->Suffix;
+ do {
+ MaxContext->cutOff(0); ExpandTextArea();
+ } while (GetUsedMemory() > 3*(SubAllocatorSize >> 2));
+ GlueCount=0; OrderFall=MaxOrder;
+ }
+}
+static PPM_CONTEXT* _FASTCALL CreateSuccessors(BOOL Skip,PPM_CONTEXT::STATE* p,
+ PPM_CONTEXT* pc);
+static PPM_CONTEXT* _FASTCALL ReduceOrder(PPM_CONTEXT::STATE* p,PPM_CONTEXT* pc)
+{
+ PPM_CONTEXT::STATE* p1, * ps[MAX_O], ** pps=ps;
+ PPM_CONTEXT* pc1=pc, * UpBranch = (PPM_CONTEXT*) pText;
+ BYTE tmp, sym=FoundState->Symbol;
+ *pps++ = FoundState; FoundState->Successor=UpBranch;
+ OrderFall++;
+ if ( p ) { pc=pc->Suffix; goto LOOP_ENTRY; }
+ for ( ; ; ) {
+ if ( !pc->Suffix ) {
+ if (MRMethod > MRM_FREEZE) {
+FROZEN: do { (*--pps)->Successor = pc; } while (pps != ps);
+ pText=HeapStart+1; OrderFall=1;
+ }
+ return pc;
+ }
+ pc=pc->Suffix;
+ if ( pc->NumStats ) {
+ if ((p=pc->Stats)->Symbol != sym)
+ do { tmp=p[1].Symbol; p++; } while (tmp != sym);
+ tmp=2*(p->Freq < MAX_FREQ-9);
+ p->Freq += tmp; pc->SummFreq += tmp;
+ } else { p=&(pc->oneState()); p->Freq += (p->Freq < 32); }
+LOOP_ENTRY:
+ if ( p->Successor ) break;
+ *pps++ = p; p->Successor=UpBranch;
+ OrderFall++;
+ }
+ if (MRMethod > MRM_FREEZE) {
+ pc = p->Successor; goto FROZEN;
+ } else if (p->Successor <= UpBranch) {
+ p1=FoundState; FoundState=p;
+ p->Successor=CreateSuccessors(FALSE,NULL,pc);
+ FoundState=p1;
+ }
+ if (OrderFall == 1 && pc1 == MaxContext) {
+ FoundState->Successor=p->Successor; pText--;
+ }
+ return p->Successor;
+}
+void PPM_CONTEXT::rescale()
+{
+ UINT OldNU, Adder, EscFreq, i=NumStats;
+ STATE tmp, * p1, * p;
+ for (p=FoundState;p != Stats;p--) SWAP(p[0],p[-1]);
+ p->Freq += 4; SummFreq += 4;
+ EscFreq=SummFreq-p->Freq;
+ Adder=(OrderFall != 0 || MRMethod > MRM_FREEZE);
+ SummFreq = (p->Freq=(p->Freq+Adder) >> 1);
+ do {
+ EscFreq -= (++p)->Freq;
+ SummFreq += (p->Freq=(p->Freq+Adder) >> 1);
+ if (p[0].Freq > p[-1].Freq) {
+ StateCpy(tmp,*(p1=p));
+ do StateCpy(p1[0],p1[-1]); while (tmp.Freq > (--p1)[-1].Freq);
+ StateCpy(*p1,tmp);
+ }
+ } while ( --i );
+ if (p->Freq == 0) {
+ do { i++; } while ((--p)->Freq == 0);
+ EscFreq += i; OldNU=(NumStats+2) >> 1;
+ if ((NumStats -= i) == 0) {
+ StateCpy(tmp,*Stats);
+ tmp.Freq=(2*tmp.Freq+EscFreq-1)/EscFreq;
+ if (tmp.Freq > MAX_FREQ/3) tmp.Freq=MAX_FREQ/3;
+ FreeUnits(Stats,OldNU); StateCpy(oneState(),tmp);
+ Flags=(Flags & 0x10)+0x08*(tmp.Symbol >= 0x40);
+ FoundState=&oneState(); return;
+ }
+ Stats = (STATE*) ShrinkUnits(Stats,OldNU,(NumStats+2) >> 1);
+ Flags &= ~0x08; i=NumStats;
+ Flags |= 0x08*((p=Stats)->Symbol >= 0x40);
+ do { Flags |= 0x08*((++p)->Symbol >= 0x40); } while ( --i );
+ }
+ SummFreq += (EscFreq -= (EscFreq >> 1));
+ Flags |= 0x04; FoundState=Stats;
+}
+static PPM_CONTEXT* _FASTCALL CreateSuccessors(BOOL Skip,PPM_CONTEXT::STATE* p,
+ PPM_CONTEXT* pc)
+{
+ PPM_CONTEXT ct, * UpBranch=FoundState->Successor;
+ PPM_CONTEXT::STATE* ps[MAX_O], ** pps=ps;
+ UINT cf, s0;
+ BYTE tmp, sym=FoundState->Symbol;
+ if ( !Skip ) {
+ *pps++ = FoundState;
+ if ( !pc->Suffix ) goto NO_LOOP;
+ }
+ if ( p ) { pc=pc->Suffix; goto LOOP_ENTRY; }
+ do {
+ pc=pc->Suffix;
+ if ( pc->NumStats ) {
+ if ((p=pc->Stats)->Symbol != sym)
+ do { tmp=p[1].Symbol; p++; } while (tmp != sym);
+ tmp=(p->Freq < MAX_FREQ-9);
+ p->Freq += tmp; pc->SummFreq += tmp;
+ } else {
+ p=&(pc->oneState());
+ p->Freq += (!pc->Suffix->NumStats & (p->Freq < 24));
+ }
+LOOP_ENTRY:
+ if (p->Successor != UpBranch) {
+ pc=p->Successor; break;
+ }
+ *pps++ = p;
+ } while ( pc->Suffix );
+NO_LOOP:
+ if (pps == ps) return pc;
+ ct.NumStats=0; ct.Flags=0x10*(sym >= 0x40);
+ ct.oneState().Symbol=sym=*(BYTE*) UpBranch;
+ ct.oneState().Successor=(PPM_CONTEXT*) (((BYTE*) UpBranch)+1);
+ ct.Flags |= 0x08*(sym >= 0x40);
+ if ( pc->NumStats ) {
+ if ((p=pc->Stats)->Symbol != sym)
+ do { tmp=p[1].Symbol; p++; } while (tmp != sym);
+ s0=pc->SummFreq-pc->NumStats-(cf=p->Freq-1);
+ ct.oneState().Freq=1+((2*cf <= s0)?(5*cf > s0):((cf+2*s0-3)/s0));
+ } else
+ ct.oneState().Freq=pc->oneState().Freq;
+ do {
+ PPM_CONTEXT* pc1 = (PPM_CONTEXT*) AllocContext();
+ if ( !pc1 ) return NULL;
+ ((DWORD*) pc1)[0] = ((DWORD*) &ct)[0];
+ ((DWORD*) pc1)[1] = ((DWORD*) &ct)[1];
+ pc1->Suffix=pc; (*--pps)->Successor=pc=pc1;
+ } while (pps != ps);
+ return pc;
+}
+static inline void UpdateModel(PPM_CONTEXT* MinContext)
+{
+ PPM_CONTEXT::STATE* p=NULL;
+ PPM_CONTEXT* Successor, * FSuccessor, * pc, * pc1=MaxContext;
+ UINT ns1, ns, cf, sf, s0, FFreq=FoundState->Freq;
+ BYTE Flag, sym, FSymbol=FoundState->Symbol;
+ FSuccessor=FoundState->Successor; pc=MinContext->Suffix;
+ if (FFreq < MAX_FREQ/4 && pc) {
+ if ( pc->NumStats ) {
+ if ((p=pc->Stats)->Symbol != FSymbol) {
+ do { sym=p[1].Symbol; p++; } while (sym != FSymbol);
+ if (p[0].Freq >= p[-1].Freq) {
+ SWAP(p[0],p[-1]); p--;
+ }
+ }
+ cf=2*(p->Freq < MAX_FREQ-9);
+ p->Freq += cf; pc->SummFreq += cf;
+ } else { p=&(pc->oneState()); p->Freq += (p->Freq < 32); }
+ }
+ if (!OrderFall && FSuccessor) {
+ FoundState->Successor=CreateSuccessors(TRUE,p,MinContext);
+ if ( !FoundState->Successor ) goto RESTART_MODEL;
+ MaxContext=FoundState->Successor; return;
+ }
+ *pText++ = FSymbol; Successor = (PPM_CONTEXT*) pText;
+ if (pText >= UnitsStart) goto RESTART_MODEL;
+ if ( FSuccessor ) {
+ if ((BYTE*) FSuccessor < UnitsStart)
+ FSuccessor=CreateSuccessors(FALSE,p,MinContext);
+ } else
+ FSuccessor=ReduceOrder(p,MinContext);
+ if ( !FSuccessor ) goto RESTART_MODEL;
+ if ( !--OrderFall ) {
+ Successor=FSuccessor; pText -= (MaxContext != MinContext);
+ } else if (MRMethod > MRM_FREEZE) {
+ Successor=FSuccessor; pText=HeapStart;
+ OrderFall=0;
+ }
+ s0=MinContext->SummFreq-(ns=MinContext->NumStats)-FFreq;
+ for (Flag=0x08*(FSymbol >= 0x40);pc1 != MinContext;pc1=pc1->Suffix) {
+ if ((ns1=pc1->NumStats) != 0) {
+ if ((ns1 & 1) != 0) {
+ p=(PPM_CONTEXT::STATE*) ExpandUnits(pc1->Stats,(ns1+1) >> 1);
+ if ( !p ) goto RESTART_MODEL;
+ pc1->Stats=p;
+ }
+ pc1->SummFreq += (3*ns1+1 < ns);
+ } else {
+ p=(PPM_CONTEXT::STATE*) AllocUnits(1);
+ if ( !p ) goto RESTART_MODEL;
+ StateCpy(*p,pc1->oneState()); pc1->Stats=p;
+ if (p->Freq < MAX_FREQ/4-1) p->Freq += p->Freq;
+ else p->Freq = MAX_FREQ-4;
+ pc1->SummFreq=p->Freq+InitEsc+(ns > 2);
+ }
+ cf=2*FFreq*(pc1->SummFreq+6); sf=s0+pc1->SummFreq;
+ if (cf < 6*sf) {
+ cf=1+(cf > sf)+(cf >= 4*sf);
+ pc1->SummFreq += 4;
+ } else {
+ cf=4+(cf > 9*sf)+(cf > 12*sf)+(cf > 15*sf);
+ pc1->SummFreq += cf;
+ }
+ p=pc1->Stats+(++pc1->NumStats); p->Successor=Successor;
+ p->Symbol = FSymbol; p->Freq = cf;
+ pc1->Flags |= Flag;
+ }
+ MaxContext=FSuccessor; return;
+RESTART_MODEL:
+ RestoreModelRare(pc1,MinContext,FSuccessor);
+}
+// Tabulated escapes for exponential symbol distribution
+static const BYTE ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
+#define GET_MEAN(SUMM,SHIFT,ROUND) ((SUMM+(1 << (SHIFT-ROUND))) >> (SHIFT))
+inline void PPM_CONTEXT::encodeBinSymbol(int symbol)
+{
+ BYTE indx=NS2BSIndx[Suffix->NumStats]+PrevSuccess+Flags;
+ STATE& rs=oneState();
+ WORD& bs=BinSumm[QTable[rs.Freq-1]][indx+((RunLength >> 26) & 0x20)];
+ if (rs.Symbol == symbol) {
+ FoundState=&rs; rs.Freq += (rs.Freq < 196);
+ SubRange.LowCount=0; SubRange.HighCount=bs;
+ bs += INTERVAL-GET_MEAN(bs,PERIOD_BITS,2);
+ PrevSuccess=1; RunLength++;
+ } else {
+ SubRange.LowCount=bs; bs -= GET_MEAN(bs,PERIOD_BITS,2);
+ SubRange.HighCount=BIN_SCALE; InitEsc=ExpEscape[bs >> 10];
+ CharMask[rs.Symbol]=EscCount;
+ NumMasked=PrevSuccess=0; FoundState=NULL;
+ }
+}
+inline void PPM_CONTEXT::decodeBinSymbol()
+{
+ BYTE indx=NS2BSIndx[Suffix->NumStats]+PrevSuccess+Flags;
+ STATE& rs=oneState();
+ WORD& bs=BinSumm[QTable[rs.Freq-1]][indx+((RunLength >> 26) & 0x20)];
+ if (ariGetCurrentShiftCount(TOT_BITS) < bs) {
+ FoundState=&rs; rs.Freq += (rs.Freq < 196);
+ SubRange.LowCount=0; SubRange.HighCount=bs;
+ bs += INTERVAL-GET_MEAN(bs,PERIOD_BITS,2);
+ PrevSuccess=1; RunLength++;
+ } else {
+ SubRange.LowCount=bs; bs -= GET_MEAN(bs,PERIOD_BITS,2);
+ SubRange.HighCount=BIN_SCALE; InitEsc=ExpEscape[bs >> 10];
+ CharMask[rs.Symbol]=EscCount;
+ NumMasked=PrevSuccess=0; FoundState=NULL;
+ }
+}
+inline void PPM_CONTEXT::update1(STATE* p)
+{
+ (FoundState=p)->Freq += 4; SummFreq += 4;
+ if (p[0].Freq > p[-1].Freq) {
+ SWAP(p[0],p[-1]); FoundState=--p;
+ if (p->Freq > MAX_FREQ) rescale();
+ }
+}
+inline void PPM_CONTEXT::encodeSymbol1(int symbol)
+{
+ UINT LoCnt, i=Stats->Symbol;
+ STATE* p=Stats; SubRange.scale=SummFreq;
+ if (i == symbol) {
+ PrevSuccess=(2*(SubRange.HighCount=p->Freq) >= SubRange.scale);
+ (FoundState=p)->Freq += 4; SummFreq += 4;
+ RunLength += PrevSuccess;
+ if (p->Freq > MAX_FREQ) rescale();
+ SubRange.LowCount=0; return;
+ }
+ LoCnt=p->Freq;
+ i=NumStats; PrevSuccess=0;
+ while ((++p)->Symbol != symbol) {
+ LoCnt += p->Freq;
+ if (--i == 0) {
+ if ( Suffix ) PrefetchData(Suffix);
+ SubRange.LowCount=LoCnt; CharMask[p->Symbol]=EscCount;
+ i=NumMasked=NumStats; FoundState=NULL;
+ do { CharMask[(--p)->Symbol]=EscCount; } while ( --i );
+ SubRange.HighCount=SubRange.scale;
+ return;
+ }
+ }
+ SubRange.HighCount=(SubRange.LowCount=LoCnt)+p->Freq;
+ update1(p);
+}
+inline void PPM_CONTEXT::decodeSymbol1()
+{
+ UINT i, count, HiCnt=Stats->Freq;
+ STATE* p=Stats; SubRange.scale=SummFreq;
+ if ((count=ariGetCurrentCount()) < HiCnt) {
+ PrevSuccess=(2*(SubRange.HighCount=HiCnt) >= SubRange.scale);
+ (FoundState=p)->Freq=(HiCnt += 4); SummFreq += 4;
+ RunLength += PrevSuccess;
+ if (HiCnt > MAX_FREQ) rescale();
+ SubRange.LowCount=0; return;
+ }
+ i=NumStats; PrevSuccess=0;
+ while ((HiCnt += (++p)->Freq) <= count)
+ if (--i == 0) {
+ if ( Suffix ) PrefetchData(Suffix);
+ SubRange.LowCount=HiCnt; CharMask[p->Symbol]=EscCount;
+ i=NumMasked=NumStats; FoundState=NULL;
+ do { CharMask[(--p)->Symbol]=EscCount; } while ( --i );
+ SubRange.HighCount=SubRange.scale;
+ return;
+ }
+ SubRange.LowCount=(SubRange.HighCount=HiCnt)-p->Freq;
+ update1(p);
+}
+inline void PPM_CONTEXT::update2(STATE* p)
+{
+ (FoundState=p)->Freq += 4; SummFreq += 4;
+ if (p->Freq > MAX_FREQ) rescale();
+ EscCount++; RunLength=InitRL;
+}
+inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2()
+{
+ BYTE* pb=(BYTE*) Stats; UINT t=2*NumStats;
+ PrefetchData(pb); PrefetchData(pb+t);
+ PrefetchData(pb += 2*t); PrefetchData(pb+t);
+ SEE2_CONTEXT* psee2c;
+ if (NumStats != 0xFF) {
+ t=Suffix->NumStats;
+ psee2c=SEE2Cont[QTable[NumStats+2]-3]+(SummFreq > 11*(NumStats+1));
+ psee2c += 2*(2*NumStats < t+NumMasked)+Flags;
+ SubRange.scale=psee2c->getMean();
+ } else {
+ psee2c=&DummySEE2Cont; SubRange.scale=1;
+ }
+ return psee2c;
+}
+inline void PPM_CONTEXT::encodeSymbol2(int symbol)
+{
+ SEE2_CONTEXT* psee2c=makeEscFreq2();
+ UINT Sym, LoCnt=0, i=NumStats-NumMasked;
+ STATE* p1, * p=Stats-1;
+ do {
+ do { Sym=p[1].Symbol; p++; } while (CharMask[Sym] == EscCount);
+ CharMask[Sym]=EscCount;
+ if (Sym == symbol) goto SYMBOL_FOUND;
+ LoCnt += p->Freq;
+ } while ( --i );
+ SubRange.HighCount=(SubRange.scale += (SubRange.LowCount=LoCnt));
+ psee2c->Summ += SubRange.scale; NumMasked = NumStats;
+ return;
+SYMBOL_FOUND:
+ SubRange.LowCount=LoCnt; SubRange.HighCount=(LoCnt+=p->Freq);
+ for (p1=p; --i ; ) {
+ do { Sym=p1[1].Symbol; p1++; } while (CharMask[Sym] == EscCount);
+ LoCnt += p1->Freq;
+ }
+ SubRange.scale += LoCnt;
+ psee2c->update(); update2(p);
+}
+inline void PPM_CONTEXT::decodeSymbol2()
+{
+ SEE2_CONTEXT* psee2c=makeEscFreq2();
+ UINT Sym, count, HiCnt=0, i=NumStats-NumMasked;
+ STATE* ps[256], ** pps=ps, * p=Stats-1;
+ do {
+ do { Sym=p[1].Symbol; p++; } while (CharMask[Sym] == EscCount);
+ HiCnt += p->Freq; *pps++ = p;
+ } while ( --i );
+ SubRange.scale += HiCnt; count=ariGetCurrentCount();
+ p=*(pps=ps);
+ if (count < HiCnt) {
+ HiCnt=0;
+ while ((HiCnt += p->Freq) <= count) p=*++pps;
+ SubRange.LowCount = (SubRange.HighCount=HiCnt)-p->Freq;
+ psee2c->update(); update2(p);
+ } else {
+ SubRange.LowCount=HiCnt; SubRange.HighCount=SubRange.scale;
+ i=NumStats-NumMasked; NumMasked = NumStats;
+ do { CharMask[(*pps)->Symbol]=EscCount; pps++; } while ( --i );
+ psee2c->Summ += SubRange.scale;
+ }
+}
+inline void ClearMask(CInfo* EncodedFile, CInfo* DecodedFile)
+{
+ EscCount=1; memset(CharMask,0,sizeof(CharMask));
+ // if (++PrintCount == 0) PrintInfo(DecodedFile,EncodedFile);
+}
+void _STDCALL EncodeFile(CSink* EncodedFile, CSource* DecodedFile,
+ int MaxOrder,MR_METHOD MRMethod)
+{
+ ariInitEncoder(); StartModelRare(MaxOrder,MRMethod);
+ for (PPM_CONTEXT* MinContext; ; ) {
+ BYTE ns=(MinContext=MaxContext)->NumStats;
+ int c = _PPMD_E_GETC(DecodedFile);
+ if ( ns ) {
+ MinContext->encodeSymbol1(c); ariEncodeSymbol();
+ } else {
+ MinContext->encodeBinSymbol(c); ariShiftEncodeSymbol(TOT_BITS);
+ }
+ while ( !FoundState ) {
+ ARI_ENC_NORMALIZE(EncodedFile);
+ do {
+ OrderFall++; MinContext=MinContext->Suffix;
+ if ( !MinContext ) goto STOP_ENCODING;
+ } while (MinContext->NumStats == NumMasked);
+ MinContext->encodeSymbol2(c); ariEncodeSymbol();
+ }
+ if (!OrderFall && (BYTE*) FoundState->Successor >= UnitsStart)
+ PrefetchData(MaxContext=FoundState->Successor);
+ else {
+ UpdateModel(MinContext); PrefetchData(MaxContext);
+ if (EscCount == 0) ClearMask(EncodedFile,DecodedFile);
+ }
+ ARI_ENC_NORMALIZE(EncodedFile);
+ }
+STOP_ENCODING:
+ ARI_FLUSH_ENCODER(EncodedFile); //PrintInfo(DecodedFile,EncodedFile);
+}
+void _STDCALL DecodeFile(CSink* DecodedFile, CSource* EncodedFile,
+ int MaxOrder,MR_METHOD MRMethod)
+{
+ ARI_INIT_DECODER(EncodedFile); StartModelRare(MaxOrder,MRMethod);
+ PPM_CONTEXT* MinContext=MaxContext;
+ for (BYTE ns=MinContext->NumStats; ; ) {
+ ( ns )?(MinContext->decodeSymbol1()):(MinContext->decodeBinSymbol());
+ ariRemoveSubrange();
+ while ( !FoundState ) {
+ ARI_DEC_NORMALIZE(EncodedFile);
+ do {
+ OrderFall++; MinContext=MinContext->Suffix;
+ if ( !MinContext ) goto STOP_DECODING;
+ } while (MinContext->NumStats == NumMasked);
+ MinContext->decodeSymbol2(); ariRemoveSubrange();
+ }
+ _PPMD_D_PUTC(FoundState->Symbol,DecodedFile);
+ if (!OrderFall && (BYTE*) FoundState->Successor >= UnitsStart)
+ PrefetchData(MaxContext=FoundState->Successor);
+ else {
+ UpdateModel(MinContext); PrefetchData(MaxContext);
+ if (EscCount == 0) ClearMask(EncodedFile,DecodedFile);
+ }
+ ns=(MinContext=MaxContext)->NumStats;
+ ARI_DEC_NORMALIZE(EncodedFile);
+ }
+STOP_DECODING:
+ // PrintInfo(DecodedFile,EncodedFile);
+ return;
+}
+
+
+
+#include "PPMd.h"
+#include "CSource.h"
+
+size_t UnPPM(bool extra, unsigned char* readbuffer, size_t reclen, unsigned char* buffer, size_t buffersize)
+{
+ unsigned short order, mem, offset = 1;
+ int type = 0;
+ if (extra)
+ {
+ order = readbuffer[1];
+ mem = readbuffer[0];
+ type = order >> 6;
+ order = (order & 63) + 2;
+ offset = 2;
+ }
+ else
+ {
+ order = readbuffer[0];
+ mem = order >> 4;
+ order = (order & 15) + 2;
+ }
+ mem++;
+ // qDebug("Mem:%u Order:%u Type:%u\n", mem, order, type);
+ StartSubAllocator(mem);
+ CMemSink sink(buffer, buffersize);
+ CMemSource source(readbuffer+offset, reclen-offset);
+ DecodeFile(&sink,&source,order,(MR_METHOD)type);
+ StopSubAllocator();
+ return sink.size();
+}
+
+
+extern "C"
+{
+
+size_t PluckerDecompress3(unsigned char* a, size_t b, unsigned char* c, size_t d)
+{
+ return UnPPM(false, a, b, c, d);
+}
+
+size_t PluckerDecompress4(unsigned char* a, size_t b, unsigned char* c, size_t d)
+{
+ return UnPPM(true, a, b, c, d);
+}
+
+size_t RebDecompress(unsigned char* a, size_t b, unsigned char* c, size_t d)
+{
+ return UnPPM(true, a, b, c, d);
+}
+
+}
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 @@
+#ifndef __MODEL_H
+#define __MODEL_H
+
+extern "C"
+{
+ size_t PluckerDecompress3(unsigned char* a, size_t b, unsigned char* c, size_t d);
+ size_t PluckerDecompress4(unsigned char* a, size_t b, unsigned char* c, size_t d);
+ size_t RebDecompress(unsigned char* a, size_t b, unsigned char* c, size_t d);
+}
+
+#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 @@
/* -*- mode: c; indent-tabs-mode: nil; -*- */
+
#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 @@
+#include <stdlib.h>
+
#include <qcheckbox.h>
@@ -20,2 +22,3 @@
#include <qlineedit.h>
+#include <qdir.h>
#ifdef USECOMBO
@@ -104,2 +107,7 @@ CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl )
+ InlineTables = new QCheckBox( bg );
+ InlineTables->setText( tr( "Inline Tables" ) );
+
+ Underlinelinks = new QCheckBox( bg );
+ Underlinelinks->setText( tr( "Underline Links" ) );
/*
@@ -564,2 +572,5 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl )
+ QCheckBox* outcodec = new QCheckBox( bg );
+ outcodec->setText( tr( "Output" ) );
+
}
@@ -595,2 +606,5 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl )
+ boutput = new QCheckBox( gb );
+ boutput->setText( tr( "Output" ) );
+
QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Plucker", this);
@@ -606,29 +620,51 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl )
Continuous->setText( tr( "Continuous" ) );
-
- bg = new QButtonGroup(2, Qt::Horizontal, "Scroll", this);
+ bg = new QButtonGroup(2, Qt::Horizontal, "Background", this);
vl->addWidget( bg );
- // scrollinplace = new QCheckBox( bg );
- // scrollinplace->setText( tr( "In Place" ) );
+// QLabel* TextLabel = new QLabel( bg );
+// TextLabel->setText( tr( "Copy an image to \"background\" in\n~/Applications/uqtreader/Theme/" ) );
+
#ifdef USECOMBO
- scrolltype = new QComboBox( bg );
+ bgtype = new QComboBox( bg );
#else
- scrolltype = new MenuButton( this);
+ bgtype = new MenuButton( this);
#endif
- scrolltype->insertItem("In Place");
- scrolltype->insertItem("Rolling (moving bg)");
- scrolltype->insertItem("Rolling (window)");
- scrolltype->insertItem("Rolling (static bg)");
- scrolltype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+ bgtype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+
+ bgtype->insertItem( tr("Centred") );
+ bgtype->insertItem( tr("Tiled") );
+ bgtype->insertItem( tr("Fitted") );
+ DoubleBuffer = new QCheckBox( bg );
+ DoubleBuffer->setText( tr( "Double Buffer" ) );
+ QLabel* TextLabel = new QLabel( bg );
+ TextLabel->setText( tr( "Minibar Colour" ) );
#ifdef USECOMBO
- scrollcolor = new QComboBox( bg );
+ minibarcol = new QComboBox( bg );
#else
- scrollcolor = new MenuButton( this);
+ minibarcol = new MenuButton( this);
#endif
- populate_colours(scrollcolor);
- scrollcolor->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+ populate_colours(minibarcol);
+ minibarcol->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+}
+
+CMiscPrefs::~CMiscPrefs()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+CScrollPrefs::CScrollPrefs( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+
+ QHBoxLayout* hl = new QHBoxLayout(this);
+ hl->setMargin( 0 );
+
+ QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, "Scroll", this);
+ hl->addWidget( bg );
+ // scrollinplace = new QCheckBox( bg );
+ // scrollinplace->setText( tr( "In Place" ) );
QLabel* TextLabel = new QLabel( bg );
@@ -641,31 +677,55 @@ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl )
TextLabel = new QLabel( bg );
- TextLabel->setText( tr( "Minibar Colour" ) );
+ TextLabel->setText( tr( "Scroll type" ) );
#ifdef USECOMBO
- minibarcol = new QComboBox( bg );
+ scrolltype = new QComboBox( bg );
#else
- minibarcol = new MenuButton( this);
+ scrolltype = new MenuButton( this);
#endif
- populate_colours(minibarcol);
- minibarcol->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+ scrolltype->insertItem("In Place");
+ scrolltype->insertItem("Rolling (moving bg)");
+ scrolltype->insertItem("Rolling (window)");
+ scrolltype->insertItem("Rolling (static bg)");
+ scrolltype->insertItem("Send to output");
+ scrolltype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+ TextLabel = new QLabel( bg );
+ TextLabel->setText( tr( "Colour of scroll\nprogress indicator" ) );
- bg = new QButtonGroup(2, Qt::Vertical, "Background", this);
- vl->addWidget( bg );
+#ifdef USECOMBO
+ scrollcolor = new QComboBox( bg );
+#else
+ scrollcolor = new MenuButton( this);
+#endif
+ populate_colours(scrollcolor);
+ scrollcolor->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
-// QLabel* TextLabel = new QLabel( bg );
-// TextLabel->setText( tr( "Copy an image to \"background\" in\n~/Applications/uqtreader/Theme/" ) );
+ TextLabel = new QLabel( bg );
+ TextLabel->setText( tr( "Output" ) );
#ifdef USECOMBO
- bgtype = new QComboBox( bg );
+ outcodec = new QComboBox( bg );
#else
- bgtype = new MenuButton( this);
+ outcodec = new MenuButton( this);
#endif
- bgtype->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
-
- bgtype->insertItem( tr("Centred") );
- bgtype->insertItem( tr("Tiled") );
- bgtype->insertItem( tr("Fitted") );
+#ifdef USEQPE
+#ifdef OPIE
+ QString codecpath(getenv("OPIEDIR"));
+#else
+ QString codecpath(getenv("QTDIR"));
+#endif
+ codecpath += "/plugins/reader/outcodecs";
+#else
+ QString codecpath(getenv("READERDIR"));
+ codecpath += "/outcodecs";
+#endif
+ QDir ocd(codecpath, "lib*.so");
+ for (int i = 0; i < ocd.count(); ++i)
+ {
+ QString tmp(ocd[i]);
+ outcodec->insertItem(tmp.mid(3,tmp.length()-6));
+ }
+ outcodec->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
}
-CMiscPrefs::~CMiscPrefs()
+CScrollPrefs::~CScrollPrefs()
{
@@ -674,2 +734,3 @@ CMiscPrefs::~CMiscPrefs()
+
CPrefs::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
layout2 = new CLayoutPrefs2(w, this);
+ scroll = new CScrollPrefs(this);
misc = new CMiscPrefs(this);
@@ -686,2 +748,3 @@ CPrefs::CPrefs( int w, bool fs, QWidget* parent, const char* name) : QDialog(par
td->addTab(inter, tr("Locale"));
+ td->addTab(scroll, tr("Scroll"));
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:
// QCheckBox* Negative;
+ QCheckBox* InlineTables;
+ QCheckBox* Underlinelinks;
};
@@ -100,2 +102,3 @@ public:
QCheckBox* Continuous;
+ QCheckBox* DoubleBuffer;
protected:
@@ -118,4 +121,21 @@ public:
- QCheckBox *annotation, *dictionary, *clipboard;
- QCheckBox *Depluck, *Dejpluck, *Continuous;
+ QCheckBox *annotation, *dictionary, *clipboard, *boutput;
+ QCheckBox *Depluck, *Dejpluck, *Continuous, *DoubleBuffer;
+
+#ifdef USECOMBO
+ QComboBox *bgtype, *minibarcol;
+#else
+ MenuButton *bgtype, *minibarcol;
+#endif
+};
+
+class CScrollPrefs : public QWidget
+{
+
+public:
+
+ friend class CPrefs;
+
+ CScrollPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~CScrollPrefs();
@@ -124,5 +144,5 @@ public:
#ifdef USECOMBO
- QComboBox *scrollcolor, *bgtype, *scrolltype, *minibarcol;
+ QComboBox *scrollcolor, *scrolltype, *outcodec;
#else
- MenuButton *scrollcolor, *bgtype, *scrolltype, *minibarcol;
+ MenuButton *scrollcolor, *scrolltype, *outcodec;
#endif
@@ -133,3 +153,3 @@ class QListViewItem;
-class CButtonPrefs : public QWidget
+sclass CButtonPrefs : public QWidget
{
@@ -191,3 +211,3 @@ Q_OBJECT
CMiscPrefs* misc;
- // CButtonPrefs* button;
+ CScrollPrefs* scroll;
CInterPrefs* inter;
@@ -223,3 +243,5 @@ Q_OBJECT
bool StripCR() { return layout->StripCR->isChecked(); }
+ bool InlineTables() { return layout->InlineTables->isChecked(); }
bool repalm() { return layout->prepalm->isChecked(); }
+ bool UnderlineLink() { return layout->Underlinelinks->isChecked(); }
bool kern() { return layout->pkern->isChecked(); }
@@ -248,3 +270,5 @@ Q_OBJECT
void StripCR(bool v) { layout->StripCR->setChecked(v); }
+ void InlineTables(bool v) { layout->InlineTables->setChecked(v); }
void repalm(bool v) { layout->prepalm->setChecked(v); }
+ void UnderlineLink(bool v) { layout->Underlinelinks->setChecked(v); }
void kern(bool v) { layout->pkern->setChecked(v); }
@@ -275,3 +299,3 @@ Q_OBJECT
void bgtype(int v) { misc->bgtype->setCurrentItem(v); }
- void scrollcolor(int v) { misc->scrollcolor->setCurrentItem(v); }
+ void scrollcolor(int v) { scroll->scrollcolor->setCurrentItem(v); }
void minibarcol(int v) { misc->minibarcol->setCurrentItem(v); }
@@ -279,3 +303,3 @@ Q_OBJECT
void bgtype(int v) { misc->bgtype->select(v); }
- void scrollcolor(int v) { misc->scrollcolor->select(v); }
+ void scrollcolor(int v) { scroll->scrollcolor->select(v); }
void minibarcol(int v) { misc->minibarcol->select(v); }
@@ -283,3 +307,3 @@ Q_OBJECT
int bgtype() { return misc->bgtype->currentItem(); }
- int scrollcolor() { return misc->scrollcolor->currentItem(); }
+ int scrollcolor() { return scroll->scrollcolor->currentItem(); }
int minibarcol() { return misc->minibarcol->currentItem(); }
@@ -302,3 +326,2 @@ Q_OBJECT
-
#ifdef USECOMBO
@@ -319,2 +342,22 @@ Q_OBJECT
+#ifdef USECOMBO
+ void outcodec(QString& s)
+ {
+ for (int i = 1; i <= scroll->outcodec->count(); i++)
+ {
+ if (scroll->outcodec->text(i) == s)
+ {
+ scroll->outcodec->setCurrentItem(i);
+ break;
+ }
+ }
+ }
+#else
+ void outcodec(QString& s) { scroll->outcodec->select(s); }
+#endif
+ QString outcodec() { return scroll->outcodec->currentText(); }
+
+ void miscoutput(bool v) { return misc->boutput->setChecked(v); }
+ bool miscoutput() { return misc->boutput->isChecked(); }
+
bool Depluck() { return misc->Depluck->isChecked(); }
@@ -325,2 +368,4 @@ Q_OBJECT
void Continuous(bool v) { misc->Continuous->setChecked(v); }
+ bool DoubleBuffer() { return misc->DoubleBuffer->isChecked(); }
+ void DoubleBuffer(bool v) { misc->DoubleBuffer->setChecked(v); }
bool SwapMouse() { return inter->SwapMouse->isChecked(); }
@@ -373,12 +418,12 @@ Q_OBJECT
int encoding() { return inter->encoding->currentItem(); }
- int scrolltype() { return misc->scrolltype->currentItem(); }
+ int scrolltype() { return scroll->scrolltype->currentItem(); }
#ifdef USECOMBO
void encoding(int v) { inter->encoding->setCurrentItem(v); }
- void scrolltype(int v) { misc->scrolltype->setCurrentItem(v); }
+ void scrolltype(int v) { scroll->scrolltype->setCurrentItem(v); }
#else
void encoding(int v) { inter->encoding->select(v); }
- void scrolltype(int v) { misc->scrolltype->select(v); }
+ void scrolltype(int v) { scroll->scrolltype->select(v); }
#endif
- void scrollstep(int v) { misc->scrollstep->setValue(v); }
- int scrollstep() { return misc->scrollstep->value(); }
+ void scrollstep(int v) { scroll->scrollstep->setValue(v); }
+ int scrollstep() { return scroll->scrollstep->value(); }
};
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;
#include <qdir.h>
+#include "TableDialog.h"
+#include "outputcodec.h"
+/*
#ifdef _UNICODE
@@ -40,2 +43,3 @@ const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 };
#endif
+*/
//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',' ','>'
-
QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
- QWidget(parent, name, f),
+ QWidget(parent, name, f | WRepaintNoErase | WResizeNoErase),
+ m_outofdate(true),
m_default_fg(0,0,0),
@@ -91,12 +95,8 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) :
{
+ m_output = NULL;
m_overlap = 1;
setKeyCompression ( true );
-#ifdef DOUBLEBUFFER
- dbuff = new QPixmap();
- dbp = new QPainter();
- // if (painter->isActive()) painter->end();
- // painter->begin(frame);
-#endif
-// init();
+ dbuff = NULL;
+ dbp = NULL;
}
@@ -119,3 +119,3 @@ QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *nam
init();
-// // qDebug("Load_file(1)");
+// // qDeb2ug("Load_file(1)");
load_file((const tchar*)filename);
@@ -140,3 +140,4 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
{
- buffdoc.unsuspend();
+ m_drageligible = false;
+ qDebug("Mouse pressed at (%u, %u)", _e->x(), _e->y());
int x, y, ht, wh;
@@ -156,10 +157,12 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
}
- if (_e->button() == RightButton)
+ if (x >= m_left_border && x <= wh - m_right_border && y >= m_topmargin && y <= ht-m_bottommargin)
{
-// qDebug("MousePress");
- mouseUpOn = false;
- if (m_swapmouse)
+ if (_e->button() == RightButton)
{
- int lineno = 0;
- /*
+ // qDebug("MousePress");
+ mouseUpOn = false;
+ if (m_swapmouse)
+ {
+ int lineno = 0;
+ /*
int hgt = textarray[0]->lineSpacing();
@@ -167,12 +170,154 @@ void QTReader::mousePressEvent( QMouseEvent* _e )
{
- hgt += textarray[++lineno]->lineSpacing();
+ hgt += textarray[++lineno]->lineSpacing();
}
- */
- size_t startpos, startoffset, tgt, tgtoffset, pictgt;
- QImage* img;
- getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img);
- processmousewordevent(startpos, startoffset, _e, lineno);
+ */
+ size_t startpos, startoffset, tgt, tgtoffset, pictgt, tabtgt;
+ QImage* img;
+ getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img, tabtgt);
+ processmousewordevent(startpos, startoffset, _e, lineno);
+ }
+ else
+ {
+ processmousepositionevent(_e);
+ }
+ }
+ }
+ else
+ {
+ int ln = -1;
+ int mp;
+ int sectionsize = (buffdoc.endSection()-buffdoc.startSection());
+ switch (m_scrollpos)
+ {
+ case 1:
+ {
+ if (m_rotated)
+ {
+ if (_e->x() < m_bottommargin)
+ {
+ ln = height();
+ mp = _e->y();
+ }
+ }
+ else
+ {
+ if (_e->y() > height()-m_bottommargin)
+ {
+ ln = width();
+ mp = _e->x();
+ }
+ }
+ }
+ break;
+ case 2:
+ {
+ if (m_rotated)
+ {
+ if (_e->y() > height() - m_right_border)
+ {
+ ln = width();
+ mp = width()-_e->x();
+ }
+ }
+ else
+ {
+ if (_e->x() > width() - m_right_border)
+ {
+ ln = height();
+ mp = _e->y();
+ }
+ }
+ }
+ break;
+ case 3:
+ {
+ if (m_rotated)
+ {
+ if (_e->y() < m_left_border)
+ {
+ ln = width();
+ mp = width()-_e->x();
+ }
+ }
+ else
+ {
+ if (_e->x() < m_left_border)
+ {
+ ln = height();
+ mp = _e->y();
+ }
+ }
+ }
+ break;
+ case 0:
+ default:
+ ln = -1;
+ break;
+ }
+ if (ln >= 0)
+ {
+ int dp = (sectionsize*mp+ln/2)/ln + buffdoc.startSection();
+ int winsize = locnarray[numlines]-locnarray[0];
+ int slidersize = 10*(sectionsize+ln/2)/ln;
+ if (slidersize > winsize)
+ {
+ int mid = (locnarray[0] + locnarray[numlines])/2;
+ slidersize /= 2;
+ if (dp < mid-slidersize)
+ {
+ dopageup();
+ }
+ else if (dp > mid+slidersize)
+ {
+ dopagedn();
+ }
+ //if (mid-slidersize < dp && dp < mid+slidersize)
+ else
+ {
+ m_drageligible = true;
+ }
+ }
+ else
+ {
+ if (dp < locnarray[0])
+ {
+ dopageup();
+ }
+ else if (dp > locnarray[numlines])
+ {
+ dopagedn();
+ }
+ //if (locnarray[0] < dp && dp < locnarray[numlines])
+ else
+ {
+ m_drageligible = true;
+ }
+ }
+ qDebug("Drag eligible:%s", (m_drageligible) ? "true" : "false");
+ }
+ else
+ {
+ if (m_scrollpos == 1)
+ {
+ if (x < m_left_border)
+ {
+ lineUp();
+ }
+ if (y > ht - m_bottommargin)
+ {
+ lineDown();
+ }
+ }
+ else if (m_scrollpos != 0)
+ {
+ if (y < m_topmargin)
+ {
+ lineUp();
+ }
+ if (y > ht - m_bottommargin)
+ {
+ lineDown();
+ }
+ }
}
- else
- processmousepositionevent(_e);
}
@@ -297,3 +442,3 @@ void QTReader::goForward()
-linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img)
+linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img, size_t& tabtgt)
{
@@ -342,3 +487,3 @@ linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t
}
- return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img);
+ return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img, tabtgt);
}
@@ -356,2 +501,34 @@ void QTReader::suspend()
+void QTReader::setDoubleBuffer(bool _b)
+{
+ m_doubleBuffered = _b;
+ if (_b || m_rotated)
+ {
+ if (dbuff == NULL)
+ {
+ dbuff = new QPixmap();
+ dbp = new QPainter();
+ }
+ if (m_rotated)
+ {
+ dbuff->resize(height(), width());
+ }
+ else
+ {
+ dbuff->resize(width(), height());
+ }
+ m_outofdate = true;
+ }
+ else
+ {
+ if (dbuff != NULL)
+ {
+ delete dbuff;
+ delete dbp;
+ }
+ dbuff = NULL;
+ dbp = NULL;
+ }
+}
+
void QTReader::setTwoTouch(bool _b)
@@ -364,3 +541,2 @@ void QTReader::setContinuous(bool _b)
{
- buffdoc.unsuspend();
buffdoc.setContinuous(m_continuousDocument = _b);
@@ -457,3 +633,3 @@ void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouse
{
- qDebug("Selecteed:%s", (const char*)wrd);
+ qDebug("Selected:%s", (const char*)wrd);
if (m_twotouch)
@@ -470,12 +646,41 @@ void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouse
-void QTReader::mouseReleaseEvent( QMouseEvent* _e )
+#ifdef USETIMER
+void QTReader::actionDrag()
{
- buffdoc.unsuspend();
- int x, y, ht, wh;
- if (m_rotated)
+ if (m_drageligible)
{
- x = _e->y();
- y = width()-_e->x();
- ht = width();
- wh = height();
+ int fivepages = 5*((2*width()+m_textsize/2)/m_textsize)*((height()+m_textsize/2)/m_textsize);
+ if (m_dragtarget > fivepages && locnarray[numlines] < m_dragtarget - fivepages)
+ {
+ int tgt = m_dragtarget - fivepages/2;
+ //qDebug("Jumping to %u (%u)", tgt, fivepages);
+ if (tgt < buffdoc.startSection())
+ {
+ tgt = buffdoc.startSection();
+ }
+ locate(tgt);
+ drawFonts();
+ }
+ else if (locnarray[0] > m_dragtarget+fivepages)
+ {
+ int tgt = m_dragtarget + fivepages/2;
+ //qDebug("Jumping to %u (%u)", tgt, fivepages);
+ if (tgt > buffdoc.endSection())
+ {
+ dopageup();
+ }
+ else
+ {
+ locate(tgt);
+ drawFonts();
+ }
+ }
+ else if (locnarray[numlines] <= m_dragtarget)
+ {
+ dopagedn();
+ }
+ else if (locnarray[0] > m_dragtarget)
+ {
+ dopageup();
+ }
}
@@ -483,187 +688,294 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e )
{
- x = _e->x();
- y = _e->y();
- ht = height();
- wh = width();
+ m_dragtimer->stop();
}
- if (_e->button() == LeftButton)
+}
+#endif
+
+void QTReader::mouseMoveEvent( QMouseEvent* _e )
+{
+ if (m_drageligible)
{
- if (mouseUpOn)
+ int ht;
+ int mp;
+ int sectionsize = (buffdoc.endSection()-buffdoc.startSection());
+ //qDebug("Mouse moved to (%u, %u)", _e->x(), _e->y());
+ switch (m_scrollpos)
{
-// qDebug("MouseRelease");
- switch(m_scrollpos)
+ case 1:
+ {
+ if (m_rotated)
+ {
+ ht = height();
+ mp = _e->y();
+ }
+ else
+ {
+ ht = width();
+ mp = _e->x();
+ }
+ }
+ break;
+ case 2:
+ case 3:
+ {
+ if (m_rotated)
+ {
+ ht = width();
+ mp = width()-_e->x();
+ }
+ else
+ {
+ ht = height();
+ mp = _e->y();
+ }
+ }
+ break;
+ case 0:
+ default:
+ ht = -1;
+ break;
+ }
+ if (ht >= 0)
+ {
+#ifdef USETIMER
+ m_dragtarget = (sectionsize*mp+ht/2)/ht + buffdoc.startSection();
+ if (!m_dragtimer->isActive())
{
- case 1: // Bottom
- if (y > ht - 5)
- {
- locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh);
- return;
- }
- break;
- case 2: // right
- if (x > wh - m_right_border)
- {
- locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht);
- return;
- }
- break;
- case 3: // left
- if (x < m_left_border)
- {
- locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht);
- return;
- }
- break;
- case 0:
- default:
- break;
+ m_dragtimer->start(0, false);
}
- if (textarray[0] != NULL)
+#else
+ int dp = (sectionsize*mp+ht/2)/ht + buffdoc.startSection();
+ locate(dp);
+#endif
+ }
+ }
+}
+
+void QTReader::mouseReleaseEvent( QMouseEvent* _e )
+{
+ qDebug("Mouse released at (%u, %u)", _e->x(), _e->y());
+ if (m_drageligible)
+ {
+ m_drageligible = false;
+ }
+ else
+ {
+ int x, y, ht, wh;
+ if (m_rotated)
+ {
+ x = _e->y();
+ y = width()-_e->x();
+ ht = width();
+ wh = height();
+ }
+ else
+ {
+ x = _e->x();
+ y = _e->y();
+ ht = height();
+ wh = width();
+ }
+ if (_e->button() == LeftButton)
+ {
+ if (mouseUpOn)
{
- QString line;
-// int lineno = _e->y()/m_linespacing;
- int lineno = 0;
- /*
- int ht = textarray[0]->lineSpacing();
- while ((ht < y) && (lineno < numlines))
+ // qDebug("MouseRelease");
+ /*
+ switch(m_scrollpos)
{
- ht += textarray[++lineno]->lineSpacing();
+ case 1: // Bottom
+ if (y > ht - 5)
+ {
+ locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh);
+ return;
}
- */
- size_t startpos, startoffset, tgt, tgtoffset, pictgt;
- QImage* img;
- if (m_currentlinkstyle != NULL)
- {
- textarray[m_currentlink]->invertLink(m_currentlinkoffset);
- m_currentlinkstyle = NULL;
- m_currentlink = -1;
- m_currentlinkoffset = -1;
- }
- linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img);
- if ((glt & eLink) != 0)
- {
- if ((glt & ePicture) != 0)
- {
- qDebug("Big Picture:%x", pictgt);
- if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0)
- {
- QImage* pm = buffdoc.getPicture(pictgt);
- if (pm != NULL)
- {
- emit OnShowPicture(*pm);
- delete pm;
- return;
- }
- }
- }
- else if (img != NULL)
- {
- if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0)
- {
- emit OnShowPicture(*img);
- return;
- }
- }
- size_t saveposn = pagelocate();
- QString href, nm;
- linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm);
- qDebug("URL(1):%s", (const char*)href);
- if ((lt & eFile) != 0)
- {
- buffdoc.saveposn(m_lastfile, saveposn);
+ break;
+ case 2: // right
+ if (x > wh - m_right_border)
+ {
+ locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht);
+ return;
+ }
+ break;
+ case 3: // left
+ if (x < m_left_border)
+ {
+ locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht);
+ return;
+ }
+ break;
+ case 0:
+ default:
+ break;
+ }
+ */
+ if (textarray[0] != NULL)
+ {
+ QString line;
+ // int lineno = _e->y()/m_linespacing;
+ int lineno = 0;
+ /*
+ int ht = textarray[0]->lineSpacing();
+ while ((ht < y) && (lineno < numlines))
+ {
+ ht += textarray[++lineno]->lineSpacing();
+ }
+ */
+ size_t startpos, startoffset, tgt, tgtoffset, pictgt, tabtgt;
+ QImage* img;
+ if (m_currentlinkstyle != NULL)
+ {
+ textarray[m_currentlink]->invertLink(m_currentlinkoffset);
+ m_currentlinkstyle = NULL;
+ m_currentlink = -1;
+ m_currentlinkoffset = -1;
+ }
+ linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img, tabtgt);
+ if (bNoInlineTables && ((glt & eTable) != 0))
+ {
+ size_t currentpos = locate();
+ QString tabtext = buffdoc.getTableAsHtml(tabtgt);
+ qDebug("TABLE:%u:%u:%s", currentpos, tabtgt, (const char*)tabtext);
+ QFont f(m_fontname, m_fontControl.currentsize());
#ifdef USEQPE
+ CTableDialog td(f, tabtext, true, this);
+#else
+ CTableDialog td(f, tabtext, false, this);
+#endif
+ td.exec();
+ jumpto(currentpos);
+ }
+ if ((glt & eLink) != 0)
+ {
+ if ((glt & ePicture) != 0)
{
- QCopEnvelope e("QPE/System", "busy()");
+ qDebug("Big Picture:%x", pictgt);
+ if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0)
+ {
+ QImage* pm = buffdoc.getPicture(pictgt);
+ if (pm != NULL)
+ {
+ emit OnShowPicture(*pm);
+ delete pm;
+ return;
+ }
+ }
}
-#endif
- ResetScroll();
- if (!href.isEmpty())
- {
- if (!buffdoc.getFile(href))
- {
- emit NewFileRequest(href);
- }
- else
- {
- ResetScroll();
- fillbuffer();
- update();
- }
- }
- if (!nm.isEmpty())
- {
- qDebug("QTReader:Finding %s", (const char*)nm);
- if (buffdoc.findanchor(nm))
- {
- fillbuffer();
- update();
- }
- }
- //fillbuffer();
- //update();
-#ifdef USEQPE
+ else if (img != NULL)
{
- QCopEnvelope e("QPE/System", "notBusy()");
+ if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0)
+ {
+ emit OnShowPicture(*img);
+ return;
+ }
}
-#endif
- }
- else if ((lt & eLink) != 0)
- {
- buffdoc.saveposn(m_lastfile, saveposn);
- ResetScroll();
- fillbuffer();
- update();
- }
- else
- {
- if ((lt & ePicture) != 0)
+ size_t saveposn = pagelocate();
+ QString href, nm;
+ linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm);
+ qDebug("URL(1):%s", (const char*)href);
+ if ((lt & eFile) != 0)
+ {
+ buffdoc.saveposn(m_lastfile, saveposn);
+#ifdef USEQPE
{
- QImage* pm = buffdoc.getPicture(tgt);
- if (pm != NULL)
- {
- emit OnShowPicture(*pm);
- delete pm;
- }
+ QCopEnvelope e("QPE/System", "busy()");
}
- else
+#endif
+ ResetScroll();
+ if (!href.isEmpty())
+ {
+ if (!buffdoc.getFile(href, nm))
+ {
+ emit NewFileRequest(href);
+ }
+ else
+ {
+ qDebug("BEFORE:%u", pagelocate());
+ buffdoc.resetPos();
+ ResetScroll();
+ fillbuffer();
+ qDebug("AFTER:%u", pagelocate());
+ m_outofdate = true;
+ update();
+ }
+ }
+ if (!nm.isEmpty())
+ {
+ qDebug("QTReader:Finding %s", (const char*)nm);
+ if (buffdoc.findanchor(nm))
+ {
+ buffdoc.resetPos();
+ fillbuffer();
+ m_outofdate = true;
+ update();
+ }
+ }
+ //fillbuffer();
+ //update();
+#ifdef USEQPE
{
- // QString anchortext = textarray[lineno]->getanchortext(startoffset);
- if (!href.isEmpty())
- {
- emit OnURLSelected(href, tgt);
- }
+ QCopEnvelope e("QPE/System", "notBusy()");
}
- locate(pagelocate());
- }
- return;
- }
- else if ((glt & ePicture) != 0)
- {
- qDebug("Big Picture:%x", pictgt);
- QImage* pm = buffdoc.getPicture(pictgt);
- if (pm != NULL)
- {
- emit OnShowPicture(*pm);
- delete pm;
- }
- else
- {
- locate(pagelocate());
- }
- return;
- }
- else if (img != NULL)
- {
- emit OnShowPicture(*img);
- return;
- }
- if (m_swapmouse)
+#endif
+ }
+ else if ((lt & eLink) != 0)
+ {
+ buffdoc.saveposn(m_lastfile, saveposn);
+ ResetScroll();
+ fillbuffer();
+ m_outofdate = true;
+ update();
+ }
+ else
+ {
+ if ((lt & ePicture) != 0)
+ {
+ QImage* pm = buffdoc.getPicture(tgt);
+ if (pm != NULL)
+ {
+ emit OnShowPicture(*pm);
+ delete pm;
+ }
+ }
+ else
+ {
+ // QString anchortext = textarray[lineno]->getanchortext(startoffset);
+ if (!href.isEmpty())
+ {
+ emit OnURLSelected(href, tgt);
+ }
+ }
+ }
+ return;
+ }
+ else if ((glt & ePicture) != 0)
+ {
+ qDebug("Big Picture:%x", pictgt);
+ QImage* pm = buffdoc.getPicture(pictgt);
+ if (pm != NULL)
+ {
+ emit OnShowPicture(*pm);
+ delete pm;
+ }
+ else
+ {
+ update();
+ }
+ return;
+ }
+ else if (img != NULL)
+ {
+ emit OnShowPicture(*img);
+ return;
+ }
+ if (m_swapmouse)
processmousepositionevent(_e);
- else
+ else
processmousewordevent(startpos, startoffset, _e, lineno);
+ }
+ }
+ else
+ {
+ mouseUpOn = true;
}
- }
- else
- {
- mouseUpOn = true;
}
@@ -674,3 +986,3 @@ void QTReader::focusInEvent(QFocusEvent* e)
{
- if (m_autoScroll) timer->start(real_delay(), false);
+ if (m_autoScroll && (m_scrolltype != 4)) timer->start(real_delay(), false);
update();
@@ -682,3 +994,10 @@ void QTReader::focusOutEvent(QFocusEvent* e)
{
- timer->stop();
+ if (m_scrolltype != 4)
+ {
+ timer->stop();
+ }
+ else
+ {
+ m_autoScroll = false;
+ }
// m_scrolldy1 = m_scrolldy2 = 0;
@@ -719,3 +1038,2 @@ void QTReader::NavUp()
{
- buffdoc.unsuspend();
if (buffdoc.hasnavigation())
@@ -739,3 +1057,2 @@ void QTReader::NavDown()
{
- buffdoc.unsuspend();
if (buffdoc.hasnavigation())
@@ -764,4 +1081,3 @@ void QTReader::zoomin()
setfont();
- locate(pagelocate());
- repaint();
+ refresh();
setautoscroll(sc);
@@ -777,4 +1093,3 @@ void QTReader::zoomout()
setfont();
- locate(pagelocate());
- repaint();
+ refresh();
setautoscroll(sc);
@@ -811,4 +1126,3 @@ void QTReader::keyPressEvent(QKeyEvent* e)
{
- buffdoc.unsuspend();
-
+
//((QTReaderApp*)parent()->parent())->handlekey(e);
@@ -908,2 +1222,3 @@ void QTReader::setautoscroll(bool _sc)
{
+ m_outofdate = true;
if (_sc == m_autoScroll) return;
@@ -929,2 +1244,5 @@ void QTReader::setautoscroll(bool _sc)
if (reusebuffer == NULL || reusebuffer->eof()) return;
+#ifndef __STATIC
+ if ((m_scrolltype == 4) && !checkoutput()) return;
+#endif
m_autoScroll = true;
@@ -949,3 +1267,2 @@ bool QTReader::getline(CDrawBuffer *buff)
{
- buffdoc.unsuspend();
bool bRet;
@@ -1067,20 +1384,2 @@ void QTReader::doinplacescroll()
{
- /*
- if (m_rotated)
- {
- blitRot2(0,0,height(),width()-m_scrolldy,NULL);
-// blitRot2(0,0,0,height(),width()-m_scrolldy,NULL);
- }
- else
- {
- if (m_bgpm.isNull())
- {
- p.fillRect(0,m_scrolldy,width(),height()-m_scrolldy,m_bg);
- }
- else
- {
- bitBlt(this, 0, m_scrolldy, dbuff, 0, m_scrolldy, width(), height()-m_scrolldy);
- }
- }
- */
m_scrolldy = m_topmargin;
@@ -1101,3 +1400,2 @@ void QTReader::doinplacescroll()
#endif
- //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll);
emit SetScrollState(m_autoScroll);
@@ -1496,5 +1794,16 @@ void QTReader::autoscroll()
{
- drawBackground();
- dbp->end();
- timer->start(real_delay(), false);
+ if (m_scrolltype == 4)
+ {
+ readAloud();
+ }
+ else
+ {
+ if (dbuff != NULL)
+ {
+ dbp->begin(dbuff);
+ drawBackground(dbp);
+ dbp->end();
+ }
+ timer->start(real_delay(), false);
+ }
}
@@ -1559,24 +1868,28 @@ void QTReader::redrawall()
{
-#ifdef DOUBLEBUFFER
- drawBackground();
- DrawStraight(dbp, height(), width());
- dbp->end();
-
- QWMatrix m;
- m.rotate(90);
- QPixmap rp = dbuff->xForm(m);
- bitBlt(this, 0,0,&rp,0,0,-1,-1);
-#else
- QPixmap dbuff(height(), width());
- QPainter dbp(&dbuff);
- // dbp.setBackgroundMode(OpaqueMode);
- dbp.fillRect(dbuff.rect(), m_bg);
-
- DrawStraight(&dbp, height(), width());
-
- QWMatrix m;
- m.rotate(90);
- QPixmap rp = dbuff.xForm(m);
- bitBlt(this, 0,0,&rp,0,0,-1,-1);
-#endif
+ if (dbuff != NULL)
+ {
+ dbp->begin(dbuff);
+ drawBackground(dbp);
+ DrawStraight(dbp, height(), width());
+ dbp->end();
+
+ QWMatrix m;
+ m.rotate(90);
+ QPixmap rp = dbuff->xForm(m);
+ bitBlt(this, 0,0,&rp,0,0,-1,-1);
+ }
+ else
+ {
+ qDebug("This shouldn't happen but it doesn't matter if it does (rotated == double buffered)");
+ QPixmap dbuff(height(), width());
+ QPainter dbp(&dbuff);
+
+ drawBackground(&dbp);
+ DrawStraight(&dbp, height(), width());
+
+ QWMatrix m;
+ m.rotate(90);
+ QPixmap rp = dbuff.xForm(m);
+ bitBlt(this, 0,0,&rp,0,0,-1,-1);
+ }
}
@@ -1584,10 +1897,16 @@ void QTReader::redrawall()
{
-#ifdef DOUBLEBUFFER
- drawBackground();
- DrawStraight(dbp, width(), height());
- dbp->end();
- bitBlt(this, 0,0,dbuff,0,0,-1,-1);
-#else
- DrawStraight(p, width(), height());
-#endif
+ if (dbuff != NULL)
+ {
+ dbp->begin(dbuff);
+ drawBackground(dbp);
+ DrawStraight(dbp, width(), height());
+ dbp->end();
+ bitBlt(this, 0,0,dbuff,0,0,-1,-1);
+ }
+ else
+ {
+ QPainter p(this);
+ drawBackground(&p);
+ DrawStraight(&p, width(), height());
+ }
}
@@ -1602,6 +1921,32 @@ void QTReader::drawFonts()
// qDebug("How refreshing...");
- if (buffdoc.empty()) return;
+ if (buffdoc.empty())
+ {
+ if (dbuff != NULL)
+ {
+ dbp->begin(dbuff);
+ drawBackground(dbp);
+ dbp->end();
+ }
+ else
+ {
+ QPainter p(this);
+ drawBackground(&p);
+ }
+ return;
+ }
setfont();
// if (!m_autoScroll) m_scrolldy1 = 0;
-#ifdef ROTATION_ENABLED
+ if (dbuff != NULL && (dbuff->width() != width() || dbuff->height() != height()))
+ {
+ qDebug("Oh no! A resize event was missed...");
+ if (m_rotated)
+ {
+ dbuff->resize(height(), width());
+ }
+ else
+ {
+ dbuff->resize(width(), height());
+ }
+ m_lastwidth = 0;
+ }
if (m_lastwidth != ((m_rotated) ? height() : width()))
@@ -1613,3 +1958,5 @@ void QTReader::drawFonts()
buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border));
- locate(pagelocate());
+ buffdoc.locate(pagelocate());
+ fillbuffer();
+ redrawall();
// qDebug("Not Optimised %d", m_lastwidth);
@@ -1653,59 +2000,2 @@ void QTReader::drawFonts()
}
-#else
- if (m_lastwidth != width())
- {
- // qDebug("Not Optimised %d", m_lastwidth);
- m_lastwidth = width();
- m_lastheight = height();
- buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border));
- locate(pagelocate());
-// qDebug("Not Optimised %d", m_lastwidth);
- }
- else
- {
- int newht = height();
- if (m_lastheight > newht)
- {
-// qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht);
- int ypos = m_topmargin;
- for (int i = 0; i < numlines; i++)
- {
- if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin)
- {
- numlines = i;
- jumpto(mylastpos = locnarray[i+1]);
- break;
- }
- }
-// qDebug("Optimised < %d", numlines);
- m_lastheight = newht;
- }
- else if (m_lastheight < newht)
- {
-// qDebug("Optimised > %d", numlines);
- int ypos = m_topmargin;
- for (int i = 0; i <= numlines; i++)
- {
- ypos += textarray[i]->lineSpacing();
- }
- fillbuffer(numlines+1, ypos, newht);
-// qDebug("Optimised > %d", numlines);
- }
- if (numlines > 0)
- {
- int ypos = textarray[0]->ascent()+m_topmargin;
- textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin);
-// int last = (m_showlast) ? numlines : numlines-1;
-// for (int i = 1; i <= last; i++)
- for (int i = 1; i < numlines; i++)
- {
-// ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2;
- ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+
- (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2;
- textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin);
- }
-// mylastpos = locate();
- }
- }
-#endif
emitRedraw();
@@ -1930,3 +2220,2 @@ void QTReader::init()
{
- buffdoc.unsuspend();
setBackgroundColor( m_bg );
@@ -1937,2 +2226,6 @@ void QTReader::init()
connect(timer, SIGNAL(timeout()), this, SLOT(doscroll()));
+#ifdef USETIMER
+ m_dragtimer = new QTimer(this);
+ connect(m_dragtimer, SIGNAL(timeout()), this, SLOT(actionDrag()));
+#endif
// QMessageBox::information(this, "init", m_lastfile, 1);
@@ -1946,6 +2239,11 @@ QTReader::~QTReader()
{
-#ifdef DOUBLEBUFFER
- delete dbuff;
- delete dbp;
-#endif
+ if (m_output != NULL)
+ {
+ delete m_output;
+ }
+ if (dbuff != NULL)
+ {
+ delete dbuff;
+ delete dbp;
+ }
#ifdef USEQPE
@@ -1984,5 +2282,43 @@ void QTReader::printIt()
-void QTReader::paintEvent( QPaintEvent * )
+void QTReader::paintEvent( QPaintEvent * p )
{
- drawFonts();
+ if ((dbuff != NULL) && !m_outofdate)
+ {
+ if (m_rotated)
+ {
+ if ((p->rect().width() != width()) || (p->rect().height() != height()))
+ {
+ qDebug("Partial paint");
+ QRect r;
+ r.setTop(width()-p->rect().right()-1);
+ r.setLeft(p->rect().top());
+ r.setHeight(p->rect().width());
+ r.setWidth(p->rect().height());
+ QPixmap p1(r.width(), r.height());
+ bitBlt(&p1, QPoint(0, 0), dbuff, r);
+ QWMatrix m;
+ m.rotate(90);
+ QPixmap p2 = p1.xForm(m);
+ bitBlt(this, p->rect().left(), p->rect().top(), &p2, 0, 0, -1, -1);
+ }
+ else
+ {
+ qDebug("Full paint");
+ QWMatrix m;
+ m.rotate(90);
+ QPixmap rp = dbuff->xForm(m);
+ bitBlt(this, 0,0,&rp,0,0,-1,-1);
+ }
+ }
+ else
+ {
+ //bitBlt(this, 0,0,dbuff,0,0,-1,-1);
+ bitBlt(this,p->rect().topLeft(),dbuff,p->rect());
+ }
+ }
+ else
+ {
+ drawFonts();
+ }
+ m_outofdate = false;
}
@@ -2018,5 +2354,14 @@ int main( int argc, tchar **argv )
+bool QTReader::locate(unsigned long n)
+{
+ m_outofdate = true;
+ m_lastwidth = 0;
+ locnarray[0] = n;
+ ResetScroll();
+ update();
+ return true;
+}
+/*
bool QTReader::locate(unsigned long n) {
//printf("Locate\n");
- buffdoc.unsuspend();
buffdoc.locate(n);
@@ -2025,2 +2370,3 @@ bool QTReader::locate(unsigned long n) {
fillbuffer();
+ m_outofdate = true;
// // qDebug("&Buffer filled");
@@ -2031,3 +2377,3 @@ bool QTReader::locate(unsigned long n) {
}
-
+*/
unsigned int QTReader::screenlines()
@@ -2041,3 +2387,2 @@ bool QTReader::fillbuffer(int reuse, int ht, int newht)
{
- buffdoc.unsuspend();
int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0);
@@ -2065,2 +2410,8 @@ bool QTReader::fillbuffer(int reuse, int ht, int newht)
ypos += textarray[numlines]->lineSpacing();
+ /*
+ QString tmp = toQString(textarray[numlines]->data());
+ printf("[%u, %u, %u](%s):%s\n", lastypos, m_lastheight-hmargin, ypos,
+ ((textarray[numlines]->showPartial()) ? "TRUE" : "FALSE"),
+ (const char*)tmp);
+ */
numlines++;
@@ -2068,7 +2419,10 @@ bool QTReader::fillbuffer(int reuse, int ht, int newht)
{
- if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/)
+ if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/)
{
qDebug("FALSE");
+ if (oldpagepos < buffdoc.endSection())
locate(oldpagepos);
- return false;
+ else
+ dopageup(buffdoc.endSection());
+ return false;
}
@@ -2103,3 +2457,2 @@ void QTReader::dopagedn()
// qDebug("HEIGHT(2):%d", m_lastheight);
- buffdoc.unsuspend();
ResetScroll();
@@ -2152,4 +2505,6 @@ bool QTReader::synch(size_t start, size_t end)
if (ch == 10) return true;
- if (ch == UEOF) return false;
- if (ch == 6) return false;
+ if ((ch == UEOF) || (ch == 6))
+ {
+ return false;
+ }
}
@@ -2160,3 +2515,2 @@ void QTReader::dopageup(unsigned int target)
{
- buffdoc.unsuspend();
ResetScroll();
@@ -2164,4 +2518,4 @@ void QTReader::dopageup(unsigned int target)
CBufferFace<size_t> loc;
-
size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0;
+ qDebug("dopageup:: locate():%u pagelocate():%u guess:%u", locate(), pagelocate(), guess);
bool ch = true;
@@ -2182,2 +2536,3 @@ void QTReader::dopageup(unsigned int target)
delta = 0; // 0 is a flag to say don't guess any more
+ qDebug("Jumping to startsection:%d", buffdoc.startSection());
jumpto(buffdoc.startSection());
@@ -2189,11 +2544,11 @@ void QTReader::dopageup(unsigned int target)
{
- lastdelta = delta;
- if (guess < 4000)
+ lastdelta = delta;
+ if (guess < 4000)
{
- guess <<= 1;
- continue;
+ guess <<= 1;
+ continue;
}
- else
+ else
{
- jumpto(target-delta);
+ jumpto(target-delta);
}
@@ -2295,4 +2650,5 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
unsigned int lcn = _lcn;
+ bDoUpdates = false;
ResetScroll();
- if (m_lastfile == newfile)
+ if (m_lastfile == newfile && lcn == 0)
{
@@ -2318,4 +2674,2 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
qDebug("buffdoc.openfile done");
- locate(lcn);
- qDebug("buffdoc.locate done");
}
@@ -2323,2 +2677,4 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn)
qDebug("Updated");
+ bDoUpdates = true;
+ locate(lcn);
return bRC;
@@ -2360,2 +2716,3 @@ void QTReader::lineDown()
mylastpos = locate();
+ m_outofdate = true;
update();
@@ -2574,12 +2931,17 @@ MarkupType QTReader::PreferredMarkup()
}
-#ifdef DOUBLEBUFFER
+
void QTReader::resizeEvent( QResizeEvent * p )
{
- if (m_rotated)
- {
- dbuff->resize(p->size().height(),p->size().width());
- }
- else
+ qDebug("Resizing");
+ m_outofdate = true;
+ if (dbuff != NULL)
{
- dbuff->resize(p->size());
+ if (m_rotated)
+ {
+ dbuff->resize(p->size().height(),p->size().width());
+ }
+ else
+ {
+ dbuff->resize(p->size());
+ }
}
@@ -2607,10 +2969,10 @@ void QTReader::resizeEvent( QResizeEvent * p )
m_right_border = (w*m_absright_border+500)/1000;
-
- qDebug("Top margin:%u", m_topmargin );
- qDebug("Bottom margin:%u", m_bottommargin );
- qDebug("Left margin:%u", m_left_border );
- qDebug("Right margin:%u", m_right_border );
}
+ if (dbuff != NULL && buffdoc.empty())
+ {
+ dbp->begin(dbuff);
+ drawBackground(dbp);
+ dbp->end();
+ }
}
-#endif
@@ -2618,14 +2980,8 @@ void QTReader::setrotated(bool sfs)
{
+ qDebug("Rotating");
m_rotated = sfs;
-#ifdef DOUBLEBUFFER
- if (m_rotated)
- {
- dbuff->resize(height(), width());
- }
- else
- {
- dbuff->resize(width(), height());
- }
+ setDoubleBuffer(m_doubleBuffered);
m_bgIsScaled = false;
-#endif
+ m_outofdate = true;
+ /*
int h, w;
@@ -2650,13 +3006,27 @@ void QTReader::setrotated(bool sfs)
qDebug("Right margin:%u", m_right_border );
+ */
}
-void QTReader::drawBackground()
+void QTReader::drawBackground(QPainter *p)
{
- dbp->begin(dbuff);
- // dbp->setBackgroundMode(OpaqueMode);
- dbp->setBackgroundColor(m_bg);
- dbp->eraseRect(dbuff->rect());
+ // p->setBackgroundMode(OpaqueMode);
+ p->setBackgroundColor(m_bg);
+ if (dbuff != NULL)
+ {
+ p->eraseRect(dbuff->rect());
+ }
+ else
+ {
+ if (m_rotated)
+ {
+ p->eraseRect(0,0,height(),width());
+ }
+ else
+ {
+ p->eraseRect(rect());
+ }
+ }
if (!m_bgpm.isNull())
{
- // dbp->setBackgroundMode(TransparentMode);
+ // p->setBackgroundMode(TransparentMode);
switch (m_bgtype)
@@ -2665,5 +3035,12 @@ void QTReader::drawBackground()
{
- int w = (dbuff->rect().width()-m_bgpm.width())/2;
- int h = (dbuff->rect().height()-m_bgpm.height())/2;
- dbp->drawPixmap(w,h,m_bgpm);
+ if (dbuff == NULL)
+ {
+ p->drawPixmap(width(),height(),m_bgpm);
+ }
+ else
+ {
+ int w = (dbuff->rect().width()-m_bgpm.width())/2;
+ int h = (dbuff->rect().height()-m_bgpm.height())/2;
+ p->drawPixmap(w,h,m_bgpm);
+ }
}
@@ -2672,12 +3049,10 @@ void QTReader::drawBackground()
{
- dbp->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm);
- /*
- for (int h = 0; h < dbuff->rect().height(); h += m_bgpm.height())
+ if (dbuff == NULL)
{
- for (int w = 0; w < dbuff->rect().width(); w += m_bgpm.width())
- {
- dbp->drawPixmap(w,h,m_bgpm);
- }
+ p->drawTiledPixmap(0,0,width(),height(),m_bgpm);
+ }
+ else
+ {
+ p->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm);
}
- */
}
@@ -2690,5 +3065,12 @@ void QTReader::drawBackground()
QImage im = m_bgpm.convertToImage();
- m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height()));
+ if (dbuff == NULL)
+ {
+ m_bgpm.convertFromImage(im.smoothScale(width(),height()));
+ }
+ else
+ {
+ m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height()));
+ }
}
- dbp->drawPixmap(0,0,m_bgpm);
+ p->drawPixmap(0,0,m_bgpm);
}
@@ -2698,3 +3080,3 @@ void QTReader::drawBackground()
}
- // dbp->setBackgroundMode(OpaqueMode);
+ // p->setBackgroundMode(OpaqueMode);
}
@@ -2761,3 +3143,8 @@ QString QTReader::about()
{
- return QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka";
+ QString ab = QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka";
+ if (m_output != NULL)
+ {
+ ab += QString("\n") + m_output->about();
+ }
+ return ab;
}
@@ -2899,3 +3286,3 @@ void QTReader::gotoLink()
{
- if (!buffdoc.getFile(href))
+ if (!buffdoc.getFile(href, nm))
{
@@ -2907,2 +3294,3 @@ void QTReader::gotoLink()
fillbuffer();
+ m_outofdate = true;
update();
@@ -2915,3 +3303,5 @@ void QTReader::gotoLink()
{
+ buffdoc.resetPos();
fillbuffer();
+ m_outofdate = true;
update();
@@ -2932,2 +3322,3 @@ void QTReader::gotoLink()
fillbuffer();
+ m_outofdate = true;
update();
@@ -2951,5 +3342,5 @@ void QTReader::gotoLink()
emit OnURLSelected(href, tgt);
+ refresh();
}
}
- locate(pagelocate());
}
@@ -2962,2 +3353,3 @@ void QTReader::refresh(bool full)
{
+ qDebug("Refreshing");
int h, w;
@@ -2983,3 +3375,118 @@ void QTReader::refresh(bool full)
if (full && m_highlightfilter) m_highlightfilter->refresh(pagelocate());
+ m_outofdate = true;
locate(pagelocate());
}
+
+#include "striphtml.h"
+
+CFilterChain* QTReader::getfilter()
+{
+ CFilterChain * filt = new CFilterChain(getencoding());
+ if (bstripcr) filt->addfilter(new stripcr);
+
+ if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt);
+ if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter);
+ // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile));
+
+#ifdef __STATIC
+ if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile));
+ if (bautofmt && (PreferredMarkup() == cCHM))
+ {
+ striphtml* f = new striphtml(m_lastfile);
+ f->setchm(true);
+ filt->addfilter(f);
+ }
+#else
+ if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile));
+ if (bautofmt && (PreferredMarkup() == cCHM))
+ {
+ ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile);
+ ((striphtml*)f->filter())->setchm(true);
+ filt->addfilter(f);
+ }
+#endif
+ m_highlightfilter = new HighlightFilter(this);
+ filt->addfilter(m_highlightfilter);
+
+ if (bdehyphen) filt->addfilter(new dehyphen);
+ if (bunindent) filt->addfilter(new unindent);
+ if (brepara) filt->addfilter(new repara(m_reparastring));
+ if (bonespace) filt->addfilter(new OnePara);
+ if (bindenter) filt->addfilter(new indenter(bindenter));
+ if (bdblspce) filt->addfilter(new dblspce);
+ if (bdepluck) filt->addfilter(new DePluck(pluckernextpart));
+ if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart));
+ if (brepalm) filt->addfilter(new repalm);
+ if (bunderlineLink) filt->addfilter(new underlineLink);
+ if (bkern) filt->addfilter(new kern);
+ if (bremap) filt->addfilter(new remap);
+ if (bmakebold) filt->addfilter(new embolden);
+ if (bfulljust) filt->addfilter(new FullJust);
+ int r,g,b;
+ m_default_bg.rgb(&r, &g, &b);
+ if (r != 255 || g != 255 || b != 255)
+ filt->addfilter(new setbg(r,g,b));
+ m_default_fg.rgb(&r, &g, &b);
+ if (r != 0 || g != 0 || b != 0)
+ filt->addfilter(new setfg(r,g,b));
+ // if (bNegative) filt->addfilter(new makeNegative);
+ if (bInverse) filt->addfilter(new makeInverse);
+ if (bNoInlineTables) filt->addfilter(new tableLink);
+ return filt;
+}
+
+void QTReader::readAloud()
+{
+#ifdef __STATIC
+ return;
+#else
+ CBuffer para;
+ jumpto(pagelocate());
+ while (m_autoScroll && (buffdoc.getpara(para) != -1))
+ {
+ if (para.length() > 0)
+ {
+ unsigned long lastpos = buffdoc.explocate();
+ while (lastpos > mylastpos)
+ {
+ dopagedn();
+ qApp->processEvents();
+ }
+ jumpto(lastpos);
+ QString txt = toQString(para.data());
+
+ doOutput(txt);
+ }
+ qApp->processEvents();
+ }
+#endif
+}
+
+bool QTReader::doOutput(const QString& wrd)
+{
+ if (m_output != NULL)
+ {
+ m_output->output(wrd);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool QTReader::checkoutput()
+{
+ if (m_output == NULL)
+ {
+ m_output = new outputcodec(m_outputName);
+ if (reinterpret_cast<outputcodec*>(m_output)->getStatus() != 0)
+ {
+ delete m_output;
+ m_output = NULL;
+ QMessageBox::warning(this, PROGNAME, QString("Couldn't find output codec\n")+m_outputName);
+ return false;
+ }
+ }
+ return true;
+}
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;
#include "BGType.h"
-#include "striphtml.h"
-#define ROTATION_ENABLED
#define SPECIALSCROLL
-#define DOUBLEBUFFER
-#ifdef DOUBLEBUFFER
+
class QPainter;
-#endif
+class COutput;
class CStyle;
+#define USETIMER
@@ -35,6 +33,11 @@ class QTReader : public QWidget
friend class QTReaderApp;
-#ifdef DOUBLEBUFFER
+#ifdef USETIMER
+ QTimer* m_dragtimer;
+ unsigned long m_dragtarget;
+#endif
+ COutput* m_output;
+ bool checkoutput();
+ bool m_outofdate, m_drageligible;
QPixmap *dbuff;
QPainter* dbp;
-#endif
void drawSingleLine(int lineno);
@@ -76,7 +79,5 @@ class QTReader : public QWidget
bool m_autoScroll, m_swapmouse;
- void drawBackground();
-#ifdef ROTATION_ENABLED
+ void drawBackground(QPainter*);
bool m_rotated;
void setrotated(bool);
-#endif
void autoscroll();
@@ -97,2 +98,3 @@ class QTReader : public QWidget
unsigned char getBaseSize() { return m_fontControl.getBaseSize(); }
+ QString m_outputName;
#ifdef _SCROLLPIPE
@@ -108,2 +110,3 @@ public:
QString about();
+ void readAloud();
CList<Bkmk>* Bkmklist() { return pBkmklist; }
@@ -155,3 +158,3 @@ public:
void clear() {};
- void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); };
+ void setText(const QString& n, const QString& s, unsigned int lcn = 0) { m_string = n; load_file((const char*)s, lcn); };
/*
@@ -227,56 +230,8 @@ public:
HighlightFilter* m_highlightfilter;
- CFilterChain* getfilter()
- {
- CFilterChain * filt = new CFilterChain(getencoding());
- if (bstripcr) filt->addfilter(new stripcr);
-
- if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt);
- if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter);
- // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile));
-
-#ifdef __STATIC
- if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile));
- if (bautofmt && (PreferredMarkup() == cCHM))
- {
- filt->addfilter(new striphtml(m_lastfile));
- }
-#else
- if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile));
- if (bautofmt && (PreferredMarkup() == cCHM))
- {
- ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile);
- ((striphtml*)f->filter())->setchm(true);
- filt->addfilter(f);
- }
-#endif
- m_highlightfilter = new HighlightFilter(this);
- filt->addfilter(m_highlightfilter);
-
- if (bdehyphen) filt->addfilter(new dehyphen);
- if (bunindent) filt->addfilter(new unindent);
- if (brepara) filt->addfilter(new repara(m_reparastring));
- if (bonespace) filt->addfilter(new OnePara);
- if (bindenter) filt->addfilter(new indenter(bindenter));
- if (bdblspce) filt->addfilter(new dblspce);
- if (bdepluck) filt->addfilter(new DePluck(pluckernextpart));
- if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart));
- if (brepalm) filt->addfilter(new repalm);
- if (bkern) filt->addfilter(new kern);
- if (bremap) filt->addfilter(new remap);
- if (bmakebold) filt->addfilter(new embolden);
- if (bfulljust) filt->addfilter(new FullJust);
- int r,g,b;
- m_default_bg.rgb(&r, &g, &b);
- if (r != 255 || g != 255 || b != 255)
- filt->addfilter(new setbg(r,g,b));
- m_default_fg.rgb(&r, &g, &b);
- if (r != 0 || g != 0 || b != 0)
- filt->addfilter(new setfg(r,g,b));
- // if (bNegative) filt->addfilter(new makeNegative);
- if (bInverse) filt->addfilter(new makeInverse);
- return filt;
- }
-
+ CFilterChain* getfilter();
private slots:
+#ifdef USETIMER
+ void actionDrag();
+#endif
void dopageup();
@@ -290,5 +245,5 @@ private slots:
void paintEvent( QPaintEvent * );
-#ifdef DOUBLEBUFFER
+
void resizeEvent( QResizeEvent * p );
-#endif
+
void keyPressEvent(QKeyEvent*);
@@ -302,2 +257,3 @@ private slots:
void init();
+ void mouseMoveEvent( QMouseEvent* );
void mousePressEvent( QMouseEvent* );
@@ -307,2 +263,5 @@ private slots:
void setfont();
+ bool m_doubleBuffered;
+
+ void setDoubleBuffer(bool _b);
//myoutput stuff
@@ -313,3 +272,3 @@ private slots:
bool mouseUpOn;
- 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*&);
+ 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&);
bool m_twotouch, m_touchone;
@@ -324,4 +283,4 @@ private slots:
// bool m_showlast;
- bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse;
- bool bkern, brepalm;
+ bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse, bNoInlineTables;
+ bool bkern, brepalm, bunderlineLink;
bool m_bpagemode, m_bMonoSpaced, m_continuousDocument;
@@ -332,2 +291,3 @@ private slots:
public:
+ bool doOutput(const QString& wrd);
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 @@
**********************************************************************/
+
#include <qregexp.h>
@@ -68,2 +69,3 @@
#include <qfontdatabase.h>
+
#ifdef USEQPE
@@ -71,3 +73,4 @@
#ifdef OPIE
-//#include <qpe/applnk.h>
+#if defined(OPIEFILEDIALOG)
+#include <qpe/applnk.h>
#include <opie2/ofiledialog.h>
@@ -78,2 +81,5 @@ using namespace Opie::Ui;
#else
+#include "fileBrowser.h"
+#endif
+#else
#include "qfiledialog.h"
@@ -90,3 +96,3 @@ using namespace Opie::Ui;
-bool CheckVersion(int&, int&, char&);
+bool CheckVersion(int&, int&, char&, QWidget*);
@@ -155,7 +161,5 @@ void QTReaderApp::listBkmkFiles()
QFileInfo *fi; // pointer for traversing
-
while ( (fi=it.current()) ) { // for each file...
- bkmkselector->insertItem(fi->fileName());
- cnt++;
+ bkmkselector->insertItem(fi->fileName(), cnt++);
@@ -179,4 +183,3 @@ void QTReaderApp::listBkmkFiles()
{
- bkmkselector->insertItem(de->d_name);
- cnt++;
+ bkmkselector->insertItem(de->d_name, cnt++);
}
@@ -204,3 +207,3 @@ void QTReaderApp::hidetoolbars()
-#ifdef USEQPE
+#if defined(USEQPE)
menubar->hide();
@@ -335,3 +338,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
-#ifdef USEQPE
+#if defined(USEQPE)
menubar = new QToolBar("Menus", this, m_tbposition);
@@ -342,3 +345,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
-#ifdef USEQPE
+#if defined(USEQPE)
QPopupMenu* tmp = new QPopupMenu(mb);
@@ -438,2 +441,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
config.setGroup( "View" );
+#if defined(USEQPE) && defined(USENEWFULLSCREEN)
+ m_usenewfullscreen = config.readBoolEntry("NewFullScreen", false);
+#endif
m_debounce = config.readNumEntry("Debounce", 0);
@@ -458,2 +464,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
+ reader->bNoInlineTables = config.readBoolEntry( "NoInlineTables", false );
reader->bpeanut = config.readBoolEntry( "Peanut", false );
@@ -473,2 +480,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1);
+ reader->m_outputName = config.readEntry( "OutputCodec", "");
+
@@ -502,4 +511,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
m_scrollishidden = config.readBoolEntry( "HideScrollBar", false );
+ m_hidebars = config.readBoolEntry( "HideToolBar", false );
reader->brepalm = config.readBoolEntry( "Repalm", false );
+ reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", true );
reader->bkern = config.readBoolEntry( "Kern", false );
@@ -508,2 +519,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
reader->setContinuous(config.readBoolEntry( "Continuous", true ));
+ reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", true));
m_targetapp = config.readEntry( "TargetApp", QString::null );
@@ -518,2 +530,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
m_doClipboard = config.readBoolEntry( "Clipboard", false);
+ m_doOutput = config.readBoolEntry( "OutputTgt", false);
/*
@@ -844,2 +857,14 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
addtoolbars(&config);
+ if (m_hidebars)
+ {
+#if defined(USEQPE)
+ menubar->hide();
+#endif
+ if (fileBar != NULL) fileBar->hide();
+ if (viewBar != NULL) viewBar->hide();
+ if (navBar != NULL) navBar->hide();
+ if (markBar != NULL) markBar->hide();
+ mb->hide();
+ }
+
@@ -974,2 +999,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
if (m_statusishidden) m_prog->hide();
+ showEditTools();
if (!reader->m_lastfile.isEmpty())
@@ -1034,4 +1060,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
}
- reader->bDoUpdates = true;
- reader->update();
+ // reader->bDoUpdates = true;
+ // reader->update();
config.setGroup("Version");
@@ -1040,3 +1066,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
char minor = config.readNumEntry("Minor", 0);
- if (CheckVersion(major, bkmktype, minor))
+ if (CheckVersion(major, bkmktype, minor, this))
{
@@ -1067,3 +1093,3 @@ void QTReaderApp::addtoolbars(Config* config)
{
-#ifdef USEQPE
+#if defined(USEQPE)
if (fileBar != menubar)
@@ -1095,3 +1121,3 @@ void QTReaderApp::addtoolbars(Config* config)
{
-#ifdef USEQPE
+#if defined(USEQPE)
if ((navBar == fileBar) && (fileBar == menubar))
@@ -1134,3 +1160,3 @@ void QTReaderApp::addtoolbars(Config* config)
{
-#ifdef USEQPE
+#if defined(USEQPE)
if ((viewBar == fileBar) && (fileBar == menubar))
@@ -1166,3 +1192,3 @@ void QTReaderApp::addtoolbars(Config* config)
{
-#ifdef USEQPE
+#if defined(USEQPE)
if ((markBar == fileBar) && (fileBar == menubar))
@@ -1235,3 +1261,3 @@ QToolBar* QTReaderApp::filebar()
{
-#ifdef USEQPE
+#if defined(USEQPE)
case cesSingle:
@@ -1719,3 +1745,2 @@ void QTReaderApp::setrotated(bool sfs)
// reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border);
- reader->repaint();
}
@@ -1735,5 +1760,4 @@ void QTReaderApp::setrotated(bool sfs)
// reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height());
- reader->repaint();
}
- // reader->update();
+ reader->refresh();
}
@@ -1930,3 +1954,3 @@ void QTReaderApp::fileOpen2()
m_nBkmkAction = cOpenFile;
- if (listbkmk(pOpenlist, "Browse")) usebrowser = false;
+ if (listbkmk(pOpenlist, "Browse", true)) usebrowser = false;
}
@@ -1953,3 +1977,3 @@ QString QTReaderApp::usefilebrowser()
QString fn;
-#ifdef OPIE
+#if defined(OPIE) && defined(OPIEFILEDIALOG)
QMap<QString, QStringList> mimeTypes;
@@ -2005,2 +2029,3 @@ void QTReaderApp::showprefs()
prefwin->repalm(reader->brepalm);
+ prefwin->UnderlineLink(reader->bunderlineLink);
prefwin->kern(reader->bkern);
@@ -2017,2 +2042,3 @@ void QTReaderApp::showprefs()
prefwin->StripCR(reader->bstripcr);
+ prefwin->InlineTables(!reader->bNoInlineTables);
prefwin->Dehyphen(reader->bdehyphen);
@@ -2058,2 +2084,3 @@ void QTReaderApp::showprefs()
prefwin->Continuous(reader->m_continuousDocument);
+ prefwin->DoubleBuffer(reader->m_doubleBuffered);
@@ -2072,2 +2099,3 @@ void QTReaderApp::showprefs()
prefwin->miscclipboard(m_doClipboard);
+ prefwin->miscoutput(m_doOutput);
@@ -2087,2 +2115,4 @@ void QTReaderApp::showprefs()
+ prefwin->outcodec(reader->m_outputName);
+
if (prefwin->exec())
@@ -2091,2 +2121,4 @@ void QTReaderApp::showprefs()
reader->brepalm = prefwin->repalm();
+ reader->bunderlineLink = prefwin->UnderlineLink();
+
reader->bkern = prefwin->kern();
@@ -2109,2 +2141,3 @@ void QTReaderApp::showprefs()
reader->bstripcr = prefwin->StripCR();
+ reader->bNoInlineTables = !prefwin->InlineTables();
reader->bdehyphen = prefwin->Dehyphen();
@@ -2151,2 +2184,3 @@ void QTReaderApp::showprefs()
reader->setContinuous(prefwin->Continuous());
+ reader->setDoubleBuffer(prefwin->DoubleBuffer());
@@ -2164,2 +2198,3 @@ void QTReaderApp::showprefs()
m_doClipboard = prefwin->miscclipboard();
+ m_doOutput = prefwin->miscoutput();
reader->m_swapmouse = prefwin->SwapMouse();
@@ -2185,2 +2220,11 @@ void QTReaderApp::showprefs()
}
+ qDebug("OutCodec:%s", (const char*)prefwin->outcodec());
+ if (reader->m_outputName != prefwin->outcodec())
+ {
+ if (reader->m_output != NULL)
+ {
+ QMessageBox::warning(this, PROGNAME, "Change of output codec\nrequires a restart");
+ }
+ reader->m_outputName = prefwin->outcodec();
+ }
delete prefwin;
@@ -2292,8 +2336,32 @@ void QTReaderApp::showinfo()
m_infoWin->setTextSize(ts);
- m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
+ if (fs > UINT_MAX/100)
+ {
+ unsigned long t1 = (ts+50)/100;
+ m_infoWin->setRatio(100-(fs + (t1 >> 1))/t1);
+ }
+ else
+ {
+ m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
+ }
m_infoWin->setLocation(pl);
- m_infoWin->setRead((100*pl + (ts >> 1))/ts);
+ if (pl > UINT_MAX/100)
+ {
+ unsigned long t1 = (ts+50)/100;
+ m_infoWin->setRead((pl + (t1 >> 1))/t1);
+ }
+ else
+ {
+ m_infoWin->setRead((100*pl + (ts >> 1))/ts);
+ }
m_infoWin->setDocSize(ds);
m_infoWin->setDocLocation(dl);
- m_infoWin->setDocRead((100*dl + (ds >> 1))/ds);
+ if (dl > UINT_MAX/100)
+ {
+ unsigned long d1 = (ds+50)/100;
+ m_infoWin->setDocRead((dl + (d1 >> 1))/d1);
+ }
+ else
+ {
+ m_infoWin->setDocRead((100*dl + (ds >> 1))/ds);
+ }
m_infoWin->setZoom(reader->m_fontControl.currentsize()*10);
@@ -2744,3 +2812,3 @@ void QTReaderApp::search()
-void QTReaderApp::openFile( const QString &f )
+void QTReaderApp::openFile( const QString &f, unsigned int loc )
{
@@ -2767,3 +2835,3 @@ void QTReaderApp::openFile( const QString &f )
clear();
- reader->setText(fm.baseName(), fm.absFilePath());
+ reader->setText(fm.baseName(), fm.absFilePath(), loc);
m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false);
@@ -2808,3 +2876,3 @@ void QTReaderApp::handlekey(QKeyEvent* e)
case Key_Escape:
-// qDebug("escape event");
+ qDebug("escape event");
if (m_disableesckey)
@@ -2893,16 +2961,13 @@ void QTReaderApp::handlekey(QKeyEvent* e)
-#ifdef NEWFULLSCREEN
-void QTReaderApp::enableFullscreen()
-{
- setFixedSize(qApp->desktop()->size());
- showNormal();
- reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
- showFullScreen();
-}
-
-void QTReaderApp::resizeEvent(QResizeEvent *)
+#if defined(USEQPE) && defined(USENEWFULLSCREEN)
+void QTReaderApp::focusInEvent(QFocusEvent *)
{
- if (m_fullscreen && (size() != qApp->desktop()->size()))
+ if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader))
{
- enableFullscreen();
+ m_usenewfullscreen = false;
+ reader->bDoUpdates = false;
+ showEditTools();
+ reader->bDoUpdates = true;
+ reader->update();
+ m_usenewfullscreen = true;
}
@@ -2910,8 +2975,12 @@ void QTReaderApp::resizeEvent(QResizeEvent *)
-void QTReaderApp::focusInEvent(QFocusEvent*)
+void QTReaderApp::resizeEvent(QResizeEvent *)
{
- if (m_fullscreen)
+ if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader))
{
- enableFullscreen();
- raise();
+ m_usenewfullscreen = false;
+ reader->bDoUpdates = false;
+ showEditTools();
+ reader->bDoUpdates = true;
+ reader->update();
+ m_usenewfullscreen = true;
}
@@ -2926,3 +2995,3 @@ void QTReaderApp::showEditTools()
{
-#ifdef USEQPE
+#if defined(USEQPE)
if (menubar != NULL) menubar->hide();
@@ -2946,8 +3015,4 @@ void QTReaderApp::showEditTools()
// showNormal();
-#ifdef NEWFULLSCREEN
- enableFullscreen();
-#else
showFullScreen();
-#endif
- }
+ }
else
@@ -2972,3 +3037,3 @@ void QTReaderApp::showEditTools()
{
-#ifdef USEQPE
+#if defined(USEQPE)
menubar->show();
@@ -3006,3 +3071,3 @@ void QTReaderApp::showEditTools()
// qDebug("sm");
-#ifdef USEQPE
+#if defined(USEQPE) && !defined(SIMPAD)
showMaximized();
@@ -3019,3 +3084,3 @@ void QTReaderApp::showEditTools()
// qDebug("ref");
- reader->refresh(true);
+ //reader->refresh(true);
// qDebug("done");
@@ -3176,3 +3241,3 @@ void QTReaderApp::do_delmark()
-bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
+bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel)
{
@@ -3184,2 +3249,3 @@ bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
int cnt = 0;
+ int slt = -1;
if (plist != NULL)
@@ -3188,9 +3254,17 @@ bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
{
+ if (presel)
+ {
+ Bkmk* p = i.pContent();
+ if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
+ {
+ slt = cnt;
+ }
+ }
#ifdef _UNICODE
// qDebug("Item:%s", (const char*)toQString(i->name()));
- bkmkselector->insertItem(toQString(i->name()));
+ bkmkselector->insertItem(toQString(i->name()), cnt++);
#else
- bkmkselector->insertItem(i->name());
+ bkmkselector->insertItem(i->name(), cnt++);
#endif
- cnt++;
+
}
@@ -3201,2 +3275,3 @@ bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
editorStack->raiseWidget( bkmkselector );
+ if (slt != -1) bkmkselector->setCurrentItem(slt);
return true;
@@ -3240,5 +3315,4 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
// qDebug("Opening");
- openFile(fn);
struct stat fnstat;
- stat((const char *)reader->m_lastfile, &fnstat);
+ stat((const char *)fn, &fnstat);
@@ -3250,2 +3324,4 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
bk->value(0);
+ reader->m_lastposn = 0;
+ openFile(fn);
}
@@ -3255,2 +3331,3 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
unsigned char* svdata = bk->filedata();
+ openFile(fn, bk->value());
reader->putSaveData(svdata, svlen);
@@ -3263,3 +3340,2 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk)
// showEditTools();
- reader->locate(bk->value());
}
@@ -3368,3 +3444,3 @@ void QTReaderApp::gotobkmk(int ind)
bool allok = false;
-#ifdef OPIE
+#if defined(OPIE) && defined(OPIEFILEDIALOG)
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)
int i = 0;
+ unsigned int llcn = reader->locate();
while (i >= 0)
{
- unsigned int lcn = reader->locate();
+ unsigned int lcn = llcn;
int pc = (100*lcn)/ts;
@@ -3724,2 +3801,10 @@ void QTReaderApp::do_autogen(const QString& regText)
pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn));
+ /*
+ llcn = reader->locate();
+ if ((i == 0) && (llcn+1 < ts))
+ {
+ reader->jumpto(++llcn);
+ i = 1;
+ }
+ */
}
@@ -4034,2 +4119,6 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2,
+ if (m_doOutput && reader->checkoutput())
+ {
+ reader->doOutput(wrd);
+ }
if (m_doClipboard)
@@ -4118,3 +4207,3 @@ void QTReaderApp::doAction(QKeyEvent* e)
{
-#ifdef USEQPE
+#if defined(USEQPE)
menubar->hide();
@@ -4129,3 +4218,3 @@ void QTReaderApp::doAction(QKeyEvent* e)
{
-#ifdef USEQPE
+#if defined(USEQPE)
menubar->show();
@@ -4342,2 +4431,3 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
config.writeEntry( "StripCr", reader->bstripcr );
+ config.writeEntry( "NoInlineTables", reader->bNoInlineTables );
config.writeEntry( "AutoFmt", reader->bautofmt );
@@ -4367,2 +4457,3 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
+ config.writeEntry( "OutputCodec", reader->m_outputName);
}
@@ -4398,2 +4489,3 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
config.writeEntry( "Clipboard", m_doClipboard);
+ config.writeEntry( "OutputTgt", m_doOutput);
/*
@@ -4412,3 +4504,5 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
config.writeEntry( "Repalm", reader->brepalm );
+ config.writeEntry( "UnderlineLink", reader->bunderlineLink );
config.writeEntry( "HideScrollBar", m_scrollishidden );
+ config.writeEntry( "HideToolBar", m_hidebars );
config.writeEntry( "Kern", reader->bkern );
@@ -4418,2 +4512,3 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
config.writeEntry( "Continuous", reader->m_continuousDocument );
+ config.writeEntry( "DoubleBuffer", reader->m_doubleBuffered);
config.writeEntry( "FullJust", reader->bfulljust );
@@ -4521,2 +4616,3 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr );
+ reader->bNoInlineTables = config.readBoolEntry( "NoInlineTables", reader->bNoInlineTables );
reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust );
@@ -4576,3 +4672,5 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden );
+ m_hidebars = config.readBoolEntry( "HideToolBar", m_hidebars );
reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm );
+ reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", reader->bunderlineLink );
reader->bkern = config.readBoolEntry( "Kern", reader->bkern );
@@ -4581,2 +4679,3 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument ));
+ reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", reader->m_doubleBuffered));
m_targetapp = config.readEntry( "TargetApp", m_targetapp );
@@ -4591,2 +4690,3 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard);
+ m_doOutput = config.readBoolEntry( "OutputTgt", m_doOutput);
#ifdef USEQPE
@@ -4597,2 +4697,4 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f
reader->setTwoTouch(m_twoTouch);
+
+ reader->m_outputName = config.readEntry( "OutputCodec", reader->m_outputName);
@@ -4639,4 +4741,3 @@ bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs)
- bkmkselector->insertItem(fi->fileName());
- cnt++;
+ bkmkselector->insertItem(fi->fileName(), cnt++);
@@ -4665,4 +4766,3 @@ bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs)
{
- bkmkselector->insertItem(de->d_name);
- cnt++;
+ bkmkselector->insertItem(de->d_name, cnt++);
}
@@ -4737,2 +4837,4 @@ void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt)
}
+ QString msg = "External URL\n" + href;
+ QMessageBox::information(this, PROGNAME, msg);
#else
@@ -4903,3 +5005,3 @@ void QTReaderApp::forceopen(const QString& filename)
*/
- if (!filename.isEmpty())
+ if (!filename.isEmpty() && QFileInfo(filename).exists())
{
@@ -4920,2 +5022,6 @@ void QTReaderApp::forceopen(const QString& filename)
}
+ else
+ {
+ OnURLSelected(filename, 0);
+ }
}
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
void suspend();
- void openFile( const QString & );
+ void openFile( const QString &, unsigned int loc = 0 );
@@ -188,6 +188,6 @@ class QTReaderApp : public QMainWindow
void closeEvent( QCloseEvent *e );
-#ifdef NEWFULLSCREEN
+#if defined(USEQPE) && defined(USENEWFULLSCREEN)
+ bool m_usenewfullscreen;
void resizeEvent(QResizeEvent *);
void focusInEvent(QFocusEvent*);
- void enableFullscreen();
#endif
@@ -210,2 +210,3 @@ class QTReaderApp : public QMainWindow
bool m_doDictionary;
+ bool m_doOutput;
bool m_doClipboard;
@@ -390,3 +391,3 @@ private slots:
QString m_targetapp, m_targetmsg, m_statusstring, m_themename;
- bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null);
+ bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null, bool presel=false);
QString usefilebrowser();
@@ -423,3 +424,3 @@ private slots:
// QPEToolBar /* *menu,*/ *fileBar;
-#ifdef USEQPE
+#if defined(USEQPE)
QToolBar *menubar;
@@ -427,3 +428,3 @@ private slots:
QToolBar *fileBar, *navBar, *viewBar, *markBar;
-#ifdef USEQPE
+#if defined(USEQPE)
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 @@
+#include <stdio.h>
+#include <string.h>
+#include <qimage.h>
+#include "decompress.h"
+#include "Reb.h"
+#include "my_list.h"
+#include "Bkmks.h"
+#include "Model.h"
+/*
+#ifdef offsetof
+#define OffsetOf(type, field) ((int) offsetof(type, field))
+#else
+#define OffsetOf(type, field) ((int) ((char *) &((type *) 0)->field))
+#endif
+
+template<class T>
+UInt32 binarychop(T* data, UInt32 n, T val)
+{
+ UInt32 jl = 0,jh = n-1,jm = (jl+jh)/2;
+ while (jh > jl+1)
+ {
+ if (data[jm] > val)
+ {
+ jh = jm;
+ }
+ else
+ {
+ jl = jm;
+ }
+ jm = (jl+jh)/2;
+ }
+ return jl;
+}
+
+template<class T, class D>
+UInt32 binarychop(D* data, UInt32 n, T val, UInt32 offset)
+{
+ UInt32 jl = 0,jh = n-1,jm = (jl+jh)/2;
+ while (jh > jl+1)
+ {
+ T* d = reinterpret_cast<T*>(reinterpret_cast<char*>(data+jm)+offset);
+ if (*d > val)
+ {
+ jh = jm;
+ }
+ else
+ {
+ jl = jm;
+ }
+ jm = (jl+jh)/2;
+ }
+ return jl;
+}
+*/
+
+CReb::CReb()
+:
+ fin(NULL), m_indexpages(NULL), m_pagedetails(NULL),tagoffset(0),
+ tags(NULL), paras(NULL), noparas(0), joins(NULL), nojoins(0)
+{
+}
+
+CReb::~CReb()
+{
+ if (fin != NULL) fclose(fin);
+ if (m_indexpages != NULL) delete [] m_indexpages;
+ if (m_pagedetails != NULL) delete [] m_pagedetails;
+ if (tags != NULL) delete [] tags;
+ if (paras != NULL) delete [] paras;
+ if (joins != NULL) delete [] joins;
+}
+
+unsigned int CReb::locate()
+{
+ return m_pagedetails[currentpage.pageno()].pagestart+currentpage.offset();
+}
+
+void CReb::locate(unsigned int n)
+{
+ /*
+ UInt32 cp = nopages-1;
+ for (int i = 0; i < nopages; ++i)
+ {
+ if (m_pagedetails[i].pagestart > n)
+ {
+ cp = i-1;
+ break;
+ }
+ }
+ qDebug("Requesting %u from page %u [%u]", n, cp, n - m_pagedetails[cp].pagestart);
+ */
+ //UInt32 jl = binarychop<UInt32, Page_detail>(m_pagedetails, nopages, n, OffsetOf(Page_detail, pagestart));
+
+ UInt32 jl = 0,jh = nopages-1,jm = (jl+jh)/2;
+ while (jh > jl+1)
+ {
+ if (m_pagedetails[jm].pagestart > n)
+ {
+ jh = jm;
+ }
+ else
+ {
+ jl = jm;
+ }
+ jm = (jl+jh)/2;
+ }
+
+ unsuspend();
+ Page_detail rs = m_pagedetails[jl];
+ UInt32 val = n - rs.pagestart;
+ if (jl != currentpage.pageno()) readindex(jl);
+ currentpage.setoffset(page2pos(jl), jl, ((rs.flags & 8) != 0), rs.len, val);
+ if (noparas > 0)
+ {
+ //jl = binarychop<int, ParaRef>(paras, noparas, val, OffsetOf(ParaRef, pos));
+
+ UInt32 jl = 0,jh = noparas-1,jm = (jl+jh)/2;
+ while (jh > jl+1)
+ {
+ if (paras[jm].pos > val)
+ {
+ jh = jm;
+ }
+ else
+ {
+ jl = jm;
+ }
+ jm = (jl+jh)/2;
+ }
+
+ qDebug("TAGS:%s", (const char*)tags[paras[jl].tag]);
+ tagstring = tags[paras[jl].tag]+"<br>"; // Add br to set extra space to 0
+ tagoffset = 0;
+ }
+ unsigned long current = locate();
+ if (m_currentstart > current || current > m_currentend)
+ {
+ start2endSection();
+ }
+ if (current != n) qDebug("ERROR:Ended up at %u", current);
+}
+
+bool CReb::getFile(const QString& href, const QString& nm)
+{
+ qDebug("File:%s, Name:%s", (const char*)href, (const char*)nm);
+ QMap<QString, UInt32>::Iterator iter = m_index.find(href);
+ if (iter != m_index.end())
+ {
+ qDebug("REB:BEFORE:%u", locate());
+ startpage(iter.data());
+ qDebug("REB:AFTER:%u", locate());
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+QImage* CReb::getPicture(const QString& ref)
+{
+ QMap<QString, UInt32>::Iterator iter = m_index.find(ref);
+ if (iter != m_index.end())
+ {
+ unsuspend();
+ Page_detail rs = m_pagedetails[iter.data()];
+ char* imgbuffer = new char[rs.len];
+ fseek(fin, page2pos(iter.data()), SEEK_SET);
+ fread(imgbuffer, rs.len, 1, fin);
+ QByteArray arr;
+ arr.assign((const char*)imgbuffer, rs.len);
+ QImage* qimage = new QImage(arr);
+ return qimage;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+CList<Bkmk>* CReb::getbkmklist() { return NULL; }
+
+void CReb::home()
+{
+ startpage(m_homepage);
+}
+
+int CReb::OpenFile(const char *src)
+{
+ m_binary = false;
+ if (fin != NULL) fclose(fin);
+ fin = fopen(src, "r");
+ if (fin == NULL)
+ {
+ return -1;
+ }
+ UInt32 type;
+ fseek(fin, 6, SEEK_SET);
+ fread(&type, 1, sizeof(type), fin);
+ qDebug("CREB:Okay %x", type);
+
+ if (type == 0x4f56554e || type == 0x574d4954 || type == 0x576d6954)
+ {
+ struct stat _stat;
+ stat(src, &_stat);
+ file_length = _stat.st_size;
+ fread(&m_blocksize, 1, sizeof(m_blocksize), fin);
+ if (type == 0x574d4954 || type == 0x576d6954)
+ {
+ if (type == 0x576d6954) m_binary = true;
+ qDebug("Blocksize(1) %x", m_blocksize);
+ unsigned char ct = (m_blocksize >> 24) & 0xff;
+ qDebug("Compress type:%x", ct);
+ switch (ct)
+ {
+ case 0:
+ m_decompress = UnZip;
+ break;
+ case 3:
+ m_decompress = getdecompressor("PluckerDecompress3");
+ break;
+ case 4:
+ m_decompress = getdecompressor("PluckerDecompress4");
+ break;
+ }
+ if (m_decompress == NULL) return -1;
+ m_blocksize = 1024*(m_blocksize & 0xffffff);
+ }
+ else
+ {
+ m_blocksize = 4096;
+ m_decompress = UnZip;
+ }
+ qDebug("Blocksize %u", m_blocksize);
+ currentpage.init(fin, m_blocksize, m_decompress);
+ qDebug("Its a REB!!!!");
+ fseek(fin, 0x18, SEEK_SET);
+ fread(&toc, 1, sizeof(toc), fin);
+ qDebug("Expect this to be 128 or 20:%x", toc);
+ fread(&type, 1, sizeof(type), fin);
+ qDebug("File length:%u", type);
+ fseek(fin, toc, SEEK_SET);
+ fread(&nopages, 1, sizeof(nopages), fin);
+ m_indexpages = new UInt32[nopages];
+ m_pagedetails = new Page_detail[nopages];
+ qDebug("There are %u pages", nopages);
+ UInt32 loc = 0;
+ UInt32 homeguess = nopages-1;
+ QString homeurl;
+ for (int i = 0; i < nopages; ++i)
+ {
+ char name[32];
+ UInt32 len, pos, flags;
+ fread(name, 1, 32, fin);
+ fread(&len, 1, 4, fin);
+ fread(&pos, 1, 4, fin);
+ fread(&flags, 1, 4, fin);
+ //qDebug("Page %u (%s) is %u bytes at %u (%u) of type %u", i, name, len, pos, loc, flags);
+ m_index[name] = i;
+ m_pagedetails[i] = Page_detail(loc, len, flags);
+
+ if (QString(name).find(".htm", 0, false) >= 0)
+ {
+ if (homeguess > i) homeguess = i;
+ if ((flags & 8) != 0)
+ {
+ UInt32 lastpos = ftell(fin);
+ loc += pagelength(i);
+ fseek(fin, lastpos, SEEK_SET);
+ }
+ else
+ {
+ loc += len;
+ }
+ }
+ if ((flags & 2) != 0)
+ {
+ UInt32 lastpos = ftell(fin);
+ RBPage* idx = new RBPage();
+ idx->init(fin, m_blocksize, m_decompress);
+ idx->startpage(page2pos(i), i, ((flags & 8) != 0), len);
+ int c = 0;
+ while (c != EOF)
+ {
+ QString s("");
+ while (1)
+ {
+ c = idx->getch(this);
+ if (c == 10 || c == EOF) break;
+ s += c;
+ }
+ if (s.left(5) == "BODY=")
+ {
+ homeurl = s.right(s.length()-5);
+ qDebug("Home:%s", (const char*)homeurl);
+ }
+ else
+ {
+ qDebug("Info:%s", (const char*)s);
+ }
+ }
+ delete idx;
+ fseek(fin, lastpos, SEEK_SET);
+ }
+ }
+ text_length = loc;
+ qDebug("Looking for homepage");
+ if (homeurl.isEmpty())
+ {
+ m_homepage = homeguess;
+ }
+ else
+ {
+ QMap<QString, UInt32>::Iterator iter = m_index.find(homeurl);
+ if (iter != m_index.end())
+ {
+ m_homepage = iter.data();
+ }
+ else
+ {
+ m_homepage = homeguess;
+ }
+ }
+ m_homepos = m_pagedetails[m_homepage].pagestart;
+ qDebug("Finding indices");
+ for (QMap<QString, UInt32>::Iterator iter = m_index.begin(); iter != m_index.end(); ++iter)
+ {
+ QString href = iter.key();
+ if (href.find(".htm", 0, false) >= 0)
+ {
+ QString hind = href.left(href.find(".htm", 0, false))+".hidx";
+ //qDebug("Index is %s", (const char*)hind);
+ QMap<QString, UInt32>::Iterator iter2 = m_index.find(hind);
+ if (iter2 != m_index.end())
+ {
+ m_indexpages[iter.data()] = iter2.data();
+ }
+ }
+ }
+ qDebug("Going home");
+ home();
+ return 0;
+ }
+ else
+ {
+ char * tmp = (char*)(&type);
+ for (int i = 0; i < 4; ++i) qDebug("%d:%c", i, tmp[i]);
+ return -1;
+ }
+}
+
+UInt32 CReb::page2pos(UInt32 page)
+{
+ fseek(fin, toc+40+44*page, SEEK_SET);
+ UInt32 pos;
+ fread(&pos, 1, 4, fin);
+ return pos;
+}
+
+UInt32 CReb::pagelength(UInt32 pagenum)
+{
+ fseek(fin, toc+40+44*pagenum, SEEK_SET);
+ UInt32 pos;
+ fread(&pos, 1, 4, fin);
+ fseek(fin, pos+4, SEEK_SET);
+ UInt32 len;
+ fread(&len, 1, sizeof(len), fin);
+ return len;
+}
+
+void CReb::readindex(UInt32 cp)
+{
+ if (joins != NULL)
+ {
+ delete [] joins;
+ joins = NULL;
+ }
+ if (tags != NULL)
+ {
+ delete [] tags;
+ tags = NULL;
+ }
+ if (paras != NULL)
+ {
+ delete [] paras;
+ paras = NULL;
+ }
+ noparas = 0;
+ nojoins = 0;
+ names.clear();
+
+ UInt32 rspage = m_indexpages[cp];
+ if (rspage != 0)
+ {
+ Page_detail rs = m_pagedetails[rspage];
+ int count = 0;
+ RBPage* idx = new RBPage();
+ idx->init(fin, m_blocksize, m_decompress);
+ idx->startpage(page2pos(rspage), rspage, ((rs.flags & 8) != 0), rs.len);
+ int c = 0;
+ int phase = 0;
+ int i;
+ if (m_binary)
+ {
+ count = idx->getuint(this);
+ qDebug("tag count:%d", count);
+ tags = new QString[count];
+ for (int i = 0; i < count; ++i)
+ {
+ QString s;
+ while (1)
+ {
+ c = idx->getch(this);
+ if (c == 0 || c == EOF) break;
+ s += c;
+ }
+ unsigned short val = idx->getuint(this);
+ if (val != 0xffff)
+ {
+ tags[i] = tags[val]+s;
+ }
+ else
+ {
+ tags[i] = s;
+ }
+ //qDebug("tags[%d](%d) = %s", i, val, (const char*)tags[i]);
+ }
+ noparas = idx->getint(this);
+ qDebug("Para count %d", noparas);
+ paras = new ParaRef[noparas];
+ for (int i = 0; i < noparas; ++i)
+ {
+ paras[i] = ParaRef(idx->getint(this), idx->getuint(this));
+ }
+ count = idx->getint(this);
+ qDebug("Name count %d", count);
+ for (int i = 0; i < count; ++i)
+ {
+ QString s;
+ while (1)
+ {
+ c = idx->getch(this);
+ if (c == 0 || c == EOF) break;
+ s += c;
+ }
+ int val = idx->getint(this);
+ names[s.mid(1,s.length()-2)] = val;
+ qDebug("names[%s] = %d", (const char*)s, val);
+ }
+ count = idx->getint(this);
+ qDebug("Join count %d", count);
+ if (count > 0)
+ {
+ nojoins = count+2;
+ joins = new UInt32[count+2];
+ joins[0] = 0;
+ joins[count+1] = currentpage.length();
+ for (int i = 1; i < count+1; ++i)
+ {
+ joins[i] = idx->getint(this);
+ }
+ }
+ }
+ else
+ {
+ while (c != EOF)
+ {
+ QString s("");
+ while (1)
+ {
+ c = idx->getch(this);
+ if (c == 10 || c == EOF) break;
+ s += c;
+ }
+ //qDebug("%s", (const char*)s);
+ if (count > 0)
+ {
+ --count;
+ int sp = s.findRev(' ');
+ QString l = s.left(sp);
+ int val = s.right(s.length()-sp).toInt();
+ switch (phase)
+ {
+ case 4:
+ //qDebug("Join %d is at offset %d", i, val);
+ joins[i++] = val;
+ break;
+ case 3:
+ //qDebug("Name %s is at offset %d", (const char*)l.mid(1,l.length()-2), val+m_pagedetails[cp].pagestart);
+ names[l.mid(1,l.length()-2)] = val;
+ break;
+ case 1:
+ //qDebug("%s:%d [%d]", (const char*)l, val, i);
+ if (val >= 0)
+ {
+ tags[i++] = tags[val]+l;
+ }
+ else
+ {
+ tags[i++] = l;
+ }
+ //qDebug("TAG:%s", (const char*)tags[i-1]);
+ break;
+ case 2:
+ paras[i++] = ParaRef(QString(l).toInt(), val);
+ //qDebug("Para:%u - %u (%s)", QString(l).toInt(), val, (const char*)s);
+ break;
+ default:
+ qDebug("%s:%d", (const char*)l, val);
+ break;
+ }
+ }
+ else
+ {
+ QString key = "[tags ";
+ if (s.left(key.length()) == key)
+ {
+ phase = 1;
+ i = 0;
+ count = s.mid(key.length(),s.length()-key.length()-1).toInt();
+ qDebug("%s:%s:%d", (const char*)key, (const char*)s, count);
+ tags = new QString[count];
+ }
+ key = "[paragraphs ";
+ if (s.left(key.length()) == key)
+ {
+ phase = 2;
+ i = 0;
+ count = s.mid(key.length(),s.length()-key.length()-1).toInt();
+ qDebug("%s:%s:%d", (const char*)key, (const char*)s, count);
+ paras = new ParaRef[count];
+ noparas = count;
+ }
+ key = "[names ";
+ if (s.left(key.length()) == key)
+ {
+ phase = 3;
+ count = s.mid(key.length(),s.length()-key.length()-1).toInt();
+ qDebug("%s:%s:%d", (const char*)key, (const char*)s, count);
+ }
+ key = "[joins ";
+ if (s.left(key.length()) == key)
+ {
+ phase = 4;
+ count = s.mid(key.length(),s.length()-key.length()-1).toInt();
+ qDebug("%s:%s:%d", (const char*)key, (const char*)s, count);
+ nojoins = count+2;
+ i = 1;
+ joins = new UInt32[count+2];
+ joins[0] = 0;
+ joins[count+1] = currentpage.length();
+ qDebug("%s:%s:%d", (const char*)key, (const char*)s, count);
+ }
+ qDebug("ZC:%s", (const char*)s);
+ }
+ }
+ }
+ // for (int i = 0; i < nojoins; ++i) qDebug("JOINS:%u %u", i, joins[i]);
+ delete idx;
+ }
+}
+
+bool CReb::findanchor(const QString& _info)
+{
+ QMap<QString, int>::Iterator iter = names.find(_info);
+ if (iter != names.end())
+ {
+ locate(iter.data()+m_pagedetails[currentpage.pageno()].pagestart);
+ return true;
+ }
+ return false;
+}
+
+#ifdef USEQPE
+void CReb::suspend()
+{
+ CExpander::suspend(fin);
+}
+void CReb::unsuspend()
+{
+ CExpander::unsuspend(fin);
+}
+#endif
+
+#ifndef __STATIC
+extern "C"
+{
+ CExpander* newcodec() { return new CReb; }
+}
+#endif
+
+void CReb::startpage(UInt32 pgno)
+{
+ Page_detail rs = m_pagedetails[pgno];
+ unsuspend();
+ readindex(pgno);
+ currentpage.startpage(page2pos(pgno), pgno, ((rs.flags & 8) != 0), rs.len);
+}
+
+void CReb::startpage(UInt32 _cp, bool _isCompressed, UInt32 _len)
+{
+ unsuspend();
+ readindex(_cp);
+ currentpage.startpage(page2pos(_cp), _cp, _isCompressed, _len);
+}
+
+void RBPage::initpage(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len)
+{
+ filepos = pos;
+ m_pageno = _cp;
+ m_Compressed = _isCompressed;
+ m_pagelen = _len;
+ currentchunk = 0;
+ pageoffset = 0;
+
+ if (chunklist != NULL) delete [] chunklist;
+
+ fseek(fin, filepos, SEEK_SET);
+ if (m_Compressed)
+ {
+ fread(&nochunks, 1, sizeof(nochunks), fin);
+ fread(&m_pagelen, 1, sizeof(m_pagelen), fin);
+ chunklist = new UInt32[nochunks];
+ fread(chunklist, nochunks, 4, fin);
+ }
+ else
+ {
+ chunklist = NULL;
+ nochunks = (_len+m_blocksize-1)/m_blocksize;
+ }
+ m_startoff = 0;
+ m_endoff = m_pagelen;
+ chunkpos = ftell(fin);
+ qDebug("Compressed:%u Expanded:%u", _len, m_pagelen);
+}
+
+void RBPage::startpage(UInt32 pos, UInt32 _cp, bool _isCompressed, UInt32 _len)
+{
+ initpage(pos, _cp, _isCompressed, _len);
+ readchunk();
+}
+
+int CReb::getch()
+{
+ if (tagoffset < tagstring.length())
+ return tagstring[tagoffset++].unicode();
+ else
+ return currentpage.getch(this);
+}
+
+int RBPage::getch(CReb* parent)
+{
+ if (chunkoffset >= chunklen)
+ {
+ if (++currentchunk >= nochunks)
+ {
+ --currentchunk;
+ return EOF;
+ }
+ pageoffset += chunklen;
+ parent->unsuspend();
+ readchunk();
+ }
+ if (offset() == m_endoff) return EOF;
+ return chunk[chunkoffset++];
+}
+
+unsigned short int RBPage::getuint(CReb* parent)
+{
+ unsigned short int ret = 0;
+ char *buffer = (char*)(&ret);
+ for (int i = 0; i < 2; ++i)
+ {
+ int ch = getch(parent);
+ if (ch == EOF) return 0;
+ buffer[i] = ch;
+ }
+ return ret;
+}
+
+int RBPage::getint(CReb* parent)
+{
+ int ret = 0;
+ char *buffer = (char*)(&ret);
+ for (int i = 0; i < 4; ++i)
+ {
+ int ch = getch(parent);
+ if (ch == EOF) return 0;
+ buffer[i] = ch;
+ }
+ return ret;
+}
+
+void RBPage::readchunk()
+{
+ if (m_Compressed)
+ {
+ chunkoffset = 0;
+ fseek(fin, chunkpos, SEEK_SET);
+ UInt8* inbuf = new UInt8[chunklist[currentchunk]];
+ fread(inbuf, 1, chunklist[currentchunk], fin);
+ chunklen = (*m_decompress)(inbuf, chunklist[currentchunk], chunk, m_blocksize);
+ delete [] inbuf;
+ chunkpos = ftell(fin);
+ }
+ else
+ {
+ chunkoffset = 0;
+ chunklen = m_blocksize;
+ if (m_blocksize*(currentchunk+1) > m_pagelen)
+ {
+ chunklen = m_pagelen - currentchunk*m_blocksize;
+ }
+ fseek(fin, chunkpos, SEEK_SET);
+ chunklen = fread(chunk, 1, chunklen, fin);
+ chunkpos = ftell(fin);
+ }
+}
+
+void RBPage::setoffset(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len, UInt32 _offset)
+{
+ if (m_pageno != _cp)
+ {
+ initpage(pos, _cp, _isCompressed, _len);
+ }
+ else
+ {
+ if (m_Compressed)
+ {
+ chunkpos = filepos + sizeof(nochunks) + sizeof(m_pagelen) + 4*nochunks;
+ }
+ else
+ {
+ chunkpos = filepos;
+ }
+ }
+
+ currentchunk = _offset/m_blocksize;
+ pageoffset = m_blocksize*currentchunk;
+ if (m_Compressed)
+ {
+ for (int i = 0; i < currentchunk; ++i)
+ {
+ chunkpos += chunklist[i];
+ }
+ }
+ else
+ {
+ chunkpos += pageoffset;
+ }
+ readchunk();
+ chunkoffset = _offset - pageoffset;
+}
+
+void CReb::start2endSection()
+{
+ if (m_pagedetails != NULL)
+ {
+ if (nojoins > 0)
+ {
+ //UInt32 jl = binarychop<UInt32>(joins, nojoins, currentpage.offset());
+
+ UInt32 jl = 0,jh = nojoins-1,jm = (jl+jh)/2;
+ while (jh > jl+1)
+ {
+ if (joins[jm] > currentpage.offset())
+ {
+ jh = jm;
+ }
+ else
+ {
+ jl = jm;
+ }
+ jm = (jl+jh)/2;
+ }
+
+ currentpage.m_startoff = joins[jl];
+ currentpage.m_endoff = joins[jl+1]-1;
+ //currentpage.m_endoff = joins[jh]-1;
+ }
+ m_currentstart = m_pagedetails[currentpage.pageno()].pagestart+currentpage.m_startoff;
+ m_currentend = m_pagedetails[currentpage.pageno()].pagestart+currentpage.m_endoff;
+ }
+ else
+ {
+ m_currentstart = m_currentend = 0;
+ }
+ qDebug("s2e:[%u, %u, %u]", m_currentstart, locate(), m_currentend);
+}
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 @@
+#ifndef __REB_H
+#define __REB_H
+#include <stdio.h>
+#include <zlib.h>
+#include <sys/stat.h>
+#ifdef USEQPE
+#include <qpe/global.h>
+#endif
+#include <qmap.h>
+
+#include "CExpander.h"
+#include <zlib.h>
+
+#ifdef _WINDOWS
+#include <winsock.h>
+#endif
+
+#include "mytypes.h"
+
+/*
+struct Reb_Segment
+{
+ UInt32 len, page, flags;
+ Reb_Segment(UInt32 _len = 0, UInt32 _page = 0, UInt32 _flags = 0)
+ :
+ len(_len), page(_page), flags(_flags)
+ {}
+};
+*/
+
+class CReb;
+
+class RBPage
+{
+ UInt32 filepos;
+ UInt32 pageoffset;
+ UInt32 nochunks, currentchunk, chunkpos, chunklen, chunkoffset;
+ UInt32 m_pagelen, m_blocksize;
+ bool m_Compressed;
+ void readchunk();
+ UInt32* chunklist;
+ UInt8* chunk;
+ FILE* fin;
+ UInt32 m_pageno;
+ void initpage(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len);
+ size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t);
+ public:
+ RBPage() : pageoffset(0), nochunks(0), currentchunk(0), chunkpos(0), chunkoffset(0), m_pagelen(0), m_Compressed(false), chunklist(NULL), chunk(NULL) {}
+ ~RBPage()
+ {
+ if (chunk != NULL) delete [] chunk;
+ if (chunklist != NULL) delete [] chunklist;
+ }
+ int getch(CReb*);
+ unsigned short int getuint(CReb*);
+ int getint(CReb*);
+ void startpage(UInt32, UInt32, bool, UInt32);
+ UInt32 pageno() { return m_pageno; }
+ UInt32 offset() { return pageoffset+chunkoffset; }
+ void setoffset(UInt32, size_t, bool, UInt32, UInt32);
+ void init(FILE* _f, UInt32 _bs, size_t (*_decompress)(UInt8*, size_t, UInt8*, size_t))
+ {
+ fin = _f;
+ m_blocksize = _bs;
+ chunk = new UInt8[m_blocksize];
+ m_decompress = _decompress;
+ }
+ UInt32 length() { return m_pagelen; }
+ UInt32 m_startoff, m_endoff;
+};
+
+struct Page_detail
+{
+ UInt32 pagestart, len, flags;
+ Page_detail(UInt32 _ps = 0, UInt32 _l = 0, UInt32 _f = 0)
+ :
+ pagestart(_ps), len(_l), flags(_f)
+ {
+ }
+};
+
+struct ParaRef
+{
+ int pos, tag;
+ ParaRef(int _pos = 0, int _tag = 0) : pos(_pos), tag(_tag)
+ {
+ //qDebug("New PARAREF:%d, %d", pos, tag);
+ }
+};
+
+class CReb : public CExpander
+{
+ //friend class RBPage;
+ size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t);
+ RBPage currentpage;
+ UInt32 nopages, m_homepage, m_blocksize;
+
+ QMap<QString, UInt32> m_index;
+
+ size_t file_length, text_length;
+ UInt32 toc;
+ FILE* fin;
+ void home();
+ void startpage(UInt32);
+ void startpage(UInt32, bool, UInt32);
+ void readchunk();
+ QString tagstring;
+ UInt32 tagoffset;
+ UInt32 pagelength(UInt32);
+ QImage* getPicture(const QString& ref);
+ UInt32 page2pos(UInt32);
+ //UInt32 m_pagelen;
+ UInt32* m_indexpages;
+ Page_detail* m_pagedetails;
+ // void UnZip(size_t bsize);
+ QMap<QString, int> names;
+ QString* tags;
+ ParaRef* paras;
+ UInt32* joins;
+ UInt32 nojoins;
+ UInt32 noparas;
+ bool m_binary;
+ void readindex(UInt32);
+public:
+ bool findanchor(const QString& _info);
+ QString about() { return QString("REB codec (c) Tim Wentford"); }
+ bool getFile(const QString& href, const QString& nm);
+ void start2endSection();
+ void sizes(unsigned long& _file, unsigned long& _text)
+ {
+ _file = file_length;
+ _text = text_length;
+ }
+ bool hasrandomaccess() { return true; }
+ virtual ~CReb();
+ CReb();
+ int OpenFile(const char *src);
+ int getch();
+ unsigned int locate();
+ void locate(unsigned int n);
+ CList<Bkmk>* getbkmklist();
+ MarkupType PreferredMarkup()
+ {
+ return cCHM;
+ }
+#ifdef USEQPE
+ void suspend();
+ void unsuspend();
+#else
+ void suspend() {}
+ void unsuspend() {}
+#endif
+};
+
+#endif
+
+
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 @@
+Makefile
+config.in
+moc_*
+.moc
+.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 @@
+DEFINES += OPIE USEQPE
+VPATH = ..
+TEMPLATE = lib
+CONFIG = qt warn_on release dll
+HEADERS = Reb.h
+
+SOURCES = Reb.cpp \
+ decompress.cpp
+
+
+INTERFACES =
+DESTDIR = $(OPIEDIR)/plugins/reader/codecs
+TARGET = Reb
+LIBS += -L$(OPIEDIR)/lib -lreader_codec
+
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+
+include( $(OPIEDIR)/include.pro )
+
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
m_AlignCentre,
- m_AlignJustify
+ m_AlignJustify,
+ m_AlignNone
};
@@ -48,2 +49,3 @@ class CBasicStyle
m_italic;
+ unsigned long m_table;
int m_fontsize;
@@ -66,2 +68,3 @@ class CBasicStyle
unset();
+ m_table = 0xffffffff;
}
@@ -148,2 +151,5 @@ class CStyle
void unset();
+ bool isTable() const { return (sty.m_table != 0xffffffff); }
+ void setTable(unsigned long _b) { sty.m_table = _b; }
+ unsigned long getTable() { return sty.m_table; }
bool isPicture() const { return (graphic != NULL); }
@@ -189,2 +195,6 @@ class CStyle
}
+ void setNoJustify()
+ {
+ sty.m_align = m_AlignNone;
+ }
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 @@
+/****************************************************************************
+ * This file is part of PPMd project *
+ * Written and distributed to public domain by Dmitry Shkarin 1997, *
+ * 1999-2001 *
+ * Contents: memory allocation routines *
+ ****************************************************************************/
+
+enum { UNIT_SIZE=12, N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4,
+ N_INDEXES=N1+N2+N3+N4 };
+
+#pragma pack(1)
+struct BLK_NODE {
+ DWORD Stamp;
+ BLK_NODE* next;
+ BOOL avail() const { return (next != NULL); }
+ void link(BLK_NODE* p) { p->next=next; next=p; }
+ void unlink() { next=next->next; }
+ void* remove() {
+ BLK_NODE* p=next; unlink();
+ Stamp--; return p;
+ }
+ inline void insert(void* pv,int NU);
+} BList[N_INDEXES];
+struct MEM_BLK: public BLK_NODE { DWORD NU; } _PACK_ATTR;
+#pragma pack()
+
+static BYTE Indx2Units[N_INDEXES], Units2Indx[128]; // constants
+static DWORD GlueCount, SubAllocatorSize=0;
+static BYTE* HeapStart, * pText, * UnitsStart, * LoUnit, * HiUnit;
+
+inline void PrefetchData(void* Addr)
+{
+#if defined(_USE_PREFETCHING)
+ BYTE PrefetchByte = *(volatile BYTE*) Addr;
+#endif /* defined(_USE_PREFETCHING) */
+}
+inline void BLK_NODE::insert(void* pv,int NU) {
+ MEM_BLK* p=(MEM_BLK*) pv; link(p);
+ p->Stamp=~0UL; p->NU=NU;
+ Stamp++;
+}
+inline UINT U2B(UINT NU) { return 8*NU+4*NU; }
+inline void SplitBlock(void* pv,UINT OldIndx,UINT NewIndx)
+{
+ UINT i, k, UDiff=Indx2Units[OldIndx]-Indx2Units[NewIndx];
+ BYTE* p=((BYTE*) pv)+U2B(Indx2Units[NewIndx]);
+ if (Indx2Units[i=Units2Indx[UDiff-1]] != UDiff) {
+ k=Indx2Units[--i]; BList[i].insert(p,k);
+ p += U2B(k); UDiff -= k;
+ }
+ BList[Units2Indx[UDiff-1]].insert(p,UDiff);
+}
+DWORD _STDCALL GetUsedMemory()
+{
+ DWORD i, RetVal=SubAllocatorSize-(HiUnit-LoUnit)-(UnitsStart-pText);
+ for (i=0;i < N_INDEXES;i++)
+ RetVal -= UNIT_SIZE*Indx2Units[i]*BList[i].Stamp;
+ return RetVal;
+}
+void _STDCALL StopSubAllocator() {
+ if ( SubAllocatorSize ) {
+ SubAllocatorSize=0; delete[] HeapStart;
+ }
+}
+BOOL _STDCALL StartSubAllocator(UINT SASize)
+{
+ DWORD t=SASize << 19U;
+ if (SubAllocatorSize == t) return TRUE;
+ StopSubAllocator();
+ if ((HeapStart=new BYTE[t]) == NULL) return FALSE;
+ SubAllocatorSize=t; return TRUE;
+}
+static inline void InitSubAllocator()
+{
+ memset(BList,0,sizeof(BList));
+ HiUnit=(pText=HeapStart)+SubAllocatorSize;
+ UINT Diff=UNIT_SIZE*(SubAllocatorSize/8/UNIT_SIZE*7);
+ LoUnit=UnitsStart=HiUnit-Diff; GlueCount=0;
+}
+static void GlueFreeBlocks()
+{
+ UINT i, k, sz;
+ MEM_BLK s0, * p, * p0, * p1;
+ if (LoUnit != HiUnit) *LoUnit=0;
+ for (i=0, (p0=&s0)->next=NULL;i < N_INDEXES;i++)
+ while ( BList[i].avail() ) {
+ p=(MEM_BLK*) BList[i].remove();
+ if ( !p->NU ) continue;
+ while ((p1=p+p->NU)->Stamp == ~0UL) {
+ p->NU += p1->NU; p1->NU=0;
+ }
+ p0->link(p); p0=p;
+ }
+ while ( s0.avail() ) {
+ p=(MEM_BLK*) s0.remove(); sz=p->NU;
+ if ( !sz ) continue;
+ for ( ;sz > 128;sz -= 128, p += 128)
+ BList[N_INDEXES-1].insert(p,128);
+ if (Indx2Units[i=Units2Indx[sz-1]] != sz) {
+ k=sz-Indx2Units[--i]; BList[k-1].insert(p+(sz-k),k);
+ }
+ BList[i].insert(p,Indx2Units[i]);
+ }
+ GlueCount=1 << 13;
+}
+static void* _STDCALL AllocUnitsRare(UINT indx)
+{
+ UINT i=indx;
+ if ( !GlueCount ) {
+ GlueFreeBlocks();
+ if ( BList[i].avail() ) return BList[i].remove();
+ }
+ do {
+ if (++i == N_INDEXES) {
+ GlueCount--; i=U2B(Indx2Units[indx]);
+ return (UnitsStart-pText > i)?(UnitsStart -= i):(NULL);
+ }
+ } while ( !BList[i].avail() );
+ void* RetVal=BList[i].remove(); SplitBlock(RetVal,i,indx);
+ return RetVal;
+}
+inline void* AllocUnits(UINT NU)
+{
+ UINT indx=Units2Indx[NU-1];
+ if ( BList[indx].avail() ) return BList[indx].remove();
+ void* RetVal=LoUnit; LoUnit += U2B(Indx2Units[indx]);
+ if (LoUnit <= HiUnit) return RetVal;
+ LoUnit -= U2B(Indx2Units[indx]); return AllocUnitsRare(indx);
+}
+inline void* AllocContext()
+{
+ if (HiUnit != LoUnit) return (HiUnit -= UNIT_SIZE);
+ else if ( BList->avail() ) return BList->remove();
+ else return AllocUnitsRare(0);
+}
+inline void UnitsCpy(void* Dest,void* Src,UINT NU)
+{
+ DWORD* p1=(DWORD*) Dest, * p2=(DWORD*) Src;
+ do {
+ p1[0]=p2[0]; p1[1]=p2[1];
+ p1[2]=p2[2];
+ p1 += 3; p2 += 3;
+ } while ( --NU );
+}
+inline void* ExpandUnits(void* OldPtr,UINT OldNU)
+{
+ UINT i0=Units2Indx[OldNU-1], i1=Units2Indx[OldNU-1+1];
+ if (i0 == i1) return OldPtr;
+ void* ptr=AllocUnits(OldNU+1);
+ if ( ptr ) {
+ UnitsCpy(ptr,OldPtr,OldNU); BList[i0].insert(OldPtr,OldNU);
+ }
+ return ptr;
+}
+inline void* ShrinkUnits(void* OldPtr,UINT OldNU,UINT NewNU)
+{
+ UINT i0=Units2Indx[OldNU-1], i1=Units2Indx[NewNU-1];
+ if (i0 == i1) return OldPtr;
+ if ( BList[i1].avail() ) {
+ void* ptr=BList[i1].remove(); UnitsCpy(ptr,OldPtr,NewNU);
+ BList[i0].insert(OldPtr,Indx2Units[i0]);
+ return ptr;
+ } else {
+ SplitBlock(OldPtr,i0,i1); return OldPtr;
+ }
+}
+inline void FreeUnits(void* ptr,UINT NU) {
+ UINT indx=Units2Indx[NU-1];
+ BList[indx].insert(ptr,Indx2Units[indx]);
+}
+inline void SpecialFreeUnit(void* ptr)
+{
+ if ((BYTE*) ptr != UnitsStart) BList->insert(ptr,1);
+ else { *(DWORD*) ptr=~0UL; UnitsStart += UNIT_SIZE; }
+}
+inline void* MoveUnitsUp(void* OldPtr,UINT NU)
+{
+ UINT indx=Units2Indx[NU-1];
+ if ((BYTE*) OldPtr > UnitsStart+16*1024 || (BLK_NODE*) OldPtr > BList[indx].next)
+ return OldPtr;
+ void* ptr=BList[indx].remove();
+ UnitsCpy(ptr,OldPtr,NU); NU=Indx2Units[indx];
+ if ((BYTE*) OldPtr != UnitsStart) BList[indx].insert(OldPtr,NU);
+ else UnitsStart += U2B(NU);
+ return ptr;
+}
+static inline void ExpandTextArea()
+{
+ BLK_NODE* p;
+ UINT Count[N_INDEXES]; memset(Count,0,sizeof(Count));
+ while ((p=(BLK_NODE*) UnitsStart)->Stamp == ~0UL) {
+ MEM_BLK* pm=(MEM_BLK*) p; UnitsStart=(BYTE*) (pm+pm->NU);
+ Count[Units2Indx[pm->NU-1]]++; pm->Stamp=0;
+ }
+ for (UINT i=0;i < N_INDEXES;i++)
+ for (p=BList+i;Count[i] != 0;p=p->next)
+ while ( !p->next->Stamp ) {
+ p->unlink(); BList[i].Stamp--;
+ if ( !--Count[i] ) break;
+ }
+}
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 @@
+#include "TableDialog.h"
+
+CTableDialog::CTableDialog(const QFont& f, const QString& tabtext, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true)
+{
+ setCaption("Table View");
+ QVBoxLayout *tmp = new QVBoxLayout(this);
+ QTextView* qtv = new QTextView(this);
+ qtv->setFont(f);
+ tmp->addWidget(qtv);
+ qtv->setText(tabtext);
+ if (fs) showMaximized();
+ else if (parent != NULL)
+ {
+ resize(parent->size());
+ move(parent->pos());
+ }
+}
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 @@
+#ifndef __TABLEDIALOG_H
+#define __TABLEDIALOG_H
+
+#include <qdialog.h>
+#include <qtextview.h>
+#include <qlayout.h>
+
+class CTableDialog : public QDialog
+{
+Q_OBJECT
+#ifndef USEQPE
+ void keyPressEvent(QKeyEvent* e)
+ {
+ switch (e->key())
+ {
+ case Key_Escape:
+ e->accept();
+ reject();
+ break;
+ case Key_Space:
+ case Key_Return:
+ e->accept();
+ accept();
+ break;
+ default:
+ QWidget::keyPressEvent(e);
+ }
+ }
+#endif
+ public:
+ CTableDialog(const QFont& f, const QString& tabtext, bool fs = true, QWidget* parent = 0, const char* name = 0);
+ ~CTableDialog() {}
+};
+#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 @@
#define CTOOLBARPREFS_H
+
#include <qvariant.h>
@@ -24,5 +25,3 @@
#endif
-//#ifdef OPIE
#define USECOMBO
-//#endif
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 @@
#include <sys/stat.h>
+#ifdef USEQPE
+#include <qpe/global.h>
+#endif
+
#include "CExpander.h"
@@ -33,3 +37,7 @@ public:
int delay = time(NULL) - sustime;
- if (delay < 10) sleep(10-delay);
+ if (delay < 10)
+ {
+ Global::statusMessage("Stalling");
+ sleep(10-delay);
+ }
}
@@ -37,6 +45,7 @@ public:
for (int i = 0; file == NULL && i < 5; i++)
- {
+ {
+ Global::statusMessage("Stalling");
sleep(5);
file = gzopen(fname, "rb");
- }
+ }
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 @@
+class ppm_expander;
+
class PPM_ReadBuf
@@ -14,10 +16,6 @@ class PPM_ReadBuf
FILE *my_file_in;
+ ppm_expander* parent;
public:
- PPM_ReadBuf(FILE* f) : my_file_in(f) {}
- UINT readbuf(UCHAR *buf,UINT len)
- {
- UINT len1;
- len1=fread(buf,1,len,my_file_in);
- return len1;
- }
+ PPM_ReadBuf(FILE* f, ppm_expander* _parent) : my_file_in(f), parent(_parent) {}
+ UINT readbuf(UCHAR *buf,UINT len);
};
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 @@
+#ifdef USENEF
+#include <qimage.h>
+#include "arrierego.h"
+
+struct CArriere_dataRecord
+{
+ UInt16 uid;
+ UInt16 nParagraphs;
+ UInt32 size;
+ UInt8 type;
+ UInt8 reserved;
+};
+
+int CArriere::HeaderSize()
+{
+ return 10;
+}
+
+void CArriere::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved)
+{
+ CArriere_dataRecord thishdr;
+ unsuspend();
+ fread(&thishdr, 1, HeaderSize(), fin);
+ uid = ntohs(thishdr.uid);
+ nParagraphs = ntohs(thishdr.nParagraphs);
+ size = ntohl(thishdr.size);
+ type = thishdr.type;
+ reserved = thishdr.reserved;
+ // qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", uid, nParagraphs, size, (unsigned int)type, (unsigned int)reserved);
+// for (int i = 0; i < sizeof(thishdr); i++)
+// printf("%d %x\n", i, (int)(((char *)(&thishdr))[i]));
+}
+
+bool CArriere::CorrectDecoder()
+{
+ char * type = (char*)(&(head.type));
+ for (int i = 0; i < 8; ++i) qDebug("%c", type[i]);
+ return (memcmp(&head.type, "ArriereG", 8) == 0);
+}
+
+int CArriere::bgetch()
+{
+ int ch = EOF;
+ if (bufferpos >= buffercontent)
+ {
+ if (bufferrec >= ntohs(head.recordList.numRecords) - 1)
+ {
+ return EOF;
+ }
+ if (isEndOfSection(bufferrec))
+ {
+ return EOF;
+ }
+ if (!expand(bufferrec+1))
+ {
+ return EOF;
+ }
+ mystyle.unset();
+ if (m_ParaOffsets[m_nextParaIndex] == 0)
+ {
+ while (m_ParaOffsets[m_nextParaIndex+1] == 0)
+ {
+ m_nextParaIndex++;
+ }
+ }
+ mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2);
+ }
+ if (bufferpos == m_nextPara)
+ {
+ while (bufferpos == m_nextPara)
+ {
+ m_nextParaIndex++;
+ if (m_nextParaIndex == m_nParas)
+ {
+ m_nextPara = -1;
+ }
+ else
+ {
+ m_nextPara += m_ParaOffsets[m_nextParaIndex];
+ }
+ }
+ mystyle.unset();
+ mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2);
+ if (m_lastBreak == locate())
+ {
+ currentpos++;
+ ch = expandedtextbuffer[bufferpos++];
+ }
+ else
+ {
+ ch = 10;
+ }
+ }
+ else
+ {
+ currentpos++;
+ ch = expandedtextbuffer[bufferpos++];
+ }
+ return ch;
+}
+
+tchar CArriere::getch(bool fast)
+{
+ mystyle.clearPicture();
+ return getch_base(fast);
+}
+
+/*
+void CArriere::setlink(QString& fn, const QString& wrd)
+{
+ fn = wrd;
+}
+*/
+
+QImage* CArriere::imagefromdata(UInt8* imgbuffer, UInt32 imgsize)
+{
+ QByteArray arr;
+ arr.assign((const char*)imgbuffer, imgsize);
+
+ QImage* qimage = new QImage(arr);
+
+ return qimage;
+}
+
+void CArriere::start2endSection()
+{
+ m_currentstart = NEFstartSection();
+ m_currentend = NEFendSection();
+}
+
+unsigned long CArriere::NEFstartSection()
+{
+//inefficient - Should calc start/end of section on entry to section?
+ UInt16 thishdr_uid, thishdr_nParagraphs;
+ UInt32 thishdr_size;
+ UInt8 thishdr_type, thishdr_reserved;
+ unsigned long textlength = currentpos-bufferpos;
+ for (UInt16 recptr = bufferrec-1; recptr >= 1; recptr--)
+ {
+ gotorecordnumber(recptr);
+ //qDebug("recptr:%u", recptr);
+ GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
+ if (thishdr_type < 2)
+ {
+ if ((thishdr_reserved && continuation_bit) == 0) break;
+ textlength -= thishdr_size;
+ //qDebug("Textlength:%u, reserved:%u, recptr:%u", textlength, thishdr_reserved, recptr);
+ }
+ }
+ return textlength;
+}
+
+unsigned long CArriere::NEFendSection()
+{
+//inefficient - Should calc start/end of section on entry to section?
+ unsigned long textlength = currentpos-bufferpos+buffercontent;
+ gotorecordnumber(bufferrec);
+ UInt16 thishdr_uid, thishdr_nParagraphs;
+ UInt32 thishdr_size;
+ UInt8 thishdr_type, thishdr_reserved;
+ GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
+ if ((thishdr_reserved && continuation_bit) != 0)
+ {
+ for (UInt16 recptr = bufferrec+1; recptr < ntohs(head.recordList.numRecords); recptr++)
+ {
+ gotorecordnumber(recptr);
+ UInt16 thishdr_uid, thishdr_nParagraphs;
+ UInt32 thishdr_size;
+ UInt8 thishdr_type, thishdr_reserved;
+ GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
+ // qDebug("recptr %u bufferrec %u type %u m_reserved %u", recptr, bufferrec, typ
+ if (thishdr_type < 2)
+ {
+ textlength += thishdr_size;
+ if ((thishdr_reserved && continuation_bit) == 0) break;
+ }
+ }
+ }
+ return textlength;
+}
+
+#ifndef __STATIC
+extern "C"
+{
+ CExpander* newcodec() { return new CArriere; }
+}
+#endif
+#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 @@
+#if (!defined(__ARRIEREGO_H)) && defined(USENEF)
+#define __ARRIEREGO_H
+#include "plucker_base.h"
+
+#ifdef LOCALPICTURES
+class QScrollView;
+class QWidget;
+#endif
+
+class CArriere : public CPlucker_base
+{
+protected:
+ bool isEndOfSection(int thisrec)
+ {
+ return !m_bufferisreserved;
+ }
+ unsigned long NEFstartSection();
+ unsigned long NEFendSection();
+ void setbuffersize()
+ {
+ compressedbuffersize = buffersize = 64*1024;
+ }
+ void GetHeader(UInt16&, UInt16&, UInt32&, UInt8&, UInt8&);
+ int HeaderSize();
+ int bgetch();
+ tchar getch(bool);
+
+ bool CorrectDecoder();
+// void setlink(QString&, const QString&);
+ QImage* imagefromdata(UInt8*, UInt32);
+ unsigned char m_reserved;
+public:
+ void start2endSection();
+ QString about() { return CPlucker_base::about()+QString("\nArriereGo codec (c) Tim Wentford"); }
+};
+
+#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 @@
+class CBkmkSelectorItem : public QListBoxText
+{
+ int m_ref;
+ public:
+ CBkmkSelectorItem(const QString& _t, int ref) : QListBoxText(_t), m_ref(ref)
+ {
+ }
+ int reference() { return m_ref; }
+};
+
class CBkmkSelector : public QWidget
@@ -12,3 +22,16 @@ class CBkmkSelector : public QWidget
QPushButton* exitButton;
-
+ /*
+ void keyPressEvent ( QKeyEvent * e )
+ {
+ if ((e->key() == Key_Return) || (e->key() == Key_Space))
+ {
+ emit selected(reinterpret_cast<CBkmkSelectorItem*>(bkmkselector->item(bkmkselector->currentItem()))->reference());
+ e->accept();
+ }
+ else
+ {
+ e->ignore();
+ }
+ }
+ */
signals:
@@ -17,5 +40,18 @@ signals:
private slots:
- void slotSelected(QListBoxItem* t) { emit selected(bkmkselector->index(t)); }
- void slotSelected(int t) { emit selected(t); }
+ void slotSelected(QListBoxItem* t)
+ {
+ if (t != NULL)
+ {
+ emit selected(reinterpret_cast<CBkmkSelectorItem*>(t)->reference());
+ }
+ }
+//void slotSelected(int t) { emit selected(t); }
void slotCancel() { emit cancelled(); }
+ void slotSort()
+ {
+ bkmkselector->sort();
+#ifdef USEQPE
+ setCurrentItem(bkmkselector->currentItem());
+#endif
+ }
public:
@@ -29,15 +65,25 @@ public:
QVBoxLayout* grid = new QVBoxLayout(this);
- bkmkselector = new QListBox(this, "Bookmarks");
- exitButton = new QPushButton("Cancel", this);
- connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) );
+ QHBoxLayout* hgrid = new QHBoxLayout();
+ bkmkselector = new QListBox(this, tr("Bookmarks"));
+ QPushButton* _sort = new QPushButton(tr("Sort"), this);
+ connect(_sort, SIGNAL(clicked()), this, SLOT( slotSort() ) );
+ exitButton = new QPushButton(tr("Cancel"), this);
+ // connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( slotSelected(int) ) );
connect(bkmkselector, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) );
+ connect(bkmkselector, SIGNAL( returnPressed(QListBoxItem*) ), this, SLOT( slotSelected(QListBoxItem*) ) );
connect(exitButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) );
grid->addWidget(bkmkselector,1);
- grid->addWidget(exitButton);
+ grid->addLayout(hgrid);
+ hgrid->addWidget(_sort);
+ hgrid->addWidget(exitButton);
}
void clear() { bkmkselector->clear(); }
- void insertItem(const QString& item) { bkmkselector->insertItem(item); }
+ void insertItem(const QString& _item, int ref)
+ {
+ CBkmkSelectorItem* item = new CBkmkSelectorItem(_item, ref);
+ bkmkselector->insertItem(item);
+ }
QString text(int index) const { return bkmkselector->text(index); }
void setText(const QString& _l) { exitButton->setText(_l); }
+ void setCurrentItem(int _i) { bkmkselector->setCurrentItem(_i); }
};
-
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 @@
depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI
+
+ source noncore/apps/opie-reader/FliteDyn/config.in
+ source noncore/apps/opie-reader/FliteDyn16/config.in
+
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 @@
+#include <string.h>
+#include "decompress.h"
+#include <zlib.h>
+#include <stdlib.h>
+
+size_t UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
+{
+ z_stream zstream;
+ memset(&zstream,sizeof(zstream),0);
+ zstream.next_in = compressedbuffer;
+ zstream.next_out = tgtbuffer;
+ zstream.avail_out = bsize;
+ zstream.avail_in = reclen;
+
+ int keylen = 0;
+
+ zstream.zalloc = Z_NULL;
+ zstream.zfree = Z_NULL;
+ zstream.opaque = Z_NULL;
+
+ // printf("Initialising\n");
+
+ inflateInit(&zstream);
+ int err = 0;
+ do {
+ if ( zstream.avail_in == 0 && 0 < keylen ) {
+ zstream.next_in = compressedbuffer + keylen;
+ zstream.avail_in = reclen - keylen;
+ keylen = 0;
+ }
+ zstream.next_out = tgtbuffer;
+ zstream.avail_out = bsize;
+
+ err = inflate( &zstream, Z_SYNC_FLUSH );
+
+ // //qDebug("err:%d - %u", err, zstream.avail_in);
+
+ } while ( err == Z_OK );
+
+ inflateEnd(&zstream);
+ return zstream.total_out;
+}
+
+#if defined(__STATIC) && defined(USENEF)
+#include "Model.h"
+size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t)
+{
+ if (strcmp(_s, "PluckerDecompress3") == 0)
+ {
+ return PluckerDecompress3;
+ }
+ if (strcmp(_s, "PluckerDecompress4") == 0)
+ {
+ return PluckerDecompress4;
+ }
+ if (strcmp(_s, "RebDecompress") == 0)
+ {
+ return RebDecompress;
+ }
+ return NULL;
+}
+#else
+
+#include "qfileinfo.h"
+
+#include <dlfcn.h>
+
+size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t)
+{
+#ifdef USEQPE
+#ifdef OPIE
+ QString codecpath(getenv("OPIEDIR"));
+#else
+ QString codecpath(getenv("QTDIR"));
+#endif
+ codecpath += "/plugins/reader/support/libpluckerdecompress.so";
+#else
+ QString codecpath(getenv("READERDIR"));
+ codecpath += "/support/libpluckerdecompress.so";
+#endif
+ qDebug("Codec:%s", (const char*)codecpath);
+ if (QFile::exists(codecpath))
+ {
+ qDebug("Codec:%s", (const char*)codecpath);
+ void* handle = dlopen(codecpath, RTLD_LAZY);
+ if (handle == 0)
+ {
+ qDebug("Can't find codec:%s", dlerror());
+ return NULL;
+ }
+ return (size_t (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s);
+ }
+ return NULL;
+}
+#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 @@
+#include "mytypes.h"
+
+size_t UnZip(UInt8* compressedbuffer,size_t reclen,UInt8* tgtbuffer,size_t bsize);
+
+size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t);
diff --git a/noncore/apps/opie-reader/ebookcodec.h b/noncore/apps/opie-reader/ebookcodec.h
index f6e2daf..4229fb9 100644
--- a/noncore/apps/opie-reader/ebookcodec.h
+++ b/noncore/apps/opie-reader/ebookcodec.h
@@ -9,4 +9,2 @@
-#include "util.h"
-
#ifndef __STATIC
@@ -19,2 +17,3 @@ class ebookcodec : public CExpander_Interface
public:
+ QString getTableAsHtml(unsigned long loc) { return codec->getTableAsHtml(loc); }
QString about()
@@ -25,3 +24,13 @@ class ebookcodec : public CExpander_Interface
{
- QString codecpath(QTReaderUtil::getPluginPath());
+#ifdef USEQPE
+#ifdef OPIE
+ QString codecpath(getenv("OPIEDIR"));
+#else
+ QString codecpath(getenv("QTDIR"));
+#endif
+ codecpath += "/plugins/reader/codecs/";
+#else
+ QString codecpath(getenv("READERDIR"));
+ codecpath += "/codecs/";
+#endif
codecpath += _s;
@@ -115,3 +124,7 @@ class ebookcodec : public CExpander_Interface
QImage* getPicture(const QString& href) { return codec->getPicture(href); }
- bool getFile(const QString& href) { return codec->getFile(href); }
+ bool getFile(const QString& href, const QString& nm) { return codec->getFile(href, nm); }
+ bool findanchor(const QString& nm)
+ {
+ return codec->findanchor(nm);
+ }
};
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
ListView->setAllColumnsShowFocus( TRUE );
- ListView->setColumnWidthMode(0, QListView::Manual);
+ ListView->setColumnWidthMode(0, ((modal) ? QListView::Manual : QListView::Maximum));
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 @@
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include "flitecmd.h"
+
+void CFliteCmd::output(const QString& txt)
+{
+ pid_t pid;
+ if ((pid = fork()) <0)
+ {
+ qDebug("No memory");
+ }
+ else if (pid == 0)
+ {
+ execlp("flite", "flite", "-t", (const char*)txt, NULL);
+ _exit(127);
+ qDebug("Can't find flite");
+ }
+ else
+ {
+ int status;
+ while (waitpid(pid, &status, 0) < 0)
+ {
+ if (errno != EINTR)
+ {
+ qDebug("Error from flite");
+ break;
+ }
+ }
+ qDebug("flite status:%d", status);
+ }
+}
+
+QString CFliteCmd::about()
+{
+ return QString("FliteCmd output codec (c) Tim Wentford\n");
+}
+
+extern "C"
+{
+ COutput* newcodec() { return new CFliteCmd; }
+}
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 @@
+#include "outputcodec.h"
+
+class CFliteCmd : public COutput
+{
+ public:
+ CFliteCmd() {}
+ ~CFliteCmd() {}
+ QString about();
+ void output(const QString& _o);
+};
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 @@
+#include "flitedyn.h"
+
+cst_voice *CFliteDyn::m_voice = NULL;
+
+CFliteDyn::CFliteDyn()
+{
+ if (m_voice == NULL)
+ {
+ qDebug("Constucting flite");
+ flite_init();
+ m_voice = register_cmu_us_kal();
+ }
+}
+
+QString CFliteDyn::about()
+{
+ return QString("FliteDyn output codec (c) Tim Wentford\n");
+}
+
+void CFliteDyn::output(const QString& _o)
+{
+ float tm = flite_text_to_speech((const char*)_o, m_voice, "play");
+ qDebug("Produced %g seconds of speech", tm);
+}
+
+extern "C"
+{
+ COutput* newcodec() { return new CFliteDyn; }
+}
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 @@
+#include "outputcodec.h"
+extern "C"
+{
+#include <flite.h>
+ cst_voice *register_cmu_us_kal();
+}
+
+class CFliteDyn : public COutput
+{
+ static cst_voice *m_voice;
+ public:
+ CFliteDyn();
+ ~CFliteDyn() {}
+ QString about();
+ void output(const QString& _o);
+};
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 @@
#include "iSilo.h"
-#ifdef _WINDOWS
-#include <winsock.h>
-#endif
+#ifdef _WINDOWS
+#include <winsock.h>
+#endif
u_int8_t *rodata = (u_int8_t *)
@@ -296,2 +296,3 @@ u_int32_t iSilo::get_bits(int num) {
if (pos == 0) {
+ unsuspend();
r = fread(buf, sizeof(u_int32_t), 256, fin);
@@ -563,8 +564,8 @@ void iSilo::read_attr()
attr[j].offset = htons(attr[j].offset);
- }
+ }
#ifdef _WINDOWS
- for (j = 0; j < attr_num; j++)
-#else
- for (int j = 0; j < attr_num; j++)
-#endif
+ for (j = 0; j < attr_num; j++)
+#else
+ for (int j = 0; j < attr_num; j++)
+#endif
{
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 @@
typedef unsigned int linkType;
-const linkType eNone = 0, eLink = 1, ePicture = 2, eFile = 4;
+const linkType eNone = 0, eLink = 1, ePicture = 2, eFile = 4, eTable = 8;
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 @@
+
#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 @@
+#ifndef __MYTYPES_H__
+#define __MYTYPES_H__
+typedef unsigned char UInt8;
+typedef unsigned short UInt16;
+typedef signed short Int16;
+typedef unsigned long UInt32;
+#endif
+
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 \
ppmsCodec \
+ FliteCmd \
+ pluckerdecompress \
+ ArriereCodec \
+ RebCodec \
reader
+# these are added only built if enabled in "make menuconfig"
+# FliteDyn
+# FliteDyn16
+
include( $(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 @@
+#include <stdlib.h>
+#include <qfileinfo.h>
+#include <qdir.h>
+
+#ifdef USEQPE
+#include <qpe/global.h>
+#endif
+
+class COutput
+{
+ public:
+ virtual ~COutput() {}
+ virtual void output(const QString&) = 0;
+ virtual QString about() = 0;
+};
+
+#ifndef __STATIC
+#include <dlfcn.h>
+class outputcodec : public COutput
+{
+ COutput *codec;
+ void *handle;
+ int status;
+ public:
+ void output(const QString& q) { codec->output(q); }
+ QString about()
+ {
+ return QString("Plug-in output codec interface (c) Tim Wentford\n")+codec->about();
+ }
+ outputcodec(const QString& _s) : codec(NULL), handle(NULL), status(-1)
+ {
+#ifdef USEQPE
+#ifdef OPIE
+ QString codecpath(getenv("OPIEDIR"));
+#else
+ QString codecpath(getenv("QTDIR"));
+#endif
+ codecpath += "/plugins/reader/outcodecs/lib";
+#else
+ QString codecpath(getenv("READERDIR"));
+ codecpath += "/outcodecs/lib";
+#endif
+ codecpath += _s;
+ codecpath += ".so";
+ if (QFile::exists(codecpath))
+ {
+ qDebug("Codec:%s", (const char*)codecpath);
+ handle = dlopen(codecpath, RTLD_LAZY);
+ if (handle == 0)
+ {
+ qDebug("Can't find codec:%s", dlerror());
+ status = -10;
+ return;
+ }
+ COutput* (*newcodec)();
+ newcodec = (COutput* (*)())dlsym(handle, "newcodec");
+ if (newcodec == NULL)
+ {
+ qDebug("Can't find newcodec");
+ status = -20;
+ return;
+ }
+ codec = (*newcodec)();
+ status = 0;
+ }
+ else
+ {
+ qDebug("Can't find codec:%s", (const char*)codecpath);
+ }
+ if (codec == NULL)
+ {
+ qDebug("Can't do newcodec");
+ status = -30;
+ return;
+ }
+ }
+ virtual ~outputcodec()
+ {
+ if (codec != NULL) delete codec;
+ if (handle != NULL) dlclose(handle);
+ }
+ int getStatus() { return status; }
+};
+#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 @@
-
#ifdef USEQPE
@@ -39,2 +38,3 @@ size_t Cpdb::recordpos(int n)
dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n;
+ unsuspend();
fseek(fin, dataoffset, SEEK_SET);
@@ -54,2 +54,3 @@ void Cpdb::gotorecordnumber(int n)
{
+unsuspend();
fseek(fin, recordpos(n), SEEK_SET);
@@ -84,4 +85,4 @@ bool Cpdb::openpdbfile(const char *src)
- qDebug("Database name:%s", head.name);
- qDebug("Total number of records:%u", ntohs(head.recordList.numRecords));
+ //qDebug("Database name:%s", head.name);
+ //qDebug("Total number of records:%u", ntohs(head.recordList.numRecords));
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 @@
#include <stdio.h>
+
#include "CExpander.h"
@@ -20,6 +21,3 @@
/* Normal Palm typedefs */
-typedef unsigned char UInt8;
-typedef unsigned short UInt16;
-typedef signed short Int16;
-typedef unsigned long UInt32;
+#include "mytypes.h"
typedef UInt32 LocalID;
@@ -94,2 +92,5 @@ class Cpdb : public CExpander
void unsuspend();
+#else
+ void suspend() {}
+ void unsuspend() {}
#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 @@
-#include "usenef.h"
#include <stdio.h>
@@ -25,3 +24,3 @@
#include "hrule.h"
-#include "util.h"
+#include "decompress.h"
@@ -44,3 +43,4 @@ void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buff
{
- if (type%2 == 0)
+unsuspend();
+ if ((type%2 == 0) && (type != 14))
{
@@ -307,3 +307,3 @@ void CPlucker_base::locate(unsigned int n)
}
- } while (locpos + bs <= n);
+ } while (locpos + bs < n);
@@ -414,3 +414,3 @@ bool CPlucker_base::expand(int thisrec)
}
-
+/*
void 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
}
-
-void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
+*/
+size_t CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
{
@@ -503,2 +503,3 @@ void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff
}
+ return i;
}
@@ -1058,2 +1059,155 @@ linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString&
}
+QString CPlucker_base::getTableAsHtml(unsigned long tgt)
+{
+ qDebug("CPlucker_base::getTableAsHtml:%u", tgt);
+ size_t reclen;
+ UInt16 thisrec = finduid(tgt);
+ qDebug("getimg:Found %u from uid:%u", thisrec, tgt);
+ reclen = recordlength(thisrec);
+ gotorecordnumber(thisrec);
+ UInt16 thishdr_uid, thishdr_nParagraphs;
+ UInt32 thishdr_size;
+ UInt8 thishdr_type, thishdr_reserved;
+ GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
+ qDebug("Found a table of type:%u", thishdr_type);
+ reclen -= HeaderSize();
+ UInt32 imgsize = thishdr_size;
+ UInt8* imgbuffer = new UInt8[imgsize];
+ Expand(reclen, thishdr_type, imgbuffer, imgsize);
+
+ QString ret;
+
+ UInt16 size, columns, rows;
+ UInt8 depth, border;
+ UInt32 borderColour, linkColour;
+ UInt8* dp(imgbuffer);
+
+ memcpy(&size, dp, sizeof(size));
+ size = ntohs(size);
+ dp += sizeof(size);
+ memcpy(&columns, dp, sizeof(columns));
+ columns = ntohs(columns);
+ dp += sizeof(columns);
+ memcpy(&rows, dp, sizeof(rows));
+ rows = ntohs(rows);
+ dp += sizeof(rows);
+ qDebug("Rows:%u Cols:%u", rows, columns);
+
+ memcpy(&depth, dp, sizeof(depth));
+ dp += sizeof(depth);
+ memcpy(&border, dp, sizeof(border));
+ dp += sizeof(border);
+
+ qDebug("Depth:%u, Border:%u", depth, border);
+
+ memcpy(&borderColour, dp, sizeof(borderColour));
+ dp += sizeof(borderColour);
+ memcpy(&linkColour, dp, sizeof(linkColour));
+ dp += sizeof(linkColour);
+
+ qDebug("Colours: border:%x, link:%x", borderColour, linkColour);
+
+ if (border)
+ {
+ ret = "<table border>";
+ }
+ else
+ {
+ ret = "<table>";
+ }
+ bool firstrow = true;
+ bool firstcol = true;
+ while (dp < imgbuffer+imgsize)
+ {
+ UInt8 ch = *dp++;
+ if (ch == 0x00)
+ {
+ ch = *dp++;
+ if (ch == 0x90)
+ {
+ if (firstrow)
+ {
+ ret += "<tr>";
+ firstrow = false;
+ firstcol = true;
+ }
+ else
+ {
+ ret += "</tr><tr>";
+ }
+ }
+ else if (ch == 0x97)
+ {
+ if (firstcol)
+ {
+ ret += "<td";
+ firstcol = false;
+ }
+ else
+ {
+ ret += "</td><td";
+ }
+ UInt8 align;
+ UInt16 imgid;
+ UInt8 cols, rows;
+ UInt16 len;
+ memcpy(&align, dp, sizeof(align));
+ dp += sizeof(align);
+ memcpy(&imgid, dp, sizeof(imgid));
+ dp += sizeof(imgid);
+ imgid = ntohs(imgid);
+ memcpy(&cols, dp, sizeof(cols));
+ dp += sizeof(cols);
+ memcpy(&rows, dp, sizeof(rows));
+ dp += sizeof(rows);
+ memcpy(&len, dp, sizeof(len));
+ dp += sizeof(len);
+ len = ntohs(len);
+ switch (align)
+ {
+ case 1:
+ ret += " align=right";
+ break;
+ case 2:
+ ret += " align=center";
+ break;
+ case 3:
+ ret += " align=justify";
+ break;
+ case 0:
+ break;
+ default:
+ qDebug("Unknown table cell alignment:%u", align);
+ }
+ if (cols != 1)
+ {
+ QString num;
+ num.setNum(cols);
+ ret += " colspan=";
+ ret += num;
+ }
+ if (rows != 1)
+ {
+ QString num;
+ num.setNum(rows);
+ ret += " rowspan=";
+ ret += num;
+ }
+ ret += ">";
+ }
+ else
+ {
+ dp += (ch & 7);
+ }
+ }
+ else
+ {
+ ret += QChar(ch);
+ }
+ }
+
+ ret += "</td></tr></table>";
+ delete [] imgbuffer;
+ return ret;
+}
@@ -1061,2 +1215,3 @@ tchar CPlucker_base::getch_base(bool fast)
{
+ mystyle.setTable(0xffffffff);
int ch = bgetch();
@@ -1121,6 +1276,2 @@ tchar CPlucker_base::getch_base(bool fast)
}
- else
- {
- mystyle.setUnderline();
- }
mystyle.setOffset(m_offset);
@@ -1331,2 +1482,11 @@ tchar CPlucker_base::getch_base(bool fast)
break;
+ case 0x92:
+ {
+ ch = bgetch();
+ ch <<= 8;
+ ch |= (tchar)bgetch();
+ mystyle.setTable(ch);
+ ch = 0x16e5;
+ }
+ break;
case 0x85:
@@ -1359,42 +1519,2 @@ tchar CPlucker_base::getch_base(bool fast)
-#if defined(__STATIC) && defined(USENEF)
-#include "Model.h"
-void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t)
-{
- if (_s == "PluckerDecompress3")
- {
- return PluckerDecompress3;
- }
- if (_s == "PluckerDecompress4")
- {
- return PluckerDecompress4;
- }
- return NULL;
-}
-#else
-
-#include "qfileinfo.h"
-
-#include <dlfcn.h>
-
-void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t)
-{
- QString codecpath(QTReaderUtil::getPluginPath("support"));
- codecpath += "/libpluckerdecompress.so";
- qDebug("Codec:%s", (const char*)codecpath);
- if (QFile::exists(codecpath))
- {
- qDebug("Codec:%s", (const char*)codecpath);
- void* handle = dlopen(codecpath, RTLD_LAZY);
- if (handle == 0)
- {
- qDebug("Can't find codec:%s", dlerror());
- return NULL;
- }
- return (void (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s);
- }
- return NULL;
-}
-#endif
-
QString CPlucker_base::about()
@@ -1404,3 +1524,3 @@ QString CPlucker_base::about()
{
- abt += "\nSpecial decompression (c) Tim Wentford";
+ abt += "\nSpecial decompression (c) Tim Wentford (ppmd by Dmitry Shkarin";
}
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:
bool expand(int);
- static void UnZip(UInt8*, size_t, UInt8*, size_t);
- static void UnDoc(UInt8*, size_t, UInt8*, size_t);
+ //static void UnZip(UInt8*, size_t, UInt8*, size_t);
+ static size_t UnDoc(UInt8*, size_t, UInt8*, size_t);
+
+ size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t);
- void (*m_decompress)(UInt8*, size_t, UInt8*, size_t);
- void (*getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t);
#ifdef LOCALPICTURES
@@ -112,2 +112,3 @@ protected:
virtual QImage* imagefromdata(UInt8*, UInt32) = 0;
+ QString getTableAsHtml(unsigned long loc);
};
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 \
-SOURCES = plucker_base.cpp
+SOURCES = plucker_base.cpp \
+ decompress.cpp
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 @@
+Makefile
+config.in
+moc_*
+.moc
+.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 @@
+DEFINES += OPIE USEQPE
+VPATH = ..
+TEMPLATE = lib
+CONFIG = qt warn_on release dll
+HEADERS = CSource.h Model.h Coder.h SubAlloc.h
+
+SOURCES = Model.cpp
+
+
+INTERFACES =
+DESTDIR = $(OPIEDIR)/plugins/reader/support
+TARGET = pluckerdecompress
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+
+include( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-reader/ppm_expander.cpp b/noncore/apps/opie-reader/ppm_expander.cpp
index 2a4318b..61ef90e 100644
--- a/noncore/apps/opie-reader/ppm_expander.cpp
+++ b/noncore/apps/opie-reader/ppm_expander.cpp
@@ -40,3 +40,3 @@ int ppm_expander::OpenFile(const char* infile)
my_file_in=fopen(infile,"rb");
- my_read_buf = new PPM_ReadBuf(my_file_in);
+ my_read_buf = new PPM_ReadBuf(my_file_in, this);
return home();
@@ -109,2 +109,11 @@ int ppm_expander::getch() {
+UINT PPM_ReadBuf::readbuf(UCHAR *buf,UINT len)
+ {
+ UINT len1;
+ parent->unsuspend();
+ len1=fread(buf,1,len,my_file_in);
+ return len1;
+ }
+
+
#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 @@
#include "ppm.h"
-#include "arith.h"
+class PPM_ReadBuf;
@@ -38,2 +38,5 @@ public:
}
+#else
+ void suspend() {}
+ void unsuspend() {}
#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 @@
+
#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 @@
-#ifndef USEQPE
-#ifndef __PREFERENCES_H
-#define __PREFERENCES_H
-
-#include <qstring.h>
-#include <qmap.h>
-
-class Config
-{
- QMap<QString, QString> values;
- QString fname;
- public:
- Config(const QString& fname);
+#ifndef USEQPE
+#ifndef __PREFERENCES_H
+#define __PREFERENCES_H
+
+#include <qstring.h>
+#include <qmap.h>
+
+class Config
+{
+ QMap<QString, QString> values;
+ QString fname;
+ public:
+ Config(const QString& fname);
~Config();
- void setGroup(const QString& s) { }
- QString readEntry(const QString&, const QString&);
- bool readBoolEntry(const QString&, const bool);
- int readNumEntry(const QString&, const int);
-
- void writeEntry(const QString&, const QString&);
- void writeEntry(const QString&, const bool);
- void writeEntry(const QString&, const int);
-};
-
-#endif // PREFERENCES
-#endif
+ void setGroup(const QString& s) { }
+ QString readEntry(const QString&, const QString&);
+ bool readBoolEntry(const QString&, const bool);
+ int readNumEntry(const QString&, const int);
+
+ void writeEntry(const QString&, const QString&);
+ void writeEntry(const QString&, const bool);
+ void writeEntry(const QString&, const int);
+};
+
+#endif // PREFERENCES
+#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 @@
-TEMPLATE = app
-CONFIG = qt warn_off debug
-HEADERS = Aportis.h \
- Bkmks.h \
- BuffDoc.h \
- ButtonPrefs.h \
- CAnnoEdit.h \
- CBuffer.h \
- CDrawBuffer.h \
- CEncoding.h \
- CEncoding_tables.h \
- CExpander.h \
- CFilter.h \
- CloseDialog.h \
- Filedata.h \
- FixedFont.h \
- FontControl.h \
- GraphicWin.h \
- Markups.h \
- Navigation.h \
- Palm2QImage.h \
- Prefs.h \
- QFloatBar.h \
- QTReader.h \
- QTReaderApp.h \
- QtrListView.h \
- Queue.h \
- StyleConsts.h \
- ToolbarPrefs.h \
- URLDialog.h \
- ZText.h \
- arith.h \
- cbkmkselector.h \
- config.h \
- fileBrowser.h \
- infowin.h \
- linktype.h \
- my_list.h \
- names.h \
- QSTATICREADERINC/opie.h \
- pdb.h \
- plucker_base.h \
- plucker.h \
- ppm.h \
- ppm_expander.h \
- preferences.h \
- QSTATICREADERINC/static.h \
- usenef.h \
- QSTATICREADERINC/useqpe.h \
- ustring.h \
- utypes.h \
- version.h \
- ztxt.h
-
-SOURCES = Aportis.cpp \
- Bkmks.cpp \
- BuffDoc.cpp \
- ButtonPrefs.cpp \
- CAnnoEdit.cpp \
- CBuffer.cpp \
- CDrawBuffer.cpp \
- CEncoding.cpp \
- CEncoding_tables.cpp \
- CExpander.cpp \
- CFilter.cpp \
- CHM.cpp \
- CRegExp.cpp \
- CloseDialog.cpp \
- FontControl.cpp \
- GraphicWin.cpp \
- Navigation.cpp \
- Palm2QImage.cpp \
- Prefs.cpp \
- QTReader.cpp \
- QTReaderApp.cpp \
- QtrListView.cpp \
- StyleConsts.cpp \
- ToolbarPrefs.cpp \
- URLDialog.cpp \
- arith_d.cpp \
- chm_lib.c \
- fileBrowser.cpp \
- hrule.cpp \
- infowin.cpp \
- iSilo.cpp \
- lzx.c \
- main.cpp \
- orkey.cpp \
- pdb.cpp \
- plucker.cpp \
- plucker_base.cpp \
- ppm.cpp \
- ppm_expander.cpp \
- preferences.cpp \
- striphtml.cpp \
- util.cpp \
- version.cpp \
- ztxt.cpp
-
-INTERFACES =
-DESTDIR = QSTATICREADEROBJS
-INCLUDEPATH += QSTATICREADERINC
-DEPENDPATH += QSTATICREADERINC
-OBJECTS_DIR = QSTATICREADEROBJS
-MOC_DIR = QSTATICREADERMOCS
-TARGET = uqtreader
-#LIBS += -lqpe
-
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 @@
-TEMPLATE = app
-CONFIG = qt warn_on release
-HEADERS = Aportis.h \
- Bkmks.h \
- BuffDoc.h \
- ButtonPrefs.h \
- CAnnoEdit.h \
- CBuffer.h \
- CDrawBuffer.h \
- CEncoding.h \
- CEncoding_tables.h \
- CExpander.h \
- CFilter.h \
- CloseDialog.h \
- Filedata.h \
- FixedFont.h \
- FontControl.h \
- GraphicWin.h \
- Markups.h \
- Navigation.h \
- Palm2QImage.h \
- Prefs.h \
- QFloatBar.h \
- QTReader.h \
- QTReaderApp.h \
- QtrListView.h \
- Queue.h \
- StateData.h \
- StyleConsts.h \
- ToolbarPrefs.h \
- URLDialog.h \
- ZText.h \
- arith.h \
- cbkmkselector.h \
- config.h \
- fileBrowser.h \
- infowin.h \
- linktype.h \
- my_list.h \
- names.h \
- ZSTATICREADERINC/opie.h \
- pdb.h \
- plucker_base.h \
- plucker.h \
- ppm.h \
- ppm_expander.h \
- preferences.h \
- ZSTATICREADERINC/static.h \
- usenef.h \
- ZSTATICREADERINC/useqpe.h \
- ustring.h \
- utypes.h \
- version.h \
- ztxt.h
-
-SOURCES = Aportis.cpp \
- Bkmks.cpp \
- BuffDoc.cpp \
- ButtonPrefs.cpp \
- CAnnoEdit.cpp \
- CBuffer.cpp \
- CDrawBuffer.cpp \
- CEncoding.cpp \
- CEncoding_tables.cpp \
- CExpander.cpp \
- CFilter.cpp \
- CHM.cpp \
- CRegExp.cpp \
- CloseDialog.cpp \
- FontControl.cpp \
- GraphicWin.cpp \
- Navigation.cpp \
- Palm2QImage.cpp \
- Prefs.cpp \
- QTReader.cpp \
- QTReaderApp.cpp \
- QtrListView.cpp \
- StyleConsts.cpp \
- ToolbarPrefs.cpp \
- URLDialog.cpp \
- arith_d.cpp \
- chm_lib.c \
- fileBrowser.cpp \
- hrule.cpp \
- infowin.cpp \
- iSilo.cpp \
- lzx.c \
- main.cpp \
- orkey.cpp \
- pdb.cpp \
- plucker.cpp \
- plucker_base.cpp \
- ppm.cpp \
- ppm_expander.cpp \
- striphtml.cpp \
- util.cpp \
- version.cpp \
- ztxt.cpp
-
-INTERFACES =
-DESTDIR = ZSTATICREADEROBJS
-INCLUDEPATH += ZSTATICREADERINC
-DEPENDPATH += ZSTATICREADERINC
-OBJECTS_DIR = ZSTATICREADEROBJS
-MOC_DIR = ZSTATICREADERMOCS
-TARGET = uqtreader
-LIBS += -lqpe
-
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 \
StyleConsts.h \
+ TableDialog.h \
ToolbarPrefs.h \
@@ -48,3 +49,2 @@ HEADERS = Aportis.h \
ppm_expander.h \
- usenef.h \
ustring.h \
@@ -70,2 +70,3 @@ SOURCES = BuffDoc.cpp \
QtrListView.cpp \
+ TableDialog.cpp \
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 @@
-red='\e[0;31m'
-RED='\e[1;31m'
-blue='\e[0;34m'
-BLUE='\e[1;34m'
-cyan='\e[0;36m'
-CYAN='\e[1;36m'
-NC='\e[0m' # No Color
-
-if test -z $OLDPATH; then
- export OLDPATH=$PATH
-fi
-
-if test -z $OLD_LD_LIBRARY_PATH; then
- export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
-fi
-
-#export QPEDIR=/opt/Qtopia
-export QTDIR=/home/tim/nevyos/qt-embedded-free-3.1.1
-export PATH=$QTDIR/bin:$OLDPATH
-export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++
-export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH
-
-#PS1="[${cyan}\T$NC][${RED}Laptop${NC}]\W> "
-#PS1="[${RED}NevyOS${NC}]\W> "
-PS1="[NevyOS]\W> "
-
-echo -e \\n${RED}NevyOS${NC} environment configured\\n
diff --git a/noncore/apps/opie-reader/seto.sh b/noncore/apps/opie-reader/seto.sh
deleted file mode 100644
index c1d1dd1..0000000
--- a/noncore/apps/opie-reader/seto.sh
+++ b/dev/null
@@ -1,25 +0,0 @@
-red='\e[0;31m'
-RED='\e[1;31m'
-blue='\e[0;34m'
-BLUE='\e[1;34m'
-cyan='\e[0;36m'
-CYAN='\e[1;36m'
-NC='\e[0m' # No Color
-
-if test -z $OLDPATH; then
- export OLDPATH=$PATH
-fi
-
-if test -z $OLD_LD_LIBRARY_PATH; then
- export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
-fi
-
-export QPEDIR=/opt/Qtopia/opie
-export QTDIR=/opt/Qtopia/opie
-export PATH=$QTDIR/bin:/usr/local/arm/3.3/bin:$OLDPATH
-export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-opie-g++
-#export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH
-
-PS1="[Opie]\W> "
-
-echo -e \\n${RED}Opie${NC} environment configured\\n
diff --git a/noncore/apps/opie-reader/setqt.sh b/noncore/apps/opie-reader/setqt.sh
deleted file mode 100644
index 1b7e7b7..0000000
--- a/noncore/apps/opie-reader/setqt.sh
+++ b/dev/null
@@ -1,30 +0,0 @@
-red='\e[0;31m'
-RED='\e[1;31m'
-blue='\e[0;34m'
-BLUE='\e[1;34m'
-cyan='\e[0;36m'
-CYAN='\e[1;36m'
-NC='\e[0m' # No Color
-
-if test -z $OLDPATH; then
- export OLDPATH=$PATH
-fi
-
-if test -z $OLD_LD_LIBRARY_PATH; then
- export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
-fi
-
-#export QPEDIR=/opt/Qtopia
-export QTDIR=/usr/lib/qt3
-export PATH=$QTDIR/bin:$OLDPATH
-#export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++
-
-export READERDIR=/home/tim/uqtreader
-export LD_LIBRARY_PATH=$READERDIR/lib:$OLD_LD_LIBRARY_PATH
-
-
-#PS1="[${cyan}\T$NC][${RED}Laptop${NC}]\W> "
-#PS1="[${RED}NevyOS${NC}]\W> "
-PS1="[QT]\W> "
-
-echo -e \\n${RED}QT${NC} environment configured\\n
diff --git a/noncore/apps/opie-reader/setws.sh b/noncore/apps/opie-reader/setws.sh
deleted file mode 100644
index 61aeccb..0000000
--- a/noncore/apps/opie-reader/setws.sh
+++ b/dev/null
@@ -1,27 +0,0 @@
-red='\e[0;31m'
-RED='\e[1;31m'
-blue='\e[0;34m'
-BLUE='\e[1;34m'
-cyan='\e[0;36m'
-CYAN='\e[1;36m'
-NC='\e[0m' # No Color
-
-if test -z $OLDPATH; then
- export OLDPATH=$PATH
-fi
-
-if test -z $OLD_LD_LIBRARY_PATH; then
- export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
-fi
-
-export QPEDIR=/opt/Qtopia
-export QTDIR=/opt/Qtopia
-export PATH=$QTDIR/bin:$OLDPATH
-export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-generic-g++
-export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH
-
-#PS1="[${cyan}\T$NC][${RED}Laptop${NC}]\W> "
-#PS1="[${RED}Laptop${NC}]\W> "
-PS1="[Laptop]\W> "
-
-echo -e \\n${RED}Laptop${NC} environment configured\\n
diff --git a/noncore/apps/opie-reader/setz.sh b/noncore/apps/opie-reader/setz.sh
deleted file mode 100644
index e2fa4cd..0000000
--- a/noncore/apps/opie-reader/setz.sh
+++ b/dev/null
@@ -1,25 +0,0 @@
-red='\e[0;31m'
-RED='\e[1;31m'
-blue='\e[0;34m'
-BLUE='\e[1;34m'
-cyan='\e[0;36m'
-CYAN='\e[1;36m'
-NC='\e[0m' # No Color
-
-if test -z $OLDPATH; then
- export OLDPATH=$PATH
-fi
-
-if test -z $OLD_LD_LIBRARY_PATH; then
- export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
-fi
-
-export QPEDIR=/opt/Qtopia/sharp
-export QTDIR=/opt/Qtopia/sharp
-export PATH=$QTDIR/bin:/usr/local/arm/bin:$OLDPATH
-export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-sharp-g++
-export LD_LIBRARY_PATH=$QTDIR/lib:$OLD_LD_LIBRARY_PATH
-
-PS1="[Zaurus]\W> "
-
-echo -e \\n${RED}Zaurus${NC} environment configured\\n
diff --git a/noncore/apps/opie-reader/striphtml.cpp b/noncore/apps/opie-reader/striphtml.cpp
index e86402b..c434dbb 100644
--- a/noncore/apps/opie-reader/striphtml.cpp
+++ b/noncore/apps/opie-reader/striphtml.cpp
@@ -10,3 +10,2 @@
#include "hrule.h"
-#include "util.h"
@@ -92,3 +91,3 @@ void striphtml::skipblock(const QString& _ent)
-void striphtml::locate(unsigned int n)
+void striphtml::reset()
{
@@ -96,7 +95,15 @@ void striphtml::locate(unsigned int n)
text_q = "";
+ q = "";
+ tablenesteddepth = 0;
forcecentre = false;
ignorespace = false;
+ indent = 0;
while (!stylestack.isEmpty()) stylestack.pop();
currentstyle.unset();
+}
+
+void striphtml::locate(unsigned int n)
+{
qDebug("striphtml:locating:%u", n);
+ reset();
parent->locate(n);
@@ -235,2 +242,9 @@ bool striphtml::findanchor(const QString& _info)
// QProgressBar dlg(0);
+ if (parent->findanchor(_info))
+ {
+ reset();
+ return true;
+ }
+ qDebug("Using html find");
+ parent->locate(parent->startSection());
#if defined(USEQPE) || defined(_WINDOWS)
@@ -297,3 +311,3 @@ bool striphtml::findanchor(const QString& _info)
-striphtml::striphtml(const QString& _s) : entmap(NULL), isPre(false), currentid(0), lastch(0), currentfile(_s), indent(0), forcecentre(false), m_inblock(false), m_bchm(false), ignorespace(false)
+striphtml::striphtml(const QString& _s) : entmap(NULL), isPre(false), currentid(0), lastch(0), currentfile(_s), indent(0), forcecentre(false), m_inblock(false), m_bchm(false), ignorespace(false), tablenesteddepth(0)
{
@@ -313,3 +327,13 @@ void striphtml::initentmap()
entmap = new QMap<QString, tchar>;
- QString fname(QTReaderUtil::getPluginPath("data"));
+#ifdef USEQPE
+#ifdef OPIE
+ QString fname(getenv("OPIEDIR"));
+#else
+ QString fname(getenv("QTDIR"));
+#endif
+ fname += "/plugins/reader/data";
+#else
+ QString fname(getenv("READERDIR"));
+ fname += "/data";
+#endif
QFileInfo fi;
@@ -414,2 +438,8 @@ QString striphtml::getattr(tchar& ch)
}
+ else if (ch == '\'')
+ {
+ mygetch(ch, sty, pos);
+ ref = getname(ch, "\'");
+ ch = skip_ws();
+ }
else
@@ -480,2 +510,7 @@ linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString&
{
+ if (parent->findanchor(name))
+ {
+ reset();
+ return eLink;
+ }
fpit = href2filepos->find(name);
@@ -490,3 +525,2 @@ linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString&
qDebug("Do a search for:%s", (const char*)name);
- parent->locate(0);
findanchor(name);
@@ -500,3 +534,3 @@ linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString&
{
- w = "/"+file;
+ w = file;
nm = name;
@@ -566,3 +600,27 @@ void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos)
{
+#ifdef REMOVE_LF_BEFORE_ENDTAG
+ parent->getch(ch, sty, pos);
+ if (ch == '<')
+ {
+ parent->getch(ch, sty, pos);
+ if (ch == '/')
+ {
+ ch = '<';
+ text_q += '/';
+ }
+ else
+ {
+ text_q += '<';
+ text_q += ch;
+ ch = ' ';
+ }
+ }
+ else
+ {
+ text_q += ch;
+ ch = ' ';
+ }
+#else
ch = ' ';
+#endif
}
@@ -586,3 +644,2 @@ void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long p
{
- qDebug("Using stack style");
currentstyle = stylestack.first();
@@ -609,2 +666,6 @@ void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long p
}
+ if (attr == "justify")
+ {
+ currentstyle.setFullJustify();
+ }
}
@@ -656,2 +717,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
sty = currentstyle;
+ lastch = ch;
return;
@@ -663,3 +725,2 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
mygetch(ch, dummy, pos);
- // if (ch == 10 && !isPre) ch = ' ';
while (ch == '<' && ch != UEOF)
@@ -667,3 +728,2 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
ch = skip_ws();
-
QString ent = getname(ch, " >").lower();
@@ -683,3 +743,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
QString attr = getattr(ch);
- qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr);
+ //qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr);
if (ent == "name")
@@ -714,3 +774,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
}
- qDebug("<a %s=%s>", (const char*)ent, (const char*)ref);
+ //qDebug("<a %s=%s>", (const char*)ent, (const char*)ref);
}
@@ -749,4 +809,5 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
parse_paragraph(currentstyle, ch, pos);
- stylestack.push_front(currentstyle);
- //indent = 0;
+ stylestack.push_front(currentstyle);
+ currentstyle.setExtraSpace(16);
+ //indent = 0;
continue;
@@ -802,2 +863,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
isPre = true;
+ currentstyle.setNoJustify();
currentstyle.setMono();
@@ -824,2 +886,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
ch = 10;
+ currentstyle.setExtraSpace(0);
currentstyle.setLeftMargin(30);
@@ -832,2 +895,4 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
ch = 10;
+ currentstyle.setExtraSpace(0);
+ lastch = 0;
continue;
@@ -863,2 +928,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
if (ch != '>') ch = skip_ws_end();
+ lastch = 0;
ch = 10;
@@ -920,2 +986,8 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
}
+ else if (ent[0] == '/' && ent[1] == 'h' && ent.length() == 3 && QString("123456789").find(ent[2]) != -1)
+ {
+ parse_paragraph(currentstyle, ch, pos);
+ currentstyle.setExtraSpace(3);
+ continue;
+ }
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)
// currentstyle.setExtraSpace(10);
- continue;
}
@@ -939,3 +1010,2 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
// currentstyle.setExtraSpace(10);
- continue;
}
@@ -948,3 +1018,2 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
// currentstyle.setExtraSpace(10);
- continue;
}
@@ -956,4 +1025,5 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
// currentstyle.setExtraSpace(10);
- continue;
}
+ ch = 10;
+ continue;
}
@@ -1049,8 +1119,5 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
if (ch != '>') ch = skip_ws_end();
- ch = 10;
- continue;
+ //ch = 10;
+ //continue;
}
-
-
-
else if (ent == "table" || ent == "/table")
@@ -1059,2 +1126,14 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
ignorespace = (ent == "table");
+ if (ent == "table")
+ {
+ if (tablenesteddepth++ == 0) currentstyle.setTable(pos);
+ }
+ else
+ {
+ if (--tablenesteddepth <= 0)
+ {
+ tablenesteddepth = 0;
+ currentstyle.setTable(0xffffffff);
+ }
+ }
if (ch == ' ') ch = skip_ws();
@@ -1068,2 +1147,6 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
+ currentstyle.setLeftMargin(6*tablenesteddepth);
+
+
+ lastch = 0; // Anything but 10
ch = 10;
@@ -1071,3 +1154,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
q += QChar(parent->getwidth());
- q += 2;
+ q += 3;
q += '\0';
@@ -1079,14 +1162,4 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
+ //bool isPageBreak = false;
if (ch == ' ') ch = skip_ws();
- // if (stylestack.isEmpty())
- // {
- currentstyle.unset();
- // }
- /*
- else
- {
- qDebug("Using stack style");
- currentstyle = stylestack.first();
- }
- */
unsigned char red = 0, green = 0, blue = 0;
@@ -1100,2 +1173,11 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
}
+ /*
+ if (ent == "size")
+ {
+ if (attr == "0")
+ {
+ isPageBreak = true;
+ }
+ }
+ */
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)
if (ch != '>') ch = skip_ws_end();
- ch = 10;
- q += '-';
- q += QChar(parent->getwidth());
- q += 3;
- q += red;
- q += green;
- q += blue;
+ /*
+ if (isPageBreak)
+ {
+ ch = UEOF;
+ }
+ else
+ {
+ */
+ // if (stylestack.isEmpty())
+ // {
+ currentstyle.unset();
+ // }
+ /*
+ else
+ {
+ qDebug("Using stack style");
+ currentstyle = stylestack.first();
+ }
+ */
+ lastch = 0; //Anything but 10 or ' '
+ ch = 10;
+ q += '-';
+ q += QChar(parent->getwidth());
+ q += 3;
+ q += red;
+ q += green;
+ q += blue;
+
continue;
@@ -1125,2 +1228,3 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
+ /*
if (m_bchm)
@@ -1133,2 +1237,10 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
}
+ */
+
+
+ QImage* img = parent->getPicture(attr);
+ if (img != NULL)
+ {
+ currentstyle.setPicture(true, img);
+ }
else
@@ -1174,2 +1286,10 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
}
+ else if (ent == "title")
+ {
+ skipblock("/title");
+ }
+ else if (ent == "head")
+ {
+ skipblock("/head");
+ }
/*
@@ -1193,3 +1313,6 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
if (ch != '>') ch = skip_ws_end();
- mygetch(ch, dummy, npos);
+ if (ent[0] == '/')
+ mygetch(ch, dummy, pos);
+ else
+ mygetch(ch, dummy, npos);
}
@@ -1236,5 +1359,9 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
// sty = (dummy == ucFontBase) ? currentstyle : dummy;
+ if (lastch == 10 && ch == 10 && sty.getExtraSpace() > currentstyle.getExtraSpace())
+ {
+ currentstyle.setExtraSpace(sty.getExtraSpace());
+ }
sty = currentstyle;
}
- while (!isPre && (lastch == ' ' || lastch == 10 || ignorespace) && ch == ' ');
+ while (!isPre && (((lastch == ' ' || lastch == 10 || ignorespace) && ch == ' ') || ((ch == 10) && (lastch == 10))));
// lastch = ch;
@@ -1244,2 +1371,41 @@ void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
+QString striphtml::getTableAsHtml(unsigned long loc)
+{
+ qDebug("striphtml::getTableAsHtml");
+ QString ret;
+ tchar ch(0);
+ CStyle sty;
+ unsigned long pos;
+ locate(loc);
+ int endpos(0);
+ QString endmarker("</table>");
+ QString startmarker("<table");
+ int startpos(0);
+ int depth(0);
+ while (ch != UEOF)
+ {
+ parent->getch(ch, sty, pos);
+ QChar qc(ch);
+ ret += qc;
+ if (qc.lower() == endmarker[endpos])
+ {
+ if ((++endpos >= endmarker.length()) && (--depth <= 0)) break;
+ }
+ else
+ {
+ endpos = 0;
+ }
+ if (qc.lower() == startmarker[startpos])
+ {
+ if (++startpos >= startmarker.length()) ++depth;
+ }
+ else
+ {
+ startpos = 0;
+ }
+ }
+ return ret;
+}
+
+
extern "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
{
+ void reset();
bool ignorespace;
bool m_bchm;
+ int tablenesteddepth;
CList<CStyle> stylestack;
@@ -91,2 +93,3 @@ class striphtml : public CFilter
void setchm(bool _b) { m_bchm = _b; }
+ QString getTableAsHtml(unsigned long loc);
};
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 @@
-#!/bin/bash
-touch infowin.cpp
-for f in *lib.omak; do make -f $f; done
-for f in *.omak; do make -f $f; done
-for f in *.omak; do make -f $f; done
-cp /home/tim/codecreader/opie-reader.desktop $QTDIR/apps/Applications/
-cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/
-cp /home/tim/codecreader/opie-pics/* $QTDIR/pics/opie-reader/
-cp HTMLentities $QTDIR/plugins/reader/data/
-rm $QTDIR/help/html/*reader*.html
-cp /home/tim/codecreader/help/*.html $QTDIR/help/html/
-rm $QTDIR/help/html/*reader*.html
-cp /home/tim/codecreader/help/*.html $QTDIR/help/html/
-rm -f $QTDIR/lib/libreader*.so
-rm -f $QTDIR/lib/libreader*.so.1
-for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done
-rm -f $QTDIR/lib/libreader*.so.1.*
-
-/home/tim/bin/zstrip.sh $QTDIR/bin/reader
-for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done
-
-for SUBDIR in codecs support filters
-do
- CDIR=$QTDIR/plugins/reader/$SUBDIR
- rm -f $CDIR/*.so
- for f in $CDIR/*.1.0.0 ; do mv -f $f $CDIR/`basename $f .1.0.0` ; done
- rm -f $CDIR/*.so.*
- for f in $CDIR/*.so ; do /home/tim/bin/zstrip.sh $f ; done
-done
-rm -f opie-reader-gcc3_*.ipk
-rm -f full/opie-reader-gcc3_*.ipk
-rm -f partial/opie-reader-gcc3_*.ipk
-mkipks opie-reader-gcc3.control
-cp opie-reader-gcc3_*.ipk full/
-for f in opie-reader-gcc3_*.ipk
- do
- cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
-done
-rm $QTDIR/plugins/reader/support/libpluckerdecompress.so
-rm $QTDIR/plugins/reader/codecs/libArriereGo.so
-rm $QTDIR/plugins/reader/codecs/libNEF.so
-mkipks opie-reader-gcc3.control
-cp opie-reader-gcc3_*.ipk partial/
-for f in opie-reader-gcc3_*.ipk
- do
- cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
-done
diff --git a/noncore/apps/opie-reader/update-opie.sh b/noncore/apps/opie-reader/update-opie.sh
deleted file mode 100755
index 261ef46..0000000
--- a/noncore/apps/opie-reader/update-opie.sh
+++ b/dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-touch infowin.cpp
-for f in *lib.zmak; do make -f $f; done
-for f in *.zmak; do make -f $f; done
-for f in *.zmak; do make -f $f; done
-cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/
-cp /home/tim/codecreader/opie-pics/* $QTDIR/pics/opie-reader/
-cp HTMLentities $QTDIR/plugins/reader/data/
-rm $QTDIR/help/html/*reader*.html
-cp /home/tim/codecreader/help/*.html $QTDIR/help/html/
-rm -f $QTDIR/lib/libreader*.so
-rm -f $QTDIR/lib/libreader*.so.1
-for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done
-rm -f $QTDIR/lib/libreader*.so.1.*
-
-/home/tim/bin/zstrip.sh $QTDIR/bin/uqtreader
-rm -f $QTDIR/bin/reader
-mv $QTDIR/bin/uqtreader $QTDIR/bin/reader
-for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done
-for SUBDIR in codecs support filters
-do
- CDIR=$QTDIR/plugins/reader/$SUBDIR
- rm -f $CDIR/*.so
- for f in $CDIR/*.1.0.0 ; do mv -f $f $CDIR/`basename $f .1.0.0` ; done
- rm -f $CDIR/*.so.*
- for f in $CDIR/*.so ; do zstrip.sh $f ; done
-done
-rm -f opie-reader-opie_*.ipk
-rm -f full/opie-reader-opie_*.ipk
-rm -f partial/opie-reader-opie_*.ipk
-mkipks opie-reader-opie.control
-cp opie-reader-opie_*.ipk full/
-for f in opie-reader-opie_*.ipk
- do
- cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
-done
-rm $QTDIR/plugins/reader/support/libpluckerdecompress.so
-rm $QTDIR/plugins/reader/codecs/libArriereGo.so
-rm $QTDIR/plugins/reader/codecs/libNEF.so
-mkipks opie-reader-opie.control
-cp opie-reader-opie_*.ipk partial/
-for f in opie-reader-opie_*.ipk
- do
- cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
-done
diff --git a/noncore/apps/opie-reader/update.sh b/noncore/apps/opie-reader/update.sh
deleted file mode 100755
index 61b8a5e..0000000
--- a/noncore/apps/opie-reader/update.sh
+++ b/dev/null
@@ -1,47 +0,0 @@
-#!/bin/bash
-touch infowin.cpp
-for f in *lib.zmak; do make -f $f; done
-for f in *.zmak; do make -f $f; done
-for f in *.zmak; do make -f $f; done
-cp /home/tim/codecreader/uqtreader*.desktop /opt/Qtopia/apps/Applications/
-cp /home/tim/codecreader/pics/* /opt/Qtopia/pics/opie-reader/
-cp /home/tim/codecreader/uqtreader*.desktop $QTDIR/apps/Applications/
-cp /home/tim/codecreader/opie-reader.desktop $QTDIR/apps/Applications/
-cp /home/tim/codecreader/pics/* $QTDIR/pics/opie-reader/
-cp HTMLentities $QTDIR/plugins/reader/data/
-rm $QTDIR/help/html/*reader*.html
-cp /home/tim/codecreader/help/*.html $QTDIR/help/html/
-rm -f $QTDIR/lib/libreader*.so
-rm -f $QTDIR/lib/libreader*.so.1
-for f in $QTDIR/lib/libreader*.1.0.0 ; do mv -f $f $QTDIR/lib/`basename $f .1.0.0`.1 ; done
-rm -f $QTDIR/lib/libreader*.so.1.*
-
-/home/tim/bin/zstrip.sh $QTDIR/bin/uqtreader
-for f in $QTDIR/lib/libreader* ; do /home/tim/bin/zstrip.sh $f; done
-
-for SUBDIR in codecs support filters
-do
- CDIR=$QTDIR/plugins/reader/$SUBDIR
- rm -f $CDIR/*.so
- for f in $CDIR/*.1.0.0 ; do mv -f $f $CDIR/`basename $f .1.0.0` ; done
- rm -f $CDIR/*.so.*
- for f in $CDIR/*.so ; do /home/tim/bin/zstrip.sh $f ; done
-done
-rm -f opie-reader_*.ipk
-rm -f full/opie-reader_*.ipk
-rm -f partial/opie-reader_*.ipk
-mkipks opie-reader.control
-cp opie-reader_*.ipk full/
-for f in opie-reader_*.ipk
- do
- cp $f full/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
-done
-rm $QTDIR/plugins/reader/support/libpluckerdecompress.so
-rm $QTDIR/plugins/reader/codecs/libArriereGo.so
-rm $QTDIR/plugins/reader/codecs/libNEF.so
-mkipks opie-reader.control
-cp opie-reader_*.ipk partial/
-for f in opie-reader_*.ipk
- do
- cp $f partial/`basename $f _arm.ipk`-`date +%y%m%d`_arm.ipk
-done
diff --git a/noncore/apps/opie-reader/usenef.h b/noncore/apps/opie-reader/usenef.h
deleted file mode 100644
index 57898cb..0000000
--- a/noncore/apps/opie-reader/usenef.h
+++ b/dev/null
@@ -1,6 +0,0 @@
-#ifndef __USENEF_H
-#define __USENEF_H
-
-//#define USENEF
-
-#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 @@
#include "util.h"
+#include <limits.h>
@@ -24,3 +25,11 @@ QString percent(unsigned long pos, unsigned long len)
{
- permil = (1000*pos+len/2)/len;
+ if (pos > UINT_MAX/1000)
+ {
+ unsigned long l1 = (len+500)/1000;
+ permil = (pos+l1/2)/l1;
+ }
+ else
+ {
+ permil = (1000*pos+len/2)/len;
+ }
}
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 @@
#include <qstring.h>
-#include <qdir.h>
-#include <stdlib.h>
@@ -10,48 +8,2 @@ QString percent(unsigned long pos, unsigned long len);
QString fmt(unsigned long pos, unsigned long len);
-
-/**
- * class with utility inline function(s)
- * (in contrast to global functions they become available by just
- * including util.h)
- */
-class QTReaderUtil
-{
- public:
-
- /**
- * searches for a specific direcory inside OpieReader installation
- *
- * @param subdir name of sub directory inside installation directory which is needed
- * @return full path name including that sub directory
- *
- * search order is (on all platforms):
- * - OPIEDIR
- * - QTDIR
- * - READERDIR
- */
- static QString getPluginPath( const char *subdir = "codecs/" )
- {
- QString dirname;
- dirname = getenv("OPIEDIR");
- dirname += "/plugins/reader/";
- dirname += subdir;
- if (QDir(dirname).exists())
- return dirname;
-
- dirname = getenv("QTDIR");
- dirname += "/plugins/reader/";
- dirname += subdir;
- if (QDir(dirname).exists())
- return dirname;
-
- dirname = getenv("READERDIR");
- dirname += "/";
- dirname += subdir;
- if (QDir(dirname).exists())
- return dirname;
-
- return "";
- }
-};
-
#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 @@
-bool CheckVersion(int& major, int& bkmktype, char& minor)
+#include <qmultilineedit.h>
+#include <qlayout.h>
+#include <qtextview.h>
+class versionbox : public QDialog
+{
+public:
+ versionbox(const QString& txt, QWidget* parent = NULL) : QDialog(parent, NULL, true)
+ {
+ setCaption(tr( "New Features" ));
+ QVBoxLayout* v = new QVBoxLayout(this);
+ /*
+ QMultiLineEdit* box = new QMultiLineEdit(this);
+ v->addWidget(box);
+ box->setReadOnly(true);
+ box->setWordWrap(QMultiLineEdit::WidgetWidth);
+ box->setText(txt);
+ */
+ QTextView* box = new QTextView(this);
+ v->addWidget(box);
+ box->setText(txt);
+#ifdef USEQPE
+ showMaximized();
+#endif
+ }
+};
+
+bool CheckVersion(int& major, int& bkmktype, char& minor, QWidget* pnt)
{
@@ -17,7 +43,14 @@ bool CheckVersion(int& major, int& bkmktype, char& minor)
minor = MINOR;
-
- QMessageBox::warning(NULL, PROGNAME,
- "New Features in this version\n\n\n"
- "Relative margin settings\n"
- "Cyrillic hyphenation");
+ versionbox v(
+ "<h2>New Features</h2>"
+ "<h3>Support for custom version of rbmake</h3>"
+ "<h3>Mini scrollbar now acts more like a QT scrollbar.</h3>"
+ "<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>"
+ "<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>"
+ "<p>The toolbar now stays hidden if you hide it.</p>"
+ "<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"
+ ,
+ pnt
+ );
+ v.exec();
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 @@
#define BKMKTYPE 7
-#define MINOR 'g'
+#define MINOR 'i'
#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)
{
+ unsuspend();
bufferrec = n / ntohs(hdr0.recordSize) + 1;
@@ -109,2 +110,3 @@ void ztxt::home()
{
+unsuspend();
if (bInit)
@@ -149,2 +151,3 @@ CList<Bkmk>* ztxt::getbkmklist()
CList<Bkmk>* t = new CList<Bkmk>;
+ unsuspend();
size_t cur = ftell(fin);