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,29 +1,35 @@ +#include "useqpe.h" #include <stdio.h> #include <string.h> +#include <qmessagebox.h> +#include <qpixmap.h> #ifdef USEQPE #include <qpe/qcopenvelope_qws.h> #endif #ifdef LOCALPICTURES #include <qscrollview.h> #endif #ifdef USEQPE #include <qpe/global.h> #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif +#include <qclipboard.h> #include "plucker.h" +#include "Aportis.h" #include "Palm2QImage.h" +#include "static.h" struct CPlucker_dataRecord { UInt16 uid; UInt16 nParagraphs; UInt16 size; UInt8 type; UInt8 reserved; }; int CPlucker::HeaderSize() @@ -34,73 +40,83 @@ int CPlucker::HeaderSize() void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) { CPlucker_dataRecord thishdr; fread(&thishdr, 1, HeaderSize(), fin); uid = ntohs(thishdr.uid); nParagraphs = ntohs(thishdr.nParagraphs); size = ntohs(thishdr.size); type = thishdr.type; reserved = thishdr.reserved; } CPlucker::CPlucker() - { /*printf("constructing:%x\n",fin);*/ } + { /*printf("constructing:%x\n",fin);*/ + EOPPhase = 0; + } bool CPlucker::CorrectDecoder() { return (memcmp(&head.type, "DataPlkr", 8) == 0); } int CPlucker::bgetch() { int ch = EOF; if (bufferpos >= buffercontent) { - if (!m_continuous) return EOF; - if (bufferrec >= ntohs(head.recordList.numRecords) - 1) return EOF; -//// odebug << "Passing through " << currentpos << "" << oendl; - if (!expand(bufferrec+1)) return EOF; + if (isEndOfSection(bufferrec)) + { + if (!m_continuous) return EOF; + } + if (bufferrec >= ntohs(head.recordList.numRecords) - 1) + { + return EOF; + } + if (!expand(bufferrec+1)) + { + return EOF; + } mystyle.unset(); if (m_ParaOffsets[m_nextParaIndex] == 0) { while (m_ParaOffsets[m_nextParaIndex+1] == 0) { -// odebug << "Skipping extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl; +// qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); m_nextParaIndex++; } } mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); -// odebug << "Using extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl; +// qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); ch = 10; - EOPPhase = 4; + if (m_continuous) EOPPhase = 4; } else if (bufferpos == m_nextPara) { while (bufferpos == m_nextPara) { UInt16 attr = m_ParaAttrs[m_nextParaIndex]; m_nextParaIndex++; -// odebug << "Skipping extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl; +// qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); if (m_nextParaIndex == m_nParas) { m_nextPara = -1; } else { m_nextPara += m_ParaOffsets[m_nextParaIndex]; } } mystyle.unset(); mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); -// odebug << "Using extraspace:" << m_ParaAttrs[m_nextParaIndex]&7 << "" << oendl; +// qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); if (m_lastBreak == locate()) { currentpos++; ch = expandedtextbuffer[bufferpos++]; } else { ch = 10; } } else { @@ -140,12 +156,76 @@ tchar CPlucker::getch(bool fast) return ch; } return getch_base(fast); } QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) { QImage* qimage = Palm2QImage(imgbuffer, imgsize); delete [] imgbuffer; return qimage; } + +void CPlucker::start2endSection() // to plucker base +{ + m_currentstart = NEFstartSection(); + m_currentend = NEFendSection(); +} + +unsigned long CPlucker::NEFstartSection() // virtual in plucker base - differs only in obsoleted nef so move implementation +{ +//inefficient - Should calc start/end of section on entry to section? + UInt16 thishdr_uid, thishdr_nParagraphs; + UInt32 thishdr_size; + UInt8 thishdr_type, thishdr_reserved; + unsigned long textlength = currentpos-bufferpos; + for (UInt16 recptr = bufferrec-1; recptr >= 1; recptr--) + { + gotorecordnumber(recptr); + //qDebug("recptr:%u", recptr); + GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); + if (thishdr_type < 2) + { + if ((thishdr_reserved && continuation_bit) == 0) break; + textlength -= thishdr_size; + //qDebug("Textlength:%u, reserved:%u, recptr:%u", textlength, thishdr_reserved, recptr); + } + } + return textlength; +} + +unsigned long CPlucker::NEFendSection() // virtual in plucker base - differs only in obsoleted nef so move implementation +{ +//inefficient - Should calc start/end of section on entry to section? + unsigned long textlength = currentpos-bufferpos+buffercontent; + gotorecordnumber(bufferrec); + UInt16 thishdr_uid, thishdr_nParagraphs; + UInt32 thishdr_size; + UInt8 thishdr_type, thishdr_reserved; + GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); + if ((thishdr_reserved && continuation_bit) != 0) + { + for (UInt16 recptr = bufferrec+1; recptr < ntohs(head.recordList.numRecords); recptr++) + { + gotorecordnumber(recptr); + UInt16 thishdr_uid, thishdr_nParagraphs; + UInt32 thishdr_size; + UInt8 thishdr_type, thishdr_reserved; + GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); + // qDebug("recptr %u bufferrec %u type %u m_reserved %u", recptr, bufferrec, typ + if (thishdr_type < 2) + { + textlength += thishdr_size; + if ((thishdr_reserved && continuation_bit) == 0) break; + } + } + } + return textlength; +} + +#ifndef __STATIC +extern "C" +{ + CExpander* newcodec() { return new CPlucker; } +} +#endif |