Commit 7ccde9c7 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat pivots - fix after testing

parent 78ecdc67
......@@ -102,7 +102,7 @@ int BopPop::serialize(std::wostream & _stream)
{
CP_XML_NODE(L"c:custSplit")
{
for (int i = 0 ; i < custom->rggrbit.pie_indices.size(); i++)
for (size_t i = 0 ; i < custom->rggrbit.pie_indices.size(); i++)
{
CP_XML_NODE(L"c:secondPiePt")
{
......
......@@ -160,7 +160,7 @@ int CF12::serialize(std::wostream & stream)
CFGradient *gradient = dynamic_cast<CFGradient*>(rgbCT.get());
CP_XML_NODE(L"colorScale")
{
for (int i = 0; i < gradient->rgInterp.size(); i ++)
for (size_t i = 0; i < gradient->rgInterp.size(); i ++)
{
CP_XML_NODE(L"cfvo")
{
......@@ -181,7 +181,7 @@ int CF12::serialize(std::wostream & stream)
CP_XML_ATTR(L"val", cfvo.numValue);
}
}
for (int i = 0; i < gradient->rgCurve.size(); i ++)
for (size_t i = 0; i < gradient->rgCurve.size(); i ++)
{
CP_XML_NODE(L"color")
{
......
......@@ -67,16 +67,36 @@ void DConRef::readFields(CFRecord& record)
//self-reference = %x0002 sheet-name
stFile = stFile_.value();
if (stFile.substr(0, 1) == L"\x0001")
while(true)
{
bFilePath = true;
stFile = stFile.substr(1);
bool bDel = false;
int pos = stFile.find(L"\x0001");
if (pos >= 0)
{
bDel = true;
stFile = stFile.substr(pos + 1);
}
pos = stFile.find(L"\x0002");
if (pos >= 0)
{
bDel = true;
stFile = stFile.substr(pos + 1);
}
pos = stFile.find(L"\x0003");
if (pos >= 0)
{
bDel = true;
stFile = stFile.substr(pos + 1);
}
if (!bDel)
break;
}
else if (stFile.substr(0, 1) == L"\x0002")
int pos = stFile.find(L"]");
if (pos >= 0)
{
bSheetName = true;
stFile = stFile.substr(1);
}
stFile = stFile.substr(pos + 1);
}
}
int unused = record.getDataSize() - record.getRdPtr();
......
......@@ -65,9 +65,8 @@ void MergeCells::readFields(CFRecord& record)
int MergeCells::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
for (int i = 0 ; i < rgref.size(); i++)
{
for (size_t i = 0 ; i < rgref.size(); i++)
{
Ref8* ref = dynamic_cast<Ref8*>(rgref[i].get());
CP_XML_NODE(L"mergeCell")
......
......@@ -86,7 +86,7 @@ int MulRk::serialize(std::wostream & stream)
{
int row = GetRow();
for (int i = 0; i < cells.size(); i++)
for (size_t i = 0; i < cells.size(); i++)
{
Cell * cell = dynamic_cast<Cell *>(cells[i].get());
RkRec * rkrec = dynamic_cast<RkRec *>(rgrkrec[i].get());
......
......@@ -103,7 +103,7 @@ int Palette::serialize(std::wostream & stream)
}
}
for(int i = 0; i < rgColor.size(); ++i)
for(size_t i = 0; i < rgColor.size(); ++i)
{
LongRGB * rgb = dynamic_cast<LongRGB *>(rgColor[i].get());
CP_XML_NODE(L"rgbColor")
......
......@@ -67,7 +67,7 @@ int SIIndex::serialize(std::wostream & _stream, int idx, const CellRef & in_ref)
int res = 0;
CP_XML_WRITER(_stream)
{
for (int i = 0 ; i < m_arData.size(); i++)
for (size_t i = 0 ; i < m_arData.size(); i++)
{
Number * number = dynamic_cast<Number*> (m_arData[i].get());
BoolErr * boolErr = dynamic_cast<BoolErr*>(m_arData[i].get());
......@@ -108,7 +108,7 @@ int SIIndex::serialize(std::wostream & _stream, ChartParsedFormula & in_ref)
int idx = 0;
CP_XML_WRITER(_stream)
{
for (int i = 0 ; i < m_arData.size(); i++)
for (size_t i = 0 ; i < m_arData.size(); i++)
{
Number * number = dynamic_cast<Number*> (m_arData[i].get());
BoolErr * boolErr = dynamic_cast<BoolErr*>(m_arData[i].get());
......
......@@ -83,7 +83,7 @@ int SST::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
for (size_t i=0; i < rgb.size(); i++)
for (size_t i = 0; i < rgb.size(); i++)
{
XLUnicodeRichExtendedString *richText = dynamic_cast<XLUnicodeRichExtendedString *>(rgb[i].get());
......
......@@ -55,6 +55,11 @@ void SXDtr::readFields(CFRecord& record)
std::wstring SXDtr::value()
{
if (mon < 1 || mon > 12) mon = 1;
if (dom < 1 || dom > 31) dom = 1;
if (yr < 1) yr = 1; //???
std::wstringstream s;
s << yr << L"-" << (mon < 10 ? L"0" : L"") << mon << L"-" << (dom < 10 ? L"0" : L"") << dom << L"T"
<< (hr < 10 ? L"0" : L"") << hr << L":" << (min < 10 ? L"0" : L"") << min << L":" << (sec < 10 ? L"0" : L"") << sec;
......
......@@ -53,15 +53,17 @@ BaseObjectPtr SXTH::clone()
void SXTH::readFields(CFRecord& record)
{
_UINT32 flags1;
unsigned short flags2;
unsigned short flags2, reserved;
record >> frtHeaderOld >> flags1 >> sxaxis >> isxvd >> csxvdXl >> flags2;
record >> frtHeaderOld >> flags1 >> sxaxis >> reserved >> isxvd >> csxvdXl >> flags2;
record >> stUnique >> stDisplay >> stDefault >> stAll >> stDimension;
record >> cisxvd;
for (int i = 0; i < cisxvd; i++)
{
if (record.getRdPtr() + 4 > record.getDataSize())
break;
_INT32 val;
record >> val;
rgisxvd.push_back(val);
......
......@@ -38,8 +38,6 @@
namespace XLS
{
// Logical representation of Style record in BIFF8
class Style: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(Style)
......@@ -49,7 +47,6 @@ public:
~Style();
BaseObjectPtr clone();
void readFields(CFRecord& record);
......
......@@ -39,6 +39,7 @@ namespace XLS
Theme::Theme()
{
nThemeDataSize = 0;
}
Theme::~Theme()
......@@ -54,16 +55,18 @@ void Theme::readFields(CFRecord& record)
{
record >> frtHeader >> dwThemeVersion;
if(!dwThemeVersion)
if (dwThemeVersion == 124226)
{
Log::info("\"Theme\" binary parsing is not implemented.");
/*
std::ofstream file1("D:\\temp.xlsx", std::ios_base::binary);
file1.write(record.getCurData<char>(), (record.getDataSize() - record.getRdPtr()));
*/
//default theme
}
else if (dwThemeVersion == 0)
{
nThemeDataSize = record.getDataSize() - record.getRdPtr();
pThemeData = boost::shared_array<char>(new char[nThemeDataSize]);
memcpy(pThemeData.get(), record.getCurData<char>(), nThemeDataSize);
record.skipNunBytes(nThemeDataSize);
}
}
} // namespace XLS
......
......@@ -54,6 +54,9 @@ public:
//-----------------------------
_UINT32 dwThemeVersion;
FrtHeader frtHeader;
_UINT32 nThemeDataSize;
boost::shared_array<char> pThemeData;
};
} // namespace XLS
......
......@@ -55,10 +55,11 @@ void XFExt::readFields(CFRecord& record)
record >> ixfe;
record.skipNunBytes(2); // reserved
record >> cexts;
while(!record.isEOF())
{
if(record.getRdPtr() + 8 < record.getDataSize())
break;// 8 = миним размер структуры
if(record.getRdPtr() + 4 > record.getDataSize())
break;// миним размер структуры
ExtPropPtr element(new ExtProp);
record >> *element;
rgExt.push_back(element);
......
......@@ -108,63 +108,70 @@ int FillInfo::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"fill")
if (!ext.empty())
{
CP_XML_NODE(L"patternFill")
stream << ext;
}
else
{
CP_XML_NODE(L"fill")
{
if (fls < 0 || fls > 18)
fls = 1;
CP_XML_NODE(L"patternFill")
{
if (fls < 0 || fls > 18)
fls = 1;
CP_XML_ATTR(L"patternType", PatternType[fls]);
CP_XML_ATTR(L"patternType", PatternType[fls]);
if (fls > 0)
{
CP_XML_NODE(L"fgColor")
if (fls > 0)
{
if (foreFillInfo_.enabled)
CP_XML_NODE(L"fgColor")
{
switch(foreFillInfo_.xclrType)
if (foreFillInfo_.enabled)
{
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
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
CP_XML_ATTR(L"theme", foreFillInfo_.xclrValue/* + 1*/);
CP_XML_ATTR(L"tint", foreFillInfo_.nTintShade / 32767.0); break;
case 4://not set
break;
}
}else
CP_XML_ATTR(L"indexed", icvFore);
switch(foreFillInfo_.xclrType)
{
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
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
CP_XML_ATTR(L"theme", foreFillInfo_.xclrValue/* + 1*/);
CP_XML_ATTR(L"tint", foreFillInfo_.nTintShade / 32767.0); break;
case 4://not set
break;
}
}else
CP_XML_ATTR(L"indexed", icvFore);
}
CP_XML_NODE(L"bgColor")
{
if (backFillInfo_.enabled)
}
CP_XML_NODE(L"bgColor")
{
switch(backFillInfo_.xclrType)
if (backFillInfo_.enabled)
{
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
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
CP_XML_ATTR(L"theme", backFillInfo_.xclrValue /*+ 1*/);
CP_XML_ATTR(L"tint", backFillInfo_.nTintShade / 32767.0); break;
case 4://not set
break;
switch(backFillInfo_.xclrType)
{
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
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
CP_XML_ATTR(L"theme", backFillInfo_.xclrValue /*+ 1*/);
CP_XML_ATTR(L"tint", backFillInfo_.nTintShade / 32767.0); break;
case 4://not set
break;
}
}
}
else
CP_XML_ATTR(L"indexed", icvBack);
else
CP_XML_ATTR(L"indexed", icvBack);
}
}
}
}
......
......@@ -79,7 +79,7 @@ struct FillInfo
FillInfoExt foreFillInfo_;
FillInfoExt backFillInfo_;
std::wstring ext;
};
struct BorderInfo
......
......@@ -154,7 +154,7 @@ void CellXF::load(CFRecord& record)
void CellXF::RegisterFillBorder()
{
for (int i = 0; i < ext_props.size(); i++ )
for (size_t i = 0; i < ext_props.size(); i++ )
{
ExtProp* ext_prop = dynamic_cast<ExtProp*>(ext_props[i].get());
......
......@@ -100,7 +100,7 @@ void ChartParsedFormula::load(CFRecord& record)
bool ChartParsedFormula::inRange(const CellRef & ref)
{
for (int i = 0 ; i < cell_ranges.size(); i++)
for (size_t i = 0 ; i < cell_ranges.size(); i++)
{
if (cell_ranges[i].inRange(ref))
{
......
......@@ -46,6 +46,11 @@ BiffStructurePtr ExtProp::clone()
void ExtProp::load(CFRecord& record)
{
record >> extType >> cb;
if ((int)(cb - 4) > (int)(record.getDataSize() - record.getRdPtr()))
{
return;
}
switch(extType)
{
case 0x0004:
......
......@@ -78,7 +78,7 @@ void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
{
}
for (int i = 0 ; i < child_records.size(); i++)
for (size_t i = 0 ; i < child_records.size(); i++)
{
switch(child_records[i]->rh_own.recType)
{
......@@ -87,7 +87,7 @@ void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
OfficeArtDgContainer * dg = dynamic_cast<OfficeArtDgContainer *>(child_records[i].get());
if (dg)
{
for (int i = 0 ; i < dg->child_records.size(); i++)
for (size_t i = 0 ; i < dg->child_records.size(); i++)
{
child_records.push_back(dg->child_records[i]);
}
......
......@@ -94,7 +94,7 @@ namespace ODRAW
//shift for all trailing zeros
std::bitset<sizeof(int)*8> bits( mask );
for ( unsigned int i = 0; i < bits.size(); i++ )
for ( size_t i = 0; i < bits.size(); i++ )
{
if ( !bits[i] )
{
......
......@@ -73,7 +73,7 @@ void OfficeArtDggContainer::loadFields(XLS::CFRecord& record)
{
OfficeArtContainer::loadFields(record);
for (int i = 0 ; i < child_records.size(); i++)
for (size_t i = 0 ; i < child_records.size(); i++)
{
switch(child_records[i]->rh_own.recType)
{
......@@ -111,7 +111,7 @@ void OfficeArtSpgrContainer::loadFields(XLS::CFRecord& record)
{
OfficeArtContainer::loadFields(record);
//for (int i = 0 ; i < child_records.size(); i++)
//for (size_t i = 0 ; i < child_records.size(); i++)
//{
// switch(child_records[i]->rh_own.recType)
// {
......@@ -128,7 +128,7 @@ void OfficeArtSpContainer::loadFields(XLS::CFRecord& record)
{
OfficeArtContainer::loadFields(record);
for (int i = 0 ; i < child_records.size(); i++)
for (size_t i = 0 ; i < child_records.size(); i++)
{
switch(child_records[i]->rh_own.recType)
{
......
......@@ -31,7 +31,9 @@
*/
#include "StyleXF.h"
#include "xfProps.h"
#include "ExtProp.h"
#include <Binary/CFRecord.h>
namespace XLS
......@@ -139,85 +141,100 @@ void StyleXF::load(CFRecord& record)
fill.icvFore = GETBITS(flags4, 0, 6);
fill.icvBack = GETBITS(flags4, 7, 13);
}
}
void StyleXF::Update(ExtProp* ext_prop)
{
if (!ext_prop) return;
switch(ext_prop->extType)
{
case 0x0004:
{
fill.foreFillInfo_.enabled = true;
fill.foreFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.foreFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.foreFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.foreFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0005:
{
fill.backFillInfo_.enabled = true;
fill.backFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.backFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.backFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.backFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0007:
{
border.topFillInfo_.enabled = true;
border.topFillInfo_.icv = ext_prop->extPropData.color.icv;
border.topFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.topFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.topFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0008:
{
border.bottomFillInfo_.enabled = true;
border.bottomFillInfo_.icv = ext_prop->extPropData.color.icv;
border.bottomFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.bottomFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.bottomFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0009:
{
border.leftFillInfo_.enabled = true;
border.leftFillInfo_.icv = ext_prop->extPropData.color.icv;
border.leftFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.leftFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.leftFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x000A:
{
border.rightFillInfo_.enabled = true;
border.rightFillInfo_.icv = ext_prop->extPropData.color.icv;
border.rightFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.rightFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.rightFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
case 0x000D:
{
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
{
font_id = ext_prop->extPropData.font_scheme;
}break;
case 0x000F:
{
cIndent = ext_prop->extPropData.indent_level;
}break;
}
}
void StyleXF::Update(XFProps* xfProps)
{
if (!xfProps) return;
std::wstringstream strm;
xfProps->serialize_fill(strm);
fill.ext = strm.str();
}
void StyleXF::RegisterFillBorder()
{
for (int i = 0; i < ext_props.size(); i++ )
for (size_t i = 0; i < ext_props.size(); i++ )
{
ExtProp* ext_prop = dynamic_cast<ExtProp*>(ext_props[i].get());
Update (ext_prop);
}
switch(ext_prop->extType)
{
case 0x0004:
{
fill.foreFillInfo_.enabled = true;
fill.foreFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.foreFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.foreFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.foreFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0005:
{
fill.backFillInfo_.enabled = true;
fill.backFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.backFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.backFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.backFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0007:
{
border.topFillInfo_.enabled = true;
border.topFillInfo_.icv = ext_prop->extPropData.color.icv;
border.topFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.topFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.topFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0008:
{
border.bottomFillInfo_.enabled = true;
border.bottomFillInfo_.icv = ext_prop->extPropData.color.icv;
border.bottomFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.bottomFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.bottomFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0009:
{
border.leftFillInfo_.enabled = true;
border.leftFillInfo_.icv = ext_prop->extPropData.color.icv;
border.leftFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.leftFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.leftFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x000A:
{
border.rightFillInfo_.enabled = true;
border.rightFillInfo_.icv = ext_prop->extPropData.color.icv;
border.rightFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.rightFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.rightFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
case 0x000D:
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
font_id = ext_prop->extPropData.font_scheme;
break;
case 0x000F:
cIndent = ext_prop->extPropData.indent_level;
break;
}
}
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
......
......@@ -36,8 +36,10 @@
namespace XLS
{
class XFProps;
class ExtProp;
class CFRecord;
class GlobalWorkbookInfo;
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
......@@ -50,13 +52,15 @@ public:
virtual void load(CFRecord& record);
GlobalWorkbookInfoPtr m_GlobalWorkbookInfo;
static const ElementType type = typeStyleXF;
int serialize(std::wostream & stream);
void Update(ExtProp* extProp); // xls style
void Update(XFProps* xfProps); //xlsx style
void RegisterFillBorder();
unsigned char alc;
......
......@@ -70,12 +70,13 @@ int XFPropColor::serialize(std::wostream & stream)
{
case 0: CP_XML_ATTR(L"auto", 1); break;
case 1: CP_XML_ATTR(L"indexed", icv); break;
case 2: CP_XML_ATTR(L"rgb", dwRgba.strRGB); break;
case 3: CP_XML_ATTR(L"theme", icv); break;
case 2:
case 3: CP_XML_ATTR(L"rgb", dwRgba.strRGB); break;
//CP_XML_ATTR(L"theme", icv); break;
}
if (nTintShade != 0)
{
CP_XML_ATTR(L"tint", nTintShade);
CP_XML_ATTR(L"tint", nTintShade/ 32767.0);
}
}
}
......
......@@ -110,15 +110,68 @@ void XFProps::load(CFRecord& record)
}
}
}
int XFProps::serialize(std::wostream & stream, bool dxf)
int XFProps::serialize_fill(std::wostream & stream)
{
if (arXFPropFill.empty()) return 0;
CP_XML_WRITER(stream)
{
XFProp *pPatternType = NULL;
XFPropGradient *pGradient = NULL;
for (size_t i = 0; i < arXFPropFill.size(); i++)
{
switch(arXFPropFill[i].xfPropType)
{
case 1:
case 0: pPatternType = &arXFPropFill[i]; break;
case 3: pGradient = dynamic_cast<XFPropGradient*>(arXFPropFill[i].xfPropDataBlob.get()); break;
}
}
CP_XML_NODE(L"fill")
{
if (pGradient || arXFPropGradient.size() > 0)
{
CP_XML_NODE(L"gradientFill")
{
if (pGradient)
pGradient->serialize_attr(CP_GET_XML_NODE());
for (size_t i = 0 ; i < arXFPropGradient.size(); i++)
{
if (arXFPropGradient[i].xfPropDataBlob == NULL) continue;
arXFPropGradient[i].xfPropDataBlob->serialize(CP_XML_STREAM());
}
}
}
else if (pPatternType)
{
CP_XML_NODE(L"patternFill")
{
pPatternType->serialize_attr(CP_GET_XML_NODE());
for (size_t i = 0; i < arXFPropFill.size(); i++)
{
arXFPropFill[i].serialize(CP_XML_STREAM());
}
}
}
}
}
return 0;
}
int XFProps::serialize(std::wostream & strm, bool dxf)
{
CP_XML_WRITER(strm)
{
if (arXFPropFont.size() > 0)
{
CP_XML_NODE(L"font")
{
for (int i = 0; i < arXFPropFont.size(); i++)
for (size_t i = 0; i < arXFPropFont.size(); i++)
{
arXFPropFont[i].serialize(CP_XML_STREAM());
}
......@@ -128,7 +181,7 @@ int XFProps::serialize(std::wostream & stream, bool dxf)
{
CP_XML_NODE(L"numFmt")
{
for (int i = 0; i < arXFPropNumFmt.size(); i++)
for (size_t i = 0; i < arXFPropNumFmt.size(); i++)
{
if (dxf)
{
......@@ -141,54 +194,13 @@ int XFProps::serialize(std::wostream & stream, bool dxf)
}
}
}
if (arXFPropFill.size() > 0)
{
XFProp pPatternType;
XFPropGradient *pGradient = NULL;
serialize_fill(strm);
for (int i = 0; i < arXFPropFill.size(); i++)
{
switch(arXFPropFill[i].xfPropType)
{
case 0: pPatternType = arXFPropFill[i]; break;
case 3: pGradient = dynamic_cast<XFPropGradient*>(arXFPropFill[i].xfPropDataBlob.get()); break;
}
}
CP_XML_NODE(L"fill")
{
if (pGradient || arXFPropGradient.size()>0)
{
CP_XML_NODE(L"gradientFill")
{
if (pGradient)
pGradient->serialize_attr(CP_GET_XML_NODE());
for (int i = 0 ; i < arXFPropGradient.size(); i++)
{
if (arXFPropGradient[i].xfPropDataBlob == NULL) continue;
arXFPropGradient[i].xfPropDataBlob->serialize(CP_XML_STREAM());
}
}
}
else
{
CP_XML_NODE(L"patternFill")
{
pPatternType.serialize_attr(CP_GET_XML_NODE());
for (int i = 0; i < arXFPropFill.size(); i++)
{
arXFPropFill[i].serialize(CP_XML_STREAM());
}
}
}
}
}
if (arXFPropAlignment.size() > 0)
{
CP_XML_NODE(L"alignment")
{
for (int i = 0; i < arXFPropAlignment.size(); i++)
for (size_t i = 0; i < arXFPropAlignment.size(); i++)
{
arXFPropAlignment[i].serialize(CP_XML_STREAM());
}
......@@ -205,7 +217,7 @@ int XFProps::serialize(std::wostream & stream, bool dxf)
if (arXFPropBorder.bottom) arXFPropBorder.bottom->serialize(CP_XML_STREAM());
//----------------------------------------
for (int i = 0; i < arXFPropBorder.other.size(); i++)
for (size_t i = 0; i < arXFPropBorder.other.size(); i++)
{
arXFPropBorder.other[i].serialize(CP_XML_STREAM());
}
......
......@@ -32,7 +32,7 @@
#pragma once
#include "BiffStructure.h"
#include "../Biff_structures/XFProp.h"
#include "XFProp.h"
namespace XLS
{
......@@ -47,13 +47,14 @@ public:
virtual void load(CFRecord& record);
static const ElementType type = typeXFProps;
unsigned short cprops;
int serialize(std::wostream & stream){ return serialize(stream, false) ; }
int serialize(std::wostream & stream, bool dxf);
int serialize_fill(std::wostream & stream);
std::vector<XFProp> arXFPropFont;
std::vector<XFProp> arXFPropNumFmt;
......
......@@ -112,7 +112,7 @@ int XLUnicodeRichExtendedString::serialize (std::wostream & _stream)
CP_XML_WRITER(_stream)
{
for (int i = 0 ; i < rgRun.size(); i++)
for (size_t i = 0 ; i < rgRun.size(); i++)
{
CP_XML_NODE(L"r")
{
......
......@@ -187,7 +187,7 @@ int AUTOFILTER::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"ref", ref);
for (int i = 0 ; i < m_arFilters.size(); i++)//todooo сделать на оставшиеся - count_columns (hidden)
for (size_t i = 0 ; i < m_arFilters.size(); i++)//todooo сделать на оставшиеся - count_columns (hidden)
{
AutoFilter * filter = dynamic_cast<AutoFilter*>(m_arFilters[i].get());
CP_XML_NODE(L"filterColumn")
......@@ -214,12 +214,12 @@ int AUTOFILTER::serialize(std::wostream & stream)
std::map<int, std::vector<BaseObjectPtr>>::iterator itF = m_mapFilters12.find(filter->iEntry);
if (itF != m_mapFilters12.end())
{
for (int j = 0 ; j < itF->second.size(); j++)
for (size_t j = 0 ; j < itF->second.size(); j++)
{
AutoFilter12* af12 = dynamic_cast<AutoFilter12*>(itF->second[j].get());
if (af12 == NULL) continue;
for (int k = 0 ; k < af12->rgbAF12Criteries.size(); k++)
for (size_t k = 0 ; k < af12->rgbAF12Criteries.size(); k++)
{
AF12Criteria * af12Criteria = dynamic_cast<AF12Criteria *>(af12->rgbAF12Criteries[k].get());
if (af12Criteria == NULL) continue;
......
......@@ -225,7 +225,7 @@ int AXES::serialize(std::wostream & _stream, bool secondary)
{
CatSerRange * iv_CatSerRange = NULL;
for (int i = 0 ; i < m_arAxes.size(); i++)
for (size_t i = 0 ; i < m_arAxes.size(); i++)
{
IVAXIS * iv = dynamic_cast<IVAXIS*> (m_arAxes[i].get());
if (iv)
......@@ -237,7 +237,7 @@ int AXES::serialize(std::wostream & _stream, bool secondary)
}
CP_XML_WRITER(_stream)
{
for (int i = 0 ; i < m_arAxes.size(); i++)
for (size_t i = 0 ; i < m_arAxes.size(); i++)
{
IVAXIS * iv = dynamic_cast<IVAXIS*> (m_arAxes[i].get());
DVAXIS * dv = dynamic_cast<DVAXIS*> (m_arAxes[i].get());
......@@ -263,7 +263,7 @@ int AXES::serialize(std::wostream & _stream, bool secondary)
CP_XML_NODE(node_ax_type)
{
ATTACHEDLABEL *label = NULL;
for ( int h = 0 ; h < m_arATTACHEDLABEL.size(); h++)
for ( size_t h = 0 ; h < m_arATTACHEDLABEL.size(); h++)
{
ATTACHEDLABEL *l_= dynamic_cast<ATTACHEDLABEL *> (m_arATTACHEDLABEL[h].get() );
......@@ -309,7 +309,7 @@ int AXES::serialize(std::wostream & _stream, bool secondary)
// }
//}
for (int j = 0 ; j < m_arAxesId.size(); j++)
for (size_t j = 0 ; j < m_arAxesId.size(); j++)
{
if (m_arAxesId[j].first != m_arAxesId[i].first && m_arAxesId[j].second != 3)
{
......
......@@ -104,7 +104,7 @@ void AXISPARENT::concatinate_second (BaseObjectPtr & addit)
if (second == NULL) return;
for (int i = 0; i < second->m_arCRT.size(); i++)
for (size_t i = 0; i < second->m_arCRT.size(); i++)
{
CRT* crt = dynamic_cast<CRT*>(second->m_arCRT[i].get());
crt->m_indAXISPARENT = 1;
......
......@@ -161,7 +161,7 @@ int AXS::serialize(std::wostream & _stream)
CP_XML_WRITER(_stream)
{
for (int i = 0 ; i < m_AxisLine_Format.size(); i++)
for (size_t i = 0 ; i < m_AxisLine_Format.size(); i++)
{
std::wstring grid;
......
......@@ -283,7 +283,7 @@ const bool CHARTFORMATS::loadContent(BinProcessor& proc)
}
BaseObjectPtr CHARTFORMATS::find_label( _UINT16 link_id, unsigned short ex)
{
for (int i = 0 ; i < m_arATTACHEDLABEL.size(); i++)
for (size_t i = 0 ; i < m_arATTACHEDLABEL.size(); i++)
{
ATTACHEDLABEL * label = dynamic_cast<ATTACHEDLABEL *> (m_arATTACHEDLABEL[i].get());
ObjectLink * obj_link = dynamic_cast<ObjectLink *> (label->m_ObjectLink.get());
......@@ -306,7 +306,7 @@ std::vector<std::pair<int, BaseObjectPtr>> CHARTFORMATS::find_labels( _UINT16 li
{
std::vector<std::pair<int, BaseObjectPtr>> result;
for (int i = 0 ; i < m_arATTACHEDLABEL.size(); i++)
for (size_t i = 0 ; i < m_arATTACHEDLABEL.size(); i++)
{
ATTACHEDLABEL * label = dynamic_cast<ATTACHEDLABEL *> (m_arATTACHEDLABEL[i].get());
ObjectLink * obj_link = dynamic_cast<ObjectLink *> (label->m_ObjectLink.get());
......
......@@ -110,7 +110,7 @@ int CONDFMT12::serialize(std::wostream & stream)
CP_XML_ATTR(L"sqref", condFmt->mainCF.sqref.strValue);
//condition_id
//condition_pos
for (int i = 0; i < m_arCF12.size(); i++)
for (size_t i = 0; i < m_arCF12.size(); i++)
{
if (m_arCF12[i] == NULL) continue;
m_arCF12[i]->serialize(CP_XML_STREAM());
......
......@@ -120,7 +120,7 @@ const bool CONDFMTS::loadContent(BinProcessor& proc)
count--;
}
for (int i = 0 ; i < m_arCFEx.size(); i++)
for (size_t i = 0 ; i < m_arCFEx.size(); i++)
{
if (!m_arCFEx[i]) continue;
......@@ -129,7 +129,7 @@ const bool CONDFMTS::loadContent(BinProcessor& proc)
{
int ind_cf = cfEx->content.icf;
for (int j = 0 ; j < m_arCONDFMT.size(); j++)
for (size_t j = 0 ; j < m_arCONDFMT.size(); j++)
{
CONDFMT * CONDFMT_ = dynamic_cast<CONDFMT *>(m_arCONDFMT[j].get());
if (CONDFMT_/* && cfEx->fIsCF12 == 0*/)
......@@ -166,7 +166,7 @@ int CONDFMTS::serialize(std::wostream & stream)
{
if (m_arCONDFMT.empty()) return 0;
for (int i = 0 ; i < m_arCONDFMT.size(); i++)
for (size_t i = 0 ; i < m_arCONDFMT.size(); i++)
{
if (!m_arCONDFMT[i]) continue;
m_arCONDFMT[i]->serialize(stream);
......
......@@ -112,7 +112,7 @@ int CONDFMT::serialize(std::wostream & stream)
CP_XML_ATTR(L"sqref", condFmt->sqref.strValue);
//condition_id
//condition_pos
for (int i = 0; i < m_arCF.size(); i++)
for (size_t i = 0; i < m_arCF.size(); i++)
{
if (m_arCF[i] == NULL) continue;
......
......@@ -181,7 +181,7 @@ int CUSTOMVIEW::serialize(std::wostream & stream)
else
CP_XML_ATTR(L"state", L"split");
}
for (int i = 0; i < m_arSelection.size(); i++)
for (size_t i = 0; i < m_arSelection.size(); i++)
{
if (m_arSelection[i] == NULL) continue;
m_arSelection[i]->serialize(CP_XML_STREAM());
......
......@@ -31,9 +31,9 @@
*/
#include "DREF.h"
#include <Logic/Biff_records/DConName.h>
#include <Logic/Biff_records/DConBin.h>
#include <Logic/Biff_records/DConRef.h>
#include "../Biff_records/DConName.h"
#include "../Biff_records/DConBin.h"
#include "../Biff_records/DConRef.h"
namespace XLS
{
......
......@@ -88,7 +88,7 @@ int DVAL::serialize(std::wostream & stream)
DVal * dval = dynamic_cast<DVal*>(m_DVal.get());
for (int i = 0 ; i < m_arDv.size(); i++)
for (size_t i = 0 ; i < m_arDv.size(); i++)
{
if (!m_arDv[i]) continue;
......
......@@ -254,10 +254,9 @@ int FDB::serialize(std::wostream & strm, bool bSql)
{
CP_XML_ATTR(L"containsSemiMixedTypes", 1);
}
else if ((bDate & bString) || (bEmpty & bInteger & bString))
else if ((bDate & bString) || ((bEmpty || !bNumber) & bInteger & bString))
{
if (bEmpty && bInteger)
bNumber = true;
if (bInteger) bNumber = true;
CP_XML_ATTR(L"containsMixedTypes", 1);
}
else if (!bEmpty && !bString && !bBool)
......
......@@ -31,18 +31,22 @@
*/
#include "FORMATTING.h"
#include <Logic/Biff_records/Font.h>
#include <Logic/Biff_records/Format.h>
#include <Logic/Biff_records/DXF.h>
#include <Logic/Biff_unions/STYLES.h>
#include <Logic/Biff_records/Palette.h>
#include <Logic/Biff_records/ClrtClient.h>
#include <Logic/Biff_records/TableStyles.h>
#include <Logic/Biff_records/Compat12.h>
#include <Logic/Biff_unions/TABLESTYLES.h>
#include <Logic/Biff_unions/XFS.h>
#include <Logic/Biff_unions/THEME.h>
#include "TABLESTYLES.h"
#include "XFS.h"
#include "THEME.h"
#include "STYLES.h"
#include "../Biff_records/XF.h"
#include "../Biff_records/Font.h"
#include "../Biff_records/Format.h"
#include "../Biff_records/DXF.h"
#include "../Biff_records/Palette.h"
#include "../Biff_records/ClrtClient.h"
#include "../Biff_records/TableStyles.h"
#include "../Biff_records/Compat12.h"
#include "../Biff_records/Style.h"
#include "../Biff_records/StyleExt.h"
namespace XLS
{
......@@ -141,9 +145,53 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
elements_.pop_back();
}
update_xfs();
return true;
}
void FORMATTING::update_xfs()
{
STYLES * st = dynamic_cast<STYLES*>(m_Styles.get());
XFS * xfs = dynamic_cast<XFS*>(m_XFS.get());
if (!xfs) return;
//for (size_t i = 0; (st) && (i < st->m_arStyles.size()); i++)
//{
// XLS::Style * style = dynamic_cast<Style*>(st->m_arStyles[i].first.get());
// XLS::StyleExt * styleExt = dynamic_cast<StyleExt*>(st->m_arStyles[i].second.get());
//
// if (styleExt && style)
// {
// if (styleExt->fBuiltIn && styleExt->xfProps.cprops > 0)
// {
// bool bFound = false;
// for (size_t i = 0; i < xfs->m_arCellStyles.size(); i++)
// {
// XF* xf = dynamic_cast<XF*>(xfs->m_arCellStyles[i].get());
// if (xf->ind_xf == style->ixfe)
// {
// xf->style.Update(&styleExt->xfProps);
// bFound = true;
// break;
// }
// }
// //for (size_t i = 0; !bFound && i < xfs->m_arCellXFs.size(); i++)
// //{
// // XF* xf = dynamic_cast<XF*>(xfs->m_arCellXFs[i].get());
// // if (xf->ind_xf == style->ixfe)
// // {
// // xf->cell.Update(&styleExt->xfProps);
// // bFound = true;
// // break;
// // }
// //}
// }
// }
//}
xfs->RegisterFillBorder();
}
void FORMATTING::concatinate(FORMATTING* ext)
{
if (ext->m_XFS)
......@@ -180,7 +228,7 @@ int FORMATTING::serialize1(std::wostream & stream)
CP_XML_NODE(L"numFmts")
{
CP_XML_ATTR(L"count", m_arFormats.size());
for (int i = 0 ; i < m_arFormats.size(); i++)
for (size_t i = 0 ; i < m_arFormats.size(); i++)
{
m_arFormats[i]->serialize(CP_XML_STREAM());
}
......@@ -191,7 +239,7 @@ int FORMATTING::serialize1(std::wostream & stream)
CP_XML_NODE(L"fonts")
{
CP_XML_ATTR(L"count", m_arFonts.size());
for (int i = 0 ; i < m_arFonts.size(); i++)
for (size_t i = 0 ; i < m_arFonts.size(); i++)
{
Font * font = dynamic_cast<Font*>(m_arFonts[i].get());
std::map<int, FillInfoExt>::iterator it = global_info->fonts_color_ext.find(i);
......@@ -225,7 +273,7 @@ int FORMATTING::serialize2(std::wostream & stream)
{
CP_XML_ATTR(L"count", global_info->cellStyleDxfs_count);
for (int i = 0 ; i < m_arDXF.size(); i++)
for (size_t i = 0 ; i < m_arDXF.size(); i++)
{
m_arDXF[i]->serialize(CP_XML_STREAM());
}
......
......@@ -53,6 +53,7 @@ public:
int serialize2(std::wostream & stream);
void concatinate(FORMATTING* ext);
void update_xfs();
static const ElementType type = typeFORMATTING;
......
......@@ -110,7 +110,7 @@ const bool FORMULA::loadContent(BinProcessor& proc)
if ((formula) && (formula->fShrFmla))
{
for (int i = 0; i < shared_formulas_locations_ref_.size(); i++)
for (size_t i = 0; i < shared_formulas_locations_ref_.size(); i++)
{
if (shared_formulas_locations_ref_[i].inRange(location)) m_sharedIndex = i;
}
......
......@@ -151,7 +151,7 @@ int LBL::serialize(std::wostream & stream)
if ((lbl->itab == 0) && (res = value.find(L"#REF!")) >= 0)
{
for (int i = 0 ; i < lbl->rgce.rgce.sequence.size(); i++)
for (size_t i = 0 ; i < lbl->rgce.rgce.sequence.size(); i++)
{
PtgRef3d* ptg = dynamic_cast<PtgRef3d*>(lbl->rgce.rgce.sequence[i].get());
if (ptg)
......
......@@ -103,8 +103,6 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
global_info_->idPivotCache = streamId->idStm;
global_info_->mapPivotCacheIndex.insert(std::make_pair(global_info_->idPivotCache, global_info_->mapPivotCacheIndex.size()));
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
if (!pivot_cache) return 0;
......@@ -113,6 +111,13 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
if (!db || !db_ex)return 0;
if (pivot_cache->m_arFDB.empty() && pivot_cache->m_arSXFORMULA.empty())
{
global_info_->mapPivotCacheStream.erase(pFind);
return 0;
}
global_info_->mapPivotCacheIndex.insert(std::make_pair(global_info_->idPivotCache, global_info_->mapPivotCacheIndex.size()));
bool bSql = false;
CP_XML_WRITER(strm)
......@@ -122,7 +127,7 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
if (pivot_cache->m_arDBB.empty() == false)
if (!pivot_cache->m_arDBB.empty())
{
CP_XML_ATTR(L"r:id", L"rId1" );
}
......@@ -142,7 +147,7 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
src->serialize(CP_XML_STREAM());
}
if (pivot_cache->m_arFDB.empty() == false)
if (!pivot_cache->m_arFDB.empty())
{
CP_XML_NODE(L"cacheFields")
{
......@@ -157,7 +162,7 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
}
}
}
if (pivot_cache->m_arSXFORMULA.empty() == false)
if (!pivot_cache->m_arSXFORMULA.empty())
{
CP_XML_NODE(L"calculatedItems")
{
......
......@@ -113,12 +113,16 @@ int PIVOTVIEW::serialize(std::wostream & strm)
SXEx *view_ex = pivot_ex ? dynamic_cast<SXEx*>(pivot_ex->m_SXEx.get()) : NULL;
SXViewEx9 *view_ex9 = pivot_ex ? dynamic_cast<SXViewEx9*>(frt9->m_SXViewEx9.get()) : NULL;
SXAddl_SXCView_SXDVer10Info *view_ex10 = addls ? dynamic_cast<SXAddl_SXCView_SXDVer10Info*>(addls->m_SXAddl_SXCView_SXDTableStyleClient.get()) : NULL;
SXAddl_SXCView_SXDVer12Info *view_ex12 = addls ? dynamic_cast<SXAddl_SXCView_SXDVer12Info*>(addls->m_SXAddl_SXCView_SXDTableStyleClient.get()) : NULL;
SXAddl_SXCView_SXDVer10Info *view_ex10 = addls ? dynamic_cast<SXAddl_SXCView_SXDVer10Info*>(addls->m_SXAddl_SXCView_SXDVer10Info.get()) : NULL;
SXAddl_SXCView_SXDVer12Info *view_ex12 = addls ? dynamic_cast<SXAddl_SXCView_SXDVer12Info*>(addls->m_SXAddl_SXCView_SXDVer12Info.get()) : NULL;
indexStream = global_info_->arPivotCacheStream[view->iCache];
std::map<int, int>::iterator pFindIndex = global_info_->mapPivotCacheIndex.find(indexStream);
if (pFindIndex == global_info_->mapPivotCacheIndex.end())
return 0;
indexCache = pFindIndex->second;
CP_XML_WRITER(strm)
......@@ -190,15 +194,18 @@ int PIVOTVIEW::serialize(std::wostream & strm)
CP_XML_ATTR(L"colPageCount", 1);
}
}
CP_XML_NODE(L"pivotFields")
if (!core->m_arPIVOTVD.empty())
{
CP_XML_ATTR(L"count", view->cDim);//Sxvd
for (size_t i = 0; i < core->m_arPIVOTVD.size(); i++)
CP_XML_NODE(L"pivotFields")
{
core->m_arPIVOTVD[i]->serialize(CP_XML_STREAM());
CP_XML_ATTR(L"count", view->cDim);//Sxvd
for (size_t i = 0; i < core->m_arPIVOTVD.size(); i++)
{
core->m_arPIVOTVD[i]->serialize(CP_XML_STREAM());
}
}
}
if (core->m_arPIVOTIVD.size() >= 1)
if (!core->m_arPIVOTIVD.empty())
{
CP_XML_NODE(L"rowFields")
{
......@@ -208,7 +215,7 @@ int PIVOTVIEW::serialize(std::wostream & strm)
ivd->serialize(CP_XML_STREAM());
}
}
if (core->m_arPIVOTLI.size() >= 1)//0 or 2
if (!core->m_arPIVOTLI.empty())//0 or 2
{
CP_XML_NODE(L"rowItems")
{
......@@ -247,7 +254,7 @@ int PIVOTVIEW::serialize(std::wostream & strm)
core->m_PIVOTPI->serialize(CP_XML_STREAM());
}
}
if (core->m_arSXDI.empty() == false)
if (!core->m_arSXDI.empty())
{
CP_XML_NODE(L"dataFields")
{
......
......@@ -86,7 +86,7 @@ int SORTDATA12::serialize(std::wostream & stream)
if (info->fCaseSensitive) CP_XML_ATTR(L"caseSensitive", 1);
if (info->fAltMethod) CP_XML_ATTR(L"sortMethod", L"stroke");
for (int i = 0 ; i < info->sortCond12Array.size(); i++)
for (size_t i = 0 ; i < info->sortCond12Array.size(); i++)
{
SortCond12 * sortCond = dynamic_cast<SortCond12 *>(info->sortCond12Array[i].get());
if (sortCond == NULL) continue;
......
......@@ -31,8 +31,9 @@
*/
#include "STYLES.h"
#include <Logic/Biff_records/Style.h>
#include <Logic/Biff_records/StyleExt.h>
#include "../Biff_records/Style.h"
#include "../Biff_records/StyleExt.h"
namespace XLS
{
......@@ -84,6 +85,17 @@ const bool STYLES::loadContent(BinProcessor& proc)
{
styles_count = proc.repeated<Parenthesis_STYLES_1>(0, 0);
for (std::list<XLS::BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end(); it++)
{
Parenthesis_STYLES_1 * style_1 = dynamic_cast<Parenthesis_STYLES_1*>(it->get());
if (style_1)
{
m_arStyles.push_back(std::make_pair(style_1->m_Style, style_1->m_StyleEx));
}
}
elements_.clear();
if (styles_count > 0) return true;
else return false;
}
......@@ -98,56 +110,51 @@ int STYLES::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"count", styles_count);
for (std::list<XLS::BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end(); it++)
for (size_t i = 0; i < m_arStyles.size(); i++)
{
Parenthesis_STYLES_1 * style_1 = dynamic_cast<Parenthesis_STYLES_1*>(it->get());
if (style_1)
CP_XML_NODE(L"cellStyle")
{
CP_XML_NODE(L"cellStyle")
XLS::Style * style = dynamic_cast<Style*> (m_arStyles[i].first.get());
XLS::StyleExt * styleExt = dynamic_cast<StyleExt*> (m_arStyles[i].second.get());
if (styleExt)
{
XLS::Style * style = dynamic_cast<Style*> (style_1->m_Style.get());
XLS::StyleExt * styleExt = dynamic_cast<StyleExt*>(style_1->m_StyleEx.get());
if (styleExt)
CP_XML_ATTR(L"name", styleExt->stName.value());
if (styleExt->fBuiltIn)
{
CP_XML_ATTR(L"name", styleExt->stName.value());
if (styleExt->fBuiltIn)
CP_XML_ATTR(L"builtinId", styleExt->builtInData.istyBuiltIn);
if (styleExt->builtInData.iLevel > 0 && styleExt->builtInData.iLevel < 255)
{
CP_XML_ATTR(L"builtinId", styleExt->builtInData.istyBuiltIn);
if (styleExt->builtInData.iLevel > 0 && styleExt->builtInData.iLevel < 255)
{
CP_XML_ATTR(L"iLevel", styleExt->builtInData.iLevel);
}
CP_XML_ATTR(L"iLevel", styleExt->builtInData.iLevel);
}
// for (int i = 0; i < styleExt->xfProps.xfPropArray.size(); i++)
//{
//}
}
else if (style)
// for (size_t i = 0; i < styleExt->xfProps.xfPropArray.size(); i++)
//{
//}
}
else if (style)
{
CP_XML_ATTR(L"name", style->user.value());
if (style->fBuiltIn)
{
CP_XML_ATTR(L"name", style->user.value());
if (style->fBuiltIn)
CP_XML_ATTR(L"builtinId", style->builtInData.istyBuiltIn);
if (style->builtInData.iLevel > 0 && style->builtInData.iLevel < 255)
{
CP_XML_ATTR(L"builtinId", style->builtInData.istyBuiltIn);
if (style->builtInData.iLevel > 0 && style->builtInData.iLevel < 255)
{
CP_XML_ATTR(L"iLevel", style->builtInData.iLevel);
}
CP_XML_ATTR(L"iLevel", style->builtInData.iLevel);
}
}
}
if (style)
{
int xfId = style->ixfe - 1;
if (xfId < 0) xfId = 0;
CP_XML_ATTR(L"xfId", xfId);
}
if (style)
{
int xfId = style->ixfe - 1;
if (xfId < 0) xfId = 0;
CP_XML_ATTR(L"xfId", xfId);
}
}
}
......
......@@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of STYLES union of records
class STYLES : public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(STYLES)
......@@ -53,6 +51,8 @@ public:
int serialize(std::wostream & stream);
std::vector<std::pair<BaseObjectPtr, BaseObjectPtr>> m_arStyles;
int styles_count;
};
......
......@@ -82,7 +82,7 @@ const bool SXOPER::loadContent(BinProcessor& proc)
bNumber = !bInteger;
node = L"n";
if (bInteger)
value = std::to_wstring((int)num->num.data.value);
value = std::to_wstring((_INT64)num->num.data.value);
else
value = boost::lexical_cast<std::wstring>(num->num.data.value);
}
......@@ -97,9 +97,9 @@ const bool SXOPER::loadContent(BinProcessor& proc)
else if(proc.optional<SxErr>())
{
SxErr* err = dynamic_cast<SxErr*>(elements_.back().get());
bNumber = true;
//bNumber = true;
node = L"e";
value = std::to_wstring(err->wbe);
value = L"#VALUE!";//std::to_wstring(err->wbe);
}
else if(proc.optional<SXString>())
{
......
......@@ -31,9 +31,9 @@
*/
#include "SXSRC.h"
#include <Logic/Biff_unions/DREF.h>
#include <Logic/Biff_unions/SXTBL.h>
#include <Logic/Biff_unions/DBQUERY.h>
#include "DREF.h"
#include "SXTBL.h"
#include "DBQUERY.h"
namespace XLS
{
......
......@@ -31,12 +31,16 @@
*/
#include "SXTBL.h"
#include <Logic/Biff_records/SXTbl.h>
#include <Logic/Biff_unions/DREF.h>
#include <Logic/Biff_records/SxTbpg.h>
#include <Logic/Biff_records/SXTBRGIITM.h>
#include <Logic/Biff_records/SXString.h>
#include "DREF.h"
#include "../Biff_records/SXTbl.h"
#include "../Biff_records/SxTbpg.h"
#include "../Biff_records/SXTBRGIITM.h"
#include "../Biff_records/SXString.h"
#include "../Biff_records/DConName.h"
#include "../Biff_records/DConBin.h"
#include "../Biff_records/DConRef.h"
namespace XLS
{
......@@ -124,11 +128,67 @@ const bool SXTBL::loadContent(BinProcessor& proc)
}
return true;
}
int SXTBL::serialize(std::wostream & stream)
int SXTBL::serialize(std::wostream & strm)
{
if (!m_SXTbl) return 0;
SXTbl *tbl = dynamic_cast<SXTbl*>(m_SXTbl.get());
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"cacheSource")
{
CP_XML_ATTR(L"type", L"consolidation");
CP_XML_NODE(L"consolidation")
{
CP_XML_NODE(L"pages")
{
CP_XML_ATTR(L"count", m_arSXTBRGIITM.size());
for (size_t i = 0; i < m_arSXTBRGIITM.size(); i++)
{
SXTBRGIITM * item = dynamic_cast<SXTBRGIITM*>(m_arSXTBRGIITM[i].item.get());
CP_XML_NODE(L"page")
{
CP_XML_ATTR(L"count", item->cItems);
for (size_t j = 0; j < m_arSXTBRGIITM[i].strings.size(); j++)
{
SXString* str = dynamic_cast<SXString*>(m_arSXTBRGIITM[i].strings[i].get());
CP_XML_NODE(L"pageItem")
{
CP_XML_ATTR(L"name", str->segment.value());
}
}
}
}
}
CP_XML_NODE(L"rangeSets")
{
CP_XML_ATTR(L"count", m_arDREF.size());
for (size_t i = 0; i < m_arDREF.size(); i++)
{
DREF* dref = dynamic_cast<DREF*>(m_arDREF[i].get());
DConName* name = dynamic_cast<DConName*>(dref->m_DCon.get());
DConBin* bin = dynamic_cast<DConBin*>(dref->m_DCon.get());
DConRef* ref = dynamic_cast<DConRef*>(dref->m_DCon.get());
CP_XML_NODE(L"rangeSet")
{
CP_XML_ATTR(L"i1", i);
if (name)
{
CP_XML_ATTR(L"name", name->stName.value());
}
}
}
}
}
}
}
return 0;
}
} // namespace XLS
......
......@@ -177,7 +177,7 @@ int WINDOW::serialize(std::wostream & stream)
CP_XML_ATTR(L"state", L"split");
}
}
for (int i = 0; i < m_arSelection.size(); i++)
for (size_t i = 0; i < m_arSelection.size(); i++)
{
if (m_arSelection[i] == NULL) continue;
m_arSelection[i]->serialize(CP_XML_STREAM());
......
......@@ -115,28 +115,45 @@ const bool XFS::loadContent(BinProcessor& proc)
count--;
}
}
//------------------------------------------------------------------------------------
return true;
}
void XFS::RegisterFillBorder()
{
int first_xf_ext = 0;
for (_UINT16 i = 0 ; i < m_arCellStyles.size(); i++)
for (size_t i = 0 ; i < m_arCellStyles.size(); i++)
{
XF *xfs = dynamic_cast<XF*>(m_arCellStyles[i].get());
XF *xfs = dynamic_cast<XF*>(m_arCellStyles[i].get());
for (size_t j = first_xf_ext ; j < m_arXFext.size(); j++)
{
XFExt *ext = dynamic_cast<XFExt*>(m_arXFext[j].get());
if (ext->ixfe > i)
break;
if (ext->ixfe == xfs->ind_xf)
{
xfs->style.ext_props = ext->rgExt;
first_xf_ext = j + 1;
break;
}
}
xfs->style.RegisterFillBorder();
}
first_xf_ext = 0;
for (int i = 0 ; i < m_arCellXFs.size(); i++)
for (size_t i = 0 ; i < m_arCellXFs.size(); i++)
{
XF *xfs = dynamic_cast<XF*>(m_arCellXFs[i].get());
XF *xfs = dynamic_cast<XF*>(m_arCellXFs[i].get());
if (m_arXFext.size() > 0 && xfs->cell.fHasXFExt)
if (!m_arXFext.empty() && xfs->cell.fHasXFExt)
{
for (_UINT16 j = first_xf_ext ; j < m_arXFext.size(); j++)
for (size_t j = first_xf_ext ; j < m_arXFext.size(); j++)
{
XFExt *ext = dynamic_cast<XFExt*>(m_arXFext[j].get());
if (ext->ixfe > i)break;
if (ext->ixfe > i)
break;
if (ext->ixfe == xfs->ind_xf)
{
......@@ -148,8 +165,6 @@ const bool XFS::loadContent(BinProcessor& proc)
}
xfs->cell.RegisterFillBorder();
}
return true;
}
int XFS::serialize(std::wostream & stream)
{
......@@ -158,7 +173,7 @@ int XFS::serialize(std::wostream & stream)
CP_XML_NODE(L"cellStyleXfs")
{
CP_XML_ATTR(L"count", m_arCellStyles.size());
for (int i = 0; i < m_arCellStyles.size(); i++)
for (size_t i = 0; i < m_arCellStyles.size(); i++)
{
m_arCellStyles[i]->serialize(CP_XML_STREAM());
}
......@@ -166,7 +181,7 @@ int XFS::serialize(std::wostream & stream)
CP_XML_NODE(L"cellXfs")
{
CP_XML_ATTR(L"count", m_arCellXFs.size());
for (int i = 0; i < m_arCellXFs.size(); i++)
for (size_t i = 0; i < m_arCellXFs.size(); i++)
{
m_arCellXFs[i]->serialize(CP_XML_STREAM());
}
......
......@@ -51,6 +51,8 @@ public:
int serialize(std::wostream & stream);
void RegisterFillBorder();
static const ElementType type = typeXFS;
size_t cell_xf_current_id;
......
......@@ -507,7 +507,7 @@ int ChartSheetSubstream::serialize_3D (std::wostream & _stream)
BaseObjectPtr wallSpPr;
BaseObjectPtr floorSpPr;
for (int i = 0; i < chart_formats->m_arAXISPARENT.size(); i++)
for (size_t i = 0; i < chart_formats->m_arAXISPARENT.size(); i++)
{
AXISPARENT* parent = dynamic_cast<AXISPARENT*> (chart_formats->m_arAXISPARENT[i].get());
AxisParent* ax_parent = dynamic_cast<AxisParent*> (parent->m_AxisParent.get());
......@@ -871,7 +871,7 @@ int ChartSheetSubstream::serialize_plot_area (std::wostream & _stream)
AXES * axes = dynamic_cast<AXES*>(parent->m_AXES.get());
if (axes)
{
for (int a = 0 ; a < axes->m_arAxesId.size(); a++)
for (size_t a = 0 ; a < axes->m_arAxesId.size(); a++)
{
CP_XML_NODE(L"c:axId")
{
......@@ -883,7 +883,7 @@ int ChartSheetSubstream::serialize_plot_area (std::wostream & _stream)
}
}
for (int i = 0; i < chart_formats->m_arAXISPARENT.size(); i++)
for (size_t i = 0; i < chart_formats->m_arAXISPARENT.size(); i++)
{
AXISPARENT* parent = dynamic_cast<AXISPARENT*> (chart_formats->m_arAXISPARENT[i].get());
AxisParent* ax_parent = dynamic_cast<AxisParent*> (parent->m_AxisParent.get());
......@@ -942,7 +942,7 @@ int ChartSheetSubstream::serialize_dPt(std::wostream & _stream, int id, CRT *crt
CP_XML_WRITER(_stream)
{
for (int i = 0 ; i < series->m_arPtSS.size(); i++)
for (size_t i = 0 ; i < series->m_arPtSS.size(); i++)
{
CP_XML_NODE(L"c:dPt")
{
......@@ -1088,7 +1088,7 @@ int ChartSheetSubstream::serialize_dLbls (std::wostream & _stream, int id, CRT *
CP_XML_NODE(L"c:showSerName") { CP_XML_ATTR (L"val" , 0); }
}
//подписи к точкам (отдельные)
for (int i = 0; i < labels.size(); i++)
for (size_t i = 0; i < labels.size(); i++)
{
CP_XML_NODE(L"c:dLbl")
{
......
......@@ -491,7 +491,7 @@ void GlobalsSubstream::LoadHFPicture()
if (m_arHFPicture.empty()) return;
int current_size_hf = 0, j = 0;
for ( int i = 0; i < m_arHFPicture.size(); i++)
for ( size_t i = 0; i < m_arHFPicture.size(); i++)
{
HFPicture* hf = dynamic_cast<HFPicture*>(m_arHFPicture[i].get());
if ((hf) && (hf->recordDrawingGroup))
......
......@@ -63,7 +63,7 @@ PropertySet::PropertySet(XLS::CFStreamPtr stream, const unsigned int property_se
}
code_page = 0;
for(unsigned int i = 0; i < prop_offsets.size(); ++i)
for(size_t i = 0; i < prop_offsets.size(); ++i)
{
if (stream->getStreamPointer() - property_set_offset > Size)
break;
......
......@@ -467,7 +467,7 @@ void WorksheetSubstream::LoadHFPicture()
if (m_arHFPicture.empty()) return;
int current_size_hf = 0, j = 0;
for ( int i = 0; i < m_arHFPicture.size(); i++)
for ( size_t i = 0; i < m_arHFPicture.size(); i++)
{
HFPicture* hf = dynamic_cast<HFPicture*>(m_arHFPicture[i].get());
if ((hf) && (hf->recordDrawingGroup))
......
......@@ -200,6 +200,7 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
{
std::list<std::string> listStream = cfile.storage_->entries("_SX_DB_CUR");
int last_index = 0;
for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
{
XLS::CFStreamCacheReader pivot_cache_reader(cfile.getNamedStream("_SX_DB_CUR/" + *it), xls_global_info);
......@@ -208,16 +209,25 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
XLS::BinReaderProcessor proc(pivot_cache_reader , pivot_cache.get() , true);
proc.mandatory(*pivot_cache.get());
int index = 0;
int index = -1;
try
{
index = atoi(it->c_str());
index = boost::lexical_cast<int>(it->c_str());
}
catch(...)
{
}
if (index < 0)
{
//может быть шестнадцатеричное
index = XmlUtils::GetHex(*it);
}
if (index < 0)
index = last_index + 1;
xls_global_info->mapPivotCacheStream.insert(std::make_pair(index, pivot_cache));
last_index = index;
}
}
if (bMacros && cfile.storage_->isDirectory("_VBA_PROJECT_CUR"))
......@@ -1947,7 +1957,6 @@ void XlsConverter::convert(XLS::PIVOTVIEW * pivot_view)
pivot_view->serialize(strm);
int index_view = xlsx_context->get_pivots_context().add_view(strm.str(), pivot_view->indexCache);
if (index_view > 0)
......
......@@ -65,6 +65,8 @@ xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl
void xlsx_pivots_context::add_cache(std::wstring definitions, std::wstring records)
{
if (definitions.empty()) return;
Impl::_pivot_cache c = {definitions, records};
impl_->caches_.push_back(c);
}
......
......@@ -60,7 +60,18 @@ namespace XmlUtils
return 0;
}
AVSINLINE static bool IsDigit (wchar_t c)
AVSINLINE static int GetDigit (char c)
{
if (c >= '0' && c <= '9')
return (int)(c - '0');
if (c >= 'a' && c <= 'f')
return 10 + (int)(c - 'a');
if (c >= 'A' && c <= 'F')
return 10 + (int)(c - 'A');
return 0;
}
AVSINLINE static bool IsDigit (wchar_t c)
{
if (c >= '0' && c <= '9')
return true;
......@@ -77,6 +88,17 @@ namespace XmlUtils
return nResult;
}
AVSINLINE static __int64 GetHex (const std::string& string)
{
__int64 nResult = 0;
size_t nLen = string.length();
for (size_t nIndex = 0; nIndex < nLen; ++nIndex )
{
nResult += GetDigit( string[nIndex] ) << ( 4 * ( nLen - 1 - nIndex ) );
}
return nResult;
}
AVSINLINE static int GetColorBGR (const std::wstring& string)
{
// variables
......
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