34
34
Charout(ostream& pOut, unsigned char pChar)
36
pOut << ( (pChar<32) || (pChar>126) ? '.' : (char)pChar);
36
pOut << ((pChar < 32) || (pChar > 126) ? '.' : (char)pChar);
40
40
Hexout(ostream& pOut, unsigned char pChar)
42
pOut << setiosflags(ios::uppercase)
42
pOut << setiosflags(ios::uppercase)
51
51
Hexout(char* pChar, int pLen)
53
std::ostrstream* lOStr = new std::ostrstream;
59
for( lIdx=0; lIdx < 16; ++lIdx )
64
cerr << (lIdx==8 ? "-" : " ");
65
Charout(*lOStr, (unsigned char)*pChar);
75
cerr << lOStr->rdbuf() << endl;
78
lOStr = new std::ostrstream;
53
std::ostrstream* lOStr = new std::ostrstream;
58
for (lIdx = 0; lIdx < 16; ++lIdx) {
61
cerr << (lIdx == 8 ? "-" : " ");
62
Charout(*lOStr, (unsigned char)*pChar);
70
cerr << lOStr->rdbuf() << endl;
73
lOStr = new std::ostrstream;
87
82
// -----------------------------------------------------------------------
89
84
QpRec::QpRec(QpRecType pType)
133
128
// -----------------------------------------------------------------------
135
130
QpRecCell::QpRecCell(QpRecType pType)
145
140
QpRecCell::~QpRecCell()
153
148
QpRecCell::attributes(QP_INT16 pAttributes)
155
cAttributes = pAttributes;
150
cAttributes = pAttributes;
159
154
QpRecCell::attributes()
165
160
QpRecCell::column(QP_UINT8 pColumn)
171
166
QpRecCell::column()
177
172
QpRecCell::row(QP_INT16 pRow)
189
184
QpRecCell::loadCellInfo(QpIStream& pIn)
191
pIn >> cColumn >> cPage >> cRow >> cAttributes;
186
pIn >> cColumn >> cPage >> cRow >> cAttributes;
193
QP_DEBUG(" col " << (unsigned)cColumn << ", Page " << (unsigned)cPage
194
<< ", Row " << cRow << ", Ref "
188
QP_DEBUG(" col " << (unsigned)cColumn << ", Page " << (unsigned)cPage
189
<< ", Row " << cRow << ", Ref "
196
191
<<*/ ", Attr " << cAttributes
199
return 6; // number of bytes consumed
194
return 6; // number of bytes consumed
219
214
//??? cope with relative/absolute references
221
std::strstream lOut(pText, 20, ios::out); // ??? ard coded len
222
int lPageRelative = pRow & 0x8000;
223
int lColRelative = pRow & 0x4000;
224
int lRowRelative = pRow & 0x2000;
225
QP_UINT8 lCol = (lColRelative ? cColumn + pColumn : pColumn);
227
// Sign bit for row is in bit 0x1000, so either set all top bits or lose all top bits
228
QP_INT16 lRow = (lRowRelative ? cRow + (pRow & 0x1000 ? pRow | 0xE000 : pRow & 0x1FFF)
232
// Are we referencing a different page ?
234
if( lPageRelative && (pPage == 0) )
236
// no - page is zero relative to this one
241
// yes - not relative & page is a different one
243
QP_UINT8 lPage = ( lPageRelative ? pPage + cPage : pPage );
245
QP_DEBUG("pTable.name((unsigned)lPage) = " << pTable.name((unsigned)lPage) << endl);
247
lOut << pTable.name((unsigned)lPage) << '!'; // is '!' compat with QPRO???
256
lOut << (char)('A' + lCol);
260
lOut << (char)('A' -1 + lCol / 26)
261
<< (char)('A' + lCol % 26);
269
lOut << (lRow & 0x1FFF) +1 << ends;
216
std::strstream lOut(pText, 20, ios::out); // ??? ard coded len
217
int lPageRelative = pRow & 0x8000;
218
int lColRelative = pRow & 0x4000;
219
int lRowRelative = pRow & 0x2000;
220
QP_UINT8 lCol = (lColRelative ? cColumn + pColumn : pColumn);
222
// Sign bit for row is in bit 0x1000, so either set all top bits or lose all top bits
223
QP_INT16 lRow = (lRowRelative ? cRow + (pRow & 0x1000 ? pRow | 0xE000 : pRow & 0x1FFF)
227
// Are we referencing a different page ?
229
if (lPageRelative && (pPage == 0)) {
230
// no - page is zero relative to this one
232
if (pPage != cPage) {
233
// yes - not relative & page is a different one
235
QP_UINT8 lPage = (lPageRelative ? pPage + cPage : pPage);
237
QP_DEBUG("pTable.name((unsigned)lPage) = " << pTable.name((unsigned)lPage) << endl);
239
lOut << pTable.name((unsigned)lPage) << '!'; // is '!' compat with QPRO???
246
lOut << (char)('A' + lCol);
248
lOut << (char)('A' -1 + lCol / 26)
249
<< (char)('A' + lCol % 26);
256
lOut << (lRow & 0x1FFF) + 1 << ends;
273
260
QpRecCell::cellRef(char* pText, QpTableNames& pTable, QpIStream& pFormulaRef)
276
pFormulaRef >> lNoteBook;
278
// block references (eg. A1..A9) have bit 0x1000 set
280
if( lNoteBook & 0x1000 )
282
QP_UINT8 lFirstColumn;
285
QP_UINT8 lLastColumn;
289
pFormulaRef >> lFirstColumn
296
QP_DEBUG("BlockRef: NoteBook " << lNoteBook
297
<< ", 1st col " << lFirstColumn
298
<< ", 1st page " << (unsigned)lFirstPage
299
<< ", 1st row " << lFirstRow
300
<< ", last col " << lLastColumn
301
<< ", last page " << (unsigned)lLastPage
302
<< ", last row " << lLastRow
263
pFormulaRef >> lNoteBook;
265
// block references (eg. A1..A9) have bit 0x1000 set
267
if (lNoteBook & 0x1000) {
268
QP_UINT8 lFirstColumn;
271
QP_UINT8 lLastColumn;
275
pFormulaRef >> lFirstColumn
282
QP_DEBUG("BlockRef: NoteBook " << lNoteBook
283
<< ", 1st col " << lFirstColumn
284
<< ", 1st page " << (unsigned)lFirstPage
285
<< ", 1st row " << lFirstRow
286
<< ", last col " << lLastColumn
287
<< ", last page " << (unsigned)lLastPage
288
<< ", last row " << lLastRow
305
291
// ??? next few lines shouldn't just add rows together
306
cellRef( pText, pTable, lNoteBook, lFirstPage, lFirstColumn, lFirstRow );
292
cellRef(pText, pTable, lNoteBook, lFirstPage, lFirstColumn, lFirstRow);
307
293
// ?? temp next line strcat( pText, ".." );
308
strcat( pText, ":" );
309
cellRef( &pText[strlen(pText)], pTable, lNoteBook, lLastPage, lLastColumn, lLastRow );
317
pFormulaRef >> lColumn >> lPage >> lRow;
319
QP_DEBUG("FormulaRef: NoteBook " << lNoteBook << ", Col " << (unsigned)lColumn
320
<< ", Page " << (unsigned)lPage << ", Row " << lRow << endl
295
cellRef(&pText[strlen(pText)], pTable, lNoteBook, lLastPage, lLastColumn, lLastRow);
301
pFormulaRef >> lColumn >> lPage >> lRow;
303
QP_DEBUG("FormulaRef: NoteBook " << lNoteBook << ", Col " << (unsigned)lColumn
304
<< ", Page " << (unsigned)lPage << ", Row " << lRow << endl
323
307
// ??? sort out what to do about lNotebook
324
308
// ??? next few lines shouldn't just add rows together
325
cellRef( pText, pTable, lNoteBook, lPage, lColumn, lRow );
309
cellRef(pText, pTable, lNoteBook, lPage, lColumn, lRow);
329
313
// -----------------------------------------------------------------------
331
315
QpRecBof::QpRecBof(QP_INT16, QpIStream& pIn)
336
QP_DEBUG("BOF fileformat=" << cFileFormat << endl);
320
QP_DEBUG("BOF fileformat=" << cFileFormat << endl);
339
323
QpRecBof::~QpRecBof()
494
478
QpRecFloatingPointCell::value()
499
483
// -----------------------------------------------------------------------
501
485
QpRecLabelCell::QpRecLabelCell(QP_INT16 pLen, QpIStream& pIn)
502
: QpRecCell( QpLabelCell )
486
: QpRecCell(QpLabelCell)
504
QP_DEBUG("Label Cell - ");
505
int lLabelLen = pLen - loadCellInfo(pIn) - 1;
509
cLabel = new char[lLabelLen];
511
pIn.read( cLabel, lLabelLen );
513
QP_DEBUG(", Prefix " << cLabelPrefix << ", Label " << cLabel << endl);
488
QP_DEBUG("Label Cell - ");
489
int lLabelLen = pLen - loadCellInfo(pIn) - 1;
493
cLabel = new char[lLabelLen];
495
pIn.read(cLabel, lLabelLen);
497
QP_DEBUG(", Prefix " << cLabelPrefix << ", Label " << cLabel << endl);
516
500
QpRecLabelCell::~QpRecLabelCell()
523
507
QpRecLabelCell::labelPrefix()
529
513
QpRecLabelCell::label()
534
518
// -----------------------------------------------------------------------
536
520
QpRecFormulaCell::QpRecFormulaCell(QP_INT16 pLen, QpIStream& pIn)
537
: QpRecCell( QpFormulaCell )
521
: QpRecCell(QpFormulaCell)
540
QP_DEBUG("Formula Cell - ");
542
int lFormulaLen = pLen - loadCellInfo(pIn);
556
cFormula = new char[lFormulaLen];
558
pIn.read( cFormula, lFormulaLen );
560
QP_DEBUG(", LastValue " << cLastValue << ", State " << cState << endl);
561
QP_DEBUG(" FormulaLen " << cLen << ", CellRef " << cCellRef << ", Formula" << endl);
524
QP_DEBUG("Formula Cell - ");
526
int lFormulaLen = pLen - loadCellInfo(pIn);
540
cFormula = new char[lFormulaLen];
542
pIn.read(cFormula, lFormulaLen);
544
QP_DEBUG(", LastValue " << cLastValue << ", State " << cState << endl);
545
QP_DEBUG(" FormulaLen " << cLen << ", CellRef " << cCellRef << ", Formula" << endl);
563
Hexout( cFormula, lFormulaLen );
547
Hexout(cFormula, lFormulaLen);
568
552
QpRecFormulaCell::~QpRecFormulaCell()
575
559
QpRecFormulaCell::formula()
581
565
QpRecFormulaCell::formulaLen()
587
571
QpRecFormulaCell::formulaReferences()
592
576
// -----------------------------------------------------------------------
594
578
QpRecUnknown::QpRecUnknown(QP_INT16 /*pType*/, QP_INT16 pLen, QpIStream& pIn)
597
QP_DEBUG("Unknown Type " << pType << ", len " << pLen << endl);
601
char* lBuf = new char[pLen];
603
pIn.read(lBuf, pLen);
581
QP_DEBUG("Unknown Type " << pType << ", len " << pLen << endl);
584
char* lBuf = new char[pLen];
586
pIn.read(lBuf, pLen);
610
593
QpRecUnknown::~QpRecUnknown()
629
612
QpRecBop::pageIndex()
635
618
// -----------------------------------------------------------------------
637
620
QpRecPageName::QpRecPageName(QP_INT16, QpIStream& pIn)
638
: QpRec( QpPageName )
642
QP_DEBUG("Page Name: " << cPageName << endl);
625
QP_DEBUG("Page Name: " << cPageName << endl);
645
628
QpRecPageName::~QpRecPageName()
651
634
QpRecPageName::pageName()
655
638
// -----------------------------------------------------------------------
657
640
QpRecPassword::QpRecPassword(QP_INT16 pLen, QpIStream& pIn)
658
: QpRec( QpPassword )
660
QP_DEBUG("Password len = " << pLen << endl);
662
cPassword = new QP_UINT8[pLen];
664
pIn.read( (char*)cPassword, pLen );
666
QP_DEBUG("Password(Hex) = ");
643
QP_DEBUG("Password len = " << pLen << endl);
645
cPassword = new QP_UINT8[pLen];
647
pIn.read((char*)cPassword, pLen);
649
QP_DEBUG("Password(Hex) = ");
668
Hexout( (char*)cPassword, pLen );
651
Hexout((char*)cPassword, pLen);
673
656
QpRecPassword::~QpRecPassword()
680
663
QpRecPassword::password()