Commit 396ec996 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

XlsFormat - fix error in style ext

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@68097 954022d7-b5bf-4e40-9824-e11837661b57
parent a2b2dd1a
...@@ -26,11 +26,11 @@ public: ...@@ -26,11 +26,11 @@ public:
int serialize(std::wostream & stream); int serialize(std::wostream & stream);
//----------------------------- //-----------------------------
BIFF_WORD ixfe; _UINT16 ixfe;
BuiltInStyle builtInData; BuiltInStyle builtInData;
XLUnicodeString user; XLUnicodeString user;
bool fBuiltIn; bool fBuiltIn;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -32,11 +32,14 @@ void TableStyles::readFields(CFRecord& record) ...@@ -32,11 +32,14 @@ void TableStyles::readFields(CFRecord& record)
{ {
record.skipNunBytes(12); record.skipNunBytes(12);
#pragma message("############################ frtHeader skipped here") #pragma message("############################ frtHeader skipped here")
unsigned short cchDefTableStyle; unsigned short cchDefTableStyle;
unsigned short cchDefPivotStyle; unsigned short cchDefPivotStyle;
record >> cts >> cchDefTableStyle >> cchDefPivotStyle; record >> cts >> cchDefTableStyle >> cchDefPivotStyle;
rgchDefTableStyle.setSize(cchDefTableStyle); rgchDefTableStyle.setSize(cchDefTableStyle);
rgchDefPivotStyle.setSize(cchDefPivotStyle); rgchDefPivotStyle.setSize(cchDefPivotStyle);
record >> rgchDefTableStyle >> rgchDefPivotStyle; record >> rgchDefTableStyle >> rgchDefPivotStyle;
} }
......
...@@ -35,6 +35,7 @@ void Theme::readFields(CFRecord& record) ...@@ -35,6 +35,7 @@ void Theme::readFields(CFRecord& record)
record.skipNunBytes(12); record.skipNunBytes(12);
#pragma message("############################ frtHeader skipped here") #pragma message("############################ frtHeader skipped here")
record >> dwThemeVersion; record >> dwThemeVersion;
if(!dwThemeVersion) if(!dwThemeVersion)
{ {
Log::info("\"Theme\" binary parsing is not implemented."); Log::info("\"Theme\" binary parsing is not implemented.");
......
...@@ -33,6 +33,7 @@ void XF::writeFields(CFRecord& record) ...@@ -33,6 +33,7 @@ void XF::writeFields(CFRecord& record)
SETBITS(flags, 4, 15, ixfParent); SETBITS(flags, 4, 15, ixfParent);
record << ifnt << ifmt << flags; record << ifnt << ifmt << flags;
if(fStyle) if(fStyle)
{ {
style.store(record); style.store(record);
......
...@@ -27,7 +27,6 @@ public: ...@@ -27,7 +27,6 @@ public:
static const ElementType type = typeXF; static const ElementType type = typeXF;
//-----------------------------
FontIndex ifnt; FontIndex ifnt;
BIFF_WORD ifmt; BIFF_WORD ifmt;
...@@ -40,6 +39,9 @@ public: ...@@ -40,6 +39,9 @@ public:
bool fStyle; bool fStyle;
bool f123Prefix; bool f123Prefix;
//-----------------------------
int ind_xf;//for ext
}; };
} // namespace XLS } // namespace XLS
......
...@@ -24,9 +24,9 @@ public: ...@@ -24,9 +24,9 @@ public:
static const ElementType type = typeXFExt; static const ElementType type = typeXFExt;
//----------------------------- //-----------------------------
BIFF_WORD ixfe; _UINT16 ixfe;
BIFF_WORD cexts; BIFF_WORD cexts;
BiffStructurePtrVector rgExt; BiffStructurePtrVector rgExt;
}; };
......
...@@ -25,21 +25,21 @@ public: ...@@ -25,21 +25,21 @@ public:
GlobalWorkbookInfoPtr m_GlobalWorkbookInfo; GlobalWorkbookInfoPtr m_GlobalWorkbookInfo;
unsigned char alc; unsigned char alc;
bool fWrap; bool fWrap;
unsigned char alcV; unsigned char alcV;
bool fJustLast; bool fJustLast;
unsigned char trot; unsigned char trot;
unsigned char cIndent; unsigned char cIndent;
bool fShrinkToFit; bool fShrinkToFit;
unsigned char iReadOrder; unsigned char iReadOrder;
bool fAtrNum; bool fAtrNum;
bool fAtrFnt; bool fAtrFnt;
bool fAtrAlc; bool fAtrAlc;
bool fAtrBdr; bool fAtrBdr;
bool fAtrPat; bool fAtrPat;
bool fAtrProt; bool fAtrProt;
BorderInfo border; BorderInfo border;
FillInfo fill; FillInfo fill;
...@@ -49,8 +49,8 @@ public: ...@@ -49,8 +49,8 @@ public:
FillInfoExt font_color; FillInfoExt font_color;
size_t font_id; size_t font_id;
bool fHasXFExt; bool fHasXFExt;
bool fsxButton; bool fsxButton;
size_t border_x_id; size_t border_x_id;
size_t fill_x_id; size_t fill_x_id;
......
...@@ -127,12 +127,27 @@ int AUTOFILTER::serialize(std::wostream & stream) ...@@ -127,12 +127,27 @@ int AUTOFILTER::serialize(std::wostream & stream)
std::wstring ref; std::wstring ref;
if (ind < it->second.size()) if (ind < it->second.size())
{
ref = it->second[ind]; //from current worksheet ref = it->second[ind]; //from current worksheet
}
if (ref.empty()) if (ref.empty())
{ {
ref = it->second[0]; //from workbook ref = it->second[0]; //from workbook
} }
if (ref.empty()) return 0;
std::wstring sheet_name = ind <= pGlobalWorkbookInfoPtr->sheets_names.size() ? pGlobalWorkbookInfoPtr->sheets_names[ind-1] : L"";
if (!sheet_name.empty())
{
int pos = ref.find(sheet_name);
if (pos >= 0)
{
pos = ref.find(L"!");
if (pos > 0)
ref.erase(0, pos + 1);
}
}
CP_XML_WRITER(stream) CP_XML_WRITER(stream)
{ {
......
...@@ -84,10 +84,16 @@ const bool FORMATTING::loadContent(BinProcessor& proc) ...@@ -84,10 +84,16 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
elements_.pop_back(); elements_.pop_back();
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
proc.optional<TABLESTYLES>(); if (proc.optional<TABLESTYLES>())
{
m_TABLESTYLES = elements_.back();
elements_.pop_back();
}
if (proc.optional<THEME>()) // - china_price.xls if (proc.optional<THEME>()) // - china_price.xls
{ {
m_THEME = elements_.back();
elements_.pop_back();
} }
proc.optional<Compat12>(); //china_price.xls proc.optional<Compat12>(); //china_price.xls
...@@ -167,7 +173,8 @@ int FORMATTING::serialize2(std::wostream & stream) ...@@ -167,7 +173,8 @@ int FORMATTING::serialize2(std::wostream & stream)
CP_XML_STREAM() << global_info->users_Dxfs_stream.str(); CP_XML_STREAM() << global_info->users_Dxfs_stream.str();
} }
} }
// tableStyles if (m_TABLESTYLES)
m_TABLESTYLES->serialize(stream);
if (m_Palette) if (m_Palette)
{ {
......
...@@ -30,6 +30,8 @@ public: ...@@ -30,6 +30,8 @@ public:
BaseObjectPtr m_Palette; BaseObjectPtr m_Palette;
BaseObjectPtr m_ClrtClient; BaseObjectPtr m_ClrtClient;
std::vector<BaseObjectPtr> m_arDXF; std::vector<BaseObjectPtr> m_arDXF;
BaseObjectPtr m_TABLESTYLES;
BaseObjectPtr m_THEME;
GlobalWorkbookInfoPtr global_info; GlobalWorkbookInfoPtr global_info;
......
...@@ -103,14 +103,10 @@ int STYLES::serialize(std::wostream & stream) ...@@ -103,14 +103,10 @@ int STYLES::serialize(std::wostream & stream)
} }
} }
} }
int xfId = style->ixfe - 1;
if (style->ixfe.value()) if (xfId < 0) xfId = 0;
{
int xfId = *style->ixfe.value() - 1;
if (xfId < 0) xfId = 0;
CP_XML_ATTR(L"xfId", xfId); CP_XML_ATTR(L"xfId", xfId);
}
} }
} }
} }
......
...@@ -19,6 +19,17 @@ public: ...@@ -19,6 +19,17 @@ public:
virtual const bool loadContent(BinProcessor& proc); virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeTABLESTYLES; static const ElementType type = typeTABLESTYLES;
int serialize(std::wostream & stream);
//----------------------------------------------------------------------------------
BaseObjectPtr m_TableStyles;
struct _table_style
{
BaseObjectPtr style_;
std::vector<BaseObjectPtr> elements_;
};
std::vector<_table_style> m_arTableStyles;
}; };
......
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
{ {
return false; return false;
} }
proc.repeated<TableStyleElement>(0, 28); int count = proc.repeated<TableStyleElement>(0, 28);
return true; return true;
}; };
}; };
...@@ -47,15 +47,58 @@ BaseObjectPtr TABLESTYLES::clone() ...@@ -47,15 +47,58 @@ BaseObjectPtr TABLESTYLES::clone()
// TABLESTYLES = TableStyles *(TableStyle *28TableStyleElement) // TABLESTYLES = TableStyles *(TableStyle *28TableStyleElement)
const bool TABLESTYLES::loadContent(BinProcessor& proc) const bool TABLESTYLES::loadContent(BinProcessor& proc)
{ {
if(!proc.mandatory<TableStyles>()) if(!proc.mandatory<TableStyles>())
{ {
return false; return false;
} }
proc.repeated<Parenthesis_TABLESTYLES_1>(0, 0);
m_TableStyles = elements_.back();
elements_.pop_back();
int count = proc.repeated<Parenthesis_TABLESTYLES_1>(0, 0);
while(!elements_.empty())
{
if (elements_.front()->get_type() == typeTableStyle)
{
_table_style new_style;
new_style.style_ = elements_.front();
m_arTableStyles.push_back(new_style);
}
else
{
if (m_arTableStyles.size() > 0)
m_arTableStyles.back().elements_.push_back(elements_.front());
}
elements_.pop_back();
}
return true; return true;
} }
int TABLESTYLES::serialize(std::wostream & stream)
{
TableStyles * styles = dynamic_cast<TableStyles*>(m_TableStyles.get());
if (!styles) return 0;
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"tableStyles")
{
CP_XML_ATTR(L"count", m_arTableStyles.size());
if (!styles->rgchDefPivotStyle.value().empty())
{
CP_XML_ATTR(L"defaultPivotStyle", styles->rgchDefPivotStyle.value());
}
if (!styles->rgchDefTableStyle.value().empty())
{
CP_XML_ATTR(L"defaultTableStyle", styles->rgchDefTableStyle.value());
}
}
}
return 0;
}
} // namespace XLS } // namespace XLS
...@@ -19,6 +19,8 @@ public: ...@@ -19,6 +19,8 @@ public:
virtual const bool loadContent(BinProcessor& proc); virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeTHEME; static const ElementType type = typeTHEME;
BaseObjectPtr m_Theme;
}; };
......
...@@ -30,6 +30,9 @@ const bool THEME::loadContent(BinProcessor& proc) ...@@ -30,6 +30,9 @@ const bool THEME::loadContent(BinProcessor& proc)
{ {
return false; return false;
} }
m_Theme = elements_.back();
elements_.pop_back();
proc.repeated<ContinueFrt12>(0, 0); proc.repeated<ContinueFrt12>(0, 0);
return true; return true;
} }
......
...@@ -37,11 +37,14 @@ const bool XFS::loadContent(BinProcessor& proc) ...@@ -37,11 +37,14 @@ const bool XFS::loadContent(BinProcessor& proc)
XF xf(cell_xf_current_id, style_xf_current_id); XF xf(cell_xf_current_id, style_xf_current_id);
int count = proc.repeated(xf ,16, 0); int count = proc.repeated(xf ,16, 0);
int ind = 0;
while (count > 0) while (count > 0)
{ {
// style & complex // style & complex
XF* xfs = dynamic_cast<XF*>(elements_.front().get()); XF* xfs = dynamic_cast<XF*>(elements_.front().get());
xfs->ind_xf = ind++;
if (xfs->fStyle) if (xfs->fStyle)
{ {
m_arCellStyles.push_back(elements_.front()); m_arCellStyles.push_back(elements_.front());
...@@ -72,34 +75,28 @@ const bool XFS::loadContent(BinProcessor& proc) ...@@ -72,34 +75,28 @@ const bool XFS::loadContent(BinProcessor& proc)
count--; count--;
} }
} }
//------------------------------------------------------------------------------------
int first_xf_ext = 0; int first_xf_ext = 0;
for (_UINT16 i = 0 ; i < m_arCellStyles.size(); i++) for (_UINT16 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());
if (m_arXFext.size() > 0 && xfs->cell.fHasXFExt) //if (m_arXFext.size() > 0 && xfs->style.fHasXFExt)
{ //{
XFExt *ext_find = NULL; // for (_UINT16 j = first_xf_ext ; j < m_arXFext.size(); j++)
// {
for (_UINT16 j = first_xf_ext ; j < m_arXFext.size(); j++) // XFExt *ext = dynamic_cast<XFExt*>(m_arXFext[j].get());
{ // if (ext->ixfe > i)break;
XFExt *ext = dynamic_cast<XFExt*>(m_arXFext[j].get());
if (ext->ixfe > i)break; // if (ext->ixfe == xfs->ind_xf)
// {
if (ext->ixfe == i) // xfs->style.ext_props = ext->rgExt;
{ // first_xf_ext = j + 1;
ext_find = ext; // break;
first_xf_ext = j + 1; // }
break; // }
} //}
}
if (ext_find)
{
xfs->style.ext_props = ext_find->rgExt;
}
}
xfs->style.RegisterFillBorder(); xfs->style.RegisterFillBorder();
//if (xfs->cell.font_id < 0xFFFF) //if (xfs->cell.font_id < 0xFFFF)
...@@ -114,20 +111,35 @@ const bool XFS::loadContent(BinProcessor& proc) ...@@ -114,20 +111,35 @@ const bool XFS::loadContent(BinProcessor& proc)
global_info->RegisterFontColorId(font_id, xfs->style.font_color); global_info->RegisterFontColorId(font_id, xfs->style.font_color);
}*/ }*/
} }
first_xf_ext = 0;
for (int i = 0 ; i < m_arCellXFs.size(); i++) for (int 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() > global_info->cellStyleXfs_count + i) ////////if (m_arXFext.size() > global_info->cellStyleXfs_count + i)
//////{
////// XFExt*ext = dynamic_cast<XFExt*>(m_arXFext[i + global_info->cellStyleXfs_count].get());
////// if (ext)
////// {
////// xfs->cell.ext_props = ext->rgExt;
////// }
//////}
if (m_arXFext.size() > 0 && xfs->cell.fHasXFExt)
{ {
XFExt*ext = dynamic_cast<XFExt*>(m_arXFext[i + global_info->cellStyleXfs_count].get()); for (_UINT16 j = first_xf_ext ; j < m_arXFext.size(); j++)
if (ext)
{ {
xfs->cell.ext_props = ext->rgExt; XFExt *ext = dynamic_cast<XFExt*>(m_arXFext[j].get());
if (ext->ixfe > i)break;
if (ext->ixfe == xfs->ind_xf)
{
xfs->cell.ext_props = ext->rgExt;
first_xf_ext = j + 1;
break;
}
} }
} }
xfs->cell.RegisterFillBorder(); xfs->cell.RegisterFillBorder();
//if (xfs->cell.font_id < 0xFFFF) //if (xfs->cell.font_id < 0xFFFF)
......
...@@ -305,7 +305,7 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc) ...@@ -305,7 +305,7 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
if (proc.optional<THEME>()) if (proc.optional<THEME>())
{ {
m_Theme = elements_.back(); m_THEME = elements_.back();
elements_.pop_back(); elements_.pop_back();
} }
proc.optional<CompressPictures>(); proc.optional<CompressPictures>();
......
...@@ -25,7 +25,7 @@ public: ...@@ -25,7 +25,7 @@ public:
static const ElementType type = typeGlobalsSubstream; static const ElementType type = typeGlobalsSubstream;
BaseObjectPtr m_Theme; BaseObjectPtr m_THEME;
BaseObjectPtr m_Formating; BaseObjectPtr m_Formating;
BaseObjectPtr m_Template; BaseObjectPtr m_Template;
BaseObjectPtr m_SHAREDSTRINGS; BaseObjectPtr m_SHAREDSTRINGS;
......
...@@ -200,8 +200,12 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) ...@@ -200,8 +200,12 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
count--; count--;
} }
proc.optional<SheetExt>(); //BulletinSearch.xls ??? if (proc.optional<SheetExt>())//BulletinSearch.xls ???
{
m_SheetExt = elements_.back();
elements_.pop_back();
}
count = proc.repeated<CUSTOMVIEW>(0, 0); count = proc.repeated<CUSTOMVIEW>(0, 0);
while(count > 0) while(count > 0)
{ {
......
...@@ -363,7 +363,7 @@ void XlsConverter::convert(XLS::GlobalsSubstream* global) ...@@ -363,7 +363,7 @@ void XlsConverter::convert(XLS::GlobalsSubstream* global)
convert((XLS::FORMATTING*)global->m_Formating.get()); convert((XLS::FORMATTING*)global->m_Formating.get());
convert((XLS::THEME*)global->m_Theme.get()); convert((XLS::THEME*)global->m_THEME.get());
convert((XLS::SHAREDSTRINGS*)global->m_SHAREDSTRINGS.get()); convert((XLS::SHAREDSTRINGS*)global->m_SHAREDSTRINGS.get());
......
...@@ -194,9 +194,15 @@ void xlsx_conversion_context::end_document() ...@@ -194,9 +194,15 @@ void xlsx_conversion_context::end_document()
{ {
CP_XML_STREAM() << xlsx_defined_names_.str(); CP_XML_STREAM() << xlsx_defined_names_.str();
} }
CP_XML_NODE(L"customWorkbookViews")
{ std::wstring str_ = xlsx_custom_views_.str();
CP_XML_STREAM() << xlsx_custom_views_.str();
if (!str_.empty())
{
CP_XML_NODE(L"customWorkbookViews")
{
CP_XML_STREAM() << str_;
}
} }
} }
} }
......
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