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.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,32 +1,33 @@
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
16#include <qapplication.h> 18#include <qapplication.h>
17#else /* USEQPE */ 19#else /* USEQPE */
18#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
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
30const UInt8 CPlucker_base::continuation_bit = 1;
30 31
31CPlucker_base::CPlucker_base() : 32CPlucker_base::CPlucker_base() :
32#ifdef LOCALPICTURES 33#ifdef LOCALPICTURES
@@ -34,7 +35,9 @@ CPlucker_base::CPlucker_base() :
34 m_picture(NULL), 35 m_picture(NULL),
35#endif 36#endif
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)
39 { /*printf("constructing:%x\n",fin);*/ } 42 { /*printf("constructing:%x\n",fin);*/ }
40 43
@@ -59,15 +62,7 @@ void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buff
59 if (readbuffer != NULL) 62 if (readbuffer != NULL)
60 { 63 {
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)
72 { 67 {
73 delete [] readbuffer; 68 delete [] readbuffer;
@@ -101,7 +96,7 @@ char* CPlucker_base::geturl(UInt16 tgt)
101 gotorecordnumber(0); 96 gotorecordnumber(0);
102 fread(&hdr0, 1, 6, fin); 97 fread(&hdr0, 1, 6, fin);
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;
106 bool urlsfound = false; 101 bool urlsfound = false;
107 char* urls = NULL; 102 char* urls = NULL;
@@ -111,14 +106,14 @@ char* CPlucker_base::geturl(UInt16 tgt)
111 UInt16 id, name; 106 UInt16 id, name;
112 fread(&name, 1, sizeof(name), fin); 107 fread(&name, 1, sizeof(name), fin);
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)
116 { 111 {
117 urlsfound = true; 112 urlsfound = true;
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 }
123 if (urlsfound) 118 if (urlsfound)
124 { 119 {
@@ -137,21 +132,21 @@ char* CPlucker_base::geturl(UInt16 tgt)
137 fread(&tctr, 1, sizeof(tctr), fin); 132 fread(&tctr, 1, sizeof(tctr), fin);
138 fread(&urlid, 1, sizeof(urlid), fin); 133 fread(&urlid, 1, sizeof(urlid), fin);
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)
142 { 137 {
143 break; 138 break;
144 } 139 }
145 urlctr = tctr; 140 urlctr = tctr;
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));
149 if (recptr != 0) 144 if (recptr != 0)
150 { 145 {
151 UInt32 reclen = recordlength(recptr) - HeaderSize(); 146 UInt32 reclen = recordlength(recptr) - HeaderSize();
152 gotorecordnumber(recptr); 147 gotorecordnumber(recptr);
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;
156 urls = new char[urlsize]; 151 urls = new char[urlsize];
157 Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); 152 Expand(reclen, thishdr_type, (UInt8*)urls, urlsize);
@@ -161,7 +156,7 @@ char* CPlucker_base::geturl(UInt16 tgt)
161 { 156 {
162 if (rn == tgt) 157 if (rn == 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;
166 pRet = new char[len]; 161 pRet = new char[len];
167 memcpy(pRet, ptr, len); 162 memcpy(pRet, ptr, len);
@@ -176,10 +171,7 @@ char* CPlucker_base::geturl(UInt16 tgt)
176 } 171 }
177 else 172 else
178 { 173 {
179 QMessageBox::information(NULL, 174 pRet = NULL;
180 QString(PROGNAME),
181 QString("No external links\nin this pluck")
182 );
183 } 175 }
184 return pRet; 176 return pRet;
185} 177}
@@ -195,8 +187,9 @@ CPlucker_base::~CPlucker_base()
195 187
196int CPlucker_base::getch() { return getch(false); } 188int CPlucker_base::getch() { return getch(false); }
197 189
198void CPlucker_base::getch(tchar& ch, CStyle& sty) 190void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos)
199{ 191{
192 pos = locate();
200 ch = getch(false); 193 ch = getch(false);
201 sty = mystyle; 194 sty = mystyle;
202} 195}
@@ -226,6 +219,15 @@ void CPlucker_base::locate(unsigned int n)
226{ 219{
227 220
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;
230 UInt16 recptr = bufferrec; 232 UInt16 recptr = bufferrec;
231 if (n < textlength/2) 233 if (n < textlength/2)
@@ -258,7 +260,7 @@ void CPlucker_base::locate(unsigned int n)
258 { 260 {
259 recptr--; 261 recptr--;
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);
263 if (thishdr_type < 2) 265 if (thishdr_type < 2)
264 { 266 {
@@ -283,30 +285,8 @@ void CPlucker_base::locate(unsigned int n)
283 } 285 }
284 } 286 }
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;
311 unsigned long locpos = 0; 291 unsigned long locpos = 0;
312 unsigned long bs = 0; 292 unsigned long bs = 0;
@@ -329,10 +309,11 @@ void CPlucker_base::locate(unsigned int n)
329 } 309 }
330 } while (locpos + bs <= n); 310 } while (locpos + bs <= 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;
337 UInt32 thishdr_size = buffercontent; 318 UInt32 thishdr_size = buffercontent;
338 UInt8 thishdr_type, thishdr_reserved; 319 UInt8 thishdr_type, thishdr_reserved;
@@ -340,11 +321,11 @@ void CPlucker_base::locate(unsigned int n)
340 { 321 {
341 gotorecordnumber(recptr); 322 gotorecordnumber(recptr);
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 }
345// QApplication::exit ( 100 ); 326// QApplication::exit ( 100 );
346 } 327 }
347 328 */
348 currentpos = locpos; 329 currentpos = locpos;
349 expand(thisrec); 330 expand(thisrec);
350 while (currentpos < n && bufferpos < buffercontent) getch_base(true); 331 while (currentpos < n && bufferpos < buffercontent) getch_base(true);
@@ -371,6 +352,8 @@ void CPlucker_base::locate(unsigned int n)
371bool CPlucker_base::expand(int thisrec) 352bool CPlucker_base::expand(int thisrec)
372{ 353{
373 mystyle.unset(); 354 mystyle.unset();
355 if (bufferrec != thisrec)
356 {
374 size_t reclen = recordlength(thisrec); 357 size_t reclen = recordlength(thisrec);
375 gotorecordnumber(thisrec); 358 gotorecordnumber(thisrec);
376 UInt16 thishdr_uid, thishdr_nParagraphs; 359 UInt16 thishdr_uid, thishdr_nParagraphs;
@@ -379,16 +362,16 @@ bool CPlucker_base::expand(int thisrec)
379 while (1) 362 while (1)
380 { 363 {
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;
386 reclen = recordlength(thisrec); 369 reclen = recordlength(thisrec);
387 gotorecordnumber(thisrec); 370 gotorecordnumber(thisrec);
388 } 371 }
389 m_nParas = thishdr_nParagraphs; 372 m_nParas = thishdr_nParagraphs;
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;
393// gotorecordnumber(thisrec); 376// gotorecordnumber(thisrec);
394// fread(expandedtextbuffer,1,10,fin); 377// fread(expandedtextbuffer,1,10,fin);
@@ -399,17 +382,7 @@ bool CPlucker_base::expand(int thisrec)
399 fread(&attrs, 1, sizeof(attrs), fin); 382 fread(&attrs, 1, sizeof(attrs), fin);
400 m_ParaOffsets[i] = ntohs(ubytes); 383 m_ParaOffsets[i] = ntohs(ubytes);
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 }
414 387
415 reclen -= HeaderSize()+4*m_nParas; 388 reclen -= HeaderSize()+4*m_nParas;
@@ -422,11 +395,23 @@ bool CPlucker_base::expand(int thisrec)
422 buffersize = thishdr_size; 395 buffersize = thishdr_size;
423 expandedtextbuffer = new UInt8[buffersize]; 396 expandedtextbuffer = new UInt8[buffersize];
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;
431} 416}
432 417
@@ -460,7 +445,7 @@ void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuff
460 445
461 err = inflate( &zstream, Z_SYNC_FLUSH ); 446 err = inflate( &zstream, Z_SYNC_FLUSH );
462 447
463// //odebug << "err:" << err << " - " << zstream.avail_in << "" << oendl; 448 ////qDebug("err:%d - %u", err, zstream.avail_in);
464 449
465 } while ( err == Z_OK ); 450 } while ( err == Z_OK );
466 451
@@ -542,14 +527,15 @@ CList<Bkmk>* CPlucker_base::getbkmklist()
542 UInt16 n; 527 UInt16 n;
543 fread(&n, 1, sizeof(n), fin); 528 fread(&n, 1, sizeof(n), fin);
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 }
549*/ 534*/
550 return NULL; 535 return NULL;
551} 536}
552 537
538#include <qnamespace.h>
553 539
554QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) 540QImage* CPlucker_base::expandimg(UInt16 tgt, bool border)
555{ 541{
@@ -600,7 +586,7 @@ QImage* CPlucker_base::getPicture(unsigned long tgt)
600#include <qpe/global.h> 586#include <qpe/global.h>
601void CPlucker_base::showimg(UInt16 tgt) 587void CPlucker_base::showimg(UInt16 tgt)
602{ 588{
603 //odebug << "Crassssssh!" << oendl; 589 //qDebug("Crassssssh!");
604 QPixmap* qimage = expandimg(tgt); 590 QPixmap* qimage = expandimg(tgt);
605 m_picture->setFixedSize(qimage->size()); 591 m_picture->setFixedSize(qimage->size());
606 m_picture->setBackgroundPixmap(*qimage); 592 m_picture->setBackgroundPixmap(*qimage);
@@ -611,14 +597,14 @@ void CPlucker_base::showimg(UInt16 tgt)
611 char tmp[] = "uqtreader.XXXXXX"; 597 char tmp[] = "uqtreader.XXXXXX";
612 QImage* qimage = getimg(tgt); 598 QImage* qimage = getimg(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);
616 delete qimage; 602 delete qimage;
617 char tmpfile[sizeof(tmp)+1]; 603 char tmpfile[sizeof(tmp)+1];
618 strcpy(tmpfile,tmp); 604 strcpy(tmpfile,tmp);
619 int f = mkstemp(tmpfile); 605 int f = mkstemp(tmpfile);
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"))
623 { 609 {
624 QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); 610 QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)");
@@ -635,7 +621,7 @@ void CPlucker_base::showimg(UInt16 tgt)
635 621
636unsigned short CPlucker_base::finduid(unsigned short urlid) 622unsigned 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);
640 unsigned short jmid = (jmin+jmax) >> 1; 626 unsigned short jmid = (jmin+jmax) >> 1;
641 while (jmax - jmin > 1) 627 while (jmax - jmin > 1)
@@ -646,7 +632,7 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
646 UInt8 thishdr_type, thishdr_reserved; 632 UInt8 thishdr_type, thishdr_reserved;
647 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 633 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
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)
651 { 637 {
652 return jmid; 638 return jmid;
@@ -667,7 +653,7 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
667 UInt8 thishdr_type, thishdr_reserved; 653 UInt8 thishdr_type, thishdr_reserved;
668 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 654 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
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)
672 { 658 {
673 return jmin; 659 return jmin;
@@ -675,15 +661,16 @@ unsigned short CPlucker_base::finduid(unsigned short urlid)
675 gotorecordnumber(jmax); 661 gotorecordnumber(jmax);
676 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 662 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
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)
680 { 666 {
681 return jmax; 667 return jmax;
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!
685} 671}
686 672
673#include <qnamespace.h>
687 674
688void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) 675void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
689{ 676{
@@ -706,7 +693,7 @@ void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsig
706#endif 693#endif
707 { 694 {
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));
711 newdata += sizeof(t); 698 newdata += sizeof(t);
712 } 699 }
@@ -729,7 +716,7 @@ void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen)
729 if (srclen >= sizeof(t)) 716 if (srclen >= sizeof(t))
730 { 717 {
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);
734 src += sizeof(t); 721 src += sizeof(t);
735 srclen -= sizeof(t); 722 srclen -= sizeof(t);
@@ -745,8 +732,9 @@ void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen)
745 732
746int CPlucker_base::OpenFile(const char *src) 733int 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 {
751 return -1; 739 return -1;
752 } 740 }
@@ -755,21 +743,45 @@ int CPlucker_base::OpenFile(const char *src)
755 743
756 gotorecordnumber(0); 744 gotorecordnumber(0);
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();
759 compressedtextbuffer = new UInt8[compressedbuffersize]; 771 compressedtextbuffer = new UInt8[compressedbuffersize];
760 expandedtextbuffer = new UInt8[buffersize]; 772 expandedtextbuffer = new UInt8[buffersize];
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;
767 for (unsigned int i = 0; i < nrecs; i++) 779 for (unsigned int i = 0; i < nrecs; i++)
768 { 780 {
769 UInt16 id, name; 781 UInt16 id, name;
770 fread(&name, 1, sizeof(name), fin); 782 fread(&name, 1, sizeof(name), fin);
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);
774 } 786 }
775 787
@@ -788,8 +800,10 @@ int CPlucker_base::OpenFile(const char *src)
788 } 800 }
789 if (thishdr_type < 2) textlength += thishdr_size; 801 if (thishdr_type < 2) textlength += thishdr_size;
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
794 if (m_viewer == NULL) 808 if (m_viewer == NULL)
795 { 809 {
@@ -806,12 +820,87 @@ QImage* CPlucker_base::getimg(UInt16 tgt)
806{ 820{
807 size_t reclen; 821 size_t reclen;
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);
810 gotorecordnumber(thisrec); 825 gotorecordnumber(thisrec);
811 UInt16 thishdr_uid, thishdr_nParagraphs; 826 UInt16 thishdr_uid, thishdr_nParagraphs;
812 UInt32 thishdr_size; 827 UInt32 thishdr_size;
813 UInt8 thishdr_type, thishdr_reserved; 828 UInt8 thishdr_type, thishdr_reserved;
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();
816 905
817 UInt32 imgsize = thishdr_size; 906 UInt32 imgsize = thishdr_size;
@@ -821,13 +910,25 @@ QImage* CPlucker_base::getimg(UInt16 tgt)
821 910
822 return imagefromdata(imgbuffer, imgsize); 911 return imagefromdata(imgbuffer, imgsize);
823} 912}
913}
824 914
825linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd) 915linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& wrd, QString&)
826{ 916{
827 visited.push_front(n); 917 visited.push_front(n);
828 UInt16 tuid = (n >> 16); 918 UInt16 tuid = (n >> 16);
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;
832 currentpos = 0; 933 currentpos = 0;
833 gotorecordnumber(thisrec); 934 gotorecordnumber(thisrec);
@@ -839,12 +940,11 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
839 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 940 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
840 if (tuid == thishdr_uid) break; 941 if (tuid == thishdr_uid) break;
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++;
844 if (thisrec >= ntohs(head.recordList.numRecords)) 945 if (thisrec >= ntohs(head.recordList.numRecords))
845 { 946 {
846 char *turl = geturl(tuid); 947 if (wrd.isEmpty())
847 if (turl == NULL)
848 { 948 {
849 QMessageBox::information(NULL, 949 QMessageBox::information(NULL,
850 QString(PROGNAME), 950 QString(PROGNAME),
@@ -853,7 +953,6 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
853 } 953 }
854 else 954 else
855 { 955 {
856 wrd = turl;
857#ifdef USEQPE 956#ifdef USEQPE
858 if (wrd.length() > 10) 957 if (wrd.length() > 10)
859 { 958 {
@@ -865,9 +964,8 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
865 } 964 }
866#else 965#else
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 }
872 return eNone; 970 return eNone;
873 } 971 }
@@ -883,7 +981,7 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
883 } 981 }
884 else 982 else
885 { 983 {
886 if (thishdr_type > 3) 984 if (thishdr_type > 3 && thishdr_type != 15)
887 { 985 {
888 QMessageBox::information(NULL, 986 QMessageBox::information(NULL,
889 QString(PROGNAME), 987 QString(PROGNAME),
@@ -912,6 +1010,8 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
912 else 1010 else
913 { 1011 {
914 expand(thisrec); 1012 expand(thisrec);
1013 unsigned int paraoffset = offset;
1014 // unsigned int noff = 0;
915 if (n != 0) 1015 if (n != 0)
916 { 1016 {
917 if (n >= m_nParas) 1017 if (n >= m_nParas)
@@ -924,9 +1024,10 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
924 } 1024 }
925 unsigned int noff = 0; 1025 unsigned int noff = 0;
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 {
931 QMessageBox::information(NULL, 1032 QMessageBox::information(NULL,
932 QString(PROGNAME), 1033 QString(PROGNAME),
@@ -934,8 +1035,8 @@ linkType CPlucker_base::hyperlink(unsigned int n, QString& wrd)
934 ); 1035 );
935 return eNone; 1036 return eNone;
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
940 mystyle.unset(); 1041 mystyle.unset();
941 bufferpos = n; 1042 bufferpos = n;
@@ -964,11 +1065,11 @@ tchar CPlucker_base::getch_base(bool fast)
964 while (ch == 0) 1065 while (ch == 0)
965 { 1066 {
966 ch = bgetch(); 1067 ch = bgetch();
967// //odebug << "Function:" << ch << "" << oendl; 1068 ////qDebug("Function:%x", ch);
968 switch (ch) 1069 switch (ch)
969 { 1070 {
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())
973 { 1074 {
974 ch = bgetch(); 1075 ch = bgetch();
@@ -988,7 +1089,7 @@ tchar CPlucker_base::getch_base(bool fast)
988 { 1089 {
989 int ch = bgetch(); 1090 int ch = bgetch();
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 }
993 if (skip == 2) 1094 if (skip == 2)
994 { 1095 {
@@ -1000,10 +1101,10 @@ tchar CPlucker_base::getch_base(bool fast)
1000 { 1101 {
1001 int ch = bgetch(); 1102 int ch = bgetch();
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);
1008 mystyle.setData(ln); 1109 mystyle.setData(ln);
1009// mystyle.setColour(255, 0, 0); 1110// mystyle.setColour(255, 0, 0);
@@ -1024,6 +1125,8 @@ tchar CPlucker_base::getch_base(bool fast)
1024 { 1125 {
1025 mystyle.setUnderline(); 1126 mystyle.setUnderline();
1026 } 1127 }
1128 mystyle.setOffset(m_offset);
1129 m_offset = 0;
1027 ch = bgetch(); 1130 ch = bgetch();
1028 } 1131 }
1029 break; 1132 break;
@@ -1046,44 +1149,50 @@ tchar CPlucker_base::getch_base(bool fast)
1046 case 0x11: 1149 case 0x11:
1047 { 1150 {
1048 ch = bgetch(); 1151 ch = bgetch();
1049// //odebug << "Font:" << ch << "" << oendl; 1152 // //qDebug("Font:%d",ch);
1050 mystyle.setVOffset(0); 1153 mystyle.setVOffset(0);
1051 mystyle.unsetMono(); 1154 mystyle.unsetMono();
1052 mystyle.unsetBold(); 1155 mystyle.unsetBold();
1053 mystyle.setFontSize(0);
1054 switch (ch) 1156 switch (ch)
1055 { 1157 {
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();
1072 break; 1176 break;
1073 case 5: 1177 case 5:
1178 mystyle.setFontSize(0);
1074 mystyle.setBold(); 1179 mystyle.setBold();
1075 break; 1180 break;
1076 case 6: 1181 case 6:
1182 mystyle.setFontSize(0);
1077 mystyle.setBold(); 1183 mystyle.setBold();
1078 break; 1184 break;
1079 case 7: 1185 case 7:
1186 mystyle.setFontSize(0);
1080 mystyle.setBold(); 1187 mystyle.setBold();
1081 break; 1188 break;
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();
1085 break; 1193 break;
1086 case 9: 1194 case 9:
1195 // mystyle.setFontSize(mystyle.getFontSize());
1087 mystyle.setFontSize(-1); 1196 mystyle.setFontSize(-1);
1088 break; 1197 break;
1089 case 10: 1198 case 10:
@@ -1095,7 +1204,7 @@ tchar CPlucker_base::getch_base(bool fast)
1095 mystyle.setVOffset(-1); 1204 mystyle.setVOffset(-1);
1096 break; 1205 break;
1097 default: 1206 default:
1098 odebug << "Unrecognised font" << oendl; 1207 qDebug("Unrecognised font");
1099 break; 1208 break;
1100 } 1209 }
1101 ch = bgetch(); 1210 ch = bgetch();
@@ -1107,19 +1216,19 @@ tchar CPlucker_base::getch_base(bool fast)
1107 { 1216 {
1108 case 0: 1217 case 0:
1109 mystyle.setLeftJustify(); 1218 mystyle.setLeftJustify();
1110// //odebug << "left" << oendl; 1219 // //qDebug("left");
1111 break; 1220 break;
1112 case 1: 1221 case 1:
1113 mystyle.setRightJustify(); 1222 mystyle.setRightJustify();
1114// //odebug << "right" << oendl; 1223 // //qDebug("right");
1115 break; 1224 break;
1116 case 2: 1225 case 2:
1117 mystyle.setCentreJustify(); 1226 mystyle.setCentreJustify();
1118// //odebug << "centre" << oendl; 1227 // //qDebug("centre");
1119 break; 1228 break;
1120 case 3: 1229 case 3:
1121 mystyle.setFullJustify(); 1230 mystyle.setFullJustify();
1122// //odebug << "full" << oendl; 1231 // //qDebug("full");
1123 break; 1232 break;
1124 1233
1125 } 1234 }
@@ -1142,7 +1251,7 @@ tchar CPlucker_base::getch_base(bool fast)
1142 ir = (ir << 8) + bgetch(); 1251 ir = (ir << 8) + bgetch();
1143 if (hasalternate) 1252 if (hasalternate)
1144 { 1253 {
1145 //odebug << "Alternate image:" << ir << "" << oendl; 1254 //qDebug("Alternate image:%x", ir);
1146 UInt16 ir2 = bgetch(); 1255 UInt16 ir2 = bgetch();
1147 ir2 = (ir2 << 8) + bgetch(); 1256 ir2 = (ir2 << 8) + bgetch();
1148 if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); 1257 if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16);
@@ -1157,7 +1266,7 @@ tchar CPlucker_base::getch_base(bool fast)
1157 { 1266 {
1158 if (!fast) mystyle.setPicture(true, expandimg(ir)); 1267 if (!fast) mystyle.setPicture(true, expandimg(ir));
1159 } 1268 }
1160// if (mystyle.getLink()) odebug << "Picture link!" << oendl; 1269 // if (mystyle.getLink()) qDebug("Picture link!");
1161 ch = '#'; 1270 ch = '#';
1162 } 1271 }
1163// ch = bgetch(); 1272// ch = bgetch();
@@ -1168,14 +1277,14 @@ tchar CPlucker_base::getch_base(bool fast)
1168 UInt8 wc = bgetch(); 1277 UInt8 wc = bgetch();
1169 UInt8 pc = bgetch(); 1278 UInt8 pc = bgetch();
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)
1173 { 1282 {
1174 w = (m_scrWidth*(unsigned long)pc)/100; 1283 w = (m_scrWidth*(unsigned long)pc)/100;
1175 } 1284 }
1176 if (w == 0) w = m_scrWidth; 1285 if (w == 0) w = m_scrWidth;
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 = '#';
1180 } 1289 }
1181 break; 1290 break;
@@ -1190,10 +1299,10 @@ tchar CPlucker_base::getch_base(bool fast)
1190 case 0x22: 1299 case 0x22:
1191 ch = bgetch(); 1300 ch = bgetch();
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();
1198 break; 1307 break;
1199 case 0x70: 1308 case 0x70:
@@ -1211,18 +1320,26 @@ tchar CPlucker_base::getch_base(bool fast)
1211 ch <<= 8; 1320 ch <<= 8;
1212 ch |= (tchar)bgetch(); 1321 ch |= (tchar)bgetch();
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 }
1216 break; 1333 break;
1217 case 0x85: 1334 case 0x85:
1218 default: 1335 default:
1219 odebug << "Function:" << ch << " NOT IMPLEMENTED" << oendl; 1336 qDebug("Function:%x NOT IMPLEMENTED", ch);
1220 { 1337 {
1221 int skip = ch & 7; 1338 int skip = ch & 7;
1222 for (int i = 0; i < skip; i++) 1339 for (int i = 0; i < skip; i++)
1223 { 1340 {
1224 ch = bgetch(); 1341 ch = bgetch();
1225 //odebug << "Arg " << i << ", " << ch << "" << oendl; 1342 //qDebug("Arg %d, %d", i, ch);
1226 } 1343 }
1227 ch = bgetch(); 1344 ch = bgetch();
1228 } 1345 }
@@ -1241,3 +1358,54 @@ tchar CPlucker_base::getch_base(bool fast)
1241 1358
1242 return (ch == EOF) ? UEOF : ch; 1359 return (ch == EOF) ? UEOF : ch;
1243} 1360}
1361
1362#include "static.h"
1363#if defined(__STATIC) && defined(USENEF)
1364#include "Model.h"
1365void (*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
1383void (*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
1403QString 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}