summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CFilter.h
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/CFilter.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CFilter.h289
1 files changed, 218 insertions, 71 deletions
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h
index 0a03b3e..cec9618 100644
--- a/noncore/apps/opie-reader/CFilter.h
+++ b/noncore/apps/opie-reader/CFilter.h
@@ -6,15 +6,49 @@
-class CFilter : public CCharacterSource
+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;
+};
+
+class CFilter : public CFilter_IFace
{
- friend class CFilterChain;
protected:
CCharacterSource* parent;
- linkType hyperlink(unsigned int n, QString& w)
+ public:
+ virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm)
{
- return parent->hyperlink(n,w);
+ return parent->hyperlink(n,noff,w,nm);
}
- public:
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); }
};
@@ -23,5 +57,5 @@ class CFilterChain
{
- CExpander* expander;
+ CExpander_Interface* expander;
CEncoding* encoder;
- CFilter* first;
+ CFilter_IFace* first;
CCharacterSource* front;
@@ -34,4 +68,4 @@ class CFilterChain
{
- CFilter* pnext = (CFilter*)p;
- p = ((CFilter*)p)->parent;
+ CFilter_IFace* pnext = (CFilter_IFace*)p;
+ p = ((CFilter_IFace*)p)->getparent();
delete pnext;
@@ -40,7 +74,15 @@ class CFilterChain
}
- void getch(tchar& ch, CStyle& sty)
+ linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm)
+ {
+ return front->hyperlink(n, noff, wrd, nm);
+ }
+ void locate(unsigned int n)
+ {
+ front->locate(n);
+ }
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
- front->getch(ch, sty);
+ front->getch(ch, sty, pos);
}
- void addfilter(CFilter* p)
+ void addfilter(CFilter_IFace* p)
{
@@ -57,3 +99,3 @@ class CFilterChain
}
- void setsource(CExpander* p)
+ void setsource(CExpander_Interface* p)
{
@@ -69,2 +111,12 @@ class CFilterChain
}
+ 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(); }
};
@@ -76,3 +128,3 @@ class stripcr : public CFilter
~stripcr() {}
- void getch(tchar& ch, CStyle& sty)
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
@@ -80,3 +132,3 @@ class stripcr : public CFilter
{
- parent->getch(ch, sty);
+ parent->getch(ch, sty, pos);
}
@@ -84,2 +136,3 @@ class stripcr : public CFilter
}
+ QString about() { return QString("StripCR filter (c) Tim Wentford\n")+parent->about(); }
};
@@ -94,3 +147,3 @@ class dehyphen : public CFilter
~dehyphen() {}
- void getch(tchar& ch, CStyle& sty)
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
@@ -103,5 +156,5 @@ class dehyphen : public CFilter
}
- parent->getch(ch, sty);
+ parent->getch(ch, sty, pos);
if (ch != '-') return;
- parent->getch(m_nextChar, m_nextSty);
+ parent->getch(m_nextChar, m_nextSty, pos);
if (m_nextChar != 10)
@@ -112,17 +165,20 @@ class dehyphen : public CFilter
}
- parent->getch(ch, sty);
+ parent->getch(ch, sty, pos);
}
+ QString about() { return QString("Hyphenation filter (c) Tim Wentford\n")+parent->about(); }
};
-class striphtml : public CFilter
+template<class A, class B>class QMap;
+
+const int m_cmaxdepth = 8;
+
+class htmlmark
{
- CStyle currentstyle;
- unsigned short skip_ws();
- unsigned short skip_ws_end();
- unsigned short parse_m();
- void mygetch(tchar& ch, CStyle& sty);
+ QString file;
+ size_t pos;
public:
- striphtml() {}
- ~striphtml() {}
- void getch(tchar& ch, CStyle& sty);
+ htmlmark() : file(), pos(0) {}
+ htmlmark(const QString& _f, size_t _p) : file(_f), pos(_p) {}
+ QString filename() { return file; }
+ size_t posn() { return pos; }
};
@@ -135,3 +191,3 @@ class unindent : public CFilter
~unindent() {}
- void getch(tchar& ch, CStyle& sty)
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
@@ -141,3 +197,3 @@ class unindent : public CFilter
{
- parent->getch(ch, sty);
+ parent->getch(ch, sty, pos);
}
@@ -145,3 +201,3 @@ class unindent : public CFilter
}
- else parent->getch(ch, sty);
+ else parent->getch(ch, sty, pos);
lc = ch;
@@ -149,4 +205,6 @@ class unindent : public CFilter
}
+ QString about() { return QString("Unindent filter (c) Tim Wentford\n")+parent->about(); }
};
+class CRegExpFilt;
class repara : public CFilter
@@ -154,24 +212,8 @@ class repara : public CFilter
tchar tch;
+ CRegExpFilt* flt;
public:
- repara() : tch(0) {}
- ~repara() {}
- void getch(tchar& ch, CStyle& sty)
- {
- parent->getch(ch, sty);
- if (ch == 10)
- {
- if (tch == 10)
- {
- return;
- }
- else
- {
- tch = ch;
- ch = ' ';
- return;
- }
- }
- tch = ch;
- return;
- }
+ repara(const QString&);
+ ~repara();
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos);
+ QString about() { return QString("Reparagraph filter (c) Tim Wentford\n")+parent->about(); }
};
@@ -186,3 +228,3 @@ class indenter : public CFilter
~indenter() {}
- void getch(tchar& ch, CStyle& sty)
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
@@ -195,3 +237,3 @@ class indenter : public CFilter
}
- parent->getch(ch, sty);
+ parent->getch(ch, sty, pos);
if (ch == 10)
@@ -203,2 +245,3 @@ class indenter : public CFilter
}
+ QString about() { return QString("Indentation filter (c) Tim Wentford\n")+parent->about(); }
};
@@ -212,3 +255,3 @@ class dblspce : public CFilter
~dblspce() {}
- void getch(tchar& ch, CStyle& sty)
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
@@ -221,3 +264,3 @@ class dblspce : public CFilter
}
- parent->getch(ch, sty);
+ parent->getch(ch, sty, pos);
if (lastlf = (ch == 10))
@@ -228,2 +271,3 @@ class dblspce : public CFilter
}
+ QString about() { return QString("Double space (c) Tim Wentford\n")+parent->about(); }
};
@@ -235,3 +279,3 @@ class textfmt : public CFilter
bool uselast;
- void mygetch(tchar&, CStyle&);
+ void mygetch(tchar&, CStyle&, unsigned long& pos);
public:
@@ -239,3 +283,4 @@ class textfmt : public CFilter
~textfmt() {}
- void getch(tchar& ch, CStyle& sty);
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos);
+ QString about() { return QString("Text formatting filter (c) Tim Wentford\n")+parent->about(); }
};
@@ -247,7 +292,8 @@ class embolden : public CFilter
~embolden() {}
- void getch(tchar& ch, CStyle& sty)
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
- parent->getch(ch, sty);
+ parent->getch(ch, sty, pos);
sty.setBold();
}
+ QString about() { return QString("Emboldening filter (c) Tim Wentford\n")+parent->about(); }
};
@@ -262,3 +308,4 @@ class remap : public CFilter
~remap() {}
- void getch(tchar& ch, CStyle& sty);
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos);
+ QString about() { return QString("Character remapping filter (c) Tim Wentford\n")+parent->about(); }
};
@@ -270,3 +317,4 @@ class PeanutFormatter : public CFilter
~PeanutFormatter() {}
- void getch(tchar& ch, CStyle& sty);
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos);
+ QString about() { return QString("PML filter (c) Tim Wentford\n")+parent->about(); }
};
@@ -279,3 +327,4 @@ class OnePara : public CFilter
~OnePara() {}
- void getch(tchar& ch, CStyle& sty);
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos);
+ QString about() { return QString("Single space filter (c) Tim Wentford\n")+parent->about(); }
};
@@ -293,6 +342,6 @@ class DePluck : public CFilter
~DePluck() {}
- void getch(tchar& ch, CStyle& sty);
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos);
+ QString about() { return QString("Depluck filter (c) Tim Wentford\n")+parent->about(); }
};
-#ifdef REPALM
class repalm : public CFilter
@@ -301,5 +350,5 @@ class repalm : public CFilter
~repalm() {}
- void getch(tchar& ch, CStyle& sty);
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos);
+ QString about() { return QString("Repalm filter (c) Tim Wentford\n")+parent->about(); }
};
-#endif
@@ -308,7 +357,8 @@ class FullJust : public CFilter
public:
- void getch(tchar& ch, CStyle& sty)
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
- parent->getch(ch, sty);
+ 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(); }
};
@@ -320,5 +370,5 @@ class AddSpace : public CFilter
AddSpace(unsigned char s) : m_espc(s) {}
- void getch(tchar& ch, CStyle& sty)
+ void getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
- parent->getch(ch, sty);
+ parent->getch(ch, sty, pos);
sty.setExtraSpace(m_espc);
@@ -327,2 +377,99 @@ class AddSpace : public CFilter
*/
+
+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(); }
+};
+
+#include "static.h"
+#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);
+ }
+ 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); }
+ 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); }
+ QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); }
+};
+#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(); }
+};
+
#endif