Commit c9476890 authored by ElenaSubbotina's avatar ElenaSubbotina

Merge remote-tracking branch 'origin/release/v5.0.0' into develop

parents 16bdbafa f575947c
......@@ -1427,7 +1427,7 @@ std::wstring NSPresentationEditor::CShapeWriter::ConvertImage()
m_oWriter.WriteString(std::wstring(L"<a:xfrm"));
if (0 != m_pImageElement->m_dRotate)
{
m_oWriter.WriteString(L" rot=\"" + std::to_wstring(m_pImageElement->m_dRotate * 60000) + L"\"");
m_oWriter.WriteString(L" rot=\"" + std::to_wstring((int)(m_pImageElement->m_dRotate * 60000)) + L"\"");
}
if (m_pImageElement->m_bFlipH)
{
......
......@@ -996,8 +996,8 @@ void CPPTUserInfo::LoadSlide(DWORD dwSlideID, CSlide* pSlide)
//даты и номера могут быть и не только в колонтитулах
//todooo ... возможно нужно все перенести плейсхолдеры без ID a-la как в AddLayout
AddLayoutSlidePlaceholder(pSlide, MasterSlideNumber , pLayout);
AddLayoutSlidePlaceholder(pSlide, MasterDate , pLayout);
//AddLayoutSlidePlaceholder(pSlide, MasterSlideNumber , pLayout);
//AddLayoutSlidePlaceholder(pSlide, MasterDate , pLayout);
//-------------элементы колонтитулов
std::multimap<int, int>::iterator it;
......
......@@ -99,10 +99,16 @@ HRESULT convert_directory(std::wstring pathName)
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
HRESULT hr = convert_single(argv[1]);
//HRESULT hr = convert_directory(argv[1]);
HRESULT hr = -1;
if (NSFile::CFileBinary::Exists(argv[1]))
{
hr = convert_single(argv[1]);
}
else if (NSDirectory::Exists(argv[1]))
{
hr = convert_directory(argv[1]);
}
return hr;
}
\ No newline at end of file
......@@ -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")
{
......
......@@ -54,14 +54,17 @@ BaseObjectPtr Chart3d::clone()
void Chart3d::readFields(CFRecord& record)
{
unsigned short flags;
unsigned short pcHeight_raw;
record >> anRot >> anElev >> pcDist >> pcHeight_raw >> pcDepth >> pcGap >> flags;
record >> anRot >> anElev >> pcDist >> pcHeightPie >> pcDepth >> pcGap >> flags;
fPerspective = GETBIT(flags, 0);
fCluster = GETBIT(flags, 1);
f3DScaling = GETBIT(flags, 2);
fNotPieChart = GETBIT(flags, 4);
fWalls2D = GETBIT(flags, 5);
pcHeight = fNotPieChart ? static_cast<short>(pcHeight_raw) : pcHeight_raw;
if (fNotPieChart)
{
pcHeight3D = static_cast<short>(pcHeightPie);
}
}
} // namespace XLS
......
......@@ -48,7 +48,6 @@ public:
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeChart3d;
......@@ -57,7 +56,8 @@ public:
_INT16 anRot;
_INT16 anElev;
_INT16 pcDist;
_UINT32 pcHeight;
_UINT16 pcHeightPie;
short pcHeight3D;
_INT16 pcDepth;
_UINT16 pcGap;
......
......@@ -31,14 +31,15 @@
*/
#include "DConRef.h"
#include "../../../../../Common/DocxFormat/Source/XML/Utils.h"
namespace XLS
{
DConRef::DConRef()
{
index_external = -1;
bFilePath = false;
bSheetName = false;
}
......@@ -54,6 +55,8 @@ BaseObjectPtr DConRef::clone()
void DConRef::readFields(CFRecord& record)
{
global_info_ = record.getGlobalWorkbookInfo();
record >> ref >> cchFile;
if (cchFile > 1)
......@@ -67,21 +70,109 @@ void DConRef::readFields(CFRecord& record)
//self-reference = %x0002 sheet-name
stFile = stFile_.value();
if (stFile.substr(0, 1) == L"\x0001")
std::wstring sTmp = stFile;
while(true)
{
bFilePath = true;
stFile = stFile.substr(1);
int pos = sTmp.find(L"\x0001");
if (pos >= 0)
{
bFilePath = true;
path.push_back(sTmp.substr(0, pos));
sTmp = sTmp.substr(pos + 1);
continue;
}
pos = sTmp.find(L"\x0002");
if (pos >= 0)
{
path.push_back(sTmp.substr(0, pos));
sTmp = sTmp.substr(pos + 1);
continue;
}
pos = sTmp.find(L"\x0003");
if (pos >= 0)
{
bFilePath = true;
path.push_back(sTmp.substr(0, pos));
sTmp = sTmp.substr(pos + 1);
continue;
}
break;
}
else if (stFile.substr(0, 1) == L"\x0002")
int pos = sTmp.find(L"]");
if (pos >= 0)
{
bSheetName = true;
stFile = stFile.substr(1);
}
file_name = sTmp.substr(1, pos - 1);
sheet_name = sTmp.substr(pos + 1);
}
else
{
sheet_name = sTmp;
}
}
int unused = record.getDataSize() - record.getRdPtr();
record.skipNunBytes(unused);
}
void DConRef::check_external()
{
bool bFound = false;
for (size_t i = 0; !bFilePath && i < global_info_->sheets_names.size(); i++)
{
if (global_info_->sheets_names[i] == sheet_name)
{
bFound = true;
break;
}
}
if (!bFound && (!path.empty() || !file_name.empty()) && bFilePath)
{//external sheet
std::wstring full_path;
if (!path.empty())
{
full_path = get_external_path();
}
std::unordered_map<std::wstring, std::wstring>::iterator pFind = global_info_->mapPivotCacheExternal.find(file_name);
if (pFind == global_info_->mapPivotCacheExternal.end())
{
index_external = global_info_->mapPivotCacheExternal.size() ;
global_info_->mapPivotCacheExternal.insert(std::make_pair(file_name, full_path));
}
else
{
if (pFind->second.empty() && !full_path.empty())
{
pFind->second = full_path;
}
index_external = std::distance( global_info_->mapPivotCacheExternal.begin(), pFind) ;
}
}
}
std::wstring DConRef::get_external_path()
{
if (path.empty() && file_name.empty()) return L"";
std::wstring result = L"file:///";
for (size_t i = 0; i < path.size(); i++)
{
result += L"\\" + path[i];
}
if (!file_name.empty())
result += L"\\" + file_name;
return result;
}
} // namespace XLS
......@@ -57,9 +57,18 @@ public:
unsigned short cchFile;
std::wstring stFile;
bool bFilePath;
bool bSheetName;
std::vector<std::wstring> path;
std::wstring file_name;
std::wstring sheet_name;
int index_external;
void check_external();
private:
GlobalWorkbookInfoPtr global_info_;
std::wstring get_external_path();
bool bFilePath;
};
} // namespace XLS
......
......@@ -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());
......
......@@ -72,6 +72,20 @@ int SXDI::serialize(std::wostream & strm)
CP_XML_ATTR(L"baseField", df);
CP_XML_ATTR(L"baseItem", isxvi);
CP_XML_ATTR(L"numFmtId", ifmt);
switch(iiftab)
{
case 0x0000: CP_XML_ATTR(L"subtotal", L"sum"); break;
case 0x0001: CP_XML_ATTR(L"subtotal", L"count"); break;
case 0x0002: CP_XML_ATTR(L"subtotal", L"average"); break;
case 0x0003: CP_XML_ATTR(L"subtotal", L"max"); break;
case 0x0004: CP_XML_ATTR(L"subtotal", L"min"); break;
case 0x0005: CP_XML_ATTR(L"subtotal", L"product"); break;
case 0x0006: CP_XML_ATTR(L"subtotal", L"countNums");break;
case 0x0007: CP_XML_ATTR(L"subtotal", L"stdDev"); break;
case 0x0008: CP_XML_ATTR(L"subtotal", L"stdDevp"); break;
case 0x0009: CP_XML_ATTR(L"subtotal", L"var"); break;
case 0x000a: CP_XML_ATTR(L"subtotal", L"varp"); break;
}
}
}
return 0;
......
......@@ -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")
{
......
......@@ -116,7 +116,7 @@ const bool AUTOFILTER::loadContent(BinProcessor& proc)
std::vector<BaseObjectPtr> ar;
ar.push_back(elements_.back());
m_mapFilters12.insert(std::pair<int, std::vector<BaseObjectPtr>>(ind, ar));
m_mapFilters12.insert(std::make_pair(ind, ar));
}
}
}
......@@ -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;
......
......@@ -78,7 +78,7 @@ public:
{
if (row->miyRw > 0 && std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.001)
{
sheet_info.customRowsHeight.insert(std::pair<int, double>(row->rw, row->miyRw / 20.));
sheet_info.customRowsHeight.insert(std::make_pair(row->rw, row->miyRw / 20.));
}
}
m_rows.push_back(elements_.front());
......@@ -102,7 +102,7 @@ public:
{
std::list<BaseObjectPtr> c;
c.push_back(elements_.front());
m_cells.insert(std::pair<int, std::list<BaseObjectPtr>>(cell->RowNumber, c));
m_cells.insert(std::make_pair(cell->RowNumber, c));
}
else
{
......
......@@ -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());
......
......@@ -77,10 +77,10 @@ const bool COLUMNS::loadContent(BinProcessor& proc)
for (int i = column_info->colFirst; i <= column_info->colLast; i++)
{
global_info_->sheet_size_info.back().customColumnsWidth.insert(std::pair<int, double>(i, column_info->coldx / 256.));
global_info_->sheet_size_info.back().customColumnsWidth.insert(std::make_pair(i, column_info->coldx / 256.));
//else if (def_ok)
//{
// global_info_->sheet_size_info.back().customColumnsWidth.insert(std::pair<int, double>(i, global_info_->sheet_size_info.back().defaultColumnWidth));
// global_info_->sheet_size_info.back().customColumnsWidth.insert(std::make_pair(i, global_info_->sheet_size_info.back().defaultColumnWidth));
//}
}
......
......@@ -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
{
......@@ -116,11 +116,18 @@ int DREF::serialize(std::wostream & strm)
}
else if(ref)
{
ref->check_external();
CP_XML_ATTR(L"type", L"worksheet");
CP_XML_NODE(L"worksheetSource")
{
CP_XML_ATTR(L"ref", ref->ref.toString());
CP_XML_ATTR(L"sheet", ref->stFile);
CP_XML_ATTR(L"sheet", ref->sheet_name);
if (ref->index_external >= 0)
{
CP_XML_ATTR(L"r:id", L"extId" + std::to_wstring(ref->index_external + 1));
}
}
}
}
......
......@@ -31,7 +31,7 @@
*/
#pragma once
#include <Logic/CompositeObject.h>
#include "../CompositeObject.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;
......
......@@ -175,7 +175,7 @@ const bool FDB::loadContent(BinProcessor& proc)
return true;
}
int FDB::serialize(std::wostream & strm, bool bSql)
int FDB::serialize(std::wostream & strm, bool bSql, bool bDBB)
{
SXFDB* fdb = dynamic_cast<SXFDB*>(m_SXFDB.get());
SXFDBType* fdb_type = dynamic_cast<SXFDBType*>(m_SXFDBType.get());
......@@ -227,7 +227,7 @@ int FDB::serialize(std::wostream & strm, bool bSql)
Formula->serialize_attr(CP_GET_XML_NODE());
}
if (m_arSRCSXOPER.empty() == false)
if (!m_arSRCSXOPER.empty() && (bDBB || (!bDBB && bSql)) )
{
CP_XML_NODE(L"sharedItems")
{
......@@ -250,19 +250,26 @@ int FDB::serialize(std::wostream & strm, bool bSql)
// }
//}
if ((bDate & bNumber) || (bNumber & bString))
if ((bDate & bNumber)/* || (bNumber & bString & !bEmpty & !bInteger)*/)
{
CP_XML_ATTR(L"containsSemiMixedTypes", 1);
}
else if ((bDate & bString) || (bEmpty & bInteger & bString))
else if ((bString && bDate) ||
(bString && (bNumber || bInteger)) ||
(!bString && bDate && bEmpty && (bNumber || bInteger)))
{
if (bEmpty && bInteger)
bNumber = true;
CP_XML_ATTR(L"containsMixedTypes", 1);
if (bString && !bNumber && bInteger) bNumber = true;
else if (bString && bNumber && bInteger) bInteger = false;
}
else if (!bEmpty && !bString && !bBool)
{
CP_XML_ATTR(L"containsSemiMixedTypes", 0);
if (bDate)
{
CP_XML_ATTR(L"containsMixedTypes", 1);
}
}
if (bDate && ! (bNumber || bInteger || bString || bEmpty ))
{
......@@ -343,5 +350,25 @@ int FDB::serialize(std::wostream & strm, bool bSql)
return 0;
}
int FDB::serialize_record(std::wostream & strm)
{
SXFDB* fdb = dynamic_cast<SXFDB*>(m_SXFDB.get());
SXFDBType* fdb_type = dynamic_cast<SXFDBType*>(m_SXFDBType.get());
if (!fdb || !fdb_type) return 0;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"r")
{
for (size_t i = 0; i < m_arSRCSXOPER.size(); i++)
{
SXOPER* oper = dynamic_cast<SXOPER*>(m_arSRCSXOPER[i].get());
oper->serialize_record(CP_XML_STREAM());
}
}
}
}
} // namespace XLS
......@@ -47,7 +47,8 @@ public:
virtual const bool loadContent(BinProcessor& proc);
int serialize(std::wostream & strm, bool bSql);
int serialize(std::wostream & strm, bool bSql, bool bDBB);
int serialize_record(std::wostream & strm);
static const ElementType type = typeFDB;
......
......@@ -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;
}
......
......@@ -122,7 +122,7 @@ const bool LBL::loadContent(BinProcessor& proc)
ar[ind_sheet] = value;
//ar.push_back(value);
global_info_->mapDefineNames.insert(std::pair<std::wstring, std::vector<std::wstring>>(name, ar));
global_info_->mapDefineNames.insert(std::make_pair(name, ar));
}
isSerialize = true;
}
......@@ -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,7 +111,15 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
if (!db || !db_ex)return 0;
bool bSql = false;
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()));
SXSRC* src = dynamic_cast<SXSRC*>(m_SXSRC.get());
bool bSql = src ? src->bSql : false;
CP_XML_WRITER(strm)
{
......@@ -122,27 +128,25 @@ 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() && bSql)
{
CP_XML_ATTR(L"r:id", L"rId1" );
CP_XML_ATTR(L"saveData", 0);
}
else
{
CP_XML_ATTR(L"saveData", 0);
CP_XML_ATTR(L"r:id", L"rId1" );
}
CP_XML_ATTR(L"enableRefresh", 1);
CP_XML_ATTR(L"refreshedBy", db->rgb.value());
CP_XML_ATTR(L"refreshedDate", db_ex->numDate.data.value);
CP_XML_ATTR(L"recordCount", db->crdbdb);
//upgradeOnRefresh="1"
SXSRC* src = dynamic_cast<SXSRC*>(m_SXSRC.get());
if (src)
{
bSql = src->bSql;
src->serialize(CP_XML_STREAM());
}
if (pivot_cache->m_arFDB.empty() == false)
if (!pivot_cache->m_arFDB.empty())
{
CP_XML_NODE(L"cacheFields")
{
......@@ -153,11 +157,11 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
FDB *field = dynamic_cast<FDB *>(pivot_cache->m_arFDB[i].get());
if (!field) continue;
field->serialize(CP_XML_STREAM(), bSql);
field->serialize(CP_XML_STREAM(), bSql, !pivot_cache->m_arDBB.empty());
}
}
}
if (pivot_cache->m_arSXFORMULA.empty() == false)
if (!pivot_cache->m_arSXFORMULA.empty())
{
CP_XML_NODE(L"calculatedItems")
{
......@@ -186,7 +190,10 @@ int PIVOTCACHEDEFINITION::serialize_records(std::wostream & strm)
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
if (!pivot_cache) return 0;
if (pivot_cache->m_arDBB.empty()) return 0;
SXSRC* src = dynamic_cast<SXSRC*>(m_SXSRC.get());
bool bSql = src ? src->bSql : false;
if (pivot_cache->m_arDBB.empty() && bSql) return 0;
CP_XML_WRITER(strm)
{
......@@ -195,11 +202,22 @@ int PIVOTCACHEDEFINITION::serialize_records(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");
CP_XML_ATTR(L"count", pivot_cache->m_arDBB.size());
for (size_t i = 0; i < pivot_cache->m_arDBB.size(); i++)
if (!pivot_cache->m_arDBB.empty())
{
pivot_cache->m_arDBB[i]->serialize(CP_XML_STREAM());
CP_XML_ATTR(L"count", pivot_cache->m_arDBB.size());
for (size_t i = 0; i < pivot_cache->m_arDBB.size(); i++)
{
pivot_cache->m_arDBB[i]->serialize(CP_XML_STREAM());
}
}
else
{
CP_XML_ATTR(L"count", pivot_cache->m_arFDB.size());
for (size_t i = 0; i < pivot_cache->m_arFDB.size(); i++)
{
FDB* fdb = dynamic_cast<FDB*>(pivot_cache->m_arFDB[i].get());
fdb->serialize_record(CP_XML_STREAM());
}
}
}
}
......
......@@ -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)
......@@ -162,7 +166,7 @@ int PIVOTVIEW::serialize(std::wostream & strm)
CP_XML_ATTR(L"compact", view_ex12->fCompactData);
CP_XML_ATTR(L"compactData", view_ex12->fCompactData);
CP_XML_ATTR(L"gridDropZones", view_ex12->fNewDropZones);
CP_XML_ATTR(L"gridDropZones", !view_ex12->fNewDropZones);
CP_XML_ATTR(L"showDrill", !view_ex12->fHideDrillIndicators);
CP_XML_ATTR(L"printDrill", view_ex12->fPrintDrillIndicators);
}
......@@ -190,51 +194,59 @@ 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)
int index_ivd = 0;
int index_tli = 0;
if (view->cDimRw > 0 && index_ivd < core->m_arPIVOTIVD.size())
{
CP_XML_NODE(L"rowFields")
{
CP_XML_ATTR(L"count", view->cDimRw);
PIVOTIVD* ivd = dynamic_cast<PIVOTIVD*>(core->m_arPIVOTIVD[0].get());
PIVOTIVD* ivd = dynamic_cast<PIVOTIVD*>(core->m_arPIVOTIVD[index_ivd].get());
ivd->serialize(CP_XML_STREAM());
index_ivd++;
}
}
if (core->m_arPIVOTLI.size() >= 1)//0 or 2
if (view->cRw > 0 && index_tli < core->m_arPIVOTLI.size())
{
CP_XML_NODE(L"rowItems")
{
CP_XML_ATTR(L"count", view->cRw);
PIVOTLI* line = dynamic_cast<PIVOTLI*>(core->m_arPIVOTLI[0].get());
PIVOTLI* line = dynamic_cast<PIVOTLI*>(core->m_arPIVOTLI[index_tli].get());
line->serialize(CP_XML_STREAM());
index_tli++;
}
}
if (core->m_arPIVOTIVD.size() == 2)//0 or 2
if (view->cDimCol > 0 && index_ivd < core->m_arPIVOTIVD.size())
{
CP_XML_NODE(L"colFields")
{
CP_XML_ATTR(L"count", view->cDimCol);
PIVOTIVD* ivd = dynamic_cast<PIVOTIVD*>(core->m_arPIVOTIVD[1].get());
PIVOTIVD* ivd = dynamic_cast<PIVOTIVD*>(core->m_arPIVOTIVD[index_ivd].get());
ivd->serialize(CP_XML_STREAM());
}
}
if (core->m_arPIVOTLI.size() == 2)//0 or 2
if (view->cCol > 0 && index_tli < core->m_arPIVOTLI.size())
{
CP_XML_NODE(L"colItems")
{
CP_XML_ATTR(L"count", view->cCol);
PIVOTLI* line = dynamic_cast<PIVOTLI*>(core->m_arPIVOTLI[1].get());
PIVOTLI* line = dynamic_cast<PIVOTLI*>(core->m_arPIVOTLI[index_tli].get());
line->serialize(CP_XML_STREAM());
}
}
......@@ -247,7 +259,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,18 @@ const bool SXOPER::loadContent(BinProcessor& proc)
else if(proc.optional<SxErr>())
{
SxErr* err = dynamic_cast<SxErr*>(elements_.back().get());
bNumber = true;
bString = true;
node = L"e";
value = std::to_wstring(err->wbe);
switch(err->wbe)
{
case 0x00: value = L"NULL!"; break;
case 0x07: value = L"#DIV/0!"; break;
case 0x0F: value = L"#VALUE!"; break;
case 0x17: value = L"#REF!"; break;
case 0x1D: value = L"#NAME?"; break;
case 0x24: value = L"#NUM!"; break;
case 0x2A: value = L"#N/A"; break;
}
}
else if(proc.optional<SXString>())
{
......@@ -146,5 +155,20 @@ int SXOPER::serialize(std::wostream & strm)
return 0;
}
int SXOPER::serialize_record(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(node)
{
if (!value.empty() || bString)
{
CP_XML_ATTR(L"v", value);
}
}
}
return 0;
}
} // namespace XLS
......@@ -48,6 +48,7 @@ public:
virtual const bool loadContent(BinProcessor& proc);
int serialize(std::wostream & strm);
int serialize_record(std::wostream & strm);
static const ElementType type = typeSXOPER;
......
......@@ -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,99 @@ 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[j].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());
}
if (bin)
{
switch(bin->nBuiltin)
{
case 0x0000: CP_XML_ATTR(L"name", L"_xlnm.Consolidate_Area"); break;
case 0x0001: CP_XML_ATTR(L"name", L"_xlnm.Auto_Open"); break;
case 0x0002: CP_XML_ATTR(L"name", L"_xlnm.Auto_Close"); break;
case 0x0003: CP_XML_ATTR(L"name", L"_xlnm.Extract"); break;
case 0x0004: CP_XML_ATTR(L"name", L"_xlnm.Database"); break;
case 0x0005: CP_XML_ATTR(L"name", L"_xlnm.Criteria"); break;
case 0x0006: CP_XML_ATTR(L"name", L"_xlnm.Print_Area"); break;
case 0x0007: CP_XML_ATTR(L"name", L"_xlnm.Print_Titles"); break;
case 0x0008: CP_XML_ATTR(L"name", L"_xlnm.Recorder"); break;
case 0x0009: CP_XML_ATTR(L"name", L"_xlnm.Data_Form"); break;
case 0x000a: CP_XML_ATTR(L"name", L"_xlnm.Auto_Activate"); break;
case 0x000b: CP_XML_ATTR(L"name", L"_xlnm.Auto_Deactivate"); break;
case 0x000c: CP_XML_ATTR(L"name", L"_xlnm.Sheet_Title"); break;
case 0x000d: CP_XML_ATTR(L"name", L"_xlnm._FilterDatabase"); break; //??
}
}
if (ref)
{
ref->check_external();
CP_XML_ATTR(L"ref", ref->ref.toString());
CP_XML_ATTR(L"sheet", ref->sheet_name);
if (ref->index_external >= 0)
{
CP_XML_ATTR(L"r:id", L"extId" + std::to_wstring(ref->index_external + 1));
}
}
}
}
}
}
}
}
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;
......
......@@ -324,6 +324,13 @@ void ChartSheetSubstream::recalc(CHARTFORMATS* charts)
int iCrt = -1;
if (charts->m_arSERIESFORMAT.empty() && !parent0->m_arCRT.empty())
{
std::vector<int> ser;
m_mapTypeChart.insert(std::make_pair(0, ser));
return;
}
for (size_t i = 0 ; i < charts->m_arSERIESFORMAT.size(); i++)
{
SERIESFORMAT * series = dynamic_cast<SERIESFORMAT *>(charts->m_arSERIESFORMAT[i].get());
......@@ -334,7 +341,7 @@ void ChartSheetSubstream::recalc(CHARTFORMATS* charts)
if ( serCrt == NULL)
{
//для доп линий может и не существовать - брать предыдущий - и объеденить!!!
std::map<int,std::vector<int>>::iterator it = m_mapTypeChart.find(iCrt);
std::unordered_map<int,std::vector<int>>::iterator it = m_mapTypeChart.find(iCrt);
if (it != m_mapTypeChart.end())
{
SERIESFORMAT * series_prev = dynamic_cast<SERIESFORMAT *>(charts->m_arSERIESFORMAT[it->second.back()].get());
......@@ -359,12 +366,12 @@ void ChartSheetSubstream::recalc(CHARTFORMATS* charts)
CRT * crt = dynamic_cast<CRT*>(parent0->m_arCRT[iCrt].get());
std::map<int,std::vector<int>>::iterator it = m_mapTypeChart.find(iCrt);
std::unordered_map<int,std::vector<int>>::iterator it = m_mapTypeChart.find(iCrt);
if (it == m_mapTypeChart.end())
{
std::vector<int> ser;
ser.push_back(i);
m_mapTypeChart.insert(std::pair<int, std::vector<int>>(iCrt, ser));
m_mapTypeChart.insert(std::make_pair(iCrt, ser));
}
else
{
......@@ -507,7 +514,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());
......@@ -545,11 +552,11 @@ int ChartSheetSubstream::serialize_3D (std::wostream & _stream)
CP_XML_ATTR (L"val" , chart3D->anElev);
}
}
if (chart3D->pcHeight != 100)
if (chart3D->pcHeight3D != 100 && chart3D->pcHeight3D >= 5 && chart3D->pcHeight3D <= 500)
{
CP_XML_NODE(L"c:hPercent")
{
CP_XML_ATTR (L"val" , chart3D->pcHeight);
CP_XML_ATTR (L"val" , chart3D->pcHeight3D);
}
}
if (chart3D->anRot != 0)
......@@ -662,7 +669,7 @@ int ChartSheetSubstream::serialize_legend (std::wostream & _stream, const std::w
//}
//todooo разобраться с разными типами в одном чарте .. считать количество серий??
std::map< int, std::vector<int>>::iterator it = m_mapTypeChart.begin();
std::unordered_map< int, std::vector<int>>::iterator it = m_mapTypeChart.begin();
if (it != m_mapTypeChart.end())
{
CRT * crt = dynamic_cast<CRT*>(parent0->m_arCRT[it->first].get());
......@@ -746,7 +753,7 @@ int ChartSheetSubstream::serialize_plot_area (std::wostream & _stream)
PlotAreaPos->serialize(CP_XML_STREAM());
}
for (std::map<int, std::vector<int>>::iterator it = m_mapTypeChart.begin(); it != m_mapTypeChart.end(); it++)
for (std::unordered_map<int, std::vector<int>>::iterator it = m_mapTypeChart.begin(); it != m_mapTypeChart.end(); it++)
{
CRT * crt = dynamic_cast<CRT*>(parent0->m_arCRT[it->first].get());
......@@ -871,7 +878,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 +890,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 +949,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")
{
......@@ -962,7 +969,7 @@ int ChartSheetSubstream::serialize_dPt(std::wostream & _stream, int id, CRT *crt
CP_XML_ATTR(L"val", series_data_format->xi);
if (format->fVaried)
present_idx.insert(std::pair<int, bool>(series_data_format->xi, true));
present_idx.insert(std::make_pair(series_data_format->xi, true));
}
series_ss->serialize (CP_XML_STREAM(), crt->m_iChartType, series_data_format->xi);
series_ss->serialize2 (CP_XML_STREAM(), crt->m_iChartType);
......@@ -1088,7 +1095,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")
{
......
......@@ -32,6 +32,7 @@
#pragma once
#include <Logic/CompositeObject.h>
#include <unordered_map>
namespace XLS
{;
......@@ -86,7 +87,7 @@ private:
void recalc(CHARTFORMATS* charts);
void recalc(SERIESDATA* data);
std::map<int, std::vector<int>> m_mapTypeChart;//тут нужен несортированый .. пока оставим этот
std::unordered_map<int, std::vector<int>> m_mapTypeChart;
GlobalWorkbookInfoPtr pGlobalWorkbookInfo;
};
......
......@@ -165,12 +165,12 @@ const size_t GlobalWorkbookInfo::RegisterFillId(const FillInfo& fill)
void GlobalWorkbookInfo::RegisterFontColorId (int id, const FillInfoExt & font_color)
{
fonts_color_ext.insert(std::pair<int, FillInfoExt>(id, font_color));
fonts_color_ext.insert(std::make_pair(id, font_color));
}
void GlobalWorkbookInfo::RegisterPaletteColor(int id, const std::wstring & rgb)
{
colors_palette.insert(std::pair<int, std::wstring>(id, rgb));
colors_palette.insert(std::make_pair(id, rgb));
}
unsigned int GlobalWorkbookInfo::GenerateAXESId()
......
......@@ -116,7 +116,8 @@ public:
std::vector<_sx_name> arPivotSxNames;
std::vector<std::wstring> arPivotCacheSxNames;
std::vector<std::wstring> arPivotCacheReferences;
std::unordered_map<std::wstring, std::wstring> mapPivotCacheExternal;
std::map<std::wstring, std::vector<std::wstring>> mapDefineNames;
std::vector<std::wstring> arDefineNames;
......
......@@ -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)
......@@ -1968,4 +1977,9 @@ void XlsConverter::convert(XLS::PIVOTCACHEDEFINITION * pivot_cached)
pivot_cached->serialize_records(strmR);
xlsx_context->get_pivots_context().add_cache(strmD.str(), strmR.str());
if (!xls_global_info->mapPivotCacheExternal.empty())
{
xlsx_context->get_pivots_context().add_cache_external(xls_global_info->mapPivotCacheExternal);
}
}
\ No newline at end of file
......@@ -43,8 +43,12 @@ class xlsx_pivots_context::Impl
public:
struct _pivot_cache
{
std::wstring definitionsData_;
std::wstring recordsData_;
_pivot_cache(const std::wstring & def, const std::wstring & rec) : definitions_(def), records_(rec) {}
std::wstring definitions_;
std::wstring records_;
std::unordered_map<std::wstring, std::wstring> externals_;
};
struct _pivot_view
{
......@@ -65,9 +69,15 @@ xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl
void xlsx_pivots_context::add_cache(std::wstring definitions, std::wstring records)
{
Impl::_pivot_cache c = {definitions, records};
if (definitions.empty()) return;
Impl::_pivot_cache c(definitions, records);
impl_->caches_.push_back(c);
}
void xlsx_pivots_context::add_cache_external(std::unordered_map<std::wstring, std::wstring> &externals)
{
impl_->caches_.back().externals_ = externals;
}
int xlsx_pivots_context::get_cache_count()
{
......@@ -79,12 +89,20 @@ bool xlsx_pivots_context::is_connections()
}
void xlsx_pivots_context::dump_rels_cache(int index, rels & Rels)
{
if (impl_->caches_[index].recordsData_.empty() == false)
if (impl_->caches_[index].records_.empty() == false)
{
Rels.add(relationship(L"rId1",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords",
L"pivotCacheRecords" + std::to_wstring(index + 1) + L".xml", L""));
}
int i = 0;
for (std::unordered_map<std::wstring, std::wstring>::iterator it = impl_->caches_[index].externals_.begin();
it != impl_->caches_[index].externals_.end(); it++, i++)
{
Rels.add(relationship(L"extId" + std::to_wstring(i + 1),
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath",
it->second, L"External"));
}
}
void xlsx_pivots_context::dump_rels_view(int index, rels & Rels)
{
......@@ -97,7 +115,7 @@ void xlsx_pivots_context::dump_rels_view(int index, rels & Rels)
}
void xlsx_pivots_context::write_cache_definitions_to(int index, std::wostream & strm)
{
strm << impl_->caches_[index].definitionsData_;
strm << impl_->caches_[index].definitions_;
}
void xlsx_pivots_context::write_connections_to(std::wostream & strm)
{
......@@ -114,7 +132,7 @@ void xlsx_pivots_context::write_connections_to(std::wostream & strm)
void xlsx_pivots_context::write_cache_records_to(int index, std::wostream & strm)
{
strm << impl_->caches_[index].recordsData_;
strm << impl_->caches_[index].records_;
}
void xlsx_pivots_context::write_table_view_to(int index, std::wostream & strm)
{
......
......@@ -31,6 +31,7 @@
*/
#pragma once
#include "oox_package.h"
#include <unordered_map>
namespace oox {
......@@ -47,6 +48,8 @@ public:
int get_view_count();
void add_cache(std::wstring definitions, std::wstring records);
void add_cache_external(std::unordered_map<std::wstring, std::wstring> &externals);
int get_cache_count();
void write_cache_definitions_to (int index, std::wostream & strm);
......
......@@ -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