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