summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/plucker.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/plucker.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/plucker.cpp98
1 files changed, 89 insertions, 9 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,5 +1,8 @@
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
@@ -12,9 +15,12 @@
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
20struct CPlucker_dataRecord 26struct CPlucker_dataRecord
@@ -43,7 +49,9 @@ void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8&
43} 49}
44 50
45CPlucker::CPlucker() 51CPlucker::CPlucker()
46 { /*printf("constructing:%x\n",fin);*/ } 52 { /*printf("constructing:%x\n",fin);*/
53 EOPPhase = 0;
54 }
47 55
48bool CPlucker::CorrectDecoder() 56bool CPlucker::CorrectDecoder()
49{ 57{
@@ -55,23 +63,31 @@ int CPlucker::bgetch()
55 int ch = EOF; 63 int ch = EOF;
56 if (bufferpos >= buffercontent) 64 if (bufferpos >= buffercontent)
57 { 65 {
66 if (isEndOfSection(bufferrec))
67 {
58 if (!m_continuous) return EOF; 68 if (!m_continuous) return EOF;
59 if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; 69 }
60 ////odebug << "Passing through " << currentpos << "" << oendl; 70 if (bufferrec >= ntohs(head.recordList.numRecords) - 1)
61 if (!expand(bufferrec+1)) return EOF; 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 {
@@ -79,7 +95,7 @@ int CPlucker::bgetch()
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;
@@ -91,7 +107,7 @@ int CPlucker::bgetch()
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++;
@@ -149,3 +165,67 @@ QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize)
149 delete [] imgbuffer; 165 delete [] imgbuffer;
150 return qimage; 166 return qimage;
151} 167}
168
169void CPlucker::start2endSection() // to plucker base
170{
171 m_currentstart = NEFstartSection();
172 m_currentend = NEFendSection();
173}
174
175unsigned 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
197unsigned 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
227extern "C"
228{
229 CExpander* newcodec() { return new CPlucker; }
230}
231#endif