Commit e2336451 authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

XlsFormatReader - формат версии 5.0

parent 9ea214e1
......@@ -130,6 +130,7 @@ CFRecordTypeValues[] =
{"SXVS", rt_SXVS},
{"MergeCells", rt_MergeCells},
{"BkHim", rt_BkHim},
{"IMDATA", rt_IMDATA},
{"MsoDrawingGroup", rt_MsoDrawingGroup},
{"MsoDrawing", rt_MsoDrawing},
{"MsoDrawingSelection", rt_MsoDrawingSelection},
......
......@@ -82,6 +82,7 @@ typedef enum CF_RECORD_TYPE
rt_Intl = 0x0061,
rt_ObjProtect = 0x0063,
rt_ColInfo = 0x007d,
rt_IMDATA = 0x007f,
rt_Guts = 0x0080,
rt_WsBool = 0x0081,
rt_GridSet = 0x0082,
......
......@@ -18,8 +18,6 @@ global_info_(global_info)
skippable_records_names.push_back("StartBlock");
skippable_records_names.push_back("EndBlock");
skippable_records_names.push_back("ChartFrtInfo");
//skippable_records_names.push_back("TextPropsStream");
//skippable_records_names.push_back("ShapePropsStream");
}
......@@ -188,6 +186,20 @@ void CFStreamCacheReader::skipNunBytes(const size_t n)
// Seek to the next substream (Read all records till EOF then skip EOF)
// Doesn't generate EndOfStreamReached if the stream is the last one
void CFStreamCacheReader::SkipRecord()
{
if (records_cache.begin() != records_cache.end())
{
CFRecordType::TypeString rec_name = records_cache.front()->getTypeString();
if (rec_name.empty())
Log::warning(L"The extracted record has obsoleted or unknown type(0x" + STR::int2hex_wstr(records_cache.front()->getTypeId(), sizeof(CFRecordType::TypeId)) + L")");
else
Log::warning("The record has been skipped (" + rec_name + ")");
records_cache.pop_front();
}
}
const bool CFStreamCacheReader::SeekToEOF()
{
while(readFromStream(1))
......
......@@ -31,6 +31,8 @@ public:
const bool isEOF() const;
// Skip the specified number of unsigned chars without processing
void skipNunBytes(const size_t n);
void SkipRecord();
// Seek to the next substream (Read all records till EOF then skip EOF)
// Doesn't generate EndOfStreamReached if the stream is the last one
const bool SeekToEOF();
......
......@@ -59,7 +59,8 @@ CFStreamPtr CompoundFile::getWorkbookStream()
{
CFStreamPtr stream = getNamedStream("Workbook");
if (stream == NULL) stream = getNamedStream("Book");
if (stream == NULL)
stream = getNamedStream("Book");
return stream;
}
......
......@@ -25,7 +25,7 @@ public:
_UINT16 iEntry;
BIFF_BYTE wJoin;
unsigned char wJoin;
bool fSimple1;
bool fSimple2;
......@@ -33,7 +33,7 @@ public:
bool fTopN;
bool fPercent;
BIFF_BYTE fTop;
unsigned char fTop;
_UINT16 wTopN;
AFDOper doper1;
......
......@@ -8,6 +8,21 @@ namespace XLS
BOF::BOF()
{
fWin = true;
fRisc = false;
fBeta = false;
fWinAny = true;
fMacAny = false;
fBetaAny = false;
fRiscAny = false;
fOOM = false;
fGlJmp = false;
fFontLimit = false;
verXLHigh = 0;
verLowestBiff = 6;
verLastXLSaved = 0;
}
......@@ -56,21 +71,21 @@ void BOF::readFields(CFRecord& record)
{
record >> vers >> dt >> rupBuild >> rupYear;
if (vers == (_UINT16)0x600)
if ( record.checkFitReadSafe(8))
{
_UINT32 flags;
record >> flags;
fWin = GETBIT(flags, 0);
fRisc = GETBIT(flags, 1);
fBeta = GETBIT(flags, 2);
fWinAny = GETBIT(flags, 3);
fMacAny = GETBIT(flags, 4);
fBetaAny = GETBIT(flags, 5);
fRiscAny = GETBIT(flags, 8);
fOOM = GETBIT(flags, 9);
fGlJmp = GETBIT(flags, 10);
fFontLimit = GETBIT(flags, 13);
fWin = GETBIT(flags, 0);
fRisc = GETBIT(flags, 1);
fBeta = GETBIT(flags, 2);
fWinAny = GETBIT(flags, 3);
fMacAny = GETBIT(flags, 4);
fBetaAny = GETBIT(flags, 5);
fRiscAny = GETBIT(flags, 8);
fOOM = GETBIT(flags, 9);
fGlJmp = GETBIT(flags, 10);
fFontLimit = GETBIT(flags, 13);
verXLHigh = static_cast<unsigned char>(GETBITS(flags, 14, 17));
......@@ -82,9 +97,6 @@ void BOF::readFields(CFRecord& record)
stream_ptr = record.getStreamPointer();
record.skipNunBytes(2); // reserved
}
else if (vers == (_UINT16)0x500)//testdoc01.xls
{
}
}
unsigned short BOF::getSubstreamType()
......
......@@ -55,8 +55,8 @@ public:
bool fFontLimit;
_UINT16 verXLHigh;
BIFF_BYTE verLowestBiff;
BIFF_BYTE verLastXLSaved;
unsigned char verLowestBiff;
unsigned char verLastXLSaved;
ForwardOnlyParam<unsigned int> stream_ptr;
......
......@@ -35,6 +35,7 @@ void BRAI::readFields(CFRecord& record)
record >> id >> rt >> flags;
fUnlinkedIfmt = static_cast<unsigned char>(GETBIT(flags, 0));
record >> ifmt;
formula.load(record);
}
......
......@@ -26,12 +26,12 @@ public:
static const ElementType type = typeBRAI;
//-----------------------------
BIFF_BYTE id;
BIFF_BYTE rt;
bool fUnlinkedIfmt;
IFmt ifmt;
unsigned char id;
unsigned char rt;
bool fUnlinkedIfmt;
unsigned short ifmt;
ChartParsedFormula formula; //
ChartParsedFormula formula; //
};
} // namespace XLS
......
......@@ -18,7 +18,6 @@ BiffRecord::~BiffRecord()
}
// Common algorithm of loading from bin to XML
const bool BiffRecord::read(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory)
{
parent_ = parent;
......@@ -53,46 +52,11 @@ const bool BiffRecord::read(CFStreamCacheReader& reader, BaseObject* parent, con
return true; // Record reading OK
}
//const bool BiffRecord::write(BinWriterProcessor& proc, const bool is_mandatory)
//{
// CFRecordPtr record(new CFRecord(getTypeId(), proc.getGlobalWorkbookInfo()));
//
// BiffStructurePtr own_tag = proc.getChildNode(getClassName(), is_mandatory);
// if(!own_tag)
// {
// return false;
// }
// BinWriterProcessor writer_proc(proc, own_tag, is_mandatory); // Creates new processor with empty tags counters and own tag
//
// toFrom(writer_proc);
// writeFields(*record);
// record->commitData();
//
// if(proc.getWriter().storeNextRecord(record))
// {
// writeCreatedContinueRecords(proc.getWriter());
// return true;
// }
// return false;
//}
//
//
//
//
// Stub. May be overridden in derivers
void BiffRecord::readFollowingContinue(CFStreamCacheReader& reader)
{
}
//// Stub. May be overridden in derivers
//void BiffRecord::writeCreatedContinueRecords(CFStreamCacheWriter& writer)
//{
//}
// Stub. May be overridden in derivers
const bool BiffRecord::storeRecordAndDecideProceeding(CFRecordPtr record)
{
return true;
......
......@@ -25,13 +25,13 @@ public:
static const ElementType type = typeBookExt;
//-----------------------------
BIFF_DWORD cb;
_UINT32 cb;
bool fDontAutoRecover;
bool fHidePivotList;
bool fFilterPrivacy;
bool fEmbedFactoids;
BIFF_BYTE mdFactoidDisplay;
unsigned char mdFactoidDisplay;
bool fSavedDuringRecovery;
bool fCreatedViaMinimalSave;
bool fOpenedViaDataRecovery;
......
......@@ -51,7 +51,18 @@ void BoundSheet8::writeFields(CFRecord& record)
void BoundSheet8::readFields(CFRecord& record)
{
unsigned short flags;
record >> lbPlyPos >> flags >> stName;
record >> lbPlyPos >> flags;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
ShortXLAnsiString name;
record >> name;
stName = name;
}
else
{
record >> stName;
}
switch(GETBITS(flags, 0, 1))
{
......
......@@ -26,8 +26,8 @@ public:
int serialize(std::wostream & stream);
//-----------------------------
BIFF_BYTE ct;
BIFF_BYTE cp;
unsigned char ct;
unsigned char cp;
DXFN rgbdxf;
......
......@@ -24,8 +24,8 @@ public:
static const ElementType type = typeCRN;
//-----------------------------
BIFF_BYTE colLast;
BIFF_BYTE colFirst;
unsigned char colLast;
unsigned char colFirst;
_UINT16 row;
BiffStructurePtrVector crnOper;
......
......@@ -25,8 +25,8 @@ public:
static const ElementType type = typeChart3DBarShape;
//-----------------------------
BIFF_BYTE riser;
BIFF_BYTE taper;
unsigned char riser;
unsigned char taper;
};
......
......@@ -23,8 +23,8 @@ public:
static const ElementType type = typeChartFrtInfo;
//-----------------------------
BIFF_BYTE verOriginator;
BIFF_BYTE verWriter;
unsigned char verOriginator;
unsigned char verWriter;
};
......
......@@ -46,7 +46,8 @@ void ColInfo::readFields(CFRecord& record)
iOutLevel = GETBITS(flags, 8, 10);
fCollapsed = GETBIT(flags, 12);
record.skipNunBytes(2); // unused
record.skipNunBytes(record.getDataSize() - record.getRdPtr()); // unused
//0x0600 - 2 bytes; lower - 1 byte
}
} // namespace XLS
......
......@@ -32,7 +32,7 @@ public:
bool fUserSet;
bool fBestFit;
bool fPhonetic;
BIFF_BYTE iOutLevel;
unsigned char iOutLevel;
bool fCollapsed;
};
......
......@@ -23,8 +23,8 @@ public:
static const ElementType type = typeCrtLayout12;
//-----------------------------
BIFF_DWORD dwCheckSum;
BIFF_BYTE autolayouttype;
_UINT32 dwCheckSum;
unsigned char autolayouttype;
CrtLayout12Mode wXMode;
CrtLayout12Mode wYMode;
......
......@@ -24,7 +24,7 @@ public:
//-----------------------------
BIFF_DWORD cb;
_UINT32 cb;
};
......
......@@ -24,10 +24,10 @@ public:
//-----------------------------
bool fWnClosed;
BIFF_DWORD xLeft;
BIFF_DWORD yTop;
BIFF_LONG idObj;
BIFF_DWORD idvMac;
_UINT32 xLeft;
_UINT32 yTop;
_INT32 idObj;
_UINT32 idvMac;
};
......
......@@ -45,7 +45,19 @@ void Dimensions::writeFields(CFRecord& record)
void Dimensions::readFields(CFRecord& record)
{
record >> rwMic >> rwMac >> colMic >> colMac;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
_UINT16 Mic, Mac;
record >> Mic >> Mac;
rwMic = Mic;
rwMac = Mac;
}
else
{
record >> rwMic >> rwMac;
}
record >> colMic >> colMac;
record.skipNunBytes(2); // reserved
......
......@@ -23,15 +23,15 @@ public:
static const ElementType type = typeDv;
//-----------------------------
BIFF_BYTE valType;
BIFF_BYTE errStyle;
unsigned char valType;
unsigned char errStyle;
bool fStrLookup;
bool fAllowBlank;
bool fSuppressCombo;
BIFF_BYTE mdImeMode;
unsigned char mdImeMode;
bool fShowInputMsg;
bool fShowErrorMsg;
BIFF_BYTE typOperator;
unsigned char typOperator;
XLUnicodeString PromptTitle;
XLUnicodeString ErrorTitle;
......
......@@ -34,12 +34,19 @@ void ExternSheet::writeFields(CFRecord& record)
void ExternSheet::readFields(CFRecord& record)
{
record >> cXTI;
for(int i = 0; i < cXTI; ++i)
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
XTIPtr xti(new XTI);
record >> *xti;
rgXTI.push_back(xti);
record.skipNunBytes(record.getDataSize() - record.getRdPtr());
}
else
{
record >> cXTI;
for(int i = 0; i < cXTI; ++i)
{
XTIPtr xti(new XTI);
record >> *xti;
rgXTI.push_back(xti);
}
}
}
......
......@@ -29,7 +29,7 @@ public:
//-----------------------------
SharedFeatureType isf;
_UINT16 cref;
BIFF_DWORD cbFeatData;
_UINT32 cbFeatData;
BiffStructurePtrVector refs;
BIFF_BSTR sqref;
......
......@@ -27,7 +27,7 @@ public:
//-----------------------------
bool is_contained_in_Globals;
SharedFeatureType isf;
BIFF_DWORD cbHdrData;
_UINT32 cbHdrData;
EnhancedProtection protection;
OSHARED::PropertyBagStore prop;
};
......
......@@ -28,7 +28,7 @@ public:
public:
FrtHeader frt;
SharedFeatureType isf;
BIFF_DWORD idListNext;
_UINT32 idListNext;
};
......
......@@ -25,10 +25,10 @@ public:
//-----------------------------
Boolean<unsigned short> fReadOnlyRec;
unsigned short wResPassNum;
BIFF_BSTR wResPass;
_UINT16 iNoResPass;
XLUnicodeString stUNUsername;
unsigned short wResPassNum;
BIFF_BSTR wResPass;
_UINT16 iNoResPass;
XLUnicodeString stUNUsername;
};
......
......@@ -35,6 +35,7 @@ void Font::writeFields(CFRecord& record)
record << dyHeight << flags;
record << icv << bls << sss << uls << bFamily << bCharSet;
record.reserveNunBytes(1, static_cast<unsigned char>(0x5E));
record << fontName;
}
......@@ -55,7 +56,18 @@ void Font::readFields(CFRecord& record)
record >> icv >> bls >> sss >> uls >> bFamily >> bCharSet;
record.skipNunBytes(1);
record >> fontName;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
ShortXLAnsiString name;
record >> name;
fontName = name;
}
else
{
record >> fontName;
}
}
int Font::serialize(std::wostream & stream)
......
......@@ -45,9 +45,9 @@ public:
_UINT16 icv;
_UINT16 bls;
_UINT16 sss;
BIFF_BYTE uls;
BIFF_BYTE bFamily;
BIFF_BYTE bCharSet;
unsigned char uls;
unsigned char bFamily;
unsigned char bCharSet;
FillInfoExt color_ext;
ShortXLUnicodeString fontName;
......
......@@ -33,7 +33,17 @@ void Footer::readFields(CFRecord& record)
{
if(!record.isEOF())
{
record >> ast;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
ShortXLAnsiString name;
record >> name;
ast = name;
}
else
{
record >> ast;
}
}
}
......
......@@ -28,7 +28,18 @@ void Format::writeFields(CFRecord& record)
void Format::readFields(CFRecord& record)
{
record >> ifmt >> stFormat;
record >> ifmt;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
ShortXLAnsiString name;
record >> name;
stFormat = name;
}
else
record >> stFormat;
stFormat = xml::utils::replace_xml_to_text(stFormat.value());
}
......
......@@ -50,8 +50,16 @@ void Formula::readFields(CFRecord& record)
fShrFmla = GETBIT(flags, 3);
fClearErrors = GETBIT(flags, 5);
_UINT32 chn = 0;
record >> chn;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
//_UINT16 chn = 0;
//record >> chn;
}
else
{
_UINT32 chn = 0;
record >> chn;
}
formula.load(record);
}
......
......@@ -33,7 +33,17 @@ void Header::readFields(CFRecord& record)
{
if(!record.isEOF())
{
record >> ast;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
ShortXLAnsiString name;
record >> name;
ast = name;
}
else
{
record >> ast;
}
}
}
......
#include "IMDATA.h"
namespace XLS
{
IMDATA::IMDATA()
{
}
IMDATA::~IMDATA()
{
}
BaseObjectPtr IMDATA::clone()
{
return BaseObjectPtr(new IMDATA(*this));
}
void IMDATA::writeFields(CFRecord& record)
{
}
void IMDATA::readFields(CFRecord& record)
{
record >> cf;
record >> env;
record >> lcb;//imageBlob size
unsigned int sz = record.getDataSize() - record.getRdPtr();
if (cf == 0x09)
{
//bitmap
}
else
{
//native
}
if (lcb < 1) return;
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
while (record.getRdPtr() + lcb > record.getDataSize() && !recs.empty())
{
record.appendRawData(recs.front());
recs.pop_front();
}
if (record.checkFitReadSafe(lcb))
{
pData = boost::shared_array<char>(new char[lcb]);
memcpy(pData.get(), record.getCurData<char>(), lcb);
record.skipNunBytes(lcb);
}
}
} // namespace XLS
#pragma once
#include "BiffRecordContinued.h"
namespace XLS
{
// Logical representation of IMDATA record in BIFF5
class IMDATA: public BiffRecordContinued
{
BIFF_RECORD_DEFINE_TYPE_INFO(IMDATA)
BASE_OBJECT_DEFINE_CLASS_NAME(IMDATA)
public:
IMDATA();
~IMDATA();
BaseObjectPtr clone();
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
static const ElementType type = typeIMDATA;
_UINT16 cf;
_UINT16 env;
_UINT32 lcb;
boost::shared_array<char> pData;
};
}
\ No newline at end of file
......@@ -33,7 +33,17 @@ void Label::readFields(CFRecord& record)
{
global_info_ = record.getGlobalWorkbookInfo();
record >> cell >> st;
record >> cell;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
LPAnsiString name;
record >> name;
st = name;
}
else
record >> st;
isst_ = global_info_->startAddedSharedStrings + global_info_->arAddedSharedStrings.size() ;
global_info_->arAddedSharedStrings.push_back(st.value());
......
......@@ -26,8 +26,8 @@ public:
static const ElementType type = typeLabel;
Cell cell;
XLUnicodeString st;
Cell cell;
XLUnicodeString st;
//-----------------------------
GlobalWorkbookInfoPtr global_info_;
......
......@@ -34,11 +34,11 @@ public:
bool fProc;
bool fCalcExp;
bool fBuiltin;
BIFF_BYTE fGrp;
unsigned char fGrp;
bool fPublished;
bool fWorkbookParam;
BIFF_BYTE chKey;
unsigned char chKey;
_UINT16 itab;
XLUnicodeStringNoCch Name_bin;
BIFF_BSTR Name;
......
......@@ -25,11 +25,11 @@ public:
static const ElementType type = typeLegend;
//-----------------------------
BIFF_DWORD x;
BIFF_DWORD y;
BIFF_DWORD dx;
BIFF_DWORD dy;
BIFF_BYTE wSpace;
_UINT32 x;
_UINT32 y;
_UINT32 dx;
_UINT32 dy;
unsigned char wSpace;
bool fAutoPosition;
bool fAutoPosX;
......
......@@ -27,7 +27,7 @@ public:
public:
FrtHeader frtHeader;
_UINT16 lsd;
BIFF_DWORD idList;
_UINT32 idList;
List12BlockLevel rgbList12BlockLevel;
List12TableStyleClientInfo rgbList12TableStyleClientInfo;
......
......@@ -20,11 +20,11 @@ public:
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
//-----------------------------
BIFF_LONG istrConnName;
BIFF_BYTE tfnSrc;
BIFF_BYTE kpiprop;
BIFF_LONG istrKPIName;
BIFF_LONG istrMbrKPI;
_INT32 istrConnName;
unsigned char tfnSrc;
unsigned char kpiprop;
_INT32 istrKPIName;
_INT32 istrMbrKPI;
};
} // namespace XLS
......
......@@ -20,10 +20,10 @@ public:
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
//-----------------------------
BIFF_LONG istrConnName;
BIFF_BYTE tfnSrc;
BIFF_DWORD istrMbr;
BIFF_DWORD istrProp;
_INT32 istrConnName;
unsigned char tfnSrc;
_UINT32 istrMbr;
_UINT32 istrProp;
};
......
......@@ -21,11 +21,11 @@ public:
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
//-----------------------------
BIFF_LONG istrConnName;
BIFF_BYTE tfnSrc;
BIFF_BYTE sso;
BIFF_DWORD istrSetDef;
BIFF_LONG cistr;
_INT32 istrConnName;
unsigned char tfnSrc;
unsigned char sso;
_UINT32 istrSetDef;
_INT32 cistr;
BiffStructurePtrVector rgistr;
};
......
......@@ -24,9 +24,9 @@ public:
static const ElementType type = typeMDXTuple;
//-----------------------------
BIFF_LONG istrConnName;
BIFF_BYTE tfnSrc;
BIFF_LONG cistr;
_INT32 istrConnName;
unsigned char tfnSrc;
_INT32 cistr;
BiffStructurePtrVector rgistr;
};
......
......@@ -23,7 +23,7 @@ public:
bool fMTREnabled;
bool fUserSetThreadCount;
BIFF_DWORD cUserThreadCount;
_UINT32 cUserThreadCount;
};
......
......@@ -33,7 +33,7 @@ public:
IcvChart icvFore;
IcvChart icvBack;
BIFF_DWORD miSize;
_UINT32 miSize;
};
} // namespace XLS
......
......@@ -24,7 +24,7 @@ public:
_UINT16 cachName;
_UINT16 fgrp;
XLNameUnicodeString rgach;
XLUnicodeString rgach;
};
......
......@@ -27,7 +27,7 @@ public:
bool fPublished;
bool fWorkbookParam;
XLNameUnicodeString strName;
XLUnicodeString strName;
};
} // namespace XLS
......
#include "Obj.h"
#include <Logic/Biff_records/MsoDrawing.h>
#include <Logic/Biff_records/TxO.h>
#include <Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtClientAnchorSheet.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtFOPT.h>
#include "../../../XlsXlsxConverter/XlsConverter.h"
#define OBJ_Group 0x0000
#define OBJ_Line 0x0001
#define OBJ_Rectangle 0x0002
#define OBJ_Oval 0x0003
#define OBJ_Arc 0x0004
#define OBJ_Text 0x0006
#define OBJ_OfficeArt 0x001E
#define OBJ_Polygon 0x0009
#define OBJ_Picture 0x0008
#define OBJ_Chart 0x0005
#define OBJ_Button 0x0007
#define OBJ_CheckBox 0x000B
#define OBJ_RadioButton 0x000C
#define OBJ_EditBox 0x000D
#define OBJ_Label 0x000E
#define OBJ_DialogBox 0x000F
#define OBJ_SpinControl 0x0010
#define OBJ_List 0x0012
#define OBJ_GroupBox 0x0013
#define OBJ_Scrollbar 0x0011
#define OBJ_DropdownList 0x0014
#define OBJ_Note 0x0019
namespace XLS
{
Obj::~Obj()
{
}
......@@ -27,7 +58,7 @@ void Obj::writeFields(CFRecord& record)
record << ft << cb; // reserved
record.reserveNunBytes(2); // unused
}
if(0x08 == cmo.ot)
if(OBJ_Picture == cmo.ot)
{
record << pictFormat << pictFlags;
}
......@@ -59,7 +90,7 @@ void Obj::writeFields(CFRecord& record)
{
macro.store(record);
}
if(0x08 != cmo.ot)
if(OBJ_Picture != cmo.ot)
{
pictFmla.store(record, pictFlags);
}
......@@ -98,82 +129,193 @@ void Obj::readFields(CFRecord& record)
{
record >> cmo;
size_t rdPtr = record.getRdPtr();
if(0 == cmo.ot)
{
record.skipNunBytes(6); // Skip FtGmo (obsolete)
}
if(0x08 == cmo.ot) // picture !!!
{
record >> pictFormat;
record >> pictFlags;
}
if(0x0B == cmo.ot || 0x0C == cmo.ot)
{
record.skipNunBytes(16); // Skip FtCbls (obsolete)
}
if(0x0C == cmo.ot)
{
record.skipNunBytes(10); // Skip FtRbo (obsolete)
}
if(0x10 == cmo.ot || 0x11 == cmo.ot || 0x12 == cmo.ot || 0x14 == cmo.ot)
{
record >> sbs;
}
if(0x19 == cmo.ot)
{
record >> nts;
}
if(false) // TODO: Find out the condition
{
macro.load(record);
}
if(0x08 == cmo.ot)
{
//pictFmla.load(record, pictFlags); // picture !!! This field MUST NOT exist unless cmo.ot is equal to 0x08.
}
if(0x0B == cmo.ot || 0x0C == cmo.ot || 0x10 == cmo.ot || 0x11 == cmo.ot || 0x12 == cmo.ot /*|| 0x14 == cmo.ot*/)
{
linkFmla.load(record);
}
if(0x0B == cmo.ot || 0x0C == cmo.ot)
{
checkBox.load(record);
}
if(0x0C == cmo.ot)
{
radioButton.load(record);
}
if(0x0D == cmo.ot)
{
edit.load(record);
}
if(0x12 == cmo.ot || 0x14 == cmo.ot)
{
list.load(record, cmo.ot);
}
if(0x13 == cmo.ot)
{
gbo.load(record);
}
if(0x12 != cmo.ot && 0x14 != cmo.ot)
{
record.skipNunBytes(4); // reserved
}
if (continue_records.size() > 0)
if (record.getGlobalWorkbookInfo()->Version >= 0x0600)
{
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
if(0 == cmo.ot)
{
record.skipNunBytes(6); // Skip FtGmo (obsolete)
}
if(OBJ_Picture == cmo.ot)
{
record >> pictFormat;
record >> pictFlags;
}
if(0x0B == cmo.ot || 0x0C == cmo.ot)
{
record.skipNunBytes(16); // Skip FtCbls (obsolete)
}
if(0x0C == cmo.ot)
{
record.skipNunBytes(10); // Skip FtRbo (obsolete)
}
if(0x10 == cmo.ot || 0x11 == cmo.ot || 0x12 == cmo.ot || 0x14 == cmo.ot)
{
record >> sbs;
}
if(0x19 == cmo.ot)
{
record >> nts;
}
//if(false) // TODO: Find out the condition
//{
// macro.load(record);
//}
if (recs.size())
if(0x0B == cmo.ot || 0x0C == cmo.ot || 0x10 == cmo.ot || 0x11 == cmo.ot || 0x12 == cmo.ot /*|| 0x14 == cmo.ot*/)
{
linkFmla.load(record);
}
if(0x0B == cmo.ot || 0x0C == cmo.ot)
{
checkBox.load(record);
}
if(0x0C == cmo.ot)
{
radioButton.load(record);
}
if(0x0D == cmo.ot)
{
edit.load(record);
}
if(0x12 == cmo.ot || 0x14 == cmo.ot)
{
list.load(record, cmo.ot);
}
if(0x13 == cmo.ot)
{
gbo.load(record);
}
if(0x12 != cmo.ot && 0x14 != cmo.ot)
{
while( !recs.empty() )
record.skipNunBytes(4); // reserved
}
if (continue_records.size() > 0)
{
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
if (recs.size())
{
mso_drawing_->storeRecordAndDecideProceeding(recs.front());
recs.pop_front();
while( !recs.empty() )
{
mso_drawing_->storeRecordAndDecideProceeding(recs.front());
recs.pop_front();
}
}
}
}
else
{
_UINT16 nLinkSize = 0, nNameLen = 0, nMacrosSize = 0;
old_version.enabled = true;
old_version.anchor = ODRAW::OfficeArtRecordPtr(new ODRAW::OfficeArtClientAnchorSheet());
old_version.anchor->loadFields(record);
record >> nMacrosSize;
record.skipNunBytes(2);
record >> nNameLen;
record.skipNunBytes(2);
if(OBJ_Line == cmo.ot)
{
record >> old_version.line;
record >> old_version.flag;
record >> old_version.flag2;
}
else
{
old_version.bFill = true;
record >> old_version.fill;
record >> old_version.line;
if(OBJ_Arc == cmo.ot)
{
unsigned char f;
record >> f;
old_version.flag = f;
record.skipNunBytes(1);
}
else
record >> old_version.flag;
}
if(OBJ_Picture == cmo.ot)
{
_UINT16 type_picture; //2 - wm or pict; 9 - bmp
record >> type_picture;
record.skipNunBytes(4);
record >> nLinkSize;
record.skipNunBytes(2);
record >> old_version.flag2; //0 bit - auto-resize ; 1 bit - dde enabled
record.skipNunBytes(4);
if (nNameLen > 0)
{
record >> old_version.name;
}
record.skipNunBytes(nMacrosSize);
//pictFmla.load(record, nLinkSize);
record.skipNunBytes(nLinkSize);
if (continue_records.size() > 0)
{//embedded
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
if (recs.size())
{
while( !recs.empty() )
{
record.appendRawData(recs.front()->getData(), recs.front()->getDataSize());
recs.pop_front();
}
}
int size = record.getDataSize() - record.getRdPtr();
const char* data = record.getData() + record.getRdPtr();
std::wstring str_type_picture;
if (type_picture == 2) str_type_picture = L".wmf";
if (type_picture == 9) str_type_picture = L"dib_data";
std::wstring id = record.getGlobalWorkbookInfo()->xls_converter->WriteMediaFile((char*)data, size, str_type_picture);
}
}
//else if ( OBJ_Chart == cmo.ot)
//{
// record.skipNunBytes(18);
// if (nNameLen > 0)
// {
// record >> old_version.name;
// }
// record.skipNunBytes(nMacrosSize);
//}
else if(OBJ_Text == cmo.ot)
{
TxO * txO = new TxO(mso_drawing_);
txO->macrosSize = nMacrosSize;
txO->nameLength = nNameLen;
txO->readFields(record);
old_version.additional.push_back(BaseObjectPtr(txO));
old_version.name = txO->name;
}
else
{
if (nNameLen > 0)
{
record >> old_version.name;
}
record.skipNunBytes(nMacrosSize);
}
}
}
......
#pragma once
#include "BiffRecordContinued.h"
#include <Logic/Biff_structures/FtCmo.h>
#include <Logic/Biff_structures/FtCf.h>
#include <Logic/Biff_structures/FtPioGrbit.h>
......@@ -28,6 +29,7 @@ class Obj : public BiffRecordContinued
public:
Obj(MsoDrawingPtr mso_drawing) : mso_drawing_(mso_drawing)
{
old_version.enabled = false;
}
~Obj();
......@@ -40,6 +42,7 @@ public:
//-----------------------------
FtCmo cmo;
FtCf pictFormat;
FtPioGrbit pictFlags;
......@@ -56,6 +59,21 @@ public:
MsoDrawingPtr mso_drawing_;
struct _
{
_() : bFill(false), enabled(false), fill(0), line(0), flag(0), flag2(0) {}
bool enabled;
ODRAW::OfficeArtRecordPtr anchor;
std::vector<BaseObjectPtr> additional;
bool bFill;
ShortXLAnsiString name;
_UINT32 fill;
_UINT32 line;
_UINT16 flag;
_UINT16 flag2;
}old_version;
};
......
......@@ -4,8 +4,7 @@
namespace XLS
{
Pls::Pls(BaseObject* parent)
: parent_(parent)
Pls::Pls()
{
}
......@@ -17,7 +16,7 @@ Pls::~Pls()
BaseObjectPtr Pls::clone()
{
return BaseObjectPtr(new Pls(*this));
return BaseObjectPtr(new Pls());
}
......@@ -63,9 +62,23 @@ void Pls::readFields(CFRecord& record)
if (record.loadAnyData(rgb) == false) return;
int size = record.getDataSize() - 2;
const char* data = record.getData() + 2;
if (continue_records.size() > 0)
{
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
if (recs.size())
{
while( !recs.empty() )
{
record.appendRawData(recs.front()->getData(), recs.front()->getDataSize());
recs.pop_front();
}
}
}
int size = record.getDataSize() - 2;
const char* data = record.getData() + 2;
boost::shared_array<char> buffer(new char[size]);
memcpy(buffer.get(), data, size);
......
#pragma once
#include "BiffRecordContinued.h"
#include <Logic/Biff_records/BiffRecordContinued.h>
#if !defined(_WIN32) && !defined(_WIN64)
......@@ -80,12 +80,12 @@ namespace XLS
// Logical representation of Pls record in BIFF8
class Pls: public BiffRecordContinued
class Pls : public BiffRecordContinued
{
BIFF_RECORD_DEFINE_TYPE_INFO(Pls)
BASE_OBJECT_DEFINE_CLASS_NAME(Pls)
public:
Pls(BaseObject* parent);
Pls();
~Pls();
BaseObjectPtr clone();
......@@ -94,12 +94,9 @@ public:
void readFields(CFRecord& record);
static const ElementType type = typePls;
//-----------------------------
DEVMODE rgb;
BIFF_LONG bin_data_id;
BaseObject* parent_;
DEVMODE rgb;
BIFF_LONG bin_data_id;
};
......
......@@ -24,7 +24,7 @@ public:
//-----------------------------
BIFF_DWORD dwBuild;
_UINT32 dwBuild;
};
......
......@@ -26,8 +26,8 @@ public:
int serialize(std::wostream & stream);
//-----------------------------
BIFF_LONG cstTotal;
BIFF_LONG cstUnique;
_INT32 cstTotal;
_INT32 cstUnique;
BiffStructurePtrVector rgb;
//-----------------------------
......
......@@ -23,11 +23,11 @@ public:
static const ElementType type = typeSerAuxErrBar;
//-----------------------------
BIFF_BYTE sertm;
BIFF_BYTE ebsrc;
Boolean<unsigned char> fTeeTop;
BIFF_DOUBLE numValue;
BIFF_WORD cnum;
unsigned char sertm;
unsigned char ebsrc;
unsigned char fTeeTop;
BIFF_DOUBLE numValue;
_UINT16 cnum;
};
......
......@@ -24,13 +24,13 @@ public:
static const ElementType type = typeSerAuxTrend;
//-----------------------------
BIFF_BYTE regt;
BIFF_BYTE ordUser;
ChartNumNillable numIntercept;
Boolean<unsigned char> fEquation;
Boolean<unsigned char> fRSquared;
BIFF_DOUBLE numForecast;
BIFF_DOUBLE numBackcast;
unsigned char regt;
unsigned char ordUser;
ChartNumNillable numIntercept;
unsigned char fEquation;
unsigned char fRSquared;
BIFF_DOUBLE numForecast;
BIFF_DOUBLE numBackcast;
};
......
......@@ -30,7 +30,15 @@ void SeriesText::writeFields(CFRecord& record)
void SeriesText::readFields(CFRecord& record)
{
record.skipNunBytes(2); // reserved
record >> stText;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
ShortXLAnsiString s;
record >> s;
stText = s;
}
else
record >> stText;
}
} // namespace XLS
......
......@@ -38,7 +38,7 @@ public:
bool fNoOrient;
bool fUsePage;
bool fEndNotes;
BIFF_BYTE iErrors;
unsigned char iErrors;
_UINT16 iRes;
_UINT16 iVRes;
......
......@@ -25,8 +25,8 @@ public:
int serialize(std::wostream & stream);
//-----------------------------
BIFF_DWORD cb;
BIFF_BYTE icvPlain;
_UINT32 cb;
unsigned char icvPlain;
SheetExtOptional sheetExtOptional;
};
......
......@@ -28,7 +28,7 @@ public:
bool fPlotVisOnly;
bool fNotSizeWith;
bool fAlwaysAutoPlotArea;
BIFF_BYTE mdBlank;
unsigned char mdBlank;
};
} // namespace XLS
......
......@@ -28,7 +28,14 @@ void String::writeFields(CFRecord& record)
void String::readFields(CFRecord& record)
{
record >> string;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
LPAnsiString s;
record >> s;
string = s;
}
else
record >> string;
}
} // namespace XLS
......
......@@ -51,7 +51,14 @@ void Style::readFields(CFRecord& record)
}
else
{
record >> user;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
ShortXLAnsiString s;
record >> s;
user = s;
}
else
record >> user;
}
}
......
......@@ -26,7 +26,7 @@ public:
//-----------------------------
bool fIsPivot;
bool fIsTable;
BIFF_DWORD ctse;
_UINT32 ctse;
LPWideStringNoCch rgchName;
......
......@@ -23,9 +23,9 @@ public:
static const ElementType type = typeTableStyleElement;
//-----------------------------
BIFF_DWORD tseType;
BIFF_DWORD size;
BIFF_DWORD index;
_UINT32 tseType;
_UINT32 size;
_UINT32 index;
};
......
......@@ -23,7 +23,7 @@ public:
static const ElementType type = typeTableStyles;
//-----------------------------
BIFF_DWORD cts;
_UINT32 cts;
LPWideStringNoCch rgchDefTableStyle;
LPWideStringNoCch rgchDefPivotStyle;
......
......@@ -23,7 +23,7 @@ public:
static const ElementType type = typeTheme;
//-----------------------------
BIFF_DWORD dwThemeVersion;
_UINT32 dwThemeVersion;
//std::wstring rgb;
};
......
......@@ -26,17 +26,17 @@ public:
int serialize(std::wostream & _stream);
//-----------------------------
BIFF_BYTE tktMajor;
BIFF_BYTE tktMinor;
BIFF_BYTE tlt;
BIFF_BYTE wBkgMode;
unsigned char tktMajor;
unsigned char tktMinor;
unsigned char tlt;
unsigned char wBkgMode;
LongRGB rgb;
bool fAutoCo;
bool fAutoMode;
BIFF_BYTE rot;
unsigned char rot;
bool fAutoRot;
BIFF_BYTE iReadingOrder;
unsigned char iReadingOrder;
_UINT16 icv;
_UINT16 trot;
......
......@@ -33,57 +33,105 @@ void TxO::readFields(CFRecord& record)
pGlobalWorkbookInfoPtr = record.getGlobalWorkbookInfo();
unsigned short flags;
record >> flags;
hAlignment = static_cast<unsigned char>(GETBITS(flags, 1, 3));
vAlignment = static_cast<unsigned char>(GETBITS(flags, 4, 6)); // reserved2 (2 bits)
fLockText = GETBIT(flags, 9); // reserved3 (4 bits)
fJustLast = GETBIT(flags, 14);
fSecretEdit = GETBIT(flags, 15);
record >> rot;
record.skipNunBytes(6); // reserved4 + reserved5
//record >> controlInfo; // The field MUST exist if and only if the value of cmo.ot in the preceding Obj record is 0, 5, 7, 11, 12, or 14.
record >> cchText;
if (cchText != 0)
record >> cbRuns;
record >> ifntEmpty;
fmla.load(record);
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
int sz = cchText;
if ( cbRuns )
{
while (record.getRdPtr() + cchText > record.getDataSize() && !recs.empty())
if (pGlobalWorkbookInfoPtr->Version < 0x0600)
{
short mnLinkSize;
short mnButtonFlags;
short mnShortcut;
short mnShortcutEA;
record >> cchText;
record.skipNunBytes( 2 );
record >> cbRuns >> ifntEmpty;
record.skipNunBytes( 2 );
record >> flags >> rot;
record.skipNunBytes( 2 );
record >> mnLinkSize;
record.skipNunBytes( 2 );
record >> mnButtonFlags >> mnShortcut >> mnShortcutEA;
if (nameLength > 0)
{
record.appendRawData(recs.front());
recs.pop_front();
record >> name;
}
commentText.setSize(cchText);
record >> commentText;
TxOruns.set_records(&recs);
bool bAutoSize = flags & 0x0080;
if (record.getRdPtr() % 2 != 0/*name.value().empty() == false*/)
record.skipNunBytes(1);
record.skipNunBytes(macrosSize);
LPAnsiStringNoCch text(cchText);
record >> text;
rawText = text;
record.skipNunBytes(mnLinkSize );
if (record.getRdPtr() % 2 != 0)
{
record.skipNunBytes( 1 );
}
TxOruns.m_runCount = cbRuns / 8 - 1;
TxOruns.load(record);
TxOruns.load(record);
}
while( !recs.empty() )
else
{
sp_enabled = true;
mso_drawing_->storeRecordAndDecideProceeding(recs.front());
recs.pop_front();
record >> flags;
record >> rot;
record.skipNunBytes(6); // reserved4 + reserved5
//record >> controlInfo; // The field MUST exist if and only if the value of cmo.ot in the preceding Obj record is 0, 5, 7, 11, 12, or 14.
record >> cchText;
if (cchText != 0)
record >> cbRuns;
record >> ifntEmpty;
fmla.load(record);
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
int sz = cchText;
if ( cbRuns )
{
while (record.getRdPtr() + cchText > record.getDataSize() && !recs.empty())
{
record.appendRawData(recs.front());
recs.pop_front();
}
rawText.setSize(cchText);
record >> rawText;
TxOruns.set_records(&recs);
TxOruns.m_runCount = cbRuns / 8 - 1;
TxOruns.load(record);
}
while( !recs.empty() )
{
sp_enabled = true;
mso_drawing_->storeRecordAndDecideProceeding(recs.front());
recs.pop_front();
}
}
hAlignment = static_cast<unsigned char>(GETBITS(flags, 1, 3));
vAlignment = static_cast<unsigned char>(GETBITS(flags, 4, 6)); // reserved2 (2 bits)
fLockText = GETBIT(flags, 9); // reserved3 (4 bits)
fJustLast = GETBIT(flags, 14);
fSecretEdit = GETBIT(flags, 15);
}
int TxO::serialize (std::wostream & _stream)
{
std::wstring str_ = commentText.value();
std::wstring str_ = rawText.value();
int str_size = str_.size();
int Fmt = 0;
......@@ -145,7 +193,7 @@ int TxO::serialize_rPr (std::wostream & _stream, int iFmt, std::wstring namespac
if (!pGlobalWorkbookInfoPtr->m_arFonts) return 0;
int sz = pGlobalWorkbookInfoPtr->m_arFonts->size();
if (iFmt -1 > sz || iFmt < 1) return 0;
if (iFmt - 1 > sz || iFmt < 1) return 0;
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts->at(iFmt-1).get());
......
......@@ -19,6 +19,8 @@ class TxO: public BiffRecordContinued
public:
TxO(MsoDrawingPtr mso_drawing) : mso_drawing_(mso_drawing), fmla(false)
{
macrosSize = 0;
nameLength = 0;
cbRuns = 0;
sp_enabled = false;
preserve_enabled = false;
......@@ -44,16 +46,16 @@ public:
BIFF_BYTE fJustLast;
BIFF_BYTE fSecretEdit;
_UINT16 rot;
_UINT16 rot;
ControlInfo controlInfo;
_UINT16 cchText;
_UINT16 cbRuns;
_UINT16 cchText;
_UINT16 cbRuns;
FontIndex ifntEmpty;
ObjFmla fmla;
TxORuns TxOruns;
XLUnicodeStringNoCch commentText;
XLUnicodeStringNoCch rawText;
bool sp_enabled;
......@@ -62,7 +64,9 @@ public:
//---------------------------------------------
bool preserve_enabled;
short macrosSize;
short nameLength;
ShortXLAnsiString name;
};
} // namespace XLS
......
......@@ -6,6 +6,22 @@ namespace XLS
Window2::Window2()
{
is_contained_in_chart_substream = false;
fSelected = false;
fDspFmlaRt = false;
fDspGridRt = false;
fDspRwColRt = false;
fFrozenRt = false;
fDspZerosRt = false;
fDefaultHdr = false;
fRightToLeft = false;
fDspGuts = false;
fFrozenNoSplit = false;
fPaged = false;
fSLV = false;
wScaleSLV = wScaleNormal = 0;
}
......@@ -43,6 +59,7 @@ void Window2::writeFields(CFRecord& record)
SETBIT(flags, 8, fFrozenNoSplit);
SETBIT(flags, 10, fPaged);
SETBIT(flags, 11, fSLV);
record << flags;
CellRef topLeftCellRef(topLeftCell);
......@@ -58,17 +75,21 @@ void Window2::writeFields(CFRecord& record)
void Window2::readFields(CFRecord& record)
{
is_contained_in_chart_substream = (10 == record.getDataSize());
if (record.getGlobalWorkbookInfo()->Version >= 0x0600)
{
is_contained_in_chart_substream = (10 == record.getDataSize());
}
unsigned short flags;
record >> flags;
fSelected = GETBIT(flags, 9);
fSelected = GETBIT(flags, 9);
if(is_contained_in_chart_substream)
{
record.skipNunBytes(8); // must be ignored
return;
}
fDspFmlaRt = GETBIT(flags, 0);
fDspGridRt = GETBIT(flags, 1);
fDspRwColRt = GETBIT(flags, 2);
......@@ -80,14 +101,17 @@ void Window2::readFields(CFRecord& record)
fFrozenNoSplit = GETBIT(flags, 8);
fPaged = GETBIT(flags, 10);
fSLV = GETBIT(flags, 11);
record >> rwTop >> colLeft >> icvHdr;
topLeftCell = static_cast<std::wstring >(CellRef(rwTop, colLeft, true, true));
record.skipNunBytes(2); // reserved
record >> wScaleSLV >> wScaleNormal;
record.skipNunBytes(4); // unused / reserved
if (10 > record.getDataSize())
{
record >> wScaleSLV >> wScaleNormal;
record.skipNunBytes(4); // unused / reserved
}
}
......
......@@ -29,8 +29,18 @@ void WriteAccess::writeFields(CFRecord& record)
void WriteAccess::readFields(CFRecord& record)
{
record >> userName;
record.skipNunBytes(112 - userName.getStructSize()); // unused
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
ShortXLAnsiString name;
record >> name;
userName = name;
}
else
{
record >> userName;
}
record.skipNunBytes(record.getDataSize() - record.getRdPtr()); // unused
}
} // namespace XLS
......
......@@ -88,7 +88,7 @@ int XF::serialize(std::wostream & stream)
//CP_XML_ATTR(L"applyBorder" , style.fAtrBdr);
//CP_XML_ATTR(L"applyNumberFormat" , style.fAtrNum);
if (style.alc >=0 && style.alc <8 && style.alcV >=0 && style.alcV <5)
if ((style.alc >=0 && style.alc <8) || (style.alcV >=0 && style.alcV <5) || (style.fShrinkToFit) || (cell.cIndent > 0) || (style.trot > 0 && style.trot < 0xff) || (style.fWrap))
{
//CP_XML_ATTR(L"applyAlignment", style.fAtrAlc);
CP_XML_NODE(L"alignment")
......@@ -100,7 +100,7 @@ int XF::serialize(std::wostream & stream)
if (cell.cIndent > 0) CP_XML_ATTR(L"indent", style.cIndent);
CP_XML_ATTR(L"wrapText" , style.fWrap);
if (style.trot > 0) CP_XML_ATTR(L"textRotation" , style.trot);
if (style.trot > 0 && style.trot < 0xff) CP_XML_ATTR(L"textRotation" , style.trot);
}
}
}
......@@ -114,10 +114,10 @@ int XF::serialize(std::wostream & stream)
CP_XML_ATTR(L"applyBorder" , cell.fAtrBdr);
CP_XML_ATTR(L"applyNumberFormat", cell.fAtrNum);
CP_XML_ATTR(L"applyFont" , cell.fAtrFnt);
CP_XML_ATTR(L"applyAlignment" , cell.fAtrAlc);
if (cell.fAtrAlc)
if ((cell.alc >=0 && cell.alc <8) || (cell.alcV >=0 && cell.alcV <5) || (cell.fShrinkToFit) || (cell.cIndent > 0) || (cell.trot > 0 && cell.trot < 0xff) || (cell.fWrap))
{
CP_XML_ATTR(L"applyAlignment", cell.fAtrAlc);
CP_XML_NODE(L"alignment")
{
if (cell.alc >=0 && cell.alc <8) CP_XML_ATTR(L"horizontal" , HorAlign[cell.alc]);
......@@ -127,7 +127,7 @@ int XF::serialize(std::wostream & stream)
if (cell.cIndent > 0) CP_XML_ATTR(L"indent", cell.cIndent);
CP_XML_ATTR(L"wrapText" , cell.fWrap);
if (cell.trot > 0) CP_XML_ATTR(L"textRotation" , cell.trot);
if (cell.trot > 0 && cell.trot < 0xff) CP_XML_ATTR(L"textRotation" , cell.trot);
}
}
}
......
......@@ -24,7 +24,7 @@ public:
//-----------------------------
_UINT16 cxfs;
BIFF_DWORD crc;
_UINT32 crc;
};
......
......@@ -16,7 +16,7 @@ public:
static const ElementType type = typeAFDOperRk;
BIFF_DWORD rk;
_UINT32 rk;
};
} // namespace XLS
\ No newline at end of file
......@@ -22,8 +22,8 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
BIFF_BYTE cch;
BIFF_BYTE fCompare;
unsigned char cch;
unsigned char fCompare;
bool m_bAutoFilter;
};
......
......@@ -40,6 +40,7 @@ public:
}
virtual void load(CFRecord& record)
{
version = record.getGlobalWorkbookInfo()->Version;
record >> val;
}
virtual void store(CFRecord& record)
......@@ -66,7 +67,9 @@ public:
bool operator==(const Type & F2){return (val == F2);}
protected:
boost::optional<Type> val;
boost::optional<Type> val;
int version;
};
//BiffAttributeSimple<std::wstring>::operator ==(const Type &F2)
......
......@@ -5,7 +5,6 @@
namespace XLS
{
BiffString::BiffString()
: struct_size(0)
{
......
......@@ -70,8 +70,7 @@ class XLUnicodeString_T : public BiffString
{
public:
XLUnicodeString_T() {}
//XLUnicodeString_T(const XLUnicodeString_T& other) : struct_size(other.struct_size), str_(other.str_), cch_(other.cch_) {};
XLUnicodeString_T(const size_t size) : BiffString(size) {}
XLUnicodeString_T(const size_t size) : BiffString(size) {}
XLUnicodeString_T(const std::wstring & str) : BiffString(str) {}
XLUnicodeString_T operator=(const std::wstring & str)
{
......@@ -90,6 +89,7 @@ private:
{
size_t struct_size_local = 0;
bool is_wide = false;
if(cch_READ_FROM_RECORD == cch_where)
{
if(aw_READ_FROM_CCH == det_id)
......@@ -118,16 +118,16 @@ private:
};
typedef XLUnicodeString_T<unsigned short, aw_READ_FROM_RECORD, cch_READ_FROM_RECORD> XLUnicodeString;
typedef XLUnicodeString_T<unsigned char, aw_READ_FROM_RECORD, cch_READ_FROM_RECORD> ShortXLUnicodeString;
typedef XLUnicodeString_T<unsigned short, aw_WIDE, cch_READ_FROM_RECORD> LPWideString;
typedef XLUnicodeString_T<unsigned short, aw_WIDE, cch_PASSED_AS_AN_ARGUMENT> LPWideStringNoCch;
typedef XLUnicodeString_T<unsigned short, aw_READ_FROM_RECORD, cch_PASSED_AS_AN_ARGUMENT> XLUnicodeStringNoCch;
typedef XLUnicodeString_T<unsigned short, aw_READ_FROM_RECORD_IF_CCH_NOT_ZERO, cch_READ_FROM_RECORD> XLUnicodeStringMin2;
typedef XLUnicodeString_T<unsigned short, aw_READ_FROM_RECORD, cch_READ_FROM_RECORD> XLUnicodeString;
typedef XLUnicodeString_T<unsigned char, aw_READ_FROM_RECORD, cch_READ_FROM_RECORD> ShortXLUnicodeString;
typedef XLUnicodeString_T<unsigned short, aw_WIDE, cch_READ_FROM_RECORD> LPWideString;
typedef XLUnicodeString_T<unsigned short, aw_WIDE, cch_PASSED_AS_AN_ARGUMENT> LPWideStringNoCch;
typedef XLUnicodeString_T<unsigned short, aw_READ_FROM_RECORD, cch_PASSED_AS_AN_ARGUMENT> XLUnicodeStringNoCch;
typedef XLUnicodeString_T<unsigned short, aw_READ_FROM_RECORD_IF_CCH_NOT_ZERO, cch_READ_FROM_RECORD> XLUnicodeStringMin2;
typedef XLUnicodeString_T<unsigned short, aw_ANSI, cch_READ_FROM_RECORD> LPAnsiString;
typedef XLUnicodeString_T<unsigned char, aw_ANSI, cch_READ_FROM_RECORD> ShortXLAnsiString;
typedef XLUnicodeString_T<unsigned short, aw_ANSI, cch_PASSED_AS_AN_ARGUMENT> LPAnsiStringNoCch;
typedef XLUnicodeString XLNameUnicodeString; // temporarily equal
typedef XLUnicodeString VirtualPath; // temporarily equal
typedef XLUnicodeString RevSheetName;
template<class cchType, AW_DETERMINATION det_id, CCH_SOURCE cch_where>
CFRecord& operator>>(CFRecord& record, XLUnicodeString_T<cchType, det_id, cch_where>& val)
......@@ -138,6 +138,8 @@ CFRecord& operator>>(CFRecord& record, XLUnicodeString_T<cchType, det_id, cch_wh
if (record.getRdPtr() >= record.getDataSize())
return record;
bool is_wide = false;
switch(cch_where)
{
case cch_READ_FROM_RECORD:
......@@ -150,8 +152,6 @@ CFRecord& operator>>(CFRecord& record, XLUnicodeString_T<cchType, det_id, cch_wh
cch = val.getSize();
break;
}
bool is_wide = false;
switch(det_id)
{
case aw_READ_FROM_RECORD_IF_CCH_NOT_ZERO:
......@@ -175,13 +175,18 @@ CFRecord& operator>>(CFRecord& record, XLUnicodeString_T<cchType, det_id, cch_wh
cch &= (static_cast<cchType>(-1) >> 1);
break;
}
struct_size += (cch << (is_wide ? 1 : 0));
val.load(record, cch, is_wide);
val.setStructSize(struct_size); // The only usage is DXFFntD::load
val.setStructSize(struct_size);
return record;
}
template<class cchType, AW_DETERMINATION det_id, CCH_SOURCE cch_where>
CFRecord& operator<<(CFRecord& record, XLUnicodeString_T<cchType, det_id, cch_where>& val)
{
......@@ -235,6 +240,7 @@ CFRecord& operator<<(CFRecord& record, XLUnicodeString_T<cchType, det_id, cch_wh
}
} // namespace XLS
......
......@@ -81,6 +81,9 @@ int FillInfo::serialize(std::wostream & stream)
{
CP_XML_NODE(L"patternFill")
{
if (fls < 0 || fls > 18)
fls = 1;
CP_XML_ATTR(L"patternType", PatternType[fls]);
if (fls > 0)
......@@ -94,7 +97,8 @@ int FillInfo::serialize(std::wostream & stream)
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
CP_XML_ATTR(L"indexed", foreFillInfo_.icv); break;
if (foreFillInfo_.icv < 64)
CP_XML_ATTR(L"indexed", foreFillInfo_.icv); break;
case 2://rgb
CP_XML_ATTR(L"rgb", STR::toARGB(foreFillInfo_.xclrValue)); break;
case 3://theme color
......@@ -116,7 +120,8 @@ int FillInfo::serialize(std::wostream & stream)
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
CP_XML_ATTR(L"indexed", backFillInfo_.icv); break;
if (backFillInfo_.icv < 64)
CP_XML_ATTR(L"indexed", backFillInfo_.icv); break;
case 2://rgb
CP_XML_ATTR(L"rgb", STR::toARGB(backFillInfo_.xclrValue)); break;
case 3://theme color
......
......@@ -32,8 +32,16 @@ void CellParsedFormula::load(CFRecord& record)
{
unsigned short cce;
record >> cce;
rgce.load(record, cce);
rgcb.load(record, rgce.getPtgs(), is_part_of_a_revision_);
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_);
}
}
......
......@@ -169,10 +169,10 @@ public:
};
typedef CellRef_T<RgceLoc_name, unsigned short, unsigned short, rel_Present> RgceLoc;
typedef CellRef_T<RgceLocRel_name, unsigned short, short, rel_Present> RgceLocRel;
typedef CellRef_T<RgceElfLocExtra_name, unsigned short, unsigned short, rel_Present> RgceElfLocExtra;
typedef CellRef_T<RgceElfLoc_name, unsigned short, unsigned short, rel_PresentQuoted> RgceElfLoc;
typedef CellRef_T<RgceLoc_name, unsigned short, unsigned short, rel_Present> RgceLoc;
typedef CellRef_T<RgceLocRel_name, unsigned short, short, rel_Present> RgceLocRel;
typedef CellRef_T<RgceElfLocExtra_name, unsigned short, unsigned short, rel_Present> RgceElfLocExtra;
typedef CellRef_T<RgceElfLoc_name, unsigned short, unsigned short, rel_PresentQuoted> RgceElfLoc;
......
......@@ -69,48 +69,102 @@ void CellXF::load(CFRecord& record)
{
m_GlobalWorkbookInfo = record.getGlobalWorkbookInfo();
_UINT32 flags1;
_UINT32 flags2;
_UINT32 flags3;
_UINT16 flags4;
record >> flags1 >> flags2 >> flags3 >> flags4;
alc = static_cast<unsigned char>(GETBITS(flags1, 0, 2));
fWrap = GETBIT(flags1, 3);
alcV = static_cast<unsigned char>(GETBITS(flags1, 4, 6));
fJustLast = GETBIT(flags1, 7);
trot = static_cast<unsigned char>(GETBITS(flags1, 8, 15));
cIndent = static_cast<unsigned char>(GETBITS(flags1, 16, 19));
fShrinkToFit = GETBIT(flags1, 20);
iReadOrder = static_cast<unsigned char>(GETBITS(flags1, 22, 23));
fAtrNum = GETBIT(flags1, 26);
fAtrFnt = GETBIT(flags1, 27);
fAtrAlc = GETBIT(flags1, 28);
fAtrBdr = GETBIT(flags1, 29);
fAtrPat = GETBIT(flags1, 30);
fAtrProt = GETBIT(flags1, 31);
border.dgLeft = static_cast<unsigned char>(GETBITS(flags2, 0, 3));
border.dgRight = static_cast<unsigned char>(GETBITS(flags2, 4, 7));
border.dgTop = static_cast<unsigned char>(GETBITS(flags2, 8, 11));
border.dgBottom = static_cast<unsigned char>(GETBITS(flags2, 12, 15));
border.dgDiag = static_cast<unsigned char>(GETBITS(flags3, 21, 24));
border.icvLeft = 0 != border.dgLeft ? static_cast<unsigned char>(GETBITS(flags2, 16, 22)) : 0;
border.icvRight = 0 != border.dgRight ? static_cast<unsigned char>(GETBITS(flags2, 23, 29)) : 0;
border.icvTop = 0 != border.dgTop ? static_cast<unsigned char>(GETBITS(flags3, 0, 6)) : 0;
border.icvBottom = 0 != border.dgBottom ? static_cast<unsigned char>(GETBITS(flags3, 7, 13)) : 0;
border.icvDiag = 0 != border.dgDiag ? static_cast<unsigned char>(GETBITS(flags3, 14, 20)) : 0;
border.grbitDiag = static_cast<unsigned char>(GETBITS(flags2, 30, 31));
fHasXFExt = GETBIT(flags3, 25);
fill.fls = static_cast<unsigned char>(GETBITS(flags3, 26, 31));
fill.icvFore = GETBITS(flags4, 0, 6);
fill.icvBack = GETBITS(flags4, 7, 13);
fsxButton = GETBIT(flags4, 14);
if (m_GlobalWorkbookInfo->Version < 0x0600)
{
_UINT16 flags1;
_UINT32 flags2;
_UINT32 flags3;
record >> flags1 >> flags2 >> flags3;
alc = GETBITS(flags1, 0, 2);
fWrap = GETBIT (flags1, 3);
alcV = GETBITS(flags1, 4, 6);
fJustLast = GETBIT (flags1, 7);
trot = 0;//static_cast<unsigned char>(GETBITS(flags1, 8, 15));
cIndent = 0;//static_cast<unsigned char>(GETBITS(flags1, 16, 19));
fShrinkToFit = 0;//GETBIT(flags1, 20);
iReadOrder = 0;//static_cast<unsigned char>(GETBITS(flags1, 22, 23));
char orient = GETBITS(flags1, 8, 10);
switch(orient)
{
case 0: trot = 0; break; // Text orientation: not rotated.
case 1: trot = 0xff; break; // Text orientation: vertically stacked.
case 2: trot = 90; break; // Text orientation: 90 deg counterclockwise.
case 3: trot = 270; break; // Text orientation: 90 deg clockwise.
}
fAtrNum = GETBIT(flags2, 10);
fAtrFnt = GETBIT(flags2, 11);
fAtrAlc = GETBIT(flags2, 12);
fAtrBdr = GETBIT(flags2, 13);
fAtrPat = GETBIT(flags2, 14);
fAtrProt = GETBIT(flags2, 15);
fill.fls = static_cast<unsigned char>(GETBITS(flags2, 16, 21));
fill.icvFore = GETBITS(flags2, 0, 6);
fill.icvBack = GETBITS(flags2, 7, 13);
border.dgTop = static_cast<unsigned char>(GETBITS(flags3, 0, 2));
border.dgLeft = static_cast<unsigned char>(GETBITS(flags3, 3, 5));
border.dgRight = static_cast<unsigned char>(GETBITS(flags3, 6, 8));
border.dgBottom = static_cast<unsigned char>(GETBITS(flags2, 22, 24));
border.dgDiag = 0;
border.icvTop = (0 != border.dgTop) ? static_cast<unsigned char>(GETBITS(flags3, 9, 15)) : 0;
border.icvLeft = (0 != border.dgLeft) ? static_cast<unsigned char>(GETBITS(flags3, 16, 22)) : 0;
border.icvRight = (0 != border.dgRight) ? static_cast<unsigned char>(GETBITS(flags3, 23, 29)) : 0;
border.icvBottom = (0 != border.dgBottom)? static_cast<unsigned char>(GETBITS(flags2, 25, 31)) : 0;
border.icvDiag = 0;
}
else
{
_UINT32 flags1;
_UINT32 flags2;
_UINT32 flags3;
_UINT16 flags4;
record >> flags1 >> flags2 >> flags3 >> flags4;
alc = static_cast<unsigned char>(GETBITS(flags1, 0, 2));
fWrap = GETBIT(flags1, 3);
alcV = static_cast<unsigned char>(GETBITS(flags1, 4, 6));
fJustLast = GETBIT(flags1, 7);
trot = static_cast<unsigned char>(GETBITS(flags1, 8, 15));
cIndent = static_cast<unsigned char>(GETBITS(flags1, 16, 19));
fShrinkToFit = GETBIT(flags1, 20);
iReadOrder = static_cast<unsigned char>(GETBITS(flags1, 22, 23));
fAtrNum = GETBIT(flags1, 26);
fAtrFnt = GETBIT(flags1, 27);
fAtrAlc = GETBIT(flags1, 28);
fAtrBdr = GETBIT(flags1, 29);
fAtrPat = GETBIT(flags1, 30);
fAtrProt = GETBIT(flags1, 31);
border.dgLeft = static_cast<unsigned char>(GETBITS(flags2, 0, 3));
border.dgRight = static_cast<unsigned char>(GETBITS(flags2, 4, 7));
border.dgTop = static_cast<unsigned char>(GETBITS(flags2, 8, 11));
border.dgBottom = static_cast<unsigned char>(GETBITS(flags2, 12, 15));
border.dgDiag = static_cast<unsigned char>(GETBITS(flags3, 21, 24));
border.icvLeft = 0 != border.dgLeft ? static_cast<unsigned char>(GETBITS(flags2, 16, 22)) : 0;
border.icvRight = 0 != border.dgRight ? static_cast<unsigned char>(GETBITS(flags2, 23, 29)) : 0;
border.icvTop = 0 != border.dgTop ? static_cast<unsigned char>(GETBITS(flags3, 0, 6)) : 0;
border.icvBottom = 0 != border.dgBottom ? static_cast<unsigned char>(GETBITS(flags3, 7, 13)) : 0;
border.icvDiag = 0 != border.dgDiag ? static_cast<unsigned char>(GETBITS(flags3, 14, 20)) : 0;
border.grbitDiag = static_cast<unsigned char>(GETBITS(flags2, 30, 31));
fHasXFExt = GETBIT(flags3, 25);
fill.fls = static_cast<unsigned char>(GETBITS(flags3, 26, 31));
fill.icvFore = GETBITS(flags4, 0, 6);
fill.icvBack = GETBITS(flags4, 7, 13);
fsxButton = GETBIT(flags4, 14);
}
}
void CellXF::RegisterFillBorder()
......
......@@ -19,12 +19,12 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
public:
BIFF_BYTE fDefault;
BIFF_BYTE fHelp;
BIFF_BYTE fCancel;
BIFF_BYTE fDismiss;
_UINT16 accel1;
BIFF_BYTE fDefault;
BIFF_BYTE fHelp;
BIFF_BYTE fCancel;
BIFF_BYTE fDismiss;
_UINT16 accel1;
};
} // namespace XLS
......
......@@ -21,7 +21,7 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
BIFF_DWORD cbAutoFilter;
_UINT32 cbAutoFilter;
AutoFilter recAutoFilter;
};
......
......@@ -21,25 +21,25 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
BIFF_DWORD idField;
BIFF_DWORD lfdt;
BIFF_DWORD lfxidt;
BIFF_DWORD ilta;
BIFF_DWORD cbFmtAgg;
BIFF_DWORD istnAgg;
BIFF_BYTE fAutoFilter;
BIFF_BYTE fAutoFilterHidden;
BIFF_BYTE fLoadXmapi;
BIFF_BYTE fLoadFmla;
BIFF_BYTE fLoadTotalFmla;
BIFF_BYTE fLoadTotalArray;
BIFF_BYTE fSaveStyleName;
BIFF_BYTE fLoadTotalStr;
BIFF_BYTE fAutoCreateCalcCol;
_UINT32 idField;
_UINT32 lfdt;
_UINT32 lfxidt;
_UINT32 ilta;
_UINT32 cbFmtAgg;
_UINT32 istnAgg;
unsigned char fAutoFilter;
unsigned char fAutoFilterHidden;
unsigned char fLoadXmapi;
unsigned char fLoadFmla;
unsigned char fLoadTotalFmla;
unsigned char fLoadTotalArray;
unsigned char fSaveStyleName;
unsigned char fLoadTotalStr;
unsigned char fAutoCreateCalcCol;
BIFF_DWORD cbFmtInsertRow;
BIFF_DWORD istnInsertRow;
_UINT32 cbFmtInsertRow;
_UINT32 istnInsertRow;
XLUnicodeString strFieldName;
XLUnicodeString strCaption;
......
......@@ -15,6 +15,7 @@ BiffStructurePtr FontIndex::clone()
const unsigned short FontIndex::getValue() const
{
unsigned short index = static_cast<unsigned short>(val.get_value_or(0));
return index < 4 ? index : index - 1;
}
void FontIndex::setValue(unsigned short val_)
......
......@@ -20,7 +20,6 @@ void FormatRun::store(CFRecord& record)
void FormatRun::load(CFRecord& record)
{
record >> ich >> ifnt;
unsigned short _ich = ich;
}
......
......@@ -37,18 +37,38 @@ void FtCmo::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short flags;
record >> ot >> id >> flags;
record.skipNunBytes(12); // unused
fLocked = GETBIT(flags, 0);
fDefaultSize = GETBIT(flags, 2);
fPublished = GETBIT(flags, 3);
fPrint = GETBIT(flags, 4);
fDisabled = GETBIT(flags, 7);
fUIObj = GETBIT(flags, 8);
fRecalcObj = GETBIT(flags, 9);
fRecalcObjAlways = GETBIT(flags, 12);
record >> ot >> id;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
unsigned char flags;
record >> flags;
fLocked = GETBIT(flags, 0);
fDefaultSize = GETBIT(flags, 2);
fPublished = GETBIT(flags, 3);
fPrint = GETBIT(flags, 4);
fDisabled = GETBIT(flags, 7);
fUIObj = false;
fRecalcObj = false;
fRecalcObjAlways = false;
}
else
{
unsigned short flags;
record >> flags;
record.skipNunBytes(12); // unused
fLocked = GETBIT(flags, 0);
fDefaultSize = GETBIT(flags, 2);
fPublished = GETBIT(flags, 3);
fPrint = GETBIT(flags, 4);
fDisabled = GETBIT(flags, 7);
fUIObj = GETBIT(flags, 8);
fRecalcObj = GETBIT(flags, 9);
fRecalcObjAlways = GETBIT(flags, 12);
}
}
......
......@@ -44,6 +44,58 @@ void FtPictFmla::store(CFRecord& record, FtPioGrbit& pictFlags)
record.registerDelayedDataSource(data_size, rt_Obj);
}
void FtPictFmla::load(CFRecord& record, int linkSize)
{
bool bLinked = false;
bool bEmbedded = false;
if( linkSize >= 6 )
{
_UINT16 nFmlaSize;
record >> nFmlaSize;
if( nFmlaSize > 0)
{
record.skipNunBytes(4);
_UINT16 nToken;
record >> nToken;
if( nToken == 1)//XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX, EXC_TOKCLASS_REF ) )
{
bLinked = true;
_UINT16 nRefIdx, nNameIdx;
record >> nRefIdx;
record.skipNunBytes(8);
record >> nNameIdx;
record.skipNunBytes(12);
//const ExtName* pExtName = GetOldRoot().pExtNameBuff->GetNameByIndex( nRefIdx, nNameIdx );
// if( pExtName && pExtName->IsOLE() )
// mnStorageId = pExtName->nStorageId;
}
else if( nToken == 2)//XclTokenArrayHelper::GetTokenId( EXC_TOKID_TBL, EXC_TOKCLASS_NONE ) )
{
bEmbedded = true;
record.skipNunBytes( nFmlaSize - 1 ); // token ID already read
if( nFmlaSize & 1 )
record.skipNunBytes( 1 ); // padding byte
// a class name may follow inside the picture link
if( record.getRdPtr() + 2 <= record.getDataSize() )
{
_UINT16 nLen;
record >> nLen;
if( nLen > 0 )
{
//maClassName = rStrm.ReadRawByteString( nLen );
}
}
}
}
}
}
void FtPictFmla::load(CFRecord& record, FtPioGrbit& pictFlags)
{
......
......@@ -17,6 +17,7 @@ public:
FtPictFmla();
BiffStructurePtr clone();
virtual void load(CFRecord& record, int linkSize);
virtual void load(CFRecord& record, FtPioGrbit& pictFlags);
virtual void store(CFRecord& record, FtPioGrbit& pictFlags);
......
......@@ -21,15 +21,15 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
BIFF_DWORD cbdxfHeader;
BIFF_DWORD istnHeader;
BIFF_DWORD cbdxfData;
BIFF_DWORD istnData;
BIFF_DWORD cbdxfAgg;
BIFF_DWORD istnAgg;
BIFF_DWORD cbdxfBorder;
BIFF_DWORD cbdxfHeaderBorder;
BIFF_DWORD cbdxfAggBorder;
_UINT32 cbdxfHeader;
_UINT32 istnHeader;
_UINT32 cbdxfData;
_UINT32 istnData;
_UINT32 cbdxfAgg;
_UINT32 istnAgg;
_UINT32 cbdxfBorder;
_UINT32 cbdxfHeaderBorder;
_UINT32 cbdxfAggBorder;
DXFN12List dxfHeader;
DXFN12List dxfData;
......@@ -37,6 +37,7 @@ public:
DXFN12List dxfBorder;
DXFN12List dxfHeaderBorder;
DXFN12List dxfAggBorder;
XLUnicodeString stHeader;
XLUnicodeString stData;
XLUnicodeString stAgg;
......
......@@ -21,7 +21,7 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
XLNameUnicodeString stListName;
XLUnicodeString stListName;
XLUnicodeString stListComment;
};
......
......@@ -21,11 +21,11 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
BIFF_BYTE fFirstColumn;
BIFF_BYTE fLastColumn;
BIFF_BYTE fRowStripes;
BIFF_BYTE fColumnStripes;
BIFF_BYTE fDefaultStyle;
unsigned char fFirstColumn;
unsigned char fLastColumn;
unsigned char fRowStripes;
unsigned char fColumnStripes;
unsigned char fDefaultStyle;
XLUnicodeString stListStyleName;
};
......
......@@ -10,6 +10,10 @@ namespace XLS
NoteSh::NoteSh()
{
x_ = y_ = 0;
fShow = false;
fRwHidden = false;
fColHidden = false;
}
......@@ -39,14 +43,27 @@ void NoteSh::load(CFRecord& record)
global_info = record.getGlobalWorkbookInfo();
unsigned short flags;
record >> row >> col >> flags;
record >> row >> col;
fShow = GETBIT(flags, 1);
fRwHidden = GETBIT(flags, 7);
fColHidden = GETBIT(flags, 8);
record >> idObj >> stAuthor;
record.skipNunBytes(1); // unused
if (global_info->Version < 0x0600)
{
LPAnsiString stText1;
record >> stText1;
stText = stText1;
}
else
{
record >> flags;
fShow = GETBIT(flags, 1);
fRwHidden = GETBIT(flags, 7);
fColHidden = GETBIT(flags, 8);
record >> idObj >> stAuthor;
record.skipNunBytes(1); // unused
}
}
//-----------------------------------------------------------------------
......
......@@ -28,7 +28,9 @@ public:
bool fRwHidden;
bool fColHidden;
ObjId idObj;
XLUnicodeString stAuthor;
XLUnicodeString stText;
//------------------------------------------
GlobalWorkbookInfoPtr global_info;
......
......@@ -38,11 +38,23 @@ void OfficeArtClientAnchorSheet::loadFields(XLS::CFRecord& record)
{
global_info = record.getGlobalWorkbookInfo();
unsigned short flags;
record >> flags >> colL >> dxL >> rwT >> dyT >> colR >> dxR >> rwB >> dyB;
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
unsigned char flags;
record >> flags;
fMove = GETBIT(flags, 0);
fSize = GETBIT(flags, 1);
}
else
{
unsigned short flags;
record >> flags;
fMove = GETBIT(flags, 0);
fSize = GETBIT(flags, 1);
}
fMove = GETBIT(flags, 0);
fSize = GETBIT(flags, 1);
record >> colL >> dxL >> rwT >> dyT >> colR >> dxR >> rwB >> dyB;
}
void OfficeArtClientAnchorSheet::calculate()
......@@ -52,23 +64,38 @@ void OfficeArtClientAnchorSheet::calculate()
global_info->sheet_size_info[global_info->current_sheet - 1] : zero;
//----------------------------------------------------------------------------------------------------
double kfCol = 17640 / 256.;
//1 inch = 72 point
//1 emu = 360000 * 2.54 inch
double kfCol = 360000 / 72.;
double kfRow = ( 360000 * 2.54 / 72) / 256. ;
double Digit_Width = 8.43;
double column_width = 0;
if (sheet_info.customColumnsWidth.find(colL) != sheet_info.customColumnsWidth.end())
{
_dxL = dxL * kfCol * sheet_info.customColumnsWidth[colL];
column_width = sheet_info.customColumnsWidth[colL] / 1024.;
}
else
_dxL = dxL * kfCol * sheet_info.defaultColumnWidth;
column_width = sheet_info.defaultColumnWidth / 1024.;
//double width = ((int)((column_width * Maximum_Digit_Width + 5 ) / Maximum_Digit_Width * 256. )) / 256.; //px
double width = (double)(((256. * column_width + (int)(128. / Digit_Width)) / 256.) * Digit_Width) * 72 / 96.;
_dxL = dxL * kfCol * width;
if (sheet_info.customColumnsWidth.find(colR) != sheet_info.customColumnsWidth.end())
{
_dxR = dxR * kfCol * sheet_info.customColumnsWidth[colR];
column_width = sheet_info.customColumnsWidth[colR];
}
else
_dxR = dxR * kfCol * sheet_info.defaultColumnWidth;
column_width = sheet_info.defaultColumnWidth;
width = (double)(((256. * column_width + (int)(128. / Digit_Width)) / 256.) * Digit_Width) * 72 / 96.;
_dxR = dxR * kfCol * width;
//---------------------------------------------------------------------------------------------------
if (sheet_info.customRowsHeight.find(rwT) != sheet_info.customRowsHeight.end())
{
......
......@@ -47,18 +47,26 @@ const std::wstring ParsedFormula::getAssembledFormula(bool full_ref) const
{
return L"";
}
AssemblerStack ptg_stack;
PtgQueue extra_data = rgcb.getPtgs();
for(PtgVectorIterator it = ptgs.begin(), itEnd = ptgs.end(); it != itEnd; ++it)
try
{
(*it)->assemble(ptg_stack, extra_data, full_ref);
AssemblerStack ptg_stack;
PtgQueue extra_data = rgcb.getPtgs();
for(PtgVectorIterator it = ptgs.begin(), itEnd = ptgs.end(); it != itEnd; ++it)
{
(*it)->assemble(ptg_stack, extra_data, full_ref);
}
if(1 != ptg_stack.size())
{
return L"";
//throw; EXCEPT::LE::WrongAPIUsage("Wrong formula assembling.", __FUNCTION__);
}
return ptg_stack.top();
}
if(1 != ptg_stack.size())
catch(...)
{
return L"";
//throw; EXCEPT::LE::WrongAPIUsage("Wrong formula assembling.", __FUNCTION__);
}
return ptg_stack.top();
return L"";
}
......
......@@ -33,16 +33,26 @@ BiffStructurePtr PtgArea3d::clone()
void PtgArea3d::storeFields(CFRecord& record)
{
record << ixti;
record << area; // Store absolutely always since no specific cell_base_ref specified in NameParsedFormula
record << area;
}
void PtgArea3d::loadFields(CFRecord& record)
{
record >> ixti;
record >> area;
area_rel = area;
global_info = record.getGlobalWorkbookInfo();
if (global_info->Version < 0x0600)
{
record >> ixals;
record .skipNunBytes(8);
record >> itabFirst >> itabLast >> grbitRwFirst >> grbitRwLast >> colFirst >> colLast;
}
else
{
record >> ixti;
record >> area;
area_rel = area;
}
}
......@@ -58,9 +68,25 @@ void PtgArea3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
return;
}
std::wstring range_ref = area.toString();
if (global_info->Version < 0x0600)
{
CellRef cell1(grbitRwFirst, colFirst, false, false);
CellRef cell2(grbitRwLast, colLast, false, false);
ptg_stack.push(XMLSTUFF::make3dRef(ixti, range_ref, global_info->xti_parsed, full_ref));
CellRangeRef range(cell1, cell2);
std::wstring range_ref = range.toString();
if (ixals == 0xffff)//current sheet
ptg_stack.push(XMLSTUFF::make3dRef(global_info->current_sheet - 1, range_ref, global_info->sheets_names, full_ref));
else
ptg_stack.push(XMLSTUFF::make3dRef(ixals, range_ref, global_info->xti_parsed, full_ref));
}
else
{
std::wstring range_ref = area.toString();
ptg_stack.push(XMLSTUFF::make3dRef(ixti, range_ref, global_info->xti_parsed, full_ref));
}
}
......
This diff is collapsed.
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