Commit a2c22962 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormatReader - fix dublicate styles

parent a3274076
......@@ -144,6 +144,33 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
return true;
}
void FORMATTING::concatinate(FORMATTING* ext)
{
if (ext->m_XFS)
{
if (!m_XFS)
m_XFS = ext->m_XFS;
else
{
XFS * xf = dynamic_cast<XFS*>(m_XFS.get());
XFS * xf_ext = dynamic_cast<XFS*>(ext->m_XFS.get());
}
}
if (ext->m_Styles)
{
if (!m_Styles)
m_Styles = ext->m_Styles;
else
{
STYLES * st = dynamic_cast<STYLES*>(m_Styles.get());
STYLES * st_ext = dynamic_cast<STYLES*>(ext->m_Styles.get());
if (st && st_ext)
st->elements_.insert(st->elements_.end(), st_ext->elements_.begin(), st_ext->elements_.end());
}
}
}
int FORMATTING::serialize1(std::wostream & stream)
{
CP_XML_WRITER(stream)
......
......@@ -52,6 +52,8 @@ public:
int serialize1(std::wostream & stream);
int serialize2(std::wostream & stream);
void concatinate(FORMATTING* ext);
static const ElementType type = typeFORMATTING;
BaseObjectPtr m_Styles;
......
......@@ -48,19 +48,24 @@ public:
const bool loadContent(BinProcessor& proc)
{
if(proc.mandatory<Style>())
bool res = false;
if(proc.optional<Style>())
{
m_Style = elements_.back();
elements_.pop_back();
}else return false;
res = true;
}
if (proc.optional<StyleExt>())
{
m_StyleEx = elements_.back();
elements_.pop_back();
res = true;
}
return true;
return res;
};
BaseObjectPtr m_StyleEx;
......@@ -79,7 +84,8 @@ const bool STYLES::loadContent(BinProcessor& proc)
{
styles_count = proc.repeated<Parenthesis_STYLES_1>(0, 0);
return true;
if (styles_count > 0) return true;
else return false;
}
int STYLES::serialize(std::wostream & stream)
......@@ -121,7 +127,7 @@ int STYLES::serialize(std::wostream & stream)
//{
//}
}
else
else if (style)
{
CP_XML_ATTR(L"name", style->user.value());
......@@ -134,6 +140,9 @@ int STYLES::serialize(std::wostream & stream)
}
}
}
if (style)
{
int xfId = style->ixfe - 1;
if (xfId < 0) xfId = 0;
......@@ -142,6 +151,7 @@ int STYLES::serialize(std::wostream & stream)
}
}
}
}
else
{
CP_XML_ATTR(L"count",1);
......
......@@ -63,8 +63,8 @@ const bool XFS::loadContent(BinProcessor& proc)
{
GlobalWorkbookInfoPtr global_info = proc.getGlobalWorkbookInfo();
global_info->cellStyleXfs_count = 0;
global_info->cellXfs_count = 0;
int cellStyleXfs_count = 0;
int cellXfs_count = 0;
XF xf(cell_xf_current_id, style_xf_current_id);
int count = proc.repeated(xf ,16, 0);
......@@ -80,18 +80,24 @@ const bool XFS::loadContent(BinProcessor& proc)
if (xfs->fStyle)
{
m_arCellStyles.push_back(elements_.front());
global_info->cellStyleXfs_count++;
cellStyleXfs_count++;
}
else
{
m_arCellXFs.push_back(elements_.front());
global_info->cellXfs_count++;
cellXfs_count++;
}
elements_.pop_front();
count--;
}
if (cellXfs_count > 0)
global_info->cellXfs_count = cellXfs_count;
if (cellStyleXfs_count > 0)
global_info->cellStyleXfs_count = cellStyleXfs_count;
if(proc.optional<XFCRC>())
{
elements_.pop_back(); // Crc не нужен
......
......@@ -318,17 +318,32 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
{
if (proc.mandatory<FORMATTING>())
{
if (!m_Formating )//todooo concatinate?
if (!m_Formating )
{
m_Formating = elements_.back();
elements_.pop_back();
FORMATTING* fmts = dynamic_cast<FORMATTING*>(m_Formating.get());
if (fmts)
{
proc.getGlobalWorkbookInfo()->cellStyleDxfs_count = fmts->m_arDXF.size(); // + будут юзерские
proc.getGlobalWorkbookInfo()->cellStyleDxfs_count = fmts->m_arDXF.size();
proc.getGlobalWorkbookInfo()->m_arFonts = &fmts->m_arFonts;
}
}
//else
//{
// FORMATTING* fmts = dynamic_cast<FORMATTING*>(m_Formating.get());
// FORMATTING* fmts_add = dynamic_cast<FORMATTING*>(elements_.back().get());
// if (fmts && fmts_add)
// {
// fmts->concatinate(fmts_add);
// elements_.pop_back();
// proc.getGlobalWorkbookInfo()->cellStyleDxfs_count = fmts->m_arDXF.size();
// proc.getGlobalWorkbookInfo()->m_arFonts = &fmts->m_arFonts;
// }
//}
}
}break;
case rt_SXStreamID: proc.repeated<PIVOTCACHEDEFINITION>(0, 0); break;
......
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