Diffstat (limited to 'noncore/apps/opie-reader/plucker.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/plucker.cpp | 100 |
1 files changed, 90 insertions, 10 deletions
diff --git a/noncore/apps/opie-reader/plucker.cpp b/noncore/apps/opie-reader/plucker.cpp index a8e688f..d1ccd6f 100644 --- a/noncore/apps/opie-reader/plucker.cpp +++ b/noncore/apps/opie-reader/plucker.cpp | |||
@@ -1,6 +1,9 @@ | |||
1 | #include "useqpe.h" | ||
1 | #include <stdio.h> | 2 | #include <stdio.h> |
2 | #include <string.h> | 3 | #include <string.h> |
4 | #include <qmessagebox.h> | ||
5 | #include <qpixmap.h> | ||
3 | #ifdef USEQPE | 6 | #ifdef USEQPE |
4 | #include <qpe/qcopenvelope_qws.h> | 7 | #include <qpe/qcopenvelope_qws.h> |
5 | #endif | 8 | #endif |
6 | #ifdef LOCALPICTURES | 9 | #ifdef LOCALPICTURES |
@@ -11,11 +14,14 @@ | |||
11 | #include <qpe/qpeapplication.h> | 14 | #include <qpe/qpeapplication.h> |
12 | #else | 15 | #else |
13 | #include <qapplication.h> | 16 | #include <qapplication.h> |
14 | #endif | 17 | #endif |
18 | #include <qclipboard.h> | ||
15 | 19 | ||
16 | #include "plucker.h" | 20 | #include "plucker.h" |
21 | #include "Aportis.h" | ||
17 | #include "Palm2QImage.h" | 22 | #include "Palm2QImage.h" |
23 | #include "static.h" | ||
18 | 24 | ||
19 | 25 | ||
20 | struct CPlucker_dataRecord | 26 | struct CPlucker_dataRecord |
21 | { | 27 | { |
@@ -42,9 +48,11 @@ void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& | |||
42 | reserved = thishdr.reserved; | 48 | reserved = thishdr.reserved; |
43 | } | 49 | } |
44 | 50 | ||
45 | CPlucker::CPlucker() | 51 | CPlucker::CPlucker() |
46 | { /*printf("constructing:%x\n",fin);*/ } | 52 | { /*printf("constructing:%x\n",fin);*/ |
53 | EOPPhase = 0; | ||
54 | } | ||
47 | 55 | ||
48 | bool CPlucker::CorrectDecoder() | 56 | bool CPlucker::CorrectDecoder() |
49 | { | 57 | { |
50 | return (memcmp(&head.type, "DataPlkr", 8) == 0); | 58 | return (memcmp(&head.type, "DataPlkr", 8) == 0); |
@@ -54,33 +62,41 @@ int CPlucker::bgetch() | |||
54 | { | 62 | { |
55 | int ch = EOF; | 63 | int ch = EOF; |
56 | if (bufferpos >= buffercontent) | 64 | if (bufferpos >= buffercontent) |
57 | { | 65 | { |
58 | if (!m_continuous) return EOF; | 66 | if (isEndOfSection(bufferrec)) |
59 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; | 67 | { |
60 | ////odebug << "Passing through " << currentpos << "" << oendl; | 68 | if (!m_continuous) return EOF; |
61 | if (!expand(bufferrec+1)) return EOF; | 69 | } |
70 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) | ||
71 | { | ||
72 | return EOF; | ||
73 | } | ||
74 | if (!expand(bufferrec+1)) | ||
75 | { | ||
76 | return EOF; | ||
77 | } | ||
62 | mystyle.unset(); | 78 | mystyle.unset(); |
63 | if (m_ParaOffsets[m_nextParaIndex] == 0) | 79 | if (m_ParaOffsets[m_nextParaIndex] == 0) |
64 | { | 80 | { |
65 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) | 81 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) |
66 | { | 82 | { |
67 | // odebug << "Skipping extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl; | 83 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
68 | m_nextParaIndex++; | 84 | m_nextParaIndex++; |
69 | } | 85 | } |
70 | } | 86 | } |
71 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | 87 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); |
72 | //odebug << "Using extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl; | 88 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
73 | ch = 10; | 89 | ch = 10; |
74 | EOPPhase = 4; | 90 | if (m_continuous) EOPPhase = 4; |
75 | } | 91 | } |
76 | else if (bufferpos == m_nextPara) | 92 | else if (bufferpos == m_nextPara) |
77 | { | 93 | { |
78 | while (bufferpos == m_nextPara) | 94 | while (bufferpos == m_nextPara) |
79 | { | 95 | { |
80 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 96 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
81 | m_nextParaIndex++; | 97 | m_nextParaIndex++; |
82 | // odebug << "Skipping extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl; | 98 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
83 | if (m_nextParaIndex == m_nParas) | 99 | if (m_nextParaIndex == m_nParas) |
84 | { | 100 | { |
85 | m_nextPara = -1; | 101 | m_nextPara = -1; |
86 | } | 102 | } |
@@ -90,9 +106,9 @@ int CPlucker::bgetch() | |||
90 | } | 106 | } |
91 | } | 107 | } |
92 | mystyle.unset(); | 108 | mystyle.unset(); |
93 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | 109 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); |
94 | //odebug << "Using extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl; | 110 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
95 | if (m_lastBreak == locate()) | 111 | if (m_lastBreak == locate()) |
96 | { | 112 | { |
97 | currentpos++; | 113 | currentpos++; |
98 | ch = expandedtextbuffer[bufferpos++]; | 114 | ch = expandedtextbuffer[bufferpos++]; |
@@ -148,4 +164,68 @@ QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) | |||
148 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); | 164 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); |
149 | delete [] imgbuffer; | 165 | delete [] imgbuffer; |
150 | return qimage; | 166 | return qimage; |
151 | } | 167 | } |
168 | |||
169 | void CPlucker::start2endSection() // to plucker base | ||
170 | { | ||
171 | m_currentstart = NEFstartSection(); | ||
172 | m_currentend = NEFendSection(); | ||
173 | } | ||
174 | |||
175 | unsigned long CPlucker::NEFstartSection() // virtual in plucker base - differs only in obsoleted nef so move implementation | ||
176 | { | ||
177 | //inefficient - Should calc start/end of section on entry to section? | ||
178 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
179 | UInt32 thishdr_size; | ||
180 | UInt8 thishdr_type, thishdr_reserved; | ||
181 | unsigned long textlength = currentpos-bufferpos; | ||
182 | for (UInt16 recptr = bufferrec-1; recptr >= 1; recptr--) | ||
183 | { | ||
184 | gotorecordnumber(recptr); | ||
185 | //qDebug("recptr:%u", recptr); | ||
186 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
187 | if (thishdr_type < 2) | ||
188 | { | ||
189 | if ((thishdr_reserved && continuation_bit) == 0) break; | ||
190 | textlength -= thishdr_size; | ||
191 | //qDebug("Textlength:%u, reserved:%u, recptr:%u", textlength, thishdr_reserved, recptr); | ||
192 | } | ||
193 | } | ||
194 | return textlength; | ||
195 | } | ||
196 | |||
197 | unsigned long CPlucker::NEFendSection() // virtual in plucker base - differs only in obsoleted nef so move implementation | ||
198 | { | ||
199 | //inefficient - Should calc start/end of section on entry to section? | ||
200 | unsigned long textlength = currentpos-bufferpos+buffercontent; | ||
201 | gotorecordnumber(bufferrec); | ||
202 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
203 | UInt32 thishdr_size; | ||
204 | UInt8 thishdr_type, thishdr_reserved; | ||
205 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
206 | if ((thishdr_reserved && continuation_bit) != 0) | ||
207 | { | ||
208 | for (UInt16 recptr = bufferrec+1; recptr < ntohs(head.recordList.numRecords); recptr++) | ||
209 | { | ||
210 | gotorecordnumber(recptr); | ||
211 | UInt16 thishdr_uid, thishdr_nParagraphs; | ||
212 | UInt32 thishdr_size; | ||
213 | UInt8 thishdr_type, thishdr_reserved; | ||
214 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | ||
215 | //qDebug("recptr %u bufferrec %u type %u m_reserved %u", recptr, bufferrec, typ | ||
216 | if (thishdr_type < 2) | ||
217 | { | ||
218 | textlength += thishdr_size; | ||
219 | if ((thishdr_reserved && continuation_bit) == 0) break; | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | return textlength; | ||
224 | } | ||
225 | |||
226 | #ifndef __STATIC | ||
227 | extern "C" | ||
228 | { | ||
229 | CExpander* newcodec() { return new CPlucker; } | ||
230 | } | ||
231 | #endif | ||