Diffstat (limited to 'noncore/apps/opie-reader/CFilter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CFilter.cpp | 54 |
1 files changed, 50 insertions, 4 deletions
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 @@ -1,59 +1,59 @@ #include <qmap.h> #include <qfileinfo.h> #include <qtextstream.h> #include <qdir.h> + #ifdef USEQPE #include <qpe/global.h> #endif #include "CDrawBuffer.h" #include "CFilter.h" #include "hrule.h" -#include "util.h" #include <qregexp.h> #include <qimage.h> #include <qpixmap.h> //#include <qprogressdialog.h> //#include <qapplication.h> void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) { if (uselast) { ch = lastchar; uselast = false; } else { parent->getch(ch, sty, pos); } } void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) { mygetch(ch, sty, pos); do { sty = currentstyle; switch (ch) { case 10: currentstyle.unset(); sty = currentstyle; break; // Use this if you want to replace -- by em-dash case '-': // parent->getch(ch, sty); mygetch(ch, sty, pos); if (ch == '-') { ch = 0x2014; } else { lastchar = ch; uselast = true; ch = '-'; } break; case '*': @@ -620,124 +620,133 @@ void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) tchar savedchar = 'f'; parent->getch(ch, sty, pos); switch (ch) { case 'i': ch = (251 << 8) + 1; break; case 'l': ch = (251 << 8) + 2; break; default: lastchar = ch; uselast = true; laststy = sty; ch = savedchar; } } break; default: break; } } class ErrorFilter : public CFilter { QString error; int currentpos; public: ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} ~ErrorFilter() {} void getch(tchar& ch, CStyle& sty, unsigned long& pos) { if (currentpos == error.length()) { ch = UEOF; currentpos = 0; } else { ch = error[currentpos++].unicode(); } } QString about() { return parent->about(); } }; #ifndef __STATIC ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) { - 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; filterpath += ".so"; if (QFile::exists(filterpath)) { qDebug("Filter:%s", (const char*)filterpath); handle = dlopen(filterpath, RTLD_LAZY); if (handle == 0) { qDebug("Can't find filter:%s", dlerror()); // status = -10; filt = new ErrorFilter(QString("Can't find plugin:")+nm); return; } CFilter* (*newfilter)(const QString&); newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); if (newfilter == NULL) { qDebug("Can't find newfilter"); filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); return; } filt = (*newfilter)(optional); } else { - qDebug("No filter path"); + qDebug("No filter path:%s", (const char*)filterpath); filt = new ErrorFilter(QString("No filter plugins installed:")+nm); } if (filt == NULL) { qDebug("Can't do newfilter"); filt = new ErrorFilter(QString("Filter creation failed:")+nm); return; } } #endif void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) { parent->getch(ch, sty, pos); int r,g,b; r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); sty.setColour(r,g,b); r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); sty.setBackground(r,g,b); r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); sty.setPaper(r,g,b); } /* void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) { parent->getch(ch, sty, pos); QColor fg(sty.Red(), sty.Green(), sty.Blue()); int h,s,v; fg.hsv(&h,&s,&v); fg.setHsv(h,s,255-v); int r,g,b; fg.rgb(&r,&g,&b); sty.setColour(r,g,b); fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); fg.hsv(&h,&s,&v); fg.setHsv(h,s,255-v); fg.rgb(&r,&g,&b); sty.setBackground(r,g,b); } */ void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) { parent->getch(ch, sty, pos); int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); if (r == 255 && g == 255 && b == 255) { sty.setPaper(m_r,m_g,m_b); @@ -768,48 +777,85 @@ void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) } #include "CRegExp.h" repara::repara(const QString& pat) : tch(0) { // QString pat("{\\n[A-Z\"]}"); flt = new CRegExpFilt(pat, false); qDebug("Construction done"); } repara::~repara() { delete flt; } void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos) { if (flt->empty()) { while (flt->empty()) { parent->getch(ch, sty, pos); flt->addch(ch); } } ch = flt->pop(); /* parent->getch(ch, sty, pos); if (ch == 10 || ch == ' ') { if (tch == 10) { tch = ch; ch = 10; return; } else { tch = ch; ch = ' '; return; } } tch = ch; */ return; } + +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(); +} |