Diffstat (limited to 'noncore/apps/opie-reader/BuffDoc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/BuffDoc.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp index e37b136..d4541ea 100644 --- a/noncore/apps/opie-reader/BuffDoc.cpp +++ b/noncore/apps/opie-reader/BuffDoc.cpp | |||
@@ -8,18 +8,18 @@ | |||
8 | bool BuffDoc::hyperlink(unsigned int n) | 8 | bool BuffDoc::hyperlink(unsigned int n) |
9 | { | 9 | { |
10 | bool bRet = false; | 10 | bool bRet = false; |
11 | lastword.empty(); | 11 | lastword.empty(); |
12 | lastsizes[0] = laststartline = n; | 12 | lastsizes[0] = laststartline = n; |
13 | lastispara = false; | 13 | lastispara = false; |
14 | if (exp != NULL) | 14 | if (exp != NULL) |
15 | { | 15 | { |
16 | bRet = exp->hyperlink(n); | 16 | bRet = exp->hyperlink(n); |
17 | lastsizes[0] = laststartline = exp->locate(); | 17 | lastsizes[0] = laststartline = exp->locate(); |
18 | } | 18 | } |
19 | return bRet; | 19 | return bRet; |
20 | } | 20 | } |
21 | 21 | ||
22 | void BuffDoc::locate(unsigned int n) | 22 | void BuffDoc::locate(unsigned int n) |
23 | { | 23 | { |
24 | // qDebug("BuffDoc:locating:%u",n); | 24 | // qDebug("BuffDoc:locating:%u",n); |
25 | lastword.empty(); | 25 | lastword.empty(); |
@@ -32,36 +32,36 @@ void BuffDoc::locate(unsigned int n) | |||
32 | 32 | ||
33 | bool BuffDoc::getline(CDrawBuffer* buff, int w) | 33 | bool BuffDoc::getline(CDrawBuffer* buff, int w) |
34 | { | 34 | { |
35 | tchar ch = 32; | 35 | tchar ch = 32; |
36 | CStyle cs; | 36 | CStyle cs; |
37 | buff->empty(); | 37 | buff->empty(); |
38 | if (exp == NULL) | 38 | if (exp == NULL) |
39 | { | 39 | { |
40 | //(*buff)[0] = '\0'; | 40 | // (*buff)[0] = '\0'; |
41 | buff->empty(); | 41 | buff->empty(); |
42 | return false; | 42 | return false; |
43 | } | 43 | } |
44 | int len = 0, lastcheck = 0; | 44 | int len = 0, lastcheck = 0; |
45 | if (lastword.length() > 0) | 45 | if (lastword.length() > 0) |
46 | { | 46 | { |
47 | *buff = lastword; | 47 | *buff = lastword; |
48 | cs = lastword.laststyle(); | 48 | cs = lastword.laststyle(); |
49 | } | 49 | } |
50 | else buff->empty(); | 50 | else buff->empty(); |
51 | // qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); | 51 | // qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); |
52 | lastcheck = len = buff->length(); | 52 | lastcheck = len = buff->length(); |
53 | unsigned int slen = buff->width(len); | 53 | unsigned int slen = buff->width(len); |
54 | if (slen > w) | 54 | if (slen > w) |
55 | { | 55 | { |
56 | for ( ; len > 0; len--) | 56 | for ( ; len > 0; len--) |
57 | { | 57 | { |
58 | if (buff->width(len) < w) break; | 58 | if (buff->width(len) < w) break; |
59 | } | 59 | } |
60 | // lastword = buff->data() + len - 1; | 60 | // lastword = buff->data() + len - 1; |
61 | laststartline = lastsizes[len-1]; | 61 | laststartline = lastsizes[len-1]; |
62 | lastword.setright(*buff, len - 1); | 62 | lastword.setright(*buff, len - 1); |
63 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; | 63 | for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; |
64 | // (*buff)[len-1] = '-'; | 64 | // (*buff)[len-1] = '-'; |
65 | buff->truncate(len-1); | 65 | buff->truncate(len-1); |
66 | buff->addch('-', cs); | 66 | buff->addch('-', cs); |
67 | (*buff)[len] = '\0'; | 67 | (*buff)[len] = '\0'; |
@@ -83,30 +83,30 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
83 | for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; | 83 | for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; |
84 | while (slen < w) | 84 | while (slen < w) |
85 | { | 85 | { |
86 | lastcheck = len; | 86 | lastcheck = len; |
87 | allsizes[len] = exp->locate(); | 87 | allsizes[len] = exp->locate(); |
88 | getch(ch, cs); | 88 | getch(ch, cs); |
89 | while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) | 89 | while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) |
90 | { | 90 | { |
91 | len++; | 91 | len++; |
92 | buff->addch(ch,cs); | 92 | buff->addch(ch,cs); |
93 | allsizes[len] = exp->locate(); | 93 | allsizes[len] = exp->locate(); |
94 | getch(ch, cs); | 94 | getch(ch, cs); |
95 | } | 95 | } |
96 | (*buff)[len] = 0; | 96 | (*buff)[len] = 0; |
97 | slen = buff->width(len); | 97 | slen = buff->width(len); |
98 | len++; | 98 | len++; |
99 | buff->addch(' ', cs); | 99 | buff->addch(' ', cs); |
100 | allsizes[len] = exp->locate(); | 100 | allsizes[len] = exp->locate(); |
101 | if (slen < w && ch != ' ') | 101 | if (slen < w && ch != ' ') |
102 | { | 102 | { |
103 | lastcheck = len; | 103 | lastcheck = len; |
104 | break; | 104 | break; |
105 | } | 105 | } |
106 | lastispara = (ch == '\012'); | 106 | lastispara = (ch == '\012'); |
107 | } | 107 | } |
108 | (*buff)[len] = '\0'; | 108 | (*buff)[len] = '\0'; |
109 | // lastword = buff->data()+lastcheck; | 109 | // lastword = buff->data()+lastcheck; |
110 | lastword.setright(*buff, lastcheck); | 110 | lastword.setright(*buff, lastcheck); |
111 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; | 111 | for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; |
112 | if (lastcheck > 0) | 112 | if (lastcheck > 0) |
@@ -125,27 +125,27 @@ bool BuffDoc::getline(CDrawBuffer* buff, int w) | |||
125 | return (ch != UEOF); | 125 | return (ch != UEOF); |
126 | } | 126 | } |
127 | 127 | ||
128 | bool BuffDoc::getline(CDrawBuffer* buff, int w, int cw) | 128 | bool BuffDoc::getline(CDrawBuffer* buff, int w, int cw) |
129 | { | 129 | { |
130 | buff->empty(); | 130 | buff->empty(); |
131 | if (exp == NULL) | 131 | if (exp == NULL) |
132 | { | 132 | { |
133 | return false; | 133 | return false; |
134 | } | 134 | } |
135 | tchar ch; | 135 | tchar ch; |
136 | CStyle cs; | 136 | CStyle cs; |
137 | int i = 0; | 137 | int i = 0; |
138 | while (i*cw < w) | 138 | while (i*cw < w) |
139 | { | 139 | { |
140 | getch(ch, cs); | 140 | getch(ch, cs); |
141 | if (ch == '\12' || ch == UEOF) break; | 141 | if (ch == '\12' || ch == UEOF) break; |
142 | buff->addch(ch,cs); | 142 | buff->addch(ch,cs); |
143 | i++; | 143 | i++; |
144 | } | 144 | } |
145 | buff->truncate(i); | 145 | buff->truncate(i); |
146 | laststartline = exp->locate(); | 146 | laststartline = exp->locate(); |
147 | return (ch != UEOF); | 147 | return (ch != UEOF); |
148 | } | 148 | } |
149 | 149 | ||
150 | int BuffDoc::openfile(QWidget* _parent, const char *src) | 150 | int BuffDoc::openfile(QWidget* _parent, const char *src) |
151 | { | 151 | { |
@@ -159,63 +159,63 @@ int BuffDoc::openfile(QWidget* _parent, const char *src) | |||
159 | exp = new Text; | 159 | exp = new Text; |
160 | int ret = exp->openfile(src); | 160 | int ret = exp->openfile(src); |
161 | */ | 161 | */ |
162 | 162 | ||
163 | exp = new Aportis; | 163 | exp = new Aportis; |
164 | int ret = exp->openfile(src); | 164 | int ret = exp->openfile(src); |
165 | if (ret == -1) | 165 | if (ret == -1) |
166 | { | 166 | { |
167 | delete exp; | 167 | delete exp; |
168 | exp = NULL; | 168 | exp = NULL; |
169 | return ret; | 169 | return ret; |
170 | } | 170 | } |
171 | if (ret == -2) | 171 | if (ret == -2) |
172 | { | 172 | { |
173 | 173 | ||
174 | delete exp; | 174 | delete exp; |
175 | exp = new ztxt; | 175 | exp = new ztxt; |
176 | ret = exp->openfile(src); | 176 | ret = exp->openfile(src); |
177 | } | 177 | } |
178 | if (ret != 0) | 178 | if (ret != 0) |
179 | { | 179 | { |
180 | 180 | ||
181 | delete exp; | 181 | delete exp; |
182 | exp = new CPlucker; | 182 | exp = new CPlucker; |
183 | ret = exp->openfile(src); | 183 | ret = exp->openfile(src); |
184 | } | 184 | } |
185 | #ifndef SMALL | 185 | #ifndef SMALL |
186 | if (ret != 0) | 186 | if (ret != 0) |
187 | { | 187 | { |
188 | delete exp; | 188 | delete exp; |
189 | qDebug("Trying ppms"); | 189 | qDebug("Trying ppms"); |
190 | exp = new ppm_expander; | 190 | exp = new ppm_expander; |
191 | ret = exp->openfile(src); | 191 | ret = exp->openfile(src); |
192 | } | 192 | } |
193 | 193 | ||
194 | if (ret != 0) | 194 | if (ret != 0) |
195 | { | 195 | { |
196 | delete exp; | 196 | delete exp; |
197 | exp = new Text; | 197 | exp = new Text; |
198 | // qDebug("Trying text"); | 198 | // qDebug("Trying text"); |
199 | ret = exp->openfile(src); | 199 | ret = exp->openfile(src); |
200 | } | 200 | } |
201 | #else | 201 | #else |
202 | if (ret != 0) | 202 | if (ret != 0) |
203 | { | 203 | { |
204 | delete exp; | 204 | delete exp; |
205 | exp = new Text; | 205 | exp = new Text; |
206 | ret = exp->openfile(src); | 206 | ret = exp->openfile(src); |
207 | } | 207 | } |
208 | #endif | 208 | #endif |
209 | if (ret != 0) | 209 | if (ret != 0) |
210 | { | 210 | { |
211 | delete exp; | 211 | delete exp; |
212 | QMessageBox::information(_parent, "QTReader", "Unknown file compression type","Try another file"); | 212 | QMessageBox::information(_parent, "OpieReader", "Unknown file compression type","Try another file"); |
213 | return ret; | 213 | return ret; |
214 | } | 214 | } |
215 | // qDebug("Doing final open:%x:%x",exp,filt); | 215 | // qDebug("Doing final open:%x:%x",exp,filt); |
216 | 216 | ||
217 | lastword.empty(); | 217 | lastword.empty(); |
218 | lastsizes[0] = laststartline = 0; | 218 | lastsizes[0] = laststartline = 0; |
219 | lastispara = false; | 219 | lastispara = false; |
220 | exp->locate(0); | 220 | exp->locate(0); |
221 | filt->setsource(exp); | 221 | filt->setsource(exp); |