author | pohly <pohly> | 2004-08-24 20:52:45 (UTC) |
---|---|---|
committer | pohly <pohly> | 2004-08-24 20:52:45 (UTC) |
commit | 73253e93327cf4ef0932de1b4afb56af22a0f37e (patch) (unidiff) | |
tree | 1c9a7a6dd3341e036a894d348a3372525d29acec /noncore/apps/opie-reader/plucker_base.cpp | |
parent | e90847c784c48bd21bf8768cb38edb853b832697 (diff) | |
download | opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.zip opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.gz opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.bz2 |
updated source to opie-reader 0.7g
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.cpp | 448 |
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,15 +1,17 @@ | |||
1 | |||
2 | |||
3 | #include "useqpe.h" | 1 | #include "useqpe.h" |
4 | #include "plucker_base.h" | 2 | #include "usenef.h" |
5 | #include "Aportis.h" | 3 | #include <stdio.h> |
6 | #include "Palm2QImage.h" | 4 | #include <string.h> |
7 | 5 | #include <qmessagebox.h> | |
8 | /* OPIE */ | 6 | #include <qpixmap.h> |
9 | #include <opie2/odebug.h> | ||
10 | #ifdef USEQPE | 7 | #ifdef USEQPE |
11 | #include <qpe/qcopenvelope_qws.h> | 8 | #include <qpe/qcopenvelope_qws.h> |
9 | #endif /* USEQPE */ | ||
10 | #ifdef LOCALPICTURES | ||
11 | #include <qscrollview.h> | ||
12 | #endif | ||
13 | #ifdef USEQPE | ||
12 | #include <qpe/global.h> | 14 | #include <qpe/global.h> |
13 | #endif /* USEQPE */ | 15 | #endif /* USEQPE */ |
14 | 16 | #include <qclipboard.h> | |
15 | #ifndef USEQPE | 17 | #ifndef USEQPE |
@@ -19,12 +21,11 @@ | |||
19 | #endif /* USEQPE */ | 21 | #endif /* USEQPE */ |
22 | #include <qimage.h> | ||
20 | 23 | ||
21 | /* QT */ | 24 | #include "static.h" |
22 | #ifdef LOCALPICTURES | 25 | #include "plucker_base.h" |
23 | #include <qscrollview.h> | 26 | #include "Aportis.h" |
24 | #endif | 27 | #include "hrule.h" |
25 | 28 | #include "util.h" | |
26 | /* STD */ | ||
27 | #include <stdio.h> | ||
28 | #include <string.h> | ||
29 | 29 | ||
30 | const UInt8 CPlucker_base::continuation_bit = 1; | ||
30 | 31 | ||
@@ -36,3 +37,5 @@ CPlucker_base::CPlucker_base() : | |||
36 | expandedtextbuffer(NULL), | 37 | expandedtextbuffer(NULL), |
37 | compressedtextbuffer(NULL) | 38 | compressedtextbuffer(NULL), |
39 | bufferrec(-1), | ||
40 | m_offset(0) | ||
38 | //, urls(NULL) | 41 | //, urls(NULL) |
@@ -61,11 +64,3 @@ void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buff | |||
61 | fread(readbuffer, reclen, sizeof(char), fin); | 64 | fread(readbuffer, reclen, sizeof(char), fin); |
62 | switch (ntohs(hdr0.version)) | 65 | (*m_decompress)(readbuffer, reclen, buffer, buffersize); |
63 | { | ||
64 | case 2: | ||
65 | UnZip(readbuffer, reclen, buffer, buffersize); | ||
66 | break; | ||
67 | case 1: | ||
68 | UnDoc(readbuffer, reclen, buffer, buffersize); | ||
69 | break; | ||
70 | } | ||
71 | if (reclen > compressedbuffersize) | 66 | if (reclen > compressedbuffersize) |
@@ -103,3 +98,3 @@ char* CPlucker_base::geturl(UInt16 tgt) | |||
103 | unsigned int nrecs = ntohs(hdr0.nRecords); | 98 | unsigned int nrecs = ntohs(hdr0.nRecords); |
104 | //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl; | 99 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); |
105 | UInt16 urlid = 0; | 100 | UInt16 urlid = 0; |
@@ -113,3 +108,3 @@ char* CPlucker_base::geturl(UInt16 tgt) | |||
113 | fread(&id, 1, sizeof(id), fin); | 108 | fread(&id, 1, sizeof(id), fin); |
114 | //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl; | 109 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
115 | if (ntohs(name) == 2) | 110 | if (ntohs(name) == 2) |
@@ -118,5 +113,5 @@ char* CPlucker_base::geturl(UInt16 tgt) | |||
118 | urlid = id; | 113 | urlid = id; |
119 | //odebug << "Found url index:" << ntohs(urlid) << "" << oendl; | 114 | //qDebug("Found url index:%d", ntohs(urlid)); |
120 | } | 115 | } |
121 | // //odebug << "" << id << "" << oendl; | 116 | ////qDebug("%x", id); |
122 | } | 117 | } |
@@ -139,3 +134,3 @@ char* CPlucker_base::geturl(UInt16 tgt) | |||
139 | tctr = ntohs(tctr); | 134 | tctr = ntohs(tctr); |
140 | //odebug << "tgt:" << tgt << " urlctr:" << urlctr << " tctr:" << tctr << "" << oendl; | 135 | //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); |
141 | if (tctr >= tgt) | 136 | if (tctr >= tgt) |
@@ -146,3 +141,3 @@ char* CPlucker_base::geturl(UInt16 tgt) | |||
146 | } | 141 | } |
147 | //odebug << "urls are in " << ntohs(urlid) << "" << oendl; | 142 | //qDebug("urls are in %d", ntohs(urlid)); |
148 | recptr = finduid(ntohs(urlid)); | 143 | recptr = finduid(ntohs(urlid)); |
@@ -153,3 +148,3 @@ char* CPlucker_base::geturl(UInt16 tgt) | |||
153 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 148 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
154 | //odebug << "Found urls:" << thishdr_type << "" << oendl; | 149 | //qDebug("Found urls:%x",thishdr_type); |
155 | urlsize = thishdr_size; | 150 | urlsize = thishdr_size; |
@@ -163,3 +158,3 @@ char* CPlucker_base::geturl(UInt16 tgt) | |||
163 | { | 158 | { |
164 | //odebug << "URL:" << ptr << "" << oendl; | 159 | //qDebug("URL:%s", ptr); |
165 | int len = strlen(ptr)+1; | 160 | int len = strlen(ptr)+1; |
@@ -178,6 +173,3 @@ char* CPlucker_base::geturl(UInt16 tgt) | |||
178 | { | 173 | { |
179 | QMessageBox::information(NULL, | 174 | pRet = NULL; |
180 | QString(PROGNAME), | ||
181 | QString("No external links\nin this pluck") | ||
182 | ); | ||
183 | } | 175 | } |
@@ -197,4 +189,5 @@ int CPlucker_base::getch() { return getch(false); } | |||
197 | 189 | ||
198 | void CPlucker_base::getch(tchar& ch, CStyle& sty) | 190 | void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
199 | { | 191 | { |
192 | pos = locate(); | ||
200 | ch = getch(false); | 193 | ch = getch(false); |
@@ -228,2 +221,11 @@ void CPlucker_base::locate(unsigned int n) | |||
228 | // clock_t start = clock(); | 221 | // clock_t start = clock(); |
222 | if (n >= currentpos-bufferpos && n < currentpos - bufferpos + buffercontent) | ||
223 | { | ||
224 | currentpos -= bufferpos; | ||
225 | expand(bufferrec); | ||
226 | while (currentpos < n && bufferpos < buffercontent) getch_base(true); | ||
227 | return; | ||
228 | } | ||
229 | /* | ||
230 | |||
229 | UInt32 textlength = currentpos - bufferpos; | 231 | UInt32 textlength = currentpos - bufferpos; |
@@ -260,3 +262,3 @@ void CPlucker_base::locate(unsigned int n) | |||
260 | gotorecordnumber(recptr); | 262 | gotorecordnumber(recptr); |
261 | //odebug << "recptr:" << recptr << "" << oendl; | 263 | //qDebug("recptr:%u", recptr); |
262 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 264 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
@@ -285,26 +287,4 @@ void CPlucker_base::locate(unsigned int n) | |||
285 | } | 287 | } |
286 | // odebug << "Time(1): " << clock()-start << "" << oendl; | ||
287 | /* | ||
288 | expand(recptr); | ||
289 | mystyle.unset(); | ||
290 | bufferpos = n-textlength; | ||
291 | currentpos = n; | ||
292 | while (bufferpos >= m_nextPara && m_nextPara >= 0) | ||
293 | { | ||
294 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | ||
295 | m_nextParaIndex++; | ||
296 | if (m_nextParaIndex == m_nParas) | ||
297 | { | ||
298 | m_nextPara = -1; | ||
299 | } | ||
300 | else | ||
301 | { | ||
302 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | ||
303 | } | ||
304 | } | ||
305 | 288 | ||
306 | return; | ||
307 | */ | 289 | */ |
308 | // start = clock(); | ||
309 | |||
310 | UInt16 thisrec = 0; | 290 | UInt16 thisrec = 0; |
@@ -331,6 +311,7 @@ void CPlucker_base::locate(unsigned int n) | |||
331 | 311 | ||
332 | // odebug << "Time(2): " << clock()-start << "" << oendl; | 312 | // qDebug("Time(2): %u", clock()-start); |
313 | /* | ||
333 | if (recptr != thisrec) | 314 | if (recptr != thisrec) |
334 | { | 315 | { |
335 | odebug << "Disaster:recptr:" << recptr << " thisrec:" << thisrec << "" << oendl; | 316 | qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); |
336 | UInt16 thishdr_uid, thishdr_nParagraphs; | 317 | UInt16 thishdr_uid, thishdr_nParagraphs; |
@@ -342,3 +323,3 @@ void CPlucker_base::locate(unsigned int n) | |||
342 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 323 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
343 | // odebug << "UID:" << thishdr_uid << " Paras:" << thishdr_nParagraphs << " Size:" << thishdr_size << " Type:" << (unsigned int)thishdr_type << " Reserved:" << (unsigned int)thishdr_reserved << "" << oendl; | 324 | // 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); |
344 | } | 325 | } |
@@ -346,3 +327,3 @@ void CPlucker_base::locate(unsigned int n) | |||
346 | } | 327 | } |
347 | 328 | */ | |
348 | currentpos = locpos; | 329 | currentpos = locpos; |
@@ -373,2 +354,4 @@ bool CPlucker_base::expand(int thisrec) | |||
373 | mystyle.unset(); | 354 | mystyle.unset(); |
355 | if (bufferrec != thisrec) | ||
356 | { | ||
374 | size_t reclen = recordlength(thisrec); | 357 | size_t reclen = recordlength(thisrec); |
@@ -381,5 +364,5 @@ bool CPlucker_base::expand(int thisrec) | |||
381 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 364 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
382 | //odebug << "This (" << thisrec << ") type is " << thishdr_type << ", uid is " << thishdr_uid << "" << oendl; | 365 | //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); |
383 | if (thishdr_type < 2) break; | 366 | if (thishdr_type < 2) break; |
384 | //odebug << "Skipping paragraph of type " << thishdr_type << "" << oendl; | 367 | //qDebug("Skipping paragraph of type %d", thishdr_type); |
385 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; | 368 | if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; |
@@ -390,3 +373,3 @@ bool CPlucker_base::expand(int thisrec) | |||
390 | m_bufferisreserved = (thishdr_reserved != 0); | 373 | m_bufferisreserved = (thishdr_reserved != 0); |
391 | //odebug << "It has " << thishdr_nParagraphs << " paragraphs and is " << thishdr_size << " bytes" << oendl; | 374 | //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); |
392 | uid = thishdr_uid; | 375 | uid = thishdr_uid; |
@@ -401,13 +384,3 @@ bool CPlucker_base::expand(int thisrec) | |||
401 | m_ParaAttrs[i] = ntohs(attrs); | 384 | m_ParaAttrs[i] = ntohs(attrs); |
402 | // //odebug << "Bytes " << ntohs(ubytes) << ", Attr " << ntohs(attrs) << "" << oendl; | 385 | ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); |
403 | } | ||
404 | if (m_nParas > 0) | ||
405 | { | ||
406 | m_nextPara = m_ParaOffsets[0]; | ||
407 | //odebug << "First offset = " << m_nextPara << "" << oendl; | ||
408 | m_nextParaIndex = 0; | ||
409 | } | ||
410 | else | ||
411 | { | ||
412 | m_nextPara = -1; | ||
413 | } | 386 | } |
@@ -424,7 +397,19 @@ bool CPlucker_base::expand(int thisrec) | |||
424 | } | 397 | } |
425 | |||
426 | Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); | 398 | Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); |
427 | bufferpos = 0; | ||
428 | bufferrec = thisrec; | 399 | bufferrec = thisrec; |
429 | //odebug << "BC:" << buffercontent << ", HS:" << thishdr_size << "" << oendl; | 400 | } |
401 | |||
402 | |||
403 | if (m_nParas > 0) | ||
404 | { | ||
405 | m_nextPara = m_ParaOffsets[0]; | ||
406 | //qDebug("First offset = %u", m_nextPara); | ||
407 | m_nextParaIndex = 0; | ||
408 | } | ||
409 | else | ||
410 | { | ||
411 | m_nextPara = -1; | ||
412 | } | ||
413 | bufferpos = 0; | ||
414 | //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); | ||
430 | return true; | 415 | return true; |
@@ -462,3 +447,3 @@ void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff | |||
462 | 447 | ||
463 | // //odebug << "err:" << err << " - " << zstream.avail_in << "" << oendl; | 448 | ////qDebug("err:%d - %u", err, zstream.avail_in); |
464 | 449 | ||
@@ -544,5 +529,5 @@ CList<Bkmk>* CPlucker_base::getbkmklist() | |||
544 | n = ntohs(n); | 529 | n = ntohs(n); |
545 | //odebug << "Found " << n << " bookmarks" << oendl; | 530 | //qDebug("Found %u bookmarks", n); |
546 | } | 531 | } |
547 | //odebug << "Found:" << i << ", " << thishdr_type << "" << oendl; | 532 | //qDebug("Found:%d, %u", i , thishdr_type); |
548 | } | 533 | } |
@@ -552,2 +537,3 @@ CList<Bkmk>* CPlucker_base::getbkmklist() | |||
552 | 537 | ||
538 | #include <qnamespace.h> | ||
553 | 539 | ||
@@ -602,3 +588,3 @@ void CPlucker_base::showimg(UInt16 tgt) | |||
602 | { | 588 | { |
603 | //odebug << "Crassssssh!" << oendl; | 589 | //qDebug("Crassssssh!"); |
604 | QPixmap* qimage = expandimg(tgt); | 590 | QPixmap* qimage = expandimg(tgt); |
@@ -613,3 +599,3 @@ void CPlucker_base::showimg(UInt16 tgt) | |||
613 | QPixmap* image = new QPixmap(0,0); | 599 | QPixmap* image = new QPixmap(0,0); |
614 | // //odebug << "New image" << oendl; | 600 | // //qDebug("New image"); |
615 | image->convertFromImage(*qimage); | 601 | image->convertFromImage(*qimage); |
@@ -620,3 +606,3 @@ void CPlucker_base::showimg(UInt16 tgt) | |||
620 | close(f); | 606 | close(f); |
621 | //odebug << "TMPFILE:" << tmpfile << "" << oendl; | 607 | //qDebug("TMPFILE:%s", tmpfile); |
622 | if (image->save(tmpfile,"PNG")) | 608 | if (image->save(tmpfile,"PNG")) |
@@ -637,3 +623,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) | |||
637 | { | 623 | { |
638 | // //odebug << "Finding " << urlid << "" << oendl; | 624 | // //qDebug("Finding %u", urlid); |
639 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); | 625 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); |
@@ -648,3 +634,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) | |||
648 | unsigned short luid = thishdr_uid; | 634 | unsigned short luid = thishdr_uid; |
649 | // //odebug << "" << jmin << " " << jmid << " " << jmax << " : " << urlid << "" << oendl; | 635 | ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); |
650 | if (luid == urlid) | 636 | if (luid == urlid) |
@@ -669,3 +655,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) | |||
669 | unsigned short luid = thishdr_uid; | 655 | unsigned short luid = thishdr_uid; |
670 | //odebug << "jmin at end:" << jmin << "," << luid << "" << oendl; | 656 | //qDebug("jmin at end:%u,%u", jmin, luid); |
671 | if (luid == urlid) | 657 | if (luid == urlid) |
@@ -677,3 +663,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) | |||
677 | luid = thishdr_uid; | 663 | luid = thishdr_uid; |
678 | //odebug << "jmax at end:" << jmax << "," << luid << "" << oendl; | 664 | //qDebug("jmax at end:%u,%u", jmax, luid); |
679 | if (luid == urlid) | 665 | if (luid == urlid) |
@@ -682,3 +668,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) | |||
682 | } | 668 | } |
683 | //odebug << "Couldn't find " << urlid << "" << oendl; | 669 | //qDebug("Couldn't find %u", urlid); |
684 | return 0; // Not found! | 670 | return 0; // Not found! |
@@ -686,2 +672,3 @@ unsigned short CPlucker_base::finduid(unsigned short urlid) | |||
686 | 672 | ||
673 | #include <qnamespace.h> | ||
687 | 674 | ||
@@ -708,3 +695,3 @@ void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsig | |||
708 | unsigned long t = *it; | 695 | unsigned long t = *it; |
709 | // odebug << "[" << t << "]" << oendl; | 696 | //qDebug("[%u]", t); |
710 | memcpy(newdata, &t, sizeof(t)); | 697 | memcpy(newdata, &t, sizeof(t)); |
@@ -731,3 +718,3 @@ void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) | |||
731 | memcpy(&t, src, sizeof(t)); | 718 | memcpy(&t, src, sizeof(t)); |
732 | // odebug << "[" << t << "]" << oendl; | 719 | // qDebug("[%u]", t); |
733 | visited.push_front(t); | 720 | visited.push_front(t); |
@@ -747,4 +734,5 @@ int CPlucker_base::OpenFile(const char *src) | |||
747 | { | 734 | { |
735 | qDebug("plucker openfile:%s", src); | ||
748 | m_lastBreak = 0; | 736 | m_lastBreak = 0; |
749 | if (!Cpdb::openfile(src)) | 737 | if (!Cpdb::openpdbfile(src)) |
750 | { | 738 | { |
@@ -757,2 +745,26 @@ int CPlucker_base::OpenFile(const char *src) | |||
757 | fread(&hdr0, 1, 6, fin); | 745 | fread(&hdr0, 1, 6, fin); |
746 | qDebug("Compression type:%u", ntohs(hdr0.version)); | ||
747 | |||
748 | |||
749 | switch (ntohs(hdr0.version)) | ||
750 | { | ||
751 | case 2: | ||
752 | m_decompress = UnZip; | ||
753 | break; | ||
754 | case 1: | ||
755 | m_decompress = UnDoc; | ||
756 | break; | ||
757 | #ifdef USENEF | ||
758 | case 3: | ||
759 | m_decompress = getdecompressor("PluckerDecompress3"); | ||
760 | break; | ||
761 | case 4: | ||
762 | m_decompress = getdecompressor("PluckerDecompress4"); | ||
763 | break; | ||
764 | #endif | ||
765 | default: | ||
766 | m_decompress = NULL; | ||
767 | } | ||
768 | if (m_decompress == NULL) return -1; | ||
769 | |||
758 | setbuffersize(); | 770 | setbuffersize(); |
@@ -761,6 +773,6 @@ int CPlucker_base::OpenFile(const char *src) | |||
761 | 773 | ||
762 | //odebug << "Total number of records:" << ntohs(head.recordList.numRecords) << "" << oendl; | ||
763 | |||
764 | unsigned int nrecs = ntohs(hdr0.nRecords); | 774 | unsigned int nrecs = ntohs(hdr0.nRecords); |
765 | //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl; | 775 | qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs); |
776 | textlength = ntohl(head.sortInfoID); | ||
777 | qDebug("Textlength at startup:%u", textlength); | ||
766 | UInt16 homerecid = 1; | 778 | UInt16 homerecid = 1; |
@@ -771,3 +783,3 @@ int CPlucker_base::OpenFile(const char *src) | |||
771 | fread(&id, 1, sizeof(id), fin); | 783 | fread(&id, 1, sizeof(id), fin); |
772 | //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl; | 784 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
773 | if (ntohs(name) == 0) homerecid = ntohs(id); | 785 | if (ntohs(name) == 0) homerecid = ntohs(id); |
@@ -790,4 +802,6 @@ int CPlucker_base::OpenFile(const char *src) | |||
790 | } | 802 | } |
803 | qDebug("Found home"); | ||
791 | textlength = 0; | 804 | textlength = 0; |
792 | home(); | 805 | home(); |
806 | qDebug("Gone home"); | ||
793 | #ifdef LOCALPICTURES | 807 | #ifdef LOCALPICTURES |
@@ -808,2 +822,3 @@ QImage* CPlucker_base::getimg(UInt16 tgt) | |||
808 | UInt16 thisrec = finduid(tgt); | 822 | UInt16 thisrec = finduid(tgt); |
823 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); | ||
809 | reclen = recordlength(thisrec); | 824 | reclen = recordlength(thisrec); |
@@ -814,2 +829,76 @@ QImage* CPlucker_base::getimg(UInt16 tgt) | |||
814 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 829 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
830 | if (thishdr_type == 15) | ||
831 | { | ||
832 | char *buffer = new char[thishdr_size]; | ||
833 | fread(buffer, thishdr_size, sizeof(char), fin); | ||
834 | unsigned short tmp; | ||
835 | memcpy(&tmp, buffer, sizeof(tmp)); | ||
836 | unsigned short cols = ntohs(tmp); | ||
837 | memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp)); | ||
838 | unsigned short rows = ntohs(tmp); | ||
839 | qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols); | ||
840 | QImage*** images; | ||
841 | images = new QImage**[rows]; | ||
842 | #ifdef _WINDOWS | ||
843 | int i; | ||
844 | for (i = 0; i < rows; i++) | ||
845 | #else | ||
846 | for (int i = 0; i < rows; i++) | ||
847 | #endif | ||
848 | { | ||
849 | images[i] = new QImage*[cols]; | ||
850 | } | ||
851 | int height = 0; | ||
852 | int width = 0; | ||
853 | #ifdef _WINDOWS | ||
854 | for (i = 0; i < rows; i++) | ||
855 | #else | ||
856 | for (int i = 0; i < rows; i++) | ||
857 | #endif | ||
858 | { | ||
859 | width = 0; | ||
860 | for (int j = 0; j < cols; j++) | ||
861 | { | ||
862 | memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp)); | ||
863 | unsigned short uid = ntohs(tmp); | ||
864 | images[i][j] = getimg(uid); | ||
865 | width += images[i][j]->width(); | ||
866 | } | ||
867 | height += images[i][0]->height(); | ||
868 | } | ||
869 | delete [] buffer; | ||
870 | QPixmap pm(width, height); | ||
871 | int hoffset = 0; | ||
872 | #ifdef _WINDOWS | ||
873 | for (i = 0; i < rows; i++) | ||
874 | #else | ||
875 | for (int i = 0; i < rows; i++) | ||
876 | #endif | ||
877 | { | ||
878 | int woffset = 0; | ||
879 | int delht = images[i][0]->height(); | ||
880 | for (int j = 0; j < cols; j++) | ||
881 | { | ||
882 | QPixmap pm2; | ||
883 | pm2.convertFromImage(*(images[i][j])); | ||
884 | delete images[i][j]; | ||
885 | bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height()); | ||
886 | woffset += pm2.width(); | ||
887 | } | ||
888 | hoffset += delht; | ||
889 | } | ||
890 | #ifdef _WINDOWS | ||
891 | for (i = 0; i < rows; i++) | ||
892 | #else | ||
893 | for (int i = 0; i < rows; i++) | ||
894 | #endif | ||
895 | { | ||
896 | delete [] images[i]; | ||
897 | } | ||
898 | delete [] images; | ||
899 | return new QImage(pm.convertToImage()); | ||
900 | } | ||
901 | else | ||
902 | { | ||
903 | qDebug("Found a picture of type:%u", thishdr_type); | ||
815 | reclen -= HeaderSize(); | 904 | reclen -= HeaderSize(); |
@@ -823,4 +912,5 @@ QImage* CPlucker_base::getimg(UInt16 tgt) | |||
823 | } | 912 | } |
913 | } | ||
824 | 914 | ||
825 | linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | 915 | linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& wrd, QString&) |
826 | { | 916 | { |
@@ -829,3 +919,14 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | |||
829 | n &= 0xffff; | 919 | n &= 0xffff; |
830 | // //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl; | 920 | char *turl = geturl(tuid); |
921 | if (turl != NULL) | ||
922 | { | ||
923 | qDebug("URL in PB:%s", turl); | ||
924 | wrd = turl; | ||
925 | delete [] turl; | ||
926 | } | ||
927 | else | ||
928 | { | ||
929 | wrd.truncate(0); | ||
930 | } | ||
931 | qDebug("Hyper: UID:%u, Para:%u, Offset:%u", tuid, n, offset); | ||
831 | UInt16 thisrec = 1; | 932 | UInt16 thisrec = 1; |
@@ -841,3 +942,3 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | |||
841 | if (thishdr_type < 2) currentpos += thishdr_size; | 942 | if (thishdr_type < 2) currentpos += thishdr_size; |
842 | // //odebug << "hyper-cp:" << currentpos << "" << oendl; | 943 | ////qDebug("hyper-cp:%u", currentpos); |
843 | thisrec++; | 944 | thisrec++; |
@@ -845,4 +946,3 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | |||
845 | { | 946 | { |
846 | char *turl = geturl(tuid); | 947 | if (wrd.isEmpty()) |
847 | if (turl == NULL) | ||
848 | { | 948 | { |
@@ -855,3 +955,2 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | |||
855 | { | 955 | { |
856 | wrd = turl; | ||
857 | #ifdef USEQPE | 956 | #ifdef USEQPE |
@@ -867,5 +966,4 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | |||
867 | #endif /* USEQPE */ | 966 | #endif /* USEQPE */ |
868 | //odebug << "Link:" << wrd << "" << oendl; | 967 | //qDebug("Link:%s", (const char*)wrd); |
869 | // setlink(fn, wrd); | 968 | // setlink(fn, wrd); |
870 | delete [] turl; | ||
871 | } | 969 | } |
@@ -885,3 +983,3 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | |||
885 | { | 983 | { |
886 | if (thishdr_type > 3) | 984 | if (thishdr_type > 3 && thishdr_type != 15) |
887 | { | 985 | { |
@@ -914,2 +1012,4 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | |||
914 | expand(thisrec); | 1012 | expand(thisrec); |
1013 | unsigned int paraoffset = offset; | ||
1014 | // unsigned int noff = 0; | ||
915 | if (n != 0) | 1015 | if (n != 0) |
@@ -926,5 +1026,6 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | |||
926 | for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; | 1026 | for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; |
927 | n = noff; | 1027 | |
1028 | paraoffset += noff; | ||
928 | } | 1029 | } |
929 | if (n > thishdr_size) | 1030 | if (paraoffset > thishdr_size) |
930 | { | 1031 | { |
@@ -936,4 +1037,4 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) | |||
936 | } | 1037 | } |
937 | //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl; | 1038 | while (bufferpos < paraoffset && bufferpos < buffercontent) getch_base(true); |
938 | while (bufferpos < n && bufferpos < buffercontent) getch_base(true); | 1039 | //qDebug("Hyper:<%u,%u,%u>", paraoffset, bufferpos, currentpos); |
939 | /* // This is faster but the alignment doesn't get set | 1040 | /* // This is faster but the alignment doesn't get set |
@@ -966,3 +1067,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
966 | ch = bgetch(); | 1067 | ch = bgetch(); |
967 | // //odebug << "Function:" << ch << "" << oendl; | 1068 | ////qDebug("Function:%x", ch); |
968 | switch (ch) | 1069 | switch (ch) |
@@ -970,3 +1071,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
970 | case 0x38: | 1071 | case 0x38: |
971 | // //odebug << "Break:" << locate() << "" << oendl; | 1072 | // //qDebug("Break:%u", locate()); |
972 | if (m_lastBreak == locate()) | 1073 | if (m_lastBreak == locate()) |
@@ -990,3 +1091,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
990 | ln = (ln << 8) + ch; | 1091 | ln = (ln << 8) + ch; |
991 | // //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl; | 1092 | // //qDebug("ch:%d, ln:%u", ch, ln); |
992 | } | 1093 | } |
@@ -1002,6 +1103,6 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1002 | ln = (ln << 8) + ch; | 1103 | ln = (ln << 8) + ch; |
1003 | // //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl; | 1104 | // //qDebug("ch:%d, ln:%u", ch, ln); |
1004 | } | 1105 | } |
1005 | } | 1106 | } |
1006 | // //odebug << "ln:" << ln << "" << oendl; | 1107 | // //qDebug("ln:%u", ln); |
1007 | mystyle.setLink(true); | 1108 | mystyle.setLink(true); |
@@ -1026,2 +1127,4 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1026 | } | 1127 | } |
1128 | mystyle.setOffset(m_offset); | ||
1129 | m_offset = 0; | ||
1027 | ch = bgetch(); | 1130 | ch = bgetch(); |
@@ -1048,3 +1151,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1048 | ch = bgetch(); | 1151 | ch = bgetch(); |
1049 | // //odebug << "Font:" << ch << "" << oendl; | 1152 | // //qDebug("Font:%d",ch); |
1050 | mystyle.setVOffset(0); | 1153 | mystyle.setVOffset(0); |
@@ -1052,3 +1155,2 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1052 | mystyle.unsetBold(); | 1155 | mystyle.unsetBold(); |
1053 | mystyle.setFontSize(0); | ||
1054 | switch (ch) | 1156 | switch (ch) |
@@ -1056,16 +1158,18 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1056 | case 0: | 1158 | case 0: |
1159 | mystyle.setFontSize(0); | ||
1057 | break; | 1160 | break; |
1058 | case 1: | 1161 | case 1: |
1059 | mystyle.setBold(); | ||
1060 | mystyle.setFontSize(3); | 1162 | mystyle.setFontSize(3); |
1163 | mystyle.setBold(); | ||
1061 | break; | 1164 | break; |
1062 | case 2: | 1165 | case 2: |
1063 | mystyle.setBold(); | ||
1064 | mystyle.setFontSize(2); | 1166 | mystyle.setFontSize(2); |
1167 | mystyle.setBold(); | ||
1065 | break; | 1168 | break; |
1066 | case 3: | 1169 | case 3: |
1067 | mystyle.setBold(); | ||
1068 | mystyle.setFontSize(1); | 1170 | mystyle.setFontSize(1); |
1171 | mystyle.setBold(); | ||
1069 | break; | 1172 | break; |
1070 | case 4: | 1173 | case 4: |
1174 | mystyle.setFontSize(0); | ||
1071 | mystyle.setBold(); | 1175 | mystyle.setBold(); |
@@ -1073,2 +1177,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1073 | case 5: | 1177 | case 5: |
1178 | mystyle.setFontSize(0); | ||
1074 | mystyle.setBold(); | 1179 | mystyle.setBold(); |
@@ -1076,2 +1181,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1076 | case 6: | 1181 | case 6: |
1182 | mystyle.setFontSize(0); | ||
1077 | mystyle.setBold(); | 1183 | mystyle.setBold(); |
@@ -1079,2 +1185,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1079 | case 7: | 1185 | case 7: |
1186 | mystyle.setFontSize(0); | ||
1080 | mystyle.setBold(); | 1187 | mystyle.setBold(); |
@@ -1082,3 +1189,4 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1082 | case 8: // should be fixed width | 1189 | case 8: // should be fixed width |
1083 | //odebug << "Trying fixed width" << oendl; | 1190 | //qDebug("Trying fixed width"); |
1191 | mystyle.setFontSize(0); | ||
1084 | mystyle.setMono(); | 1192 | mystyle.setMono(); |
@@ -1086,2 +1194,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1086 | case 9: | 1194 | case 9: |
1195 | // mystyle.setFontSize(mystyle.getFontSize()); | ||
1087 | mystyle.setFontSize(-1); | 1196 | mystyle.setFontSize(-1); |
@@ -1097,3 +1206,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1097 | default: | 1206 | default: |
1098 | odebug << "Unrecognised font" << oendl; | 1207 | qDebug("Unrecognised font"); |
1099 | break; | 1208 | break; |
@@ -1109,3 +1218,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1109 | mystyle.setLeftJustify(); | 1218 | mystyle.setLeftJustify(); |
1110 | // //odebug << "left" << oendl; | 1219 | // //qDebug("left"); |
1111 | break; | 1220 | break; |
@@ -1113,3 +1222,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1113 | mystyle.setRightJustify(); | 1222 | mystyle.setRightJustify(); |
1114 | // //odebug << "right" << oendl; | 1223 | // //qDebug("right"); |
1115 | break; | 1224 | break; |
@@ -1117,3 +1226,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1117 | mystyle.setCentreJustify(); | 1226 | mystyle.setCentreJustify(); |
1118 | // //odebug << "centre" << oendl; | 1227 | // //qDebug("centre"); |
1119 | break; | 1228 | break; |
@@ -1121,3 +1230,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1121 | mystyle.setFullJustify(); | 1230 | mystyle.setFullJustify(); |
1122 | // //odebug << "full" << oendl; | 1231 | // //qDebug("full"); |
1123 | break; | 1232 | break; |
@@ -1144,3 +1253,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1144 | { | 1253 | { |
1145 | //odebug << "Alternate image:" << ir << "" << oendl; | 1254 | //qDebug("Alternate image:%x", ir); |
1146 | UInt16 ir2 = bgetch(); | 1255 | UInt16 ir2 = bgetch(); |
@@ -1159,3 +1268,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1159 | } | 1268 | } |
1160 | // if (mystyle.getLink()) odebug << "Picture link!" << oendl; | 1269 | // if (mystyle.getLink()) qDebug("Picture link!"); |
1161 | ch = '#'; | 1270 | ch = '#'; |
@@ -1170,3 +1279,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1170 | UInt16 w = wc; | 1279 | UInt16 w = wc; |
1171 | // //odebug << "h,w,pc [" << h << ", " << w << ", " << pc << "]" << oendl; | 1280 | // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); |
1172 | if (w == 0) | 1281 | if (w == 0) |
@@ -1177,3 +1286,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1177 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); | 1286 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); |
1178 | // if (mystyle.getLink()) //odebug << "hRule link!" << oendl; | 1287 | // if (mystyle.getLink()) //qDebug("hRule link!"); |
1179 | ch = '#'; | 1288 | ch = '#'; |
@@ -1192,6 +1301,6 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1192 | mystyle.setLeftMargin(ch); | 1301 | mystyle.setLeftMargin(ch); |
1193 | // //odebug << "Left margin:" << ch << "" << oendl; | 1302 | // //qDebug("Left margin:%d", ch); |
1194 | ch = bgetch(); | 1303 | ch = bgetch(); |
1195 | mystyle.setRightMargin(ch); | 1304 | mystyle.setRightMargin(ch); |
1196 | // //odebug << "Right margin:" << ch << "" << oendl; | 1305 | // //qDebug("Right margin:%d", ch); |
1197 | ch = bgetch(); | 1306 | ch = bgetch(); |
@@ -1213,3 +1322,11 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1213 | for (int i = 0; i < tlen; i++) bgetch(); | 1322 | for (int i = 0; i < tlen; i++) bgetch(); |
1214 | //odebug << "Function 83" << oendl; | 1323 | //qDebug("Function 83"); |
1324 | } | ||
1325 | break; | ||
1326 | case 0x9a: | ||
1327 | { | ||
1328 | m_offset = 255*bgetch(); | ||
1329 | m_offset += bgetch(); | ||
1330 | qDebug("Found offset:%u", m_offset); | ||
1331 | ch = bgetch(); | ||
1215 | } | 1332 | } |
@@ -1218,3 +1335,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1218 | default: | 1335 | default: |
1219 | odebug << "Function:" << ch << " NOT IMPLEMENTED" << oendl; | 1336 | qDebug("Function:%x NOT IMPLEMENTED", ch); |
1220 | { | 1337 | { |
@@ -1224,3 +1341,3 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1224 | ch = bgetch(); | 1341 | ch = bgetch(); |
1225 | //odebug << "Arg " << i << ", " << ch << "" << oendl; | 1342 | //qDebug("Arg %d, %d", i, ch); |
1226 | } | 1343 | } |
@@ -1243 +1360,52 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1243 | } | 1360 | } |
1361 | |||
1362 | #include "static.h" | ||
1363 | #if defined(__STATIC) && defined(USENEF) | ||
1364 | #include "Model.h" | ||
1365 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | ||
1366 | { | ||
1367 | if (_s == "PluckerDecompress3") | ||
1368 | { | ||
1369 | return PluckerDecompress3; | ||
1370 | } | ||
1371 | if (_s == "PluckerDecompress4") | ||
1372 | { | ||
1373 | return PluckerDecompress4; | ||
1374 | } | ||
1375 | return NULL; | ||
1376 | } | ||
1377 | #else | ||
1378 | |||
1379 | #include "qfileinfo.h" | ||
1380 | |||
1381 | #include <dlfcn.h> | ||
1382 | |||
1383 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | ||
1384 | { | ||
1385 | QString codecpath(QTReaderUtil::getPluginPath("support")); | ||
1386 | codecpath += "/libpluckerdecompress.so"; | ||
1387 | qDebug("Codec:%s", (const char*)codecpath); | ||
1388 | if (QFile::exists(codecpath)) | ||
1389 | { | ||
1390 | qDebug("Codec:%s", (const char*)codecpath); | ||
1391 | void* handle = dlopen(codecpath, RTLD_LAZY); | ||
1392 | if (handle == 0) | ||
1393 | { | ||
1394 | qDebug("Can't find codec:%s", dlerror()); | ||
1395 | return NULL; | ||
1396 | } | ||
1397 | return (void (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); | ||
1398 | } | ||
1399 | return NULL; | ||
1400 | } | ||
1401 | #endif | ||
1402 | |||
1403 | QString CPlucker_base::about() | ||
1404 | { | ||
1405 | QString abt = "Plucker base codec (c) Tim Wentford"; | ||
1406 | if (m_decompress != UnDoc && m_decompress != UnZip) | ||
1407 | { | ||
1408 | abt += "\nSpecial decompression (c) Tim Wentford"; | ||
1409 | } | ||
1410 | return abt; | ||
1411 | } | ||