summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/plucker_base.cpp
Unidiff
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.cpp148
1 files changed, 78 insertions, 70 deletions
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp
index caa945d..b523a54 100644
--- a/noncore/apps/opie-reader/plucker_base.cpp
+++ b/noncore/apps/opie-reader/plucker_base.cpp
@@ -1,27 +1,35 @@
1
2
1#include "useqpe.h" 3#include "useqpe.h"
2#include <stdio.h> 4#include "plucker_base.h"
3#include <string.h> 5#include "Aportis.h"
6#include "Palm2QImage.h"
7
8/* OPIE */
9#include <opie2/odebug.h>
4#ifdef USEQPE 10#ifdef USEQPE
5#include <qpe/qcopenvelope_qws.h> 11#include <qpe/qcopenvelope_qws.h>
6#endif /* USEQPE */
7#ifdef LOCALPICTURES
8#include <qscrollview.h>
9#endif
10#ifdef USEQPE
11#include <qpe/global.h> 12#include <qpe/global.h>
12#endif /* USEQPE */ 13#endif /* USEQPE */
14
13#ifndef USEQPE 15#ifndef USEQPE
14#include <qapplication.h> 16#include <qapplication.h>
15#else /* USEQPE */ 17#else /* USEQPE */
16#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
17#endif /* USEQPE */ 19#endif /* USEQPE */
18 20
19#include "plucker_base.h" 21/* QT */
20#include "Aportis.h" 22#ifdef LOCALPICTURES
21#include "Palm2QImage.h" 23#include <qscrollview.h>
24#endif
25
26/* STD */
27#include <stdio.h>
28#include <string.h>
29
22 30
23CPlucker_base::CPlucker_base() : 31CPlucker_base::CPlucker_base() :
24#ifdef LOCALPICTURES 32#ifdef LOCALPICTURES
25 m_viewer(NULL), 33 m_viewer(NULL),
26 m_picture(NULL), 34 m_picture(NULL),
27#endif 35#endif
@@ -90,30 +98,30 @@ void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text)
90char* CPlucker_base::geturl(UInt16 tgt) 98char* CPlucker_base::geturl(UInt16 tgt)
91{ 99{
92 char * pRet = NULL; 100 char * pRet = NULL;
93 gotorecordnumber(0); 101 gotorecordnumber(0);
94 fread(&hdr0, 1, 6, fin); 102 fread(&hdr0, 1, 6, fin);
95 unsigned int nrecs = ntohs(hdr0.nRecords); 103 unsigned int nrecs = ntohs(hdr0.nRecords);
96 //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); 104 //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl;
97 UInt16 urlid = 0; 105 UInt16 urlid = 0;
98 bool urlsfound = false; 106 bool urlsfound = false;
99 char* urls = NULL; 107 char* urls = NULL;
100 size_t urlsize = 0; 108 size_t urlsize = 0;
101 for (unsigned int i = 0; i < nrecs; i++) 109 for (unsigned int i = 0; i < nrecs; i++)
102 { 110 {
103 UInt16 id, name; 111 UInt16 id, name;
104 fread(&name, 1, sizeof(name), fin); 112 fread(&name, 1, sizeof(name), fin);
105 fread(&id, 1, sizeof(id), fin); 113 fread(&id, 1, sizeof(id), fin);
106 //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); 114 //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl;
107 if (ntohs(name) == 2) 115 if (ntohs(name) == 2)
108 { 116 {
109 urlsfound = true; 117 urlsfound = true;
110 urlid = id; 118 urlid = id;
111 //qDebug("Found url index:%d", ntohs(urlid)); 119 //odebug << "Found url index:" << ntohs(urlid) << "" << oendl;
112 } 120 }
113 ////qDebug("%x", id); 121// //odebug << "" << id << "" << oendl;
114 } 122 }
115 if (urlsfound) 123 if (urlsfound)
116 { 124 {
117 unsigned short recptr = finduid(ntohs(urlid)); 125 unsigned short recptr = finduid(ntohs(urlid));
118 if (recptr != 0) 126 if (recptr != 0)
119 { 127 {
@@ -126,37 +134,37 @@ char* CPlucker_base::geturl(UInt16 tgt)
126 while (1) 134 while (1)
127 { 135 {
128 UInt16 tctr; 136 UInt16 tctr;
129 fread(&tctr, 1, sizeof(tctr), fin); 137 fread(&tctr, 1, sizeof(tctr), fin);
130 fread(&urlid, 1, sizeof(urlid), fin); 138 fread(&urlid, 1, sizeof(urlid), fin);
131 tctr = ntohs(tctr); 139 tctr = ntohs(tctr);
132 //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); 140 //odebug << "tgt:" << tgt << " urlctr:" << urlctr << " tctr:" << tctr << "" << oendl;
133 if (tctr >= tgt) 141 if (tctr >= tgt)
134 { 142 {
135 break; 143 break;
136 } 144 }
137 urlctr = tctr; 145 urlctr = tctr;
138 } 146 }
139 //qDebug("urls are in %d", ntohs(urlid)); 147 //odebug << "urls are in " << ntohs(urlid) << "" << oendl;
140 recptr = finduid(ntohs(urlid)); 148 recptr = finduid(ntohs(urlid));
141 if (recptr != 0) 149 if (recptr != 0)
142 { 150 {
143 UInt32 reclen = recordlength(recptr) - HeaderSize(); 151 UInt32 reclen = recordlength(recptr) - HeaderSize();
144 gotorecordnumber(recptr); 152 gotorecordnumber(recptr);
145 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 153 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
146 //qDebug("Found urls:%x",thishdr_type); 154 //odebug << "Found urls:" << thishdr_type << "" << oendl;
147 urlsize = thishdr_size; 155 urlsize = thishdr_size;
148 urls = new char[urlsize]; 156 urls = new char[urlsize];
149 Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); 157 Expand(reclen, thishdr_type, (UInt8*)urls, urlsize);
150 char* ptr = urls; 158 char* ptr = urls;
151 int rn = urlctr+1; 159 int rn = urlctr+1;
152 while (ptr - urls < urlsize) 160 while (ptr - urls < urlsize)
153 { 161 {
154 if (rn == tgt) 162 if (rn == tgt)
155 { 163 {
156 //qDebug("URL:%s", ptr); 164 //odebug << "URL:" << ptr << "" << oendl;
157 int len = strlen(ptr)+1; 165 int len = strlen(ptr)+1;
158 pRet = new char[len]; 166 pRet = new char[len];
159 memcpy(pRet, ptr, len); 167 memcpy(pRet, ptr, len);
160 break; 168 break;
161 } 169 }
162 ptr += strlen(ptr)+1; 170 ptr += strlen(ptr)+1;
@@ -247,13 +255,13 @@ void CPlucker_base::locate(unsigned int n)
247 UInt32 thishdr_size; 255 UInt32 thishdr_size;
248 UInt8 thishdr_type, thishdr_reserved; 256 UInt8 thishdr_type, thishdr_reserved;
249 while (n < textlength && recptr > 1) 257 while (n < textlength && recptr > 1)
250 { 258 {
251 recptr--; 259 recptr--;
252 gotorecordnumber(recptr); 260 gotorecordnumber(recptr);
253 //qDebug("recptr:%u", recptr); 261 //odebug << "recptr:" << recptr << "" << oendl;
254 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 262 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
255 if (thishdr_type < 2) 263 if (thishdr_type < 2)
256 { 264 {
257 textlength -= thishdr_size; 265 textlength -= thishdr_size;
258 } 266 }
259 } 267 }
@@ -272,13 +280,13 @@ void CPlucker_base::locate(unsigned int n)
272 if (!(thishdr_type < 2)) 280 if (!(thishdr_type < 2))
273 { 281 {
274 thishdr_size = 0; 282 thishdr_size = 0;
275 } 283 }
276 } 284 }
277 } 285 }
278// qDebug("Time(1): %u", clock()-start); 286// odebug << "Time(1): " << clock()-start << "" << oendl;
279/* 287/*
280 expand(recptr); 288 expand(recptr);
281 mystyle.unset(); 289 mystyle.unset();
282 bufferpos = n-textlength; 290 bufferpos = n-textlength;
283 currentpos = n; 291 currentpos = n;
284 while (bufferpos >= m_nextPara && m_nextPara >= 0) 292 while (bufferpos >= m_nextPara && m_nextPara >= 0)
@@ -318,24 +326,24 @@ void CPlucker_base::locate(unsigned int n)
318 else 326 else
319 { 327 {
320 bs = 0; 328 bs = 0;
321 } 329 }
322 } while (locpos + bs <= n); 330 } while (locpos + bs <= n);
323 331
324// qDebug("Time(2): %u", clock()-start); 332// odebug << "Time(2): " << clock()-start << "" << oendl;
325 if (recptr != thisrec) 333 if (recptr != thisrec)
326 { 334 {
327 qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); 335 odebug << "Disaster:recptr:" << recptr << " thisrec:" << thisrec << "" << oendl;
328 UInt16 thishdr_uid, thishdr_nParagraphs; 336 UInt16 thishdr_uid, thishdr_nParagraphs;
329 UInt32 thishdr_size = buffercontent; 337 UInt32 thishdr_size = buffercontent;
330 UInt8 thishdr_type, thishdr_reserved; 338 UInt8 thishdr_type, thishdr_reserved;
331 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 339 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
332 { 340 {
333 gotorecordnumber(recptr); 341 gotorecordnumber(recptr);
334 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 342 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
335 // 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); 343// odebug << "UID:" << thishdr_uid << " Paras:" << thishdr_nParagraphs << " Size:" << thishdr_size << " Type:" << (unsigned int)thishdr_type << " Reserved:" << (unsigned int)thishdr_reserved << "" << oendl;
336 } 344 }
337 //QApplication::exit ( 100 ); 345 //QApplication::exit ( 100 );
338 } 346 }
339 347
340 currentpos = locpos; 348 currentpos = locpos;
341 expand(thisrec); 349 expand(thisrec);
@@ -368,38 +376,38 @@ bool CPlucker_base::expand(int thisrec)
368 UInt16 thishdr_uid, thishdr_nParagraphs; 376 UInt16 thishdr_uid, thishdr_nParagraphs;
369 UInt32 thishdr_size; 377 UInt32 thishdr_size;
370 UInt8 thishdr_type, thishdr_reserved; 378 UInt8 thishdr_type, thishdr_reserved;
371 while (1) 379 while (1)
372 { 380 {
373 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 381 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
374 //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); 382 //odebug << "This (" << thisrec << ") type is " << thishdr_type << ", uid is " << thishdr_uid << "" << oendl;
375 if (thishdr_type < 2) break; 383 if (thishdr_type < 2) break;
376 //qDebug("Skipping paragraph of type %d", thishdr_type); 384 //odebug << "Skipping paragraph of type " << thishdr_type << "" << oendl;
377 if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; 385 if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false;
378 reclen = recordlength(thisrec); 386 reclen = recordlength(thisrec);
379 gotorecordnumber(thisrec); 387 gotorecordnumber(thisrec);
380 } 388 }
381 m_nParas = thishdr_nParagraphs; 389 m_nParas = thishdr_nParagraphs;
382 m_bufferisreserved = (thishdr_reserved != 0); 390 m_bufferisreserved = (thishdr_reserved != 0);
383 //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); 391 //odebug << "It has " << thishdr_nParagraphs << " paragraphs and is " << thishdr_size << " bytes" << oendl;
384 uid = thishdr_uid; 392 uid = thishdr_uid;
385// gotorecordnumber(thisrec); 393// gotorecordnumber(thisrec);
386// fread(expandedtextbuffer,1,10,fin); 394// fread(expandedtextbuffer,1,10,fin);
387 for (int i = 0; i < m_nParas; i++) 395 for (int i = 0; i < m_nParas; i++)
388 { 396 {
389 UInt16 ubytes, attrs; 397 UInt16 ubytes, attrs;
390 fread(&ubytes, 1, sizeof(ubytes), fin); 398 fread(&ubytes, 1, sizeof(ubytes), fin);
391 fread(&attrs, 1, sizeof(attrs), fin); 399 fread(&attrs, 1, sizeof(attrs), fin);
392 m_ParaOffsets[i] = ntohs(ubytes); 400 m_ParaOffsets[i] = ntohs(ubytes);
393 m_ParaAttrs[i] = ntohs(attrs); 401 m_ParaAttrs[i] = ntohs(attrs);
394 ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); 402// //odebug << "Bytes " << ntohs(ubytes) << ", Attr " << ntohs(attrs) << "" << oendl;
395 } 403 }
396 if (m_nParas > 0) 404 if (m_nParas > 0)
397 { 405 {
398 m_nextPara = m_ParaOffsets[0]; 406 m_nextPara = m_ParaOffsets[0];
399 //qDebug("First offset = %u", m_nextPara); 407 //odebug << "First offset = " << m_nextPara << "" << oendl;
400 m_nextParaIndex = 0; 408 m_nextParaIndex = 0;
401 } 409 }
402 else 410 else
403 { 411 {
404 m_nextPara = -1; 412 m_nextPara = -1;
405 } 413 }
@@ -415,13 +423,13 @@ bool CPlucker_base::expand(int thisrec)
415 expandedtextbuffer = new UInt8[buffersize]; 423 expandedtextbuffer = new UInt8[buffersize];
416 } 424 }
417 425
418 Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); 426 Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent);
419 bufferpos = 0; 427 bufferpos = 0;
420 bufferrec = thisrec; 428 bufferrec = thisrec;
421 //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); 429 //odebug << "BC:" << buffercontent << ", HS:" << thishdr_size << "" << oendl;
422 return true; 430 return true;
423} 431}
424 432
425void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) 433void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
426{ 434{
427 z_stream zstream; 435 z_stream zstream;
@@ -449,13 +457,13 @@ void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff
449 } 457 }
450 zstream.next_out = tgtbuffer; 458 zstream.next_out = tgtbuffer;
451 zstream.avail_out = bsize; 459 zstream.avail_out = bsize;
452 460
453 err = inflate( &zstream, Z_SYNC_FLUSH ); 461 err = inflate( &zstream, Z_SYNC_FLUSH );
454 462
455 ////qDebug("err:%d - %u", err, zstream.avail_in); 463// //odebug << "err:" << err << " - " << zstream.avail_in << "" << oendl;
456 464
457 } while ( err == Z_OK ); 465 } while ( err == Z_OK );
458 466
459 inflateEnd(&zstream); 467 inflateEnd(&zstream);
460} 468}
461 469
@@ -531,15 +539,15 @@ CList<Bkmk>* CPlucker_base::getbkmklist()
531 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 539 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
532 if (thishdr_type == 8) 540 if (thishdr_type == 8)
533 { 541 {
534 UInt16 n; 542 UInt16 n;
535 fread(&n, 1, sizeof(n), fin); 543 fread(&n, 1, sizeof(n), fin);
536 n = ntohs(n); 544 n = ntohs(n);
537 //qDebug("Found %u bookmarks", n); 545 //odebug << "Found " << n << " bookmarks" << oendl;
538 } 546 }
539 //qDebug("Found:%d, %u", i , thishdr_type); 547 //odebug << "Found:" << i << ", " << thishdr_type << "" << oendl;
540 } 548 }
541*/ 549*/
542 return NULL; 550 return NULL;
543} 551}
544 552
545 553
@@ -589,31 +597,31 @@ QImage* CPlucker_base::getPicture(unsigned long tgt)
589 597
590#ifdef LOCALPICTURES 598#ifdef LOCALPICTURES
591#include <unistd.h> 599#include <unistd.h>
592#include <qpe/global.h> 600#include <qpe/global.h>
593void CPlucker_base::showimg(UInt16 tgt) 601void CPlucker_base::showimg(UInt16 tgt)
594{ 602{
595 //qDebug("Crassssssh!"); 603 //odebug << "Crassssssh!" << oendl;
596 QPixmap* qimage = expandimg(tgt); 604 QPixmap* qimage = expandimg(tgt);
597 m_picture->setFixedSize(qimage->size()); 605 m_picture->setFixedSize(qimage->size());
598 m_picture->setBackgroundPixmap(*qimage); 606 m_picture->setBackgroundPixmap(*qimage);
599 delete qimage; 607 delete qimage;
600 m_viewer->show(); 608 m_viewer->show();
601 609
602/* 610/*
603 char tmp[] = "uqtreader.XXXXXX"; 611 char tmp[] = "uqtreader.XXXXXX";
604 QImage* qimage = getimg(tgt); 612 QImage* qimage = getimg(tgt);
605 QPixmap* image = new QPixmap(0,0); 613 QPixmap* image = new QPixmap(0,0);
606// //qDebug("New image"); 614// //odebug << "New image" << oendl;
607 image->convertFromImage(*qimage); 615 image->convertFromImage(*qimage);
608 delete qimage; 616 delete qimage;
609 char tmpfile[sizeof(tmp)+1]; 617 char tmpfile[sizeof(tmp)+1];
610 strcpy(tmpfile,tmp); 618 strcpy(tmpfile,tmp);
611 int f = mkstemp(tmpfile); 619 int f = mkstemp(tmpfile);
612 close(f); 620 close(f);
613 //qDebug("TMPFILE:%s", tmpfile); 621 //odebug << "TMPFILE:" << tmpfile << "" << oendl;
614 if (image->save(tmpfile,"PNG")) 622 if (image->save(tmpfile,"PNG"))
615 { 623 {
616 QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); 624 QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)");
617 e << QString(tmpfile); 625 e << QString(tmpfile);
618 } 626 }
619 Global::statusMessage("Opening image"); 627 Global::statusMessage("Opening image");
@@ -624,24 +632,24 @@ void CPlucker_base::showimg(UInt16 tgt)
624} 632}
625 633
626#endif 634#endif
627 635
628unsigned short CPlucker_base::finduid(unsigned short urlid) 636unsigned short CPlucker_base::finduid(unsigned short urlid)
629{ 637{
630// //qDebug("Finding %u", urlid); 638// //odebug << "Finding " << urlid << "" << oendl;
631 unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); 639 unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords);
632 unsigned short jmid = (jmin+jmax) >> 1; 640 unsigned short jmid = (jmin+jmax) >> 1;
633 while (jmax - jmin > 1) 641 while (jmax - jmin > 1)
634 { 642 {
635 gotorecordnumber(jmid); 643 gotorecordnumber(jmid);
636 UInt16 thishdr_uid, thishdr_nParagraphs; 644 UInt16 thishdr_uid, thishdr_nParagraphs;
637 UInt32 thishdr_size; 645 UInt32 thishdr_size;
638 UInt8 thishdr_type, thishdr_reserved; 646 UInt8 thishdr_type, thishdr_reserved;
639 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 647 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
640 unsigned short luid = thishdr_uid; 648 unsigned short luid = thishdr_uid;
641 ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); 649// //odebug << "" << jmin << " " << jmid << " " << jmax << " : " << urlid << "" << oendl;
642 if (luid == urlid) 650 if (luid == urlid)
643 { 651 {
644 return jmid; 652 return jmid;
645 } 653 }
646 if (luid < urlid) 654 if (luid < urlid)
647 { 655 {
@@ -656,26 +664,26 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
656 gotorecordnumber(jmin); 664 gotorecordnumber(jmin);
657 UInt16 thishdr_uid, thishdr_nParagraphs; 665 UInt16 thishdr_uid, thishdr_nParagraphs;
658 UInt32 thishdr_size; 666 UInt32 thishdr_size;
659 UInt8 thishdr_type, thishdr_reserved; 667 UInt8 thishdr_type, thishdr_reserved;
660 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 668 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
661 unsigned short luid = thishdr_uid; 669 unsigned short luid = thishdr_uid;
662 //qDebug("jmin at end:%u,%u", jmin, luid); 670 //odebug << "jmin at end:" << jmin << "," << luid << "" << oendl;
663 if (luid == urlid) 671 if (luid == urlid)
664 { 672 {
665 return jmin; 673 return jmin;
666 } 674 }
667 gotorecordnumber(jmax); 675 gotorecordnumber(jmax);
668 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 676 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
669 luid = thishdr_uid; 677 luid = thishdr_uid;
670 //qDebug("jmax at end:%u,%u", jmax, luid); 678 //odebug << "jmax at end:" << jmax << "," << luid << "" << oendl;
671 if (luid == urlid) 679 if (luid == urlid)
672 { 680 {
673 return jmax; 681 return jmax;
674 } 682 }
675 //qDebug("Couldn't find %u", urlid); 683 //odebug << "Couldn't find " << urlid << "" << oendl;
676 return 0; // Not found! 684 return 0; // Not found!
677} 685}
678 686
679 687
680void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) 688void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
681{ 689{
@@ -695,13 +703,13 @@ void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsig
695 for (it = visited.begin(); it != visited.end(); it++) 703 for (it = visited.begin(); it != visited.end(); it++)
696#else 704#else
697 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) 705 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
698#endif 706#endif
699 { 707 {
700 unsigned long t = *it; 708 unsigned long t = *it;
701 //qDebug("[%u]", t); 709// odebug << "[" << t << "]" << oendl;
702 memcpy(newdata, &t, sizeof(t)); 710 memcpy(newdata, &t, sizeof(t));
703 newdata += sizeof(t); 711 newdata += sizeof(t);
704 } 712 }
705 m_nav.setSaveData(data, len, pdata, newlen); 713 m_nav.setSaveData(data, len, pdata, newlen);
706 delete [] pdata; 714 delete [] pdata;
707} 715}
@@ -718,13 +726,13 @@ void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen)
718 for (int i = 0; i < sz; i++) 726 for (int i = 0; i < sz; i++)
719 { 727 {
720 unsigned long t; 728 unsigned long t;
721 if (srclen >= sizeof(t)) 729 if (srclen >= sizeof(t))
722 { 730 {
723 memcpy(&t, src, sizeof(t)); 731 memcpy(&t, src, sizeof(t));
724 // qDebug("[%u]", t); 732// odebug << "[" << t << "]" << oendl;
725 visited.push_front(t); 733 visited.push_front(t);
726 src += sizeof(t); 734 src += sizeof(t);
727 srclen -= sizeof(t); 735 srclen -= sizeof(t);
728 } 736 }
729 else 737 else
730 { 738 {
@@ -748,23 +756,23 @@ int CPlucker_base::OpenFile(const char *src)
748 gotorecordnumber(0); 756 gotorecordnumber(0);
749 fread(&hdr0, 1, 6, fin); 757 fread(&hdr0, 1, 6, fin);
750 setbuffersize(); 758 setbuffersize();
751 compressedtextbuffer = new UInt8[compressedbuffersize]; 759 compressedtextbuffer = new UInt8[compressedbuffersize];
752 expandedtextbuffer = new UInt8[buffersize]; 760 expandedtextbuffer = new UInt8[buffersize];
753 761
754 //qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); 762 //odebug << "Total number of records:" << ntohs(head.recordList.numRecords) << "" << oendl;
755 763
756 unsigned int nrecs = ntohs(hdr0.nRecords); 764 unsigned int nrecs = ntohs(hdr0.nRecords);
757 //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); 765 //odebug << "Version " << ntohs(hdr0.version) << ", no. recs " << nrecs << "" << oendl;
758 UInt16 homerecid = 1; 766 UInt16 homerecid = 1;
759 for (unsigned int i = 0; i < nrecs; i++) 767 for (unsigned int i = 0; i < nrecs; i++)
760 { 768 {
761 UInt16 id, name; 769 UInt16 id, name;
762 fread(&name, 1, sizeof(name), fin); 770 fread(&name, 1, sizeof(name), fin);
763 fread(&id, 1, sizeof(id), fin); 771 fread(&id, 1, sizeof(id), fin);
764 //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); 772 //odebug << "N:" << ntohs(name) << ", I:" << ntohs(id) << "" << oendl;
765 if (ntohs(name) == 0) homerecid = ntohs(id); 773 if (ntohs(name) == 0) homerecid = ntohs(id);
766 } 774 }
767 775
768 textlength = 0; 776 textlength = 0;
769 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 777 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
770 { 778 {
@@ -816,25 +824,25 @@ QImage* CPlucker_base::getimg(UInt16 tgt)
816 824
817linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) 825linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
818{ 826{
819 visited.push_front(n); 827 visited.push_front(n);
820 UInt16 tuid = (n >> 16); 828 UInt16 tuid = (n >> 16);
821 n &= 0xffff; 829 n &= 0xffff;
822// //qDebug("Hyper:<%u,%u>", tuid, n); 830// //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl;
823 UInt16 thisrec = 1; 831 UInt16 thisrec = 1;
824 currentpos = 0; 832 currentpos = 0;
825 gotorecordnumber(thisrec); 833 gotorecordnumber(thisrec);
826 UInt16 thishdr_uid, thishdr_nParagraphs; 834 UInt16 thishdr_uid, thishdr_nParagraphs;
827 UInt32 thishdr_size; 835 UInt32 thishdr_size;
828 UInt8 thishdr_type, thishdr_reserved; 836 UInt8 thishdr_type, thishdr_reserved;
829 while (1) 837 while (1)
830 { 838 {
831 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 839 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
832 if (tuid == thishdr_uid) break; 840 if (tuid == thishdr_uid) break;
833 if (thishdr_type < 2) currentpos += thishdr_size; 841 if (thishdr_type < 2) currentpos += thishdr_size;
834 ////qDebug("hyper-cp:%u", currentpos); 842// //odebug << "hyper-cp:" << currentpos << "" << oendl;
835 thisrec++; 843 thisrec++;
836 if (thisrec >= ntohs(head.recordList.numRecords)) 844 if (thisrec >= ntohs(head.recordList.numRecords))
837 { 845 {
838 char *turl = geturl(tuid); 846 char *turl = geturl(tuid);
839 if (turl == NULL) 847 if (turl == NULL)
840 { 848 {
@@ -854,13 +862,13 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
854 else 862 else
855 { 863 {
856 Global::statusMessage(wrd); 864 Global::statusMessage(wrd);
857 } 865 }
858#else 866#else
859#endif /* USEQPE */ 867#endif /* USEQPE */
860 //qDebug("Link:%s", (const char*)wrd); 868 //odebug << "Link:" << wrd << "" << oendl;
861 // setlink(fn, wrd); 869 // setlink(fn, wrd);
862 delete [] turl; 870 delete [] turl;
863 } 871 }
864 return eNone; 872 return eNone;
865 } 873 }
866 gotorecordnumber(thisrec); 874 gotorecordnumber(thisrec);
@@ -923,13 +931,13 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
923 QMessageBox::information(NULL, 931 QMessageBox::information(NULL,
924 QString(PROGNAME), 932 QString(PROGNAME),
925 QString("Error in link\nOffset too big") 933 QString("Error in link\nOffset too big")
926 ); 934 );
927 return eNone; 935 return eNone;
928 } 936 }
929 //qDebug("Hyper:<%u,%u>", tuid, n); 937 //odebug << "Hyper:<" << tuid << "," << n << ">" << oendl;
930 while (bufferpos < n && bufferpos < buffercontent) getch_base(true); 938 while (bufferpos < n && bufferpos < buffercontent) getch_base(true);
931/* // This is faster but the alignment doesn't get set 939/* // This is faster but the alignment doesn't get set
932 mystyle.unset(); 940 mystyle.unset();
933 bufferpos = n; 941 bufferpos = n;
934 currentpos += n; 942 currentpos += n;
935 while (bufferpos >= m_nextPara && m_nextPara >= 0) 943 while (bufferpos >= m_nextPara && m_nextPara >= 0)
@@ -953,17 +961,17 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
953tchar CPlucker_base::getch_base(bool fast) 961tchar CPlucker_base::getch_base(bool fast)
954{ 962{
955 int ch = bgetch(); 963 int ch = bgetch();
956 while (ch == 0) 964 while (ch == 0)
957 { 965 {
958 ch = bgetch(); 966 ch = bgetch();
959 ////qDebug("Function:%x", ch); 967// //odebug << "Function:" << ch << "" << oendl;
960 switch (ch) 968 switch (ch)
961 { 969 {
962 case 0x38: 970 case 0x38:
963 // //qDebug("Break:%u", locate()); 971// //odebug << "Break:" << locate() << "" << oendl;
964 if (m_lastBreak == locate()) 972 if (m_lastBreak == locate())
965 { 973 {
966 ch = bgetch(); 974 ch = bgetch();
967 } 975 }
968 else 976 else
969 { 977 {
@@ -977,28 +985,28 @@ tchar CPlucker_base::getch_base(bool fast)
977 unsigned long ln = 0; 985 unsigned long ln = 0;
978 int skip = ch & 7; 986 int skip = ch & 7;
979 for (int i = 0; i < 2; i++) 987 for (int i = 0; i < 2; i++)
980 { 988 {
981 int ch = bgetch(); 989 int ch = bgetch();
982 ln = (ln << 8) + ch; 990 ln = (ln << 8) + ch;
983 // //qDebug("ch:%d, ln:%u", ch, ln); 991// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl;
984 } 992 }
985 if (skip == 2) 993 if (skip == 2)
986 { 994 {
987 ln <<= 16; 995 ln <<= 16;
988 } 996 }
989 else 997 else
990 { 998 {
991 for (int i = 0; i < 2; i++) 999 for (int i = 0; i < 2; i++)
992 { 1000 {
993 int ch = bgetch(); 1001 int ch = bgetch();
994 ln = (ln << 8) + ch; 1002 ln = (ln << 8) + ch;
995 // //qDebug("ch:%d, ln:%u", ch, ln); 1003// //odebug << "ch:" << ch << ", ln:" << ln << "" << oendl;
996 } 1004 }
997 } 1005 }
998 // //qDebug("ln:%u", ln); 1006// //odebug << "ln:" << ln << "" << oendl;
999 mystyle.setLink(true); 1007 mystyle.setLink(true);
1000 mystyle.setData(ln); 1008 mystyle.setData(ln);
1001 // mystyle.setColour(255, 0, 0); 1009 // mystyle.setColour(255, 0, 0);
1002 bool hasseen = false; 1010 bool hasseen = false;
1003 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) 1011 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
1004 { 1012 {
@@ -1035,13 +1043,13 @@ tchar CPlucker_base::getch_base(bool fast)
1035 mystyle.unsetItalic(); 1043 mystyle.unsetItalic();
1036 ch = bgetch(); 1044 ch = bgetch();
1037 break; 1045 break;
1038 case 0x11: 1046 case 0x11:
1039 { 1047 {
1040 ch = bgetch(); 1048 ch = bgetch();
1041 // //qDebug("Font:%d",ch); 1049// //odebug << "Font:" << ch << "" << oendl;
1042 mystyle.setVOffset(0); 1050 mystyle.setVOffset(0);
1043 mystyle.unsetMono(); 1051 mystyle.unsetMono();
1044 mystyle.unsetBold(); 1052 mystyle.unsetBold();
1045 mystyle.setFontSize(0); 1053 mystyle.setFontSize(0);
1046 switch (ch) 1054 switch (ch)
1047 { 1055 {
@@ -1069,13 +1077,13 @@ tchar CPlucker_base::getch_base(bool fast)
1069 mystyle.setBold(); 1077 mystyle.setBold();
1070 break; 1078 break;
1071 case 7: 1079 case 7:
1072 mystyle.setBold(); 1080 mystyle.setBold();
1073 break; 1081 break;
1074 case 8: // should be fixed width 1082 case 8: // should be fixed width
1075 //qDebug("Trying fixed width"); 1083 //odebug << "Trying fixed width" << oendl;
1076 mystyle.setMono(); 1084 mystyle.setMono();
1077 break; 1085 break;
1078 case 9: 1086 case 9:
1079 mystyle.setFontSize(-1); 1087 mystyle.setFontSize(-1);
1080 break; 1088 break;
1081 case 10: 1089 case 10:
@@ -1084,37 +1092,37 @@ tchar CPlucker_base::getch_base(bool fast)
1084 break; 1092 break;
1085 case 11: 1093 case 11:
1086 mystyle.setFontSize(-2); 1094 mystyle.setFontSize(-2);
1087 mystyle.setVOffset(-1); 1095 mystyle.setVOffset(-1);
1088 break; 1096 break;
1089 default: 1097 default:
1090 qDebug("Unrecognised font"); 1098 odebug << "Unrecognised font" << oendl;
1091 break; 1099 break;
1092 } 1100 }
1093 ch = bgetch(); 1101 ch = bgetch();
1094 } 1102 }
1095 break; 1103 break;
1096 case 0x29: 1104 case 0x29:
1097 ch = bgetch(); 1105 ch = bgetch();
1098 switch (ch) 1106 switch (ch)
1099 { 1107 {
1100 case 0: 1108 case 0:
1101 mystyle.setLeftJustify(); 1109 mystyle.setLeftJustify();
1102 // //qDebug("left"); 1110// //odebug << "left" << oendl;
1103 break; 1111 break;
1104 case 1: 1112 case 1:
1105 mystyle.setRightJustify(); 1113 mystyle.setRightJustify();
1106 // //qDebug("right"); 1114// //odebug << "right" << oendl;
1107 break; 1115 break;
1108 case 2: 1116 case 2:
1109 mystyle.setCentreJustify(); 1117 mystyle.setCentreJustify();
1110 // //qDebug("centre"); 1118// //odebug << "centre" << oendl;
1111 break; 1119 break;
1112 case 3: 1120 case 3:
1113 mystyle.setFullJustify(); 1121 mystyle.setFullJustify();
1114 // //qDebug("full"); 1122// //odebug << "full" << oendl;
1115 break; 1123 break;
1116 1124
1117 } 1125 }
1118 ch = bgetch(); 1126 ch = bgetch();
1119 break; 1127 break;
1120 case 0x53: 1128 case 0x53:
@@ -1131,13 +1139,13 @@ tchar CPlucker_base::getch_base(bool fast)
1131 { 1139 {
1132 bool hasalternate = (ch == 0x5c); 1140 bool hasalternate = (ch == 0x5c);
1133 UInt16 ir = bgetch(); 1141 UInt16 ir = bgetch();
1134 ir = (ir << 8) + bgetch(); 1142 ir = (ir << 8) + bgetch();
1135 if (hasalternate) 1143 if (hasalternate)
1136 { 1144 {
1137 //qDebug("Alternate image:%x", ir); 1145 //odebug << "Alternate image:" << ir << "" << oendl;
1138 UInt16 ir2 = bgetch(); 1146 UInt16 ir2 = bgetch();
1139 ir2 = (ir2 << 8) + bgetch(); 1147 ir2 = (ir2 << 8) + bgetch();
1140 if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); 1148 if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16);
1141#ifdef LOCALPICTURES 1149#ifdef LOCALPICTURES
1142 UInt32 ln = ir; 1150 UInt32 ln = ir;
1143 ln <<= 16; 1151 ln <<= 16;
@@ -1146,31 +1154,31 @@ tchar CPlucker_base::getch_base(bool fast)
1146#endif 1154#endif
1147 } 1155 }
1148 else 1156 else
1149 { 1157 {
1150 if (!fast) mystyle.setPicture(true, expandimg(ir)); 1158 if (!fast) mystyle.setPicture(true, expandimg(ir));
1151 } 1159 }
1152 // if (mystyle.getLink()) qDebug("Picture link!"); 1160// if (mystyle.getLink()) odebug << "Picture link!" << oendl;
1153 ch = '#'; 1161 ch = '#';
1154 } 1162 }
1155 // ch = bgetch(); 1163 // ch = bgetch();
1156 break; 1164 break;
1157 case 0x33: 1165 case 0x33:
1158 { 1166 {
1159 UInt8 h = bgetch(); 1167 UInt8 h = bgetch();
1160 UInt8 wc = bgetch(); 1168 UInt8 wc = bgetch();
1161 UInt8 pc = bgetch(); 1169 UInt8 pc = bgetch();
1162 UInt16 w = wc; 1170 UInt16 w = wc;
1163 // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); 1171// //odebug << "h,w,pc [" << h << ", " << w << ", " << pc << "]" << oendl;
1164 if (w == 0) 1172 if (w == 0)
1165 { 1173 {
1166 w = (m_scrWidth*(unsigned long)pc)/100; 1174 w = (m_scrWidth*(unsigned long)pc)/100;
1167 } 1175 }
1168 if (w == 0) w = m_scrWidth; 1176 if (w == 0) w = m_scrWidth;
1169 mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); 1177 mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue()));
1170 // if (mystyle.getLink()) //qDebug("hRule link!"); 1178// if (mystyle.getLink()) //odebug << "hRule link!" << oendl;
1171 ch = '#'; 1179 ch = '#';
1172 } 1180 }
1173 break; 1181 break;
1174 case 0x60: 1182 case 0x60:
1175 mystyle.setUnderline(); 1183 mystyle.setUnderline();
1176 ch = bgetch(); 1184 ch = bgetch();
@@ -1179,16 +1187,16 @@ tchar CPlucker_base::getch_base(bool fast)
1179 mystyle.unsetUnderline(); 1187 mystyle.unsetUnderline();
1180 ch = bgetch(); 1188 ch = bgetch();
1181 break; 1189 break;
1182 case 0x22: 1190 case 0x22:
1183 ch = bgetch(); 1191 ch = bgetch();
1184 mystyle.setLeftMargin(ch); 1192 mystyle.setLeftMargin(ch);
1185 // //qDebug("Left margin:%d", ch); 1193// //odebug << "Left margin:" << ch << "" << oendl;
1186 ch = bgetch(); 1194 ch = bgetch();
1187 mystyle.setRightMargin(ch); 1195 mystyle.setRightMargin(ch);
1188 // //qDebug("Right margin:%d", ch); 1196// //odebug << "Right margin:" << ch << "" << oendl;
1189 ch = bgetch(); 1197 ch = bgetch();
1190 break; 1198 break;
1191 case 0x70: 1199 case 0x70:
1192 mystyle.setStrikethru(); 1200 mystyle.setStrikethru();
1193 ch = bgetch(); 1201 ch = bgetch();
1194 break; 1202 break;
@@ -1200,24 +1208,24 @@ tchar CPlucker_base::getch_base(bool fast)
1200 { 1208 {
1201 int tlen = bgetch(); 1209 int tlen = bgetch();
1202 ch = bgetch(); 1210 ch = bgetch();
1203 ch <<= 8; 1211 ch <<= 8;
1204 ch |= (tchar)bgetch(); 1212 ch |= (tchar)bgetch();
1205 for (int i = 0; i < tlen; i++) bgetch(); 1213 for (int i = 0; i < tlen; i++) bgetch();
1206 //qDebug("Function 83"); 1214 //odebug << "Function 83" << oendl;
1207 } 1215 }
1208 break; 1216 break;
1209 case 0x85: 1217 case 0x85:
1210 default: 1218 default:
1211 qDebug("Function:%x NOT IMPLEMENTED", ch); 1219 odebug << "Function:" << ch << " NOT IMPLEMENTED" << oendl;
1212 { 1220 {
1213 int skip = ch & 7; 1221 int skip = ch & 7;
1214 for (int i = 0; i < skip; i++) 1222 for (int i = 0; i < skip; i++)
1215 { 1223 {
1216 ch = bgetch(); 1224 ch = bgetch();
1217 //qDebug("Arg %d, %d", i, ch); 1225 //odebug << "Arg " << i << ", " << ch << "" << oendl;
1218 } 1226 }
1219 ch = bgetch(); 1227 ch = bgetch();
1220 } 1228 }
1221 } 1229 }
1222 } 1230 }
1223 1231