Diffstat (limited to 'noncore/apps/opie-reader/CFilter.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CFilter.h | 55 |
1 files changed, 52 insertions, 3 deletions
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 @@ -1,134 +1,151 @@ #ifndef __CFILTER_H #define __CFILTER_H #include "CExpander.h" #include "CEncoding.h" class CFilter_IFace : public CCharacterSource { public: virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) = 0; virtual void setparent(CCharacterSource* p) = 0; virtual ~CFilter_IFace() {}; virtual void locate(unsigned int n) = 0; virtual bool findanchor(const QString& nm) = 0; virtual void saveposn(const QString& f, size_t posn) = 0; virtual void writeposn(const QString& f, size_t posn) = 0; virtual linkType forward(QString& f, size_t& loc) = 0; virtual linkType back(QString& f, size_t& loc) = 0; virtual bool hasnavigation() = 0; virtual int getwidth() = 0; virtual CCharacterSource* getparent() = 0; + virtual unsigned long startSection() = 0; }; class CFilter : public CFilter_IFace { protected: CCharacterSource* parent; 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) { return parent->hyperlink(n,noff,w,nm); } CFilter() : parent(NULL) {} void setparent(CCharacterSource* p) { parent = p; } CCharacterSource* getparent() { return parent; } virtual ~CFilter() {}; virtual void locate(unsigned int n) { parent->locate(n); } virtual bool findanchor(const QString& nm) { return parent->findanchor(nm); } virtual void saveposn(const QString& f, size_t posn) { parent->saveposn(f, posn); } virtual void writeposn(const QString& f, size_t posn) { parent->writeposn(f, posn); } virtual linkType forward(QString& f, size_t& loc) { return parent->forward(f, loc); } virtual linkType back(QString& f, size_t& loc) { return parent->back(f, loc); } virtual bool hasnavigation() { return parent->hasnavigation(); } virtual int getwidth() { return parent->getwidth(); } QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } 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(); } }; class CFilterChain { CExpander_Interface* expander; CEncoding* encoder; CFilter_IFace* first; CCharacterSource* front; public: CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; ~CFilterChain() { CCharacterSource* p = front; while (p != encoder) { CFilter_IFace* pnext = (CFilter_IFace*)p; p = ((CFilter_IFace*)p)->getparent(); delete pnext; } delete encoder; } linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) { return front->hyperlink(n, noff, wrd, nm); } + QString getTableAsHtml(unsigned long loc) + { + return front->getTableAsHtml(loc); + } void locate(unsigned int n) { front->locate(n); } void getch(tchar& ch, CStyle& sty, unsigned long& pos) { front->getch(ch, sty, pos); } + /* + void rawgetch(tchar& ch, CStyle& sty, unsigned long& pos) + { + encoder->getch(ch, sty, pos); + } + */ void addfilter(CFilter_IFace* p) { if (first == NULL) { front = first = p; p->setparent(encoder); } else { p->setparent(front); front = p; } } void setsource(CExpander_Interface* p) { expander = p; encoder->setparent(p); } void setencoder(CEncoding* p) { delete encoder; encoder = p; first->setparent(p); encoder->setparent(expander); } bool findanchor(const QString& nm) { return front->findanchor(nm); } void saveposn(const QString& f, size_t posn) { front->saveposn(f, posn); } void writeposn(const QString& f, size_t posn) { front->writeposn(f, posn); } linkType forward(QString& f, size_t& loc) { return front->forward(f, loc); } linkType back(QString& f, size_t& loc) { return front->back(f, loc); } bool hasnavigation() { return front->hasnavigation(); } QString about() { return QString("Filter chain (c) Tim Wentford\n")+front->about(); } }; class stripcr : public CFilter { public: stripcr() {} ~stripcr() {} void getch(tchar& ch, CStyle& sty, unsigned long& pos) { do { parent->getch(ch, sty, pos); } @@ -358,117 +375,149 @@ class FullJust : public CFilter void getch(tchar& ch, CStyle& sty, unsigned long& pos) { parent->getch(ch, sty, pos); if (sty.getJustify() == m_AlignLeft) sty.setFullJustify(); } QString about() { return QString("Full justification filter (c) Tim Wentford\n")+parent->about(); } }; /* class AddSpace : public CFilter { unsigned char m_espc; public: AddSpace(unsigned char s) : m_espc(s) {} void getch(tchar& ch, CStyle& sty, unsigned long& pos) { parent->getch(ch, sty, pos); sty.setExtraSpace(m_espc); } }; */ class QTReader; class HighlightFilter : public CFilter { QTReader* pReader; unsigned long lastpos, nextpos; unsigned char red, green, blue; CList<Bkmk>* bkmks; public: HighlightFilter(QTReader*); void getch(tchar& ch, CStyle& sty, unsigned long& pos); void refresh(unsigned long); QString about() { return QString("High-lighting filter (c) Tim Wentford\n")+parent->about(); } }; #ifndef __STATIC #include <dlfcn.h> class ExternFilter : public CFilter_IFace { CFilter* filt; void *handle; public: linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) { return filt->hyperlink(n, noff, w, nm); } + QString getTableAsHtml(unsigned long loc) + { + qDebug("ExternFilter::getTableAsHtml()"); + return filt->getTableAsHtml(loc); + } void setparent(CCharacterSource* p) { filt->setparent(p); } ExternFilter(const QString& nm, const QString& optional); ~ExternFilter() { if (filt != NULL) delete filt; if (handle != NULL) dlclose(handle); } 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); } void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } bool hasnavigation() { return filt->hasnavigation(); } int getwidth() { return filt->getwidth(); } CCharacterSource* getparent() { return filt->getparent(); } void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } CFilter* filter() { return filt; } 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(); } }; #endif class kern : public CFilter { tchar lastchar; bool uselast; CStyle laststy; public: kern() : lastchar(0), uselast(false) {} ~kern() {} void getch(tchar& ch, CStyle& sty, unsigned long& pos); QString about() { return QString("Kerning filter (c) Tim Wentford\n")+parent->about(); } }; class makeInverse : public CFilter { public: void getch(tchar& ch, CStyle& sty, unsigned long& pos); QString about() { return QString("Colourmap inversion filter (c) Tim Wentford\n")+parent->about(); } }; /* class makeNegative : public CFilter { public: void getch(tchar& ch, CStyle& sty, unsigned long& pos); }; */ class setbg : public CFilter { int m_r, m_g, m_b; public: setbg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} void getch(tchar& ch, CStyle& sty, unsigned long& pos); QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } }; class setfg : public CFilter { int m_r, m_g, m_b; public: setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} void getch(tchar& ch, CStyle& sty, unsigned long& pos); QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } }; +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 |