1#include <qpro/common.h>
7#include <qpro/record.h>
8#include <qpro/formula.h>
16Charout(ostream& pOut,
unsigned char pChar)
18 pOut << ( (pChar<32) || (pChar>126) ?
'.' : (char)pChar);
22Hexout(ostream& pOut,
unsigned char pChar)
24 pOut << setiosflags(ios::uppercase)
33Hexout(
char* pChar,
int pLen)
35 std::ostringstream* lOStr =
new std::ostringstream;
41 for( lIdx=0; lIdx < 16; ++lIdx )
46 cerr << (lIdx==8 ?
"-" :
" ");
47 Charout(*lOStr, (
unsigned char)*pChar);
57 cerr << lOStr->rdbuf() << endl;
60 lOStr =
new std::ostringstream;
71QpRec::QpRec(QpRecType pType)
117QpRecCell::QpRecCell(QpRecType pType)
127QpRecCell::~QpRecCell()
135QpRecCell::attributes(TQP_INT16 pAttributes)
137 cAttributes = pAttributes;
141QpRecCell::attributes()
147QpRecCell::column(TQP_UINT8 pColumn)
159QpRecCell::row(TQP_INT16 pRow)
171QpRecCell::loadCellInfo(QpIStream& pIn)
173 pIn >> cColumn >> cPage >> cRow >> cAttributes;
175 TQP_DEBUG(
" col " << (
unsigned)cColumn <<
", Page " << (
unsigned)cPage
176 <<
", Row " << cRow <<
", Ref "
178 ", Attr " << cAttributes
199QpRecCell::cellRef(
char* pText, QpTableNames& pTable, TQP_INT16 , TQP_UINT8 pPage, TQP_UINT8 pColumn, TQP_INT16 pRow)
203 std::stringstream lOut(pText, ios::out);
204 int lPageRelative = pRow & 0x8000;
205 int lColRelative = pRow & 0x4000;
206 int lRowRelative = pRow & 0x2000;
207 TQP_UINT8 lCol = (lColRelative ? cColumn + pColumn : pColumn);
210 TQP_INT16 lRow = (lRowRelative ? cRow + (pRow & 0x1000 ? pRow | 0xE000 : pRow & 0x1FFF)
216 if( lPageRelative && (pPage == 0) )
225 TQP_UINT8 lPage = ( lPageRelative ? pPage + cPage : pPage );
227 TQP_DEBUG(
"pTable.name((unsigned)lPage) = " << pTable.name((
unsigned)lPage) << endl);
229 lOut << pTable.name((
unsigned)lPage) <<
'!';
238 lOut << (char)(
'A' + lCol);
242 lOut << (char)(
'A' -1 + lCol / 26)
243 << (char)(
'A' + lCol % 26);
251 lOut << (lRow & 0x1FFF) +1 << ends;
255QpRecCell::cellRef(
char* pText, QpTableNames& pTable, QpIStream& pFormulaRef)
258 pFormulaRef >> lNoteBook;
262 if( lNoteBook & 0x1000 )
264 TQP_UINT8 lFirstColumn;
265 TQP_UINT8 lFirstPage;
267 TQP_UINT8 lLastColumn;
271 pFormulaRef >> lFirstColumn
278 TQP_DEBUG(
"BlockRef: NoteBook " << lNoteBook
279 <<
", 1st col " << lFirstColumn
280 <<
", 1st page " << (
unsigned)lFirstPage
281 <<
", 1st row " << lFirstRow
282 <<
", last col " << lLastColumn
283 <<
", last page " << (
unsigned)lLastPage
284 <<
", last row " << lLastRow
288 cellRef( pText, pTable, lNoteBook, lFirstPage, lFirstColumn, lFirstRow );
290 strcat( pText,
":" );
291 cellRef( &pText[strlen(pText)], pTable, lNoteBook, lLastPage, lLastColumn, lLastRow );
299 pFormulaRef >> lColumn >> lPage >> lRow;
301 TQP_DEBUG(
"FormulaRef: NoteBook " << lNoteBook <<
", Col " << (
unsigned)lColumn
302 <<
", Page " << (
unsigned)lPage <<
", Row " << lRow << endl
307 cellRef( pText, pTable, lNoteBook, lPage, lColumn, lRow );
313QpRecBof::QpRecBof(TQP_INT16, QpIStream& pIn)
318 TQP_DEBUG(
"BOF fileformat=" << cFileFormat << endl);
327QpRecEof::QpRecEof(TQP_INT16, QpIStream&)
330 TQP_DEBUG(
"EOF" << endl);
340QpRecRecalcMode::QpRecRecalcMode(TQP_INT16, QpIStream& pIn)
341 : QpRec( QpRecalcMode )
347 cMode = (MODE)(
unsigned char) lMode;
349 TQP_DEBUG(
"Recalc Mode = "
350 << (
int)lMode << ( cMode == Manual ?
" (Manual)"
351 : cMode == Background ?
" (Background)"
352 : cMode == Automatic ?
" (Automatic)"
359QpRecRecalcMode::~QpRecRecalcMode()
365QpRecRecalcMode::mode(MODE pMode)
371QpRecRecalcMode::mode()
379QpRecRecalcOrder::QpRecRecalcOrder(TQP_INT16, QpIStream& pIn)
380 : QpRec( QpRecalcOrder )
386 cOrder = (ORDER)(
unsigned char) lOrder;
388 TQP_DEBUG(
"Recalc Order = "
389 << (
int)lOrder << ( cOrder == Natural ?
" (Natural)"
390 : cOrder ==
Column ?
" (Column)"
391 : cOrder ==
Row ?
" (Row)"
398QpRecRecalcOrder::~QpRecRecalcOrder()
404QpRecRecalcOrder::order(ORDER pOrder)
409QpRecRecalcOrder::ORDER
410QpRecRecalcOrder::order()
418QpRecEmptyCell::QpRecEmptyCell(TQP_INT16, QpIStream& pIn)
419 : QpRecCell( QpEmptyCell )
421 TQP_DEBUG(
"Empty Cell - ");
428QpRecEmptyCell::~QpRecEmptyCell()
435QpRecIntegerCell::QpRecIntegerCell(TQP_INT16, QpIStream& pIn)
436 : QpRecCell( QpIntegerCell )
438 TQP_DEBUG(
"Integer Cell - ");
444 TQP_DEBUG(
", Int " << cInt << endl);
447QpRecIntegerCell::~QpRecIntegerCell()
452QpRecIntegerCell::integer()
459QpRecFloatingPointCell::QpRecFloatingPointCell(TQP_INT16, QpIStream& pIn)
460 : QpRecCell( QpFloatingPointCell )
462 TQP_DEBUG(
"Float Cell - ");
468 TQP_DEBUG(
", Value " << cValue << endl);
471QpRecFloatingPointCell::~QpRecFloatingPointCell()
476QpRecFloatingPointCell::value()
483QpRecLabelCell::QpRecLabelCell(TQP_INT16 pLen, QpIStream& pIn)
484 : QpRecCell( QpLabelCell )
486 TQP_DEBUG(
"Label Cell - ");
487 int lLabelLen = pLen - loadCellInfo(pIn) - 1;
491 cLabel =
new char[lLabelLen];
493 pIn.read( cLabel, lLabelLen );
495 TQP_DEBUG(
", Prefix " << cLabelPrefix <<
", Label " << cLabel << endl);
498QpRecLabelCell::~QpRecLabelCell()
505QpRecLabelCell::labelPrefix()
511QpRecLabelCell::label()
518QpRecFormulaCell::QpRecFormulaCell(TQP_INT16 pLen, QpIStream& pIn)
519 : QpRecCell( QpFormulaCell )
522 TQP_DEBUG(
"Formula Cell - ");
524 int lFormulaLen = pLen - loadCellInfo(pIn);
538 cFormula =
new char[lFormulaLen];
540 pIn.read( cFormula, lFormulaLen );
542 TQP_DEBUG(
", LastValue " << cLastValue <<
", State " << cState << endl);
543 TQP_DEBUG(
" FormulaLen " << cLen <<
", CellRef " << cCellRef <<
", Formula" << endl);
545 Hexout( cFormula, lFormulaLen );
550QpRecFormulaCell::~QpRecFormulaCell()
557QpRecFormulaCell::formula()
563QpRecFormulaCell::formulaLen()
569QpRecFormulaCell::formulaReferences()
576QpRecUnknown::QpRecUnknown(TQP_INT16 , TQP_INT16 pLen, QpIStream& pIn)
579 TQP_DEBUG(
"Unknown Type " << pType <<
", len " << pLen << endl);
583 char* lBuf =
new char[pLen];
585 pIn.read(lBuf, pLen);
592QpRecUnknown::~QpRecUnknown()
598QpRecBop::QpRecBop(TQP_INT16, QpIStream& pIn)
602 TQP_DEBUG(
"BOP: " << (
unsigned)cPageIndex << endl);
619QpRecPageName::QpRecPageName(TQP_INT16, QpIStream& pIn)
620 : QpRec( QpPageName )
624 TQP_DEBUG(
"Page Name: " << cPageName << endl);
627QpRecPageName::~QpRecPageName()
632QpRecPageName::pageName()
638QpRecPassword::QpRecPassword(TQP_INT16 pLen, QpIStream& pIn)
639 : QpRec( QpPassword )
641 TQP_DEBUG(
"Password len = " << pLen << endl);
643 cPassword =
new TQP_UINT8[pLen];
645 pIn.read( (
char*)cPassword, pLen );
647 TQP_DEBUG(
"Password(Hex) = ");
649 Hexout( (
char*)cPassword, pLen );
654QpRecPassword::~QpRecPassword()
661QpRecPassword::password()
This class hold a column.