summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/plucker_base.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/plucker_base.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/plucker_base.cpp448
1 files changed, 308 insertions, 140 deletions
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp
index b523a54..0b7fae8 100644
--- a/noncore/apps/opie-reader/plucker_base.cpp
+++ b/noncore/apps/opie-reader/plucker_base.cpp
@@ -1,16 +1,18 @@
-
-
#include "useqpe.h"
-#include "plucker_base.h"
-#include "Aportis.h"
-#include "Palm2QImage.h"
-
-/* OPIE */
-#include <opie2/odebug.h>
+#include "usenef.h"
+#include <stdio.h>
+#include <string.h>
+#include <qmessagebox.h>
+#include <qpixmap.h>
#ifdef USEQPE
#include <qpe/qcopenvelope_qws.h>
+#endif /* USEQPE */
+#ifdef LOCALPICTURES
+#include <qscrollview.h>
+#endif
+#ifdef USEQPE
#include <qpe/global.h>
#endif /* USEQPE */
-
+#include <qclipboard.h>
#ifndef USEQPE
#include <qapplication.h>
@@ -18,14 +20,13 @@
#include <qpe/qpeapplication.h>
#endif /* USEQPE */
+#include <qimage.h>
-/* QT */
-#ifdef LOCALPICTURES
-#include <qscrollview.h>
-#endif
-
-/* STD */
-#include <stdio.h>
-#include <string.h>
+#include "static.h"
+#include "plucker_base.h"
+#include "Aportis.h"
+#include "hrule.h"
+#include "util.h"
+const UInt8 CPlucker_base::continuation_bit = 1;
CPlucker_base::CPlucker_base() :
@@ -35,5 +36,7 @@ CPlucker_base::CPlucker_base() :
#endif
expandedtextbuffer(NULL),
- compressedtextbuffer(NULL)
+ compressedtextbuffer(NULL),
+ bufferrec(-1),
+ m_offset(0)
//, urls(NULL)
{ /*printf("constructing:%x\n",fin);*/ }
@@ -60,13 +63,5 @@ void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buff
{
fread(readbuffer, reclen, sizeof(char), fin);
- switch (ntohs(hdr0.version))
- {
- case 2:
- UnZip(readbuffer, reclen, buffer, buffersize);
- break;
- case 1:
- UnDoc(readbuffer, reclen, buffer, buffersize);
- break;
- }
+ (*m_decompress)(readbuffer, reclen, buffer, buffersize);
if (reclen > compressedbuffersize)
{
@@ -102,5 +97,5 @@ char* CPlucker_base::geturl(UInt16 tgt)
fread(&hdr0, 1, 6, fin);
unsigned int nrecs = ntohs(hdr0.nRecords);
- //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl;
+ //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs);
UInt16 urlid = 0;
bool urlsfound = false;
@@ -112,12 +107,12 @@ char* CPlucker_base::geturl(UInt16 tgt)
fread(&name, 1, sizeof(name), fin);
fread(&id, 1, sizeof(id), fin);
- //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl;
+ //qDebug("N:%d, I:%d", ntohs(name), ntohs(id));
if (ntohs(name) == 2)
{
urlsfound = true;
urlid = id;
- //odebug << "Found url index:" << ntohs(urlid) << "" << oendl;
+ //qDebug("Found url index:%d", ntohs(urlid));
}
-// //odebug << "" << id << "" << oendl;
+ // //qDebug("%x", id);
}
if (urlsfound)
@@ -138,5 +133,5 @@ char* CPlucker_base::geturl(UInt16 tgt)
fread(&urlid, 1, sizeof(urlid), fin);
tctr = ntohs(tctr);
- //odebug << "tgt:" << tgt << " urlctr:" << urlctr << " tctr:" << tctr << "" << oendl;
+ //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr);
if (tctr >= tgt)
{
@@ -145,5 +140,5 @@ char* CPlucker_base::geturl(UInt16 tgt)
urlctr = tctr;
}
- //odebug << "urls are in " << ntohs(urlid) << "" << oendl;
+ //qDebug("urls are in %d", ntohs(urlid));
recptr = finduid(ntohs(urlid));
if (recptr != 0)
@@ -152,5 +147,5 @@ char* CPlucker_base::geturl(UInt16 tgt)
gotorecordnumber(recptr);
GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
- //odebug << "Found urls:" << thishdr_type << "" << oendl;
+ //qDebug("Found urls:%x",thishdr_type);
urlsize = thishdr_size;
urls = new char[urlsize];
@@ -162,5 +157,5 @@ char* CPlucker_base::geturl(UInt16 tgt)
if (rn == tgt)
{
- //odebug << "URL:" << ptr << "" << oendl;
+ //qDebug("URL:%s", ptr);
int len = strlen(ptr)+1;
pRet = new char[len];
@@ -177,8 +172,5 @@ char* CPlucker_base::geturl(UInt16 tgt)
else
{
- QMessageBox::information(NULL,
- QString(PROGNAME),
- QString("No external links\nin this pluck")
- );
+ pRet = NULL;
}
return pRet;
@@ -196,6 +188,7 @@ CPlucker_base::~CPlucker_base()
int CPlucker_base::getch() { return getch(false); }
-void CPlucker_base::getch(tchar& ch, CStyle& sty)
+void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos)
{
+ pos = locate();
ch = getch(false);
sty = mystyle;
@@ -227,4 +220,13 @@ void CPlucker_base::locate(unsigned int n)
// clock_t start = clock();
+ if (n >= currentpos-bufferpos && n < currentpos - bufferpos + buffercontent)
+ {
+ currentpos -= bufferpos;
+ expand(bufferrec);
+ while (currentpos < n && bufferpos < buffercontent) getch_base(true);
+ return;
+ }
+ /*
+
UInt32 textlength = currentpos - bufferpos;
UInt16 recptr = bufferrec;
@@ -259,5 +261,5 @@ void CPlucker_base::locate(unsigned int n)
recptr--;
gotorecordnumber(recptr);
- //odebug << "recptr:" << recptr << "" << oendl;
+ //qDebug("recptr:%u", recptr);
GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
if (thishdr_type < 2)
@@ -284,28 +286,6 @@ void CPlucker_base::locate(unsigned int n)
}
}
-// odebug << "Time(1): " << clock()-start << "" << oendl;
-/*
- expand(recptr);
- mystyle.unset();
- bufferpos = n-textlength;
- currentpos = n;
- while (bufferpos >= m_nextPara && m_nextPara >= 0)
- {
- UInt16 attr = m_ParaAttrs[m_nextParaIndex];
- m_nextParaIndex++;
- if (m_nextParaIndex == m_nParas)
- {
- m_nextPara = -1;
- }
- else
- {
- m_nextPara += m_ParaOffsets[m_nextParaIndex];
- }
- }
- return;
*/
-// start = clock();
-
UInt16 thisrec = 0;
unsigned long locpos = 0;
@@ -330,8 +310,9 @@ void CPlucker_base::locate(unsigned int n)
} while (locpos + bs <= n);
-// odebug << "Time(2): " << clock()-start << "" << oendl;
+ // qDebug("Time(2): %u", clock()-start);
+ /*
if (recptr != thisrec)
{
- odebug << "Disaster:recptr:" << recptr << " thisrec:" << thisrec << "" << oendl;
+ qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec);
UInt16 thishdr_uid, thishdr_nParagraphs;
UInt32 thishdr_size = buffercontent;
@@ -341,9 +322,9 @@ void CPlucker_base::locate(unsigned int n)
gotorecordnumber(recptr);
GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
-// odebug << "UID:" << thishdr_uid << " Paras:" << thishdr_nParagraphs << " Size:" << thishdr_size << " Type:" << (unsigned int)thishdr_type << " Reserved:" << (unsigned int)thishdr_reserved << "" << oendl;
+ // qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", thishdr_uid, thishdr_nParagraphs, thishdr_size, (unsigned int)thishdr_type, (unsigned int)thishdr_reserved);
}
// QApplication::exit ( 100 );
}
-
+ */
currentpos = locpos;
expand(thisrec);
@@ -372,4 +353,6 @@ bool CPlucker_base::expand(int thisrec)
{
mystyle.unset();
+ if (bufferrec != thisrec)
+ {
size_t reclen = recordlength(thisrec);
gotorecordnumber(thisrec);
@@ -380,7 +363,7 @@ bool CPlucker_base::expand(int thisrec)
{
GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
- //odebug << "This (" << thisrec << ") type is " << thishdr_type << ", uid is " << thishdr_uid << "" << oendl;
+ //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid);
if (thishdr_type < 2) break;
- //odebug << "Skipping paragraph of type " << thishdr_type << "" << oendl;
+ //qDebug("Skipping paragraph of type %d", thishdr_type);
if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false;
reclen = recordlength(thisrec);
@@ -389,5 +372,5 @@ bool CPlucker_base::expand(int thisrec)
m_nParas = thishdr_nParagraphs;
m_bufferisreserved = (thishdr_reserved != 0);
- //odebug << "It has " << thishdr_nParagraphs << " paragraphs and is " << thishdr_size << " bytes" << oendl;
+ //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size);
uid = thishdr_uid;
// gotorecordnumber(thisrec);
@@ -400,15 +383,5 @@ bool CPlucker_base::expand(int thisrec)
m_ParaOffsets[i] = ntohs(ubytes);
m_ParaAttrs[i] = ntohs(attrs);
-// //odebug << "Bytes " << ntohs(ubytes) << ", Attr " << ntohs(attrs) << "" << oendl;
- }
- if (m_nParas > 0)
- {
- m_nextPara = m_ParaOffsets[0];
- //odebug << "First offset = " << m_nextPara << "" << oendl;
- m_nextParaIndex = 0;
- }
- else
- {
- m_nextPara = -1;
+ // //qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs));
}
@@ -423,9 +396,21 @@ bool CPlucker_base::expand(int thisrec)
expandedtextbuffer = new UInt8[buffersize];
}
-
Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent);
- bufferpos = 0;
bufferrec = thisrec;
- //odebug << "BC:" << buffercontent << ", HS:" << thishdr_size << "" << oendl;
+ }
+
+
+ if (m_nParas > 0)
+ {
+ m_nextPara = m_ParaOffsets[0];
+ //qDebug("First offset = %u", m_nextPara);
+ m_nextParaIndex = 0;
+ }
+ else
+ {
+ m_nextPara = -1;
+ }
+ bufferpos = 0;
+ //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size);
return true;
}
@@ -461,5 +446,5 @@ void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff
err = inflate( &zstream, Z_SYNC_FLUSH );
-// //odebug << "err:" << err << " - " << zstream.avail_in << "" << oendl;
+ // //qDebug("err:%d - %u", err, zstream.avail_in);
} while ( err == Z_OK );
@@ -543,7 +528,7 @@ CList<Bkmk>* CPlucker_base::getbkmklist()
fread(&n, 1, sizeof(n), fin);
n = ntohs(n);
- //odebug << "Found " << n << " bookmarks" << oendl;
+ //qDebug("Found %u bookmarks", n);
}
- //odebug << "Found:" << i << ", " << thishdr_type << "" << oendl;
+ //qDebug("Found:%d, %u", i , thishdr_type);
}
*/
@@ -551,4 +536,5 @@ CList<Bkmk>* CPlucker_base::getbkmklist()
}
+#include <qnamespace.h>
QImage* CPlucker_base::expandimg(UInt16 tgt, bool border)
@@ -601,5 +587,5 @@ QImage* CPlucker_base::getPicture(unsigned long tgt)
void CPlucker_base::showimg(UInt16 tgt)
{
- //odebug << "Crassssssh!" << oendl;
+ //qDebug("Crassssssh!");
QPixmap* qimage = expandimg(tgt);
m_picture->setFixedSize(qimage->size());
@@ -612,5 +598,5 @@ void CPlucker_base::showimg(UInt16 tgt)
QImage* qimage = getimg(tgt);
QPixmap* image = new QPixmap(0,0);
-// //odebug << "New image" << oendl;
+ // //qDebug("New image");
image->convertFromImage(*qimage);
delete qimage;
@@ -619,5 +605,5 @@ void CPlucker_base::showimg(UInt16 tgt)
int f = mkstemp(tmpfile);
close(f);
- //odebug << "TMPFILE:" << tmpfile << "" << oendl;
+ //qDebug("TMPFILE:%s", tmpfile);
if (image->save(tmpfile,"PNG"))
{
@@ -636,5 +622,5 @@ void CPlucker_base::showimg(UInt16 tgt)
unsigned short CPlucker_base::finduid(unsigned short urlid)
{
-// //odebug << "Finding " << urlid << "" << oendl;
+ // //qDebug("Finding %u", urlid);
unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords);
unsigned short jmid = (jmin+jmax) >> 1;
@@ -647,5 +633,5 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
unsigned short luid = thishdr_uid;
-// //odebug << "" << jmin << " " << jmid << " " << jmax << " : " << urlid << "" << oendl;
+ // //qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid);
if (luid == urlid)
{
@@ -668,5 +654,5 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
unsigned short luid = thishdr_uid;
- //odebug << "jmin at end:" << jmin << "," << luid << "" << oendl;
+ //qDebug("jmin at end:%u,%u", jmin, luid);
if (luid == urlid)
{
@@ -676,13 +662,14 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
luid = thishdr_uid;
- //odebug << "jmax at end:" << jmax << "," << luid << "" << oendl;
+ //qDebug("jmax at end:%u,%u", jmax, luid);
if (luid == urlid)
{
return jmax;
}
- //odebug << "Couldn't find " << urlid << "" << oendl;
+ //qDebug("Couldn't find %u", urlid);
return 0; // Not found!
}
+#include <qnamespace.h>
void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
@@ -707,5 +694,5 @@ void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsig
{
unsigned long t = *it;
-// odebug << "[" << t << "]" << oendl;
+ // qDebug("[%u]", t);
memcpy(newdata, &t, sizeof(t));
newdata += sizeof(t);
@@ -730,5 +717,5 @@ void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen)
{
memcpy(&t, src, sizeof(t));
-// odebug << "[" << t << "]" << oendl;
+ // qDebug("[%u]", t);
visited.push_front(t);
src += sizeof(t);
@@ -746,6 +733,7 @@ void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen)
int CPlucker_base::OpenFile(const char *src)
{
+ qDebug("plucker openfile:%s", src);
m_lastBreak = 0;
- if (!Cpdb::openfile(src))
+ if (!Cpdb::openpdbfile(src))
{
return -1;
@@ -756,12 +744,36 @@ int CPlucker_base::OpenFile(const char *src)
gotorecordnumber(0);
fread(&hdr0, 1, 6, fin);
+ qDebug("Compression type:%u", ntohs(hdr0.version));
+
+
+ switch (ntohs(hdr0.version))
+ {
+ case 2:
+ m_decompress = UnZip;
+ break;
+ case 1:
+ m_decompress = UnDoc;
+ break;
+#ifdef USENEF
+ case 3:
+ m_decompress = getdecompressor("PluckerDecompress3");
+ break;
+ case 4:
+ m_decompress = getdecompressor("PluckerDecompress4");
+ break;
+#endif
+ default:
+ m_decompress = NULL;
+ }
+ if (m_decompress == NULL) return -1;
+
setbuffersize();
compressedtextbuffer = new UInt8[compressedbuffersize];
expandedtextbuffer = new UInt8[buffersize];
- //odebug << "Total number of records:" << ntohs(head.recordList.numRecords) << "" << oendl;
-
unsigned int nrecs = ntohs(hdr0.nRecords);
- //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl;
+ qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs);
+ textlength = ntohl(head.sortInfoID);
+ qDebug("Textlength at startup:%u", textlength);
UInt16 homerecid = 1;
for (unsigned int i = 0; i < nrecs; i++)
@@ -770,5 +782,5 @@ int CPlucker_base::OpenFile(const char *src)
fread(&name, 1, sizeof(name), fin);
fread(&id, 1, sizeof(id), fin);
- //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl;
+ //qDebug("N:%d, I:%d", ntohs(name), ntohs(id));
if (ntohs(name) == 0) homerecid = ntohs(id);
}
@@ -789,6 +801,8 @@ int CPlucker_base::OpenFile(const char *src)
if (thishdr_type < 2) textlength += thishdr_size;
}
+ qDebug("Found home");
textlength = 0;
home();
+ qDebug("Gone home");
#ifdef LOCALPICTURES
if (m_viewer == NULL)
@@ -807,4 +821,5 @@ QImage* CPlucker_base::getimg(UInt16 tgt)
size_t reclen;
UInt16 thisrec = finduid(tgt);
+ qDebug("getimg:Found %u from uid:%u", thisrec, tgt);
reclen = recordlength(thisrec);
gotorecordnumber(thisrec);
@@ -813,4 +828,78 @@ QImage* CPlucker_base::getimg(UInt16 tgt)
UInt8 thishdr_type, thishdr_reserved;
GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
+ if (thishdr_type == 15)
+ {
+ char *buffer = new char[thishdr_size];
+ fread(buffer, thishdr_size, sizeof(char), fin);
+ unsigned short tmp;
+ memcpy(&tmp, buffer, sizeof(tmp));
+ unsigned short cols = ntohs(tmp);
+ memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp));
+ unsigned short rows = ntohs(tmp);
+ qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols);
+ QImage*** images;
+ images = new QImage**[rows];
+#ifdef _WINDOWS
+ int i;
+ for (i = 0; i < rows; i++)
+#else
+ for (int i = 0; i < rows; i++)
+#endif
+ {
+ images[i] = new QImage*[cols];
+ }
+ int height = 0;
+ int width = 0;
+#ifdef _WINDOWS
+ for (i = 0; i < rows; i++)
+#else
+ for (int i = 0; i < rows; i++)
+#endif
+ {
+ width = 0;
+ for (int j = 0; j < cols; j++)
+ {
+ memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp));
+ unsigned short uid = ntohs(tmp);
+ images[i][j] = getimg(uid);
+ width += images[i][j]->width();
+ }
+ height += images[i][0]->height();
+ }
+ delete [] buffer;
+ QPixmap pm(width, height);
+ int hoffset = 0;
+#ifdef _WINDOWS
+ for (i = 0; i < rows; i++)
+#else
+ for (int i = 0; i < rows; i++)
+#endif
+ {
+ int woffset = 0;
+ int delht = images[i][0]->height();
+ for (int j = 0; j < cols; j++)
+ {
+ QPixmap pm2;
+ pm2.convertFromImage(*(images[i][j]));
+ delete images[i][j];
+ bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height());
+ woffset += pm2.width();
+ }
+ hoffset += delht;
+ }
+#ifdef _WINDOWS
+ for (i = 0; i < rows; i++)
+#else
+ for (int i = 0; i < rows; i++)
+#endif
+ {
+ delete [] images[i];
+ }
+ delete [] images;
+ return new QImage(pm.convertToImage());
+ }
+ else
+ {
+ qDebug("Found a picture of type:%u", thishdr_type);
reclen -= HeaderSize();
@@ -822,11 +911,23 @@ QImage* CPlucker_base::getimg(UInt16 tgt)
return imagefromdata(imgbuffer, imgsize);
}
+}
-linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
+linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& wrd, QString&)
{
visited.push_front(n);
UInt16 tuid = (n >> 16);
n &= 0xffff;
-// //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl;
+ char *turl = geturl(tuid);
+ if (turl != NULL)
+ {
+ qDebug("URL in PB:%s", turl);
+ wrd = turl;
+ delete [] turl;
+ }
+ else
+ {
+ wrd.truncate(0);
+ }
+ qDebug("Hyper: UID:%u, Para:%u, Offset:%u", tuid, n, offset);
UInt16 thisrec = 1;
currentpos = 0;
@@ -840,10 +941,9 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
if (tuid == thishdr_uid) break;
if (thishdr_type < 2) currentpos += thishdr_size;
-// //odebug << "hyper-cp:" << currentpos << "" << oendl;
+ // //qDebug("hyper-cp:%u", currentpos);
thisrec++;
if (thisrec >= ntohs(head.recordList.numRecords))
{
- char *turl = geturl(tuid);
- if (turl == NULL)
+ if (wrd.isEmpty())
{
QMessageBox::information(NULL,
@@ -854,5 +954,4 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
else
{
- wrd = turl;
#ifdef USEQPE
if (wrd.length() > 10)
@@ -866,7 +965,6 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
#else
#endif /* USEQPE */
- //odebug << "Link:" << wrd << "" << oendl;
+ //qDebug("Link:%s", (const char*)wrd);
// setlink(fn, wrd);
- delete [] turl;
}
return eNone;
@@ -884,5 +982,5 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
else
{
- if (thishdr_type > 3)
+ if (thishdr_type > 3 && thishdr_type != 15)
{
QMessageBox::information(NULL,
@@ -913,4 +1011,6 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
{
expand(thisrec);
+ unsigned int paraoffset = offset;
+ // unsigned int noff = 0;
if (n != 0)
{
@@ -925,7 +1025,8 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
unsigned int noff = 0;
for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i];
- n = noff;
+
+ paraoffset += noff;
}
- if (n > thishdr_size)
+ if (paraoffset > thishdr_size)
{
QMessageBox::information(NULL,
@@ -935,6 +1036,6 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
return eNone;
}
- //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl;
- while (bufferpos < n && bufferpos < buffercontent) getch_base(true);
+ while (bufferpos < paraoffset && bufferpos < buffercontent) getch_base(true);
+ //qDebug("Hyper:<%u,%u,%u>", paraoffset, bufferpos, currentpos);
/* // This is faster but the alignment doesn't get set
mystyle.unset();
@@ -965,9 +1066,9 @@ tchar CPlucker_base::getch_base(bool fast)
{
ch = bgetch();
-// //odebug << "Function:" << ch << "" << oendl;
+ // //qDebug("Function:%x", ch);
switch (ch)
{
case 0x38:
-// //odebug << "Break:" << locate() << "" << oendl;
+ // //qDebug("Break:%u", locate());
if (m_lastBreak == locate())
{
@@ -989,5 +1090,5 @@ tchar CPlucker_base::getch_base(bool fast)
int ch = bgetch();
ln = (ln << 8) + ch;
-// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl;
+ // //qDebug("ch:%d, ln:%u", ch, ln);
}
if (skip == 2)
@@ -1001,8 +1102,8 @@ tchar CPlucker_base::getch_base(bool fast)
int ch = bgetch();
ln = (ln << 8) + ch;
-// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl;
+ // //qDebug("ch:%d, ln:%u", ch, ln);
}
}
-// //odebug << "ln:" << ln << "" << oendl;
+ // //qDebug("ln:%u", ln);
mystyle.setLink(true);
mystyle.setData(ln);
@@ -1025,4 +1126,6 @@ tchar CPlucker_base::getch_base(bool fast)
mystyle.setUnderline();
}
+ mystyle.setOffset(m_offset);
+ m_offset = 0;
ch = bgetch();
}
@@ -1047,42 +1150,48 @@ tchar CPlucker_base::getch_base(bool fast)
{
ch = bgetch();
-// //odebug << "Font:" << ch << "" << oendl;
+ // //qDebug("Font:%d",ch);
mystyle.setVOffset(0);
mystyle.unsetMono();
mystyle.unsetBold();
- mystyle.setFontSize(0);
switch (ch)
{
case 0:
+ mystyle.setFontSize(0);
break;
case 1:
- mystyle.setBold();
mystyle.setFontSize(3);
+ mystyle.setBold();
break;
case 2:
- mystyle.setBold();
mystyle.setFontSize(2);
+ mystyle.setBold();
break;
case 3:
- mystyle.setBold();
mystyle.setFontSize(1);
+ mystyle.setBold();
break;
case 4:
+ mystyle.setFontSize(0);
mystyle.setBold();
break;
case 5:
+ mystyle.setFontSize(0);
mystyle.setBold();
break;
case 6:
+ mystyle.setFontSize(0);
mystyle.setBold();
break;
case 7:
+ mystyle.setFontSize(0);
mystyle.setBold();
break;
case 8: // should be fixed width
- //odebug << "Trying fixed width" << oendl;
+ //qDebug("Trying fixed width");
+ mystyle.setFontSize(0);
mystyle.setMono();
break;
case 9:
+ // mystyle.setFontSize(mystyle.getFontSize());
mystyle.setFontSize(-1);
break;
@@ -1096,5 +1205,5 @@ tchar CPlucker_base::getch_base(bool fast)
break;
default:
- odebug << "Unrecognised font" << oendl;
+ qDebug("Unrecognised font");
break;
}
@@ -1108,17 +1217,17 @@ tchar CPlucker_base::getch_base(bool fast)
case 0:
mystyle.setLeftJustify();
-// //odebug << "left" << oendl;
+ // //qDebug("left");
break;
case 1:
mystyle.setRightJustify();
-// //odebug << "right" << oendl;
+ // //qDebug("right");
break;
case 2:
mystyle.setCentreJustify();
-// //odebug << "centre" << oendl;
+ // //qDebug("centre");
break;
case 3:
mystyle.setFullJustify();
-// //odebug << "full" << oendl;
+ // //qDebug("full");
break;
@@ -1143,5 +1252,5 @@ tchar CPlucker_base::getch_base(bool fast)
if (hasalternate)
{
- //odebug << "Alternate image:" << ir << "" << oendl;
+ //qDebug("Alternate image:%x", ir);
UInt16 ir2 = bgetch();
ir2 = (ir2 << 8) + bgetch();
@@ -1158,5 +1267,5 @@ tchar CPlucker_base::getch_base(bool fast)
if (!fast) mystyle.setPicture(true, expandimg(ir));
}
-// if (mystyle.getLink()) odebug << "Picture link!" << oendl;
+ // if (mystyle.getLink()) qDebug("Picture link!");
ch = '#';
}
@@ -1169,5 +1278,5 @@ tchar CPlucker_base::getch_base(bool fast)
UInt8 pc = bgetch();
UInt16 w = wc;
-// //odebug << "h,w,pc [" << h << ", " << w << ", " << pc << "]" << oendl;
+ // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc);
if (w == 0)
{
@@ -1176,5 +1285,5 @@ tchar CPlucker_base::getch_base(bool fast)
if (w == 0) w = m_scrWidth;
mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue()));
-// if (mystyle.getLink()) //odebug << "hRule link!" << oendl;
+ // if (mystyle.getLink()) //qDebug("hRule link!");
ch = '#';
}
@@ -1191,8 +1300,8 @@ tchar CPlucker_base::getch_base(bool fast)
ch = bgetch();
mystyle.setLeftMargin(ch);
-// //odebug << "Left margin:" << ch << "" << oendl;
+ // //qDebug("Left margin:%d", ch);
ch = bgetch();
mystyle.setRightMargin(ch);
-// //odebug << "Right margin:" << ch << "" << oendl;
+ // //qDebug("Right margin:%d", ch);
ch = bgetch();
break;
@@ -1212,10 +1321,18 @@ tchar CPlucker_base::getch_base(bool fast)
ch |= (tchar)bgetch();
for (int i = 0; i < tlen; i++) bgetch();
- //odebug << "Function 83" << oendl;
+ //qDebug("Function 83");
+ }
+ break;
+ case 0x9a:
+ {
+ m_offset = 255*bgetch();
+ m_offset += bgetch();
+ qDebug("Found offset:%u", m_offset);
+ ch = bgetch();
}
break;
case 0x85:
default:
- odebug << "Function:" << ch << " NOT IMPLEMENTED" << oendl;
+ qDebug("Function:%x NOT IMPLEMENTED", ch);
{
int skip = ch & 7;
@@ -1223,5 +1340,5 @@ tchar CPlucker_base::getch_base(bool fast)
{
ch = bgetch();
- //odebug << "Arg " << i << ", " << ch << "" << oendl;
+ //qDebug("Arg %d, %d", i, ch);
}
ch = bgetch();
@@ -1242,2 +1359,53 @@ tchar CPlucker_base::getch_base(bool fast)
return (ch == EOF) ? UEOF : ch;
}
+
+#include "static.h"
+#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()
+{
+ QString abt = "Plucker base codec (c) Tim Wentford";
+ if (m_decompress != UnDoc && m_decompress != UnZip)
+ {
+ abt += "\nSpecial decompression (c) Tim Wentford";
+ }
+ return abt;
+}