Commit 3e93d9aa authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

XlsFormat - формулы формата 5.0 и ниже

parent 87652986
......@@ -50,12 +50,12 @@ void Formula::readFields(CFRecord& record)
fShrFmla = GETBIT(flags, 3);
fClearErrors = GETBIT(flags, 5);
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
//_UINT16 chn = 0;
//record >> chn;
}
else
//if (record.getGlobalWorkbookInfo()->Version < 0x0600)
//{
// _UINT16 chn = 0;
// record >> chn;
//}
//else
{
_UINT32 chn = 0;
record >> chn;
......
......@@ -33,11 +33,11 @@ void CellParsedFormula::load(CFRecord& record)
unsigned short cce;
record >> cce;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
record.skipNunBytes(record.getDataSize() - record.getRdPtr());
}
else
//if (record.getGlobalWorkbookInfo()->Version < 0x0600)
//{
// record.skipNunBytes(record.getDataSize() - record.getRdPtr());
//}
//else
{
rgce.load(record, cce);
rgcb.load(record, rgce.getPtgs(), is_part_of_a_revision_);
......
......@@ -25,23 +25,20 @@ public:
void operator+=(const CellRef& appended_ref);
void operator-=(const CellRef& subtracted_ref);
private:
virtual void load(CFRecord& record) {}
virtual void store(CFRecord& record) {}
public:
const int getRow() const;
const int getColumn() const;
const bool getRowRelative() const;
const bool getColumnRelative() const;
protected:
int row;
int column;
bool rowRelative;
bool colRelative;
protected:
bool fQuoted;
mutable std::wstring to_string_cache;
};
......
......@@ -34,7 +34,27 @@ void PtgArea::storeFields(CFRecord& record)
void PtgArea::loadFields(CFRecord& record)
{
record >> area;
if (record.getGlobalWorkbookInfo()->Version < 0x600)
{
unsigned char colFirst, colLast;
_UINT16 rwFirst, rwLast;
record >> rwFirst >> rwLast >> colFirst >> colLast;
area.rowFirstRelative = rwFirst & 0x8000;
area.columnLastRelative = rwFirst & 0x4000;
area.columnFirst = colFirst;
area.rowFirst = rwFirst & 0x3FFF;
area.rowLastRelative = rwLast & 0x8000;
area.columnLastRelative = rwLast & 0x4000;
area.columnLast = colLast;
area.rowLast = rwLast & 0x3FFF;
}
else
record >> area;
}
......
......@@ -43,9 +43,25 @@ void PtgArea3d::loadFields(CFRecord& record)
if (global_info->Version < 0x0600)
{
unsigned short rwFirst, rwLast;
unsigned char colFirst, colLast;
record >> ixals;
record .skipNunBytes(8);
record >> itabFirst >> itabLast >> grbitRwFirst >> grbitRwLast >> colFirst >> colLast;
record >> itabFirst >> itabLast >> rwFirst >> rwLast >> colFirst >> colLast;
area.rowFirstRelative = rwFirst & 0x8000;
area.columnLastRelative = rwFirst & 0x4000;
area.columnFirst = colFirst;
area.rowFirst = rwFirst & 0x3FFF;
area.rowLastRelative = rwLast & 0x8000;
area.columnLastRelative = rwLast & 0x4000;
area.columnLast = colLast;
area.rowLast = rwLast & 0x3FFF;
}
else
{
......@@ -67,16 +83,10 @@ void PtgArea3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
extra_data.pop();
return;
}
std::wstring range_ref = area.toString();
if (global_info->Version < 0x0600)
{
CellRef cell1(grbitRwFirst, colFirst, false, false);
CellRef cell2(grbitRwLast, colLast, false, false);
CellRangeRef range(cell1, cell2);
std::wstring range_ref = range.toString();
if (ixals == 0xffff)
{
std::wstring prefix = XMLSTUFF::xti_indexes2sheet_name(itabFirst, itabLast, global_info->sheets_names);
......@@ -91,7 +101,6 @@ void PtgArea3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
}
else
{
std::wstring range_ref = area.toString();
ptg_stack.push(XMLSTUFF::make3dRef(ixti, range_ref, global_info->xti_parsed, full_ref));
}
......
......@@ -34,10 +34,6 @@ public:
unsigned short ixals;
unsigned short itabFirst;
unsigned short itabLast;
unsigned short grbitRwFirst;
unsigned short grbitRwLast;
unsigned char colFirst;
unsigned char colLast;
};
} // namespace XLS
......
......@@ -35,7 +35,27 @@ void PtgAreaN::storeFields(CFRecord& record)
void PtgAreaN::loadFields(CFRecord& record)
{
record >> area;
if (record.getGlobalWorkbookInfo()->Version < 0x600)
{
unsigned char colFirst, colLast;
_UINT16 rwFirst, rwLast;
record >> rwFirst >> rwLast >> colFirst >> colLast;
area.rowFirstRelative = rwFirst & 0x8000;
area.columnFirstRelative = rwFirst & 0x4000;
area.columnFirst = colFirst;
area.rowFirst = rwFirst & 0x3FFF;
area.rowLastRelative = rwLast & 0x8000;
area.columnLastRelative = rwLast & 0x4000;
area.columnLast = colLast;
area.rowLast = rwLast & 0x3FFF;
}
else
record >> area;
}
......
......@@ -35,6 +35,15 @@ void PtgName::loadFields(CFRecord& record)
{
record >> nameindex;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
record.skipNunBytes(12);
}
else
{
record.skipNunBytes(2);
}
global_info = record.getGlobalWorkbookInfo();
}
......
......@@ -24,7 +24,7 @@ public:
static const unsigned short fixed_id = 0x03;
_UINT32 nameindex;
_UINT16 nameindex;
private:
GlobalWorkbookInfoPtr global_info;
};
......
......@@ -33,7 +33,20 @@ void PtgNameX::storeFields(CFRecord& record)
void PtgNameX::loadFields(CFRecord& record)
{
record >> ixti >> nameindex;
record >> ixti;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
record.skipNunBytes(8);
_UINT16 val;
record >> val;
nameindex = val;
record.skipNunBytes(12);
}
else
record >> nameindex;
global_info = record.getGlobalWorkbookInfo();
}
......
......@@ -33,7 +33,20 @@ void PtgRef::storeFields(CFRecord& record)
void PtgRef::loadFields(CFRecord& record)
{
record >> loc;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
unsigned char col;
_UINT16 rw;
record >> rw >> col;
loc.rowRelative = GETBIT(rw, 15);
loc.colRelative = GETBIT(rw, 14);
loc.column = col;
loc.row = GETBITS(rw, 0, 13);
}
else
record >> loc;
}
void PtgRef::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full_ref)
......
......@@ -43,10 +43,18 @@ void PtgRef3d::loadFields(CFRecord& record)
if (global_info->Version < 0x0600)
{
_UINT16 rw;
unsigned char col;
record >> ixals;
record.skipNunBytes(8);
record >> itabFirst >> itabLast >> grbitRw >> col;
record >> itabFirst >> itabLast >> rw >> col;
rgce_loc.rowRelative = GETBIT(rw, 15);
rgce_loc.colRelative = GETBIT(rw, 14);
rgce_loc.column = col;
rgce_loc.row = GETBITS(rw, 0, 13);
}
else
{
......@@ -69,28 +77,24 @@ void PtgRef3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool fu
extra_data.pop();
return;
}
std::wstring cell_ref = rgce_loc.toString();
if (global_info->Version < 0x0600)
{
CellRef cell(grbitRw,col, false, false);
std::wstring range_ref = cell.toString();
if (ixals == 0xffff)
{
std::wstring prefix = XMLSTUFF::xti_indexes2sheet_name(itabFirst, itabLast, global_info->sheets_names);
if (!prefix.empty()) prefix += L"!";
ptg_stack.push(prefix + range_ref);
ptg_stack.push(prefix + cell_ref);
}
else
{
ptg_stack.push(XMLSTUFF::make3dRef(ixals, range_ref, global_info->xti_parsed, full_ref)); // from External !
ptg_stack.push(XMLSTUFF::make3dRef(ixals, cell_ref, global_info->xti_parsed, full_ref)); // from External !
}
}
else
{
std::wstring cell_ref = rgce_loc.toString();
cell_ref = XMLSTUFF::make3dRef(ixti, cell_ref, global_info->xti_parsed, full_ref);
ptg_stack.push(cell_ref);
}
......
......@@ -34,8 +34,6 @@ private:
_UINT16 ixals;
_UINT16 itabFirst;
_UINT16 itabLast;
_UINT16 grbitRw;
unsigned char col;
GlobalWorkbookInfoPtr global_info;
......
......@@ -35,7 +35,20 @@ void PtgRefN::storeFields(CFRecord& record)
void PtgRefN::loadFields(CFRecord& record)
{
record >> loc;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
unsigned char col;
_UINT16 rw;
record >> rw >> col;
loc.rowRelative = rw & 0x8000;
loc.colRelative = rw & 0x4000;
loc.column = col;
loc.row = GETBITS(rw, 0, 13);
}
else
record >> loc;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment