summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/BuffDoc.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/BuffDoc.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp122
1 files changed, 91 insertions, 31 deletions
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp
index 1123960..2402904 100644
--- a/noncore/apps/opie-reader/BuffDoc.cpp
+++ b/noncore/apps/opie-reader/BuffDoc.cpp
@@ -1,2 +1,4 @@
1#include "name.h" 1#include "names.h"
2
3#define NEWLINEBREAK
2 4
@@ -7,15 +9,26 @@
7#include "plucker.h" 9#include "plucker.h"
10#include "usenef.h"
11#ifdef USENEF
12#include "nef.h"
13#include "arrierego.h"
14#endif
8 15
9 16linkType BuffDoc::hyperlink(unsigned int n, QString& wrd)
10bool BuffDoc::hyperlink(unsigned int n) 17{
18 linkType bRet = eNone;
19 if (exp != NULL)
20 {
21 bRet = exp->hyperlink(n, wrd);
22 if (bRet == eLink)
11{ 23{
12 bool bRet = false;
13 lastword.empty(); 24 lastword.empty();
14 lastsizes[0] = laststartline = n; 25 lastsizes[0] = laststartline = n;
26#ifdef NEWLINEBREAK
27 lastispara = true;
28#else
15 lastispara = false; 29 lastispara = false;
16 if (exp != NULL) 30#endif
17 {
18 bRet = exp->hyperlink(n);
19 lastsizes[0] = laststartline = exp->locate(); 31 lastsizes[0] = laststartline = exp->locate();
20 } 32 }
33 }
21 return bRet; 34 return bRet;
@@ -25,14 +38,17 @@ void BuffDoc::locate(unsigned int n)
25{ 38{
26 // qDebug("BuffDoc:locating:%u",n); 39 // //qDebug("BuffDoc:locating:%u",n);
27 lastword.empty(); 40 lastword.empty();
28 lastsizes[0] = laststartline = n; 41 lastsizes[0] = laststartline = n;
42#ifdef NEWLINEBREAK
43 lastispara = true;
44#else
29 lastispara = false; 45 lastispara = false;
46#endif
30 // tchar linebuf[1024]; 47 // tchar linebuf[1024];
31 if (exp != NULL) exp->locate(n); 48 if (exp != NULL) exp->locate(n);
32 // qDebug("BuffDoc:Located"); 49 // //qDebug("BuffDoc:Located");
33} 50}
34 51
35#define NEWLINEBREAK
36#ifdef NEWLINEBREAK 52#ifdef NEWLINEBREAK
37bool BuffDoc::getline(CDrawBuffer* buff, int wth) 53bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border)
38{ 54{
@@ -40,3 +56,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
40 bool margindone = false; 56 bool margindone = false;
41 int w = wth-2*BORDER; 57 int w = wth-2*_border;
42 tchar ch = 32; 58 tchar ch = 32;
@@ -62,3 +78,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
62 unsigned int slen = buff->width(len); 78 unsigned int slen = buff->width(len);
63 lastispara = false; 79 if (lastispara) buff->setstartpara();
64 while (1) 80 while (1)
@@ -67,5 +83,9 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
67 getch(ch, cs); 83 getch(ch, cs);
84 if (ch == 10 && len == 0 && !lastispara)
85 {
86 lastsizes[len] = exp->locate();
87 getch(ch, cs);
88 }
68 if (ch == UEOF) 89 if (ch == UEOF)
69 { 90 {
70 lastword.empty();
71 if (len == 0) 91 if (len == 0)
@@ -80,3 +100,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
80 { 100 {
81 lastword.empty(); 101 buff->setendpara();
82 lastispara = true; 102 lastispara = true;
@@ -85,2 +105,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
85 } 105 }
106 lastispara = false;
86 buff->addch(ch, cs); 107 buff->addch(ch, cs);
@@ -96,3 +117,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
96 { 117 {
97 lastword.empty(); 118 if (ch == ' ') buff->truncate(len-1);
98 laststartline = exp->locate(); 119 laststartline = exp->locate();
@@ -102,3 +123,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
102 { 123 {
103 for (int i = len-1; i > 0; i--) 124 for (int i = len-2; i > 0; i--)
104 { 125 {
@@ -118,4 +139,19 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
118 } 139 }
140 if ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-')))
141 {
142 (*buff)[len] = 0;
143 lastword.setright(*buff, i+1);
144 buff->truncate(i+1);
145 (*buff)[i+1] = '\0';
146 laststartline = lastsizes[i+1];
147 buff->resize();
148 for (int j = 0; j < lastword.length(); j++)
149 {
150 lastsizes[j] = lastsizes[j+i+1];
151 }
152 return true;
153 }
119 } 154 }
120 laststartline = lastsizes[len-1]; 155 laststartline = lastsizes[len-1];
156 (*buff)[len] = 0;
121 lastword.setright(*buff, len - 1); 157 lastword.setright(*buff, len - 1);
@@ -136,6 +172,6 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
136#else 172#else
137bool BuffDoc::getline(CDrawBuffer* buff, int wth) 173bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned char _border)
138{ 174{
139 bool margindone = false; 175 bool margindone = false;
140 int w = wth-2*BORDER; 176 int w = wth-2*_border;
141 tchar ch = 32; 177 tchar ch = 32;
@@ -158,3 +194,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
158 else buff->empty(); 194 else buff->empty();
159// qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); 195// //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data()));
160 lastcheck = len = buff->length(); 196 lastcheck = len = buff->length();
@@ -233,3 +269,3 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
233// lastword = buff->data()+lastcheck; 269// lastword = buff->data()+lastcheck;
234#ifdef WINDOWS 270#ifdef _WINDOWS
235 lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); 271 lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1);
@@ -266,5 +302,5 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth)
266 302
267bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw) 303bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned char _border)
268{ 304{
269 int w = wth-2*BORDER; 305 int w = wth-2*_border;
270 buff->empty(); 306 buff->empty();
@@ -276,4 +312,4 @@ bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw)
276 CStyle cs; 312 CStyle cs;
277 int i = 0; 313 int i = 1;
278 while (i*cw < w) 314 while (i*cw < w-buff->offset(w,0))
279 { 315 {
@@ -292,4 +328,4 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
292{ 328{
293 // qDebug("BuffDoc:Openfile:%s", src); 329 // //qDebug("BuffDoc:Openfile:%s", src);
294 // qDebug("Trying aportis %x",exp); 330 // //qDebug("Trying aportis %x",exp);
295 if (exp != NULL) delete exp; 331 if (exp != NULL) delete exp;
@@ -297,3 +333,7 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
297 lastsizes[0] = laststartline = 0; 333 lastsizes[0] = laststartline = 0;
334#ifdef NEWLINEBREAK
335 lastispara = true;
336#else
298 lastispara = false; 337 lastispara = false;
338#endif
299 /* 339 /*
@@ -318,2 +358,18 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
318 } 358 }
359#ifdef USENEF
360 if (ret != 0)
361 {
362
363 delete exp;
364 exp = new CArriere;
365 ret = exp->openfile(src);
366 }
367 if (ret != 0)
368 {
369
370 delete exp;
371 exp = new CNEF;
372 ret = exp->openfile(src);
373 }
374#endif
319 if (ret != 0) 375 if (ret != 0)
@@ -328,3 +384,3 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
328 delete exp; 384 delete exp;
329 qDebug("Trying ppms"); 385 //qDebug("Trying ppms");
330 exp = new ppm_expander; 386 exp = new ppm_expander;
@@ -336,3 +392,3 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
336 exp = new Text; 392 exp = new Text;
337 // qDebug("Trying text"); 393 // //qDebug("Trying text");
338 ret = exp->openfile(src); 394 ret = exp->openfile(src);
@@ -346,3 +402,3 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
346 } 402 }
347 // qDebug("Doing final open:%x:%x",exp,filt); 403 // //qDebug("Doing final open:%x:%x",exp,filt);
348 404
@@ -350,6 +406,10 @@ int BuffDoc::openfile(QWidget* _parent, const char *src)
350 lastsizes[0] = laststartline = 0; 406 lastsizes[0] = laststartline = 0;
407#ifdef NEWLINEBREAK
408 lastispara = true;
409#else
351 lastispara = false; 410 lastispara = false;
411#endif
352 exp->locate(0); 412 exp->locate(0);
353 filt->setsource(exp); 413 filt->setsource(exp);
354 // qDebug("BuffDoc:file opened"); 414 // //qDebug("BuffDoc:file opened");
355 return 0; 415 return 0;