summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CFilter.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/CFilter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CFilter.cpp54
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,35 +1,35 @@
1#include <qmap.h> 1#include <qmap.h>
2#include <qfileinfo.h> 2#include <qfileinfo.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <qdir.h> 4#include <qdir.h>
5
5#ifdef USEQPE 6#ifdef USEQPE
6#include <qpe/global.h> 7#include <qpe/global.h>
7#endif 8#endif
8#include "CDrawBuffer.h" 9#include "CDrawBuffer.h"
9#include "CFilter.h" 10#include "CFilter.h"
10#include "hrule.h" 11#include "hrule.h"
11#include "util.h"
12 12
13#include <qregexp.h> 13#include <qregexp.h>
14#include <qimage.h> 14#include <qimage.h>
15#include <qpixmap.h> 15#include <qpixmap.h>
16//#include <qprogressdialog.h> 16//#include <qprogressdialog.h>
17//#include <qapplication.h> 17//#include <qapplication.h>
18 18
19void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) 19void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos)
20{ 20{
21 if (uselast) 21 if (uselast)
22 { 22 {
23 ch = lastchar; 23 ch = lastchar;
24 uselast = false; 24 uselast = false;
25 } 25 }
26 else 26 else
27 { 27 {
28 parent->getch(ch, sty, pos); 28 parent->getch(ch, sty, pos);
29 } 29 }
30} 30}
31 31
32void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) 32void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos)
33{ 33{
34 mygetch(ch, sty, pos); 34 mygetch(ch, sty, pos);
35 do 35 do
@@ -644,76 +644,85 @@ class ErrorFilter : public CFilter
644{ 644{
645 QString error; 645 QString error;
646 int currentpos; 646 int currentpos;
647 public: 647 public:
648 ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} 648 ErrorFilter(const QString& _s) : error(_s), currentpos(0) {}
649 ~ErrorFilter() {} 649 ~ErrorFilter() {}
650 void getch(tchar& ch, CStyle& sty, unsigned long& pos) 650 void getch(tchar& ch, CStyle& sty, unsigned long& pos)
651 { 651 {
652 if (currentpos == error.length()) 652 if (currentpos == error.length())
653 { 653 {
654 ch = UEOF; 654 ch = UEOF;
655 currentpos = 0; 655 currentpos = 0;
656 } 656 }
657 else 657 else
658 { 658 {
659 ch = error[currentpos++].unicode(); 659 ch = error[currentpos++].unicode();
660 } 660 }
661 } 661 }
662 QString about() { return parent->about(); } 662 QString about() { return parent->about(); }
663}; 663};
664 664
665#ifndef __STATIC 665#ifndef __STATIC
666ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) 666ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL)
667{ 667{
668 QString filterpath(QTReaderUtil::getPluginPath("filters")); 668#ifdef USEQPE
669 filterpath += "/lib"; 669#ifdef OPIE
670 QString filterpath(getenv("OPIEDIR"));
671#else
672 QString filterpath(getenv("QTDIR"));
673#endif
674 filterpath += "/plugins/reader/filters/lib";
675#else
676 QString filterpath(getenv("READERDIR"));
677 filterpath += "/filters/lib";
678#endif
670 filterpath += nm; 679 filterpath += nm;
671 filterpath += ".so"; 680 filterpath += ".so";
672 if (QFile::exists(filterpath)) 681 if (QFile::exists(filterpath))
673 { 682 {
674 qDebug("Filter:%s", (const char*)filterpath); 683 qDebug("Filter:%s", (const char*)filterpath);
675 handle = dlopen(filterpath, RTLD_LAZY); 684 handle = dlopen(filterpath, RTLD_LAZY);
676 if (handle == 0) 685 if (handle == 0)
677 { 686 {
678 qDebug("Can't find filter:%s", dlerror()); 687 qDebug("Can't find filter:%s", dlerror());
679 // status = -10; 688 // status = -10;
680 filt = new ErrorFilter(QString("Can't find plugin:")+nm); 689 filt = new ErrorFilter(QString("Can't find plugin:")+nm);
681 return; 690 return;
682 } 691 }
683 CFilter* (*newfilter)(const QString&); 692 CFilter* (*newfilter)(const QString&);
684 newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); 693 newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter");
685 if (newfilter == NULL) 694 if (newfilter == NULL)
686 { 695 {
687 qDebug("Can't find newfilter"); 696 qDebug("Can't find newfilter");
688 filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); 697 filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm);
689 return; 698 return;
690 } 699 }
691 filt = (*newfilter)(optional); 700 filt = (*newfilter)(optional);
692 } 701 }
693 else 702 else
694 { 703 {
695 qDebug("No filter path"); 704 qDebug("No filter path:%s", (const char*)filterpath);
696 filt = new ErrorFilter(QString("No filter plugins installed:")+nm); 705 filt = new ErrorFilter(QString("No filter plugins installed:")+nm);
697 } 706 }
698 if (filt == NULL) 707 if (filt == NULL)
699 { 708 {
700 qDebug("Can't do newfilter"); 709 qDebug("Can't do newfilter");
701 filt = new ErrorFilter(QString("Filter creation failed:")+nm); 710 filt = new ErrorFilter(QString("Filter creation failed:")+nm);
702 return; 711 return;
703 } 712 }
704} 713}
705#endif 714#endif
706 715
707void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) 716void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos)
708{ 717{
709 parent->getch(ch, sty, pos); 718 parent->getch(ch, sty, pos);
710 int r,g,b; 719 int r,g,b;
711 r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); 720 r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue();
712 sty.setColour(r,g,b); 721 sty.setColour(r,g,b);
713 r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); 722 r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue();
714 sty.setBackground(r,g,b); 723 sty.setBackground(r,g,b);
715 r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); 724 r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue();
716 sty.setPaper(r,g,b); 725 sty.setPaper(r,g,b);
717} 726}
718/* 727/*
719void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) 728void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos)
@@ -792,24 +801,61 @@ void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos)
792 } 801 }
793 } 802 }
794 ch = flt->pop(); 803 ch = flt->pop();
795 /* 804 /*
796 parent->getch(ch, sty, pos); 805 parent->getch(ch, sty, pos);
797 if (ch == 10 || ch == ' ') 806 if (ch == 10 || ch == ' ')
798 { 807 {
799 if (tch == 10) 808 if (tch == 10)
800 { 809 {
801 tch = ch; 810 tch = ch;
802 ch = 10; 811 ch = 10;
803 return; 812 return;
804 } 813 }
805 else 814 else
806 { 815 {
807 tch = ch; 816 tch = ch;
808 ch = ' '; 817 ch = ' ';
809 return; 818 return;
810 } 819 }
811 } 820 }
812 tch = ch; 821 tch = ch;
813 */ 822 */
814 return; 823 return;
815} 824}
825
826void tableLink::getch(tchar& ch, CStyle& sty, unsigned long& pos)
827{
828 if (offset >= (int)text.length())
829 {
830 offset = -1;
831 sty.setColour(m_r, m_g, m_b);
832 do
833 {
834 parent->getch(ch, sty, pos);
835 }
836 while (sty.isTable());
837 return;
838 }
839 if (offset >= 0)
840 {
841 ch = text[offset++].unicode();
842 return;
843 }
844 parent->getch(ch, sty, pos);
845 if (sty.isTable())
846 {
847 offset = 1;
848 ch = text[0].unicode();
849 m_r = sty.Red(), m_g = sty.Green(), m_b = sty.Blue();
850 sty.setColour(255, 0, 0);
851 }
852 return;
853}
854
855void underlineLink::getch(tchar& ch, CStyle& sty, unsigned long& pos)
856{
857 parent->getch(ch, sty, pos);
858 if (sty.getLink()) sty.setUnderline();
859 //if (isLink && !sty.getLink()) sty.unsetUnderline();
860 //isLink = sty.getLink();
861}