diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Style.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Style.h index 480a0a8b16..5700b51009 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Style.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Style.h @@ -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 diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/TableStyles.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/TableStyles.cpp index 62ed06ea6c..b3a021d5d9 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/TableStyles.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/TableStyles.cpp @@ -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; } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Theme.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Theme.cpp index d4eac4eb9c..4f8b34fb79 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Theme.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Theme.cpp @@ -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."); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XF.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XF.cpp index a981349eb0..9c228ae6f7 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XF.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XF.cpp @@ -33,6 +33,7 @@ void XF::writeFields(CFRecord& record) SETBITS(flags, 4, 15, ixfParent); record << ifnt << ifmt << flags; + if(fStyle) { style.store(record); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XF.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XF.h index 4a653a0ab7..836cafb95a 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XF.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XF.h @@ -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 diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XFExt.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XFExt.h index 0a168c2649..146ef253f8 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XFExt.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/XFExt.h @@ -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; }; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CellXF.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CellXF.h index a71e8422fc..dd4c5e0e31 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CellXF.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CellXF.h @@ -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; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/AUTOFILTER_bu.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/AUTOFILTER_bu.cpp index 54c432fd96..64ecbcdf09 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/AUTOFILTER_bu.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/AUTOFILTER_bu.cpp @@ -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) { diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FORMATTING.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FORMATTING.cpp index d8f4b98c29..d62a69c171 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FORMATTING.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FORMATTING.cpp @@ -84,10 +84,16 @@ const bool FORMATTING::loadContent(BinProcessor& proc) elements_.pop_back(); } //---------------------------------------------------------------------------------------------------- - proc.optional(); + if (proc.optional()) + { + m_TABLESTYLES = elements_.back(); + elements_.pop_back(); + } if (proc.optional()) // не по стандарту - china_price.xls { + m_THEME = elements_.back(); + elements_.pop_back(); } proc.optional(); //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) { diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FORMATTING.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FORMATTING.h index 71dcd8c906..a197142445 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FORMATTING.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FORMATTING.h @@ -30,6 +30,8 @@ public: BaseObjectPtr m_Palette; BaseObjectPtr m_ClrtClient; std::vector m_arDXF; + BaseObjectPtr m_TABLESTYLES; + BaseObjectPtr m_THEME; GlobalWorkbookInfoPtr global_info; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/STYLES.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/STYLES.cpp index 4dee48bd19..e52e1cfb1f 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/STYLES.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/STYLES.cpp @@ -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); } } } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/TABLESTYLES.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/TABLESTYLES.h index 22ffba5614..cdf874f727 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/TABLESTYLES.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/TABLESTYLES.h @@ -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 elements_; + }; + std::vector<_table_style> m_arTableStyles; }; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/TABLESTYLES_bu.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/TABLESTYLES_bu.cpp index 4151a7e0eb..8d782eb74f 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/TABLESTYLES_bu.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/TABLESTYLES_bu.cpp @@ -34,7 +34,7 @@ public: { return false; } - proc.repeated(0, 28); + int count = proc.repeated(0, 28); return true; }; }; @@ -47,15 +47,58 @@ BaseObjectPtr TABLESTYLES::clone() // TABLESTYLES = TableStyles *(TableStyle *28TableStyleElement) + const bool TABLESTYLES::loadContent(BinProcessor& proc) { if(!proc.mandatory()) { return false; } - proc.repeated(0, 0); + + m_TableStyles = elements_.back(); + elements_.pop_back(); + + int count = proc.repeated(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(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 diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/THEME.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/THEME.h index 42c72cdfc6..079c3c39e4 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/THEME.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/THEME.h @@ -19,6 +19,8 @@ public: virtual const bool loadContent(BinProcessor& proc); static const ElementType type = typeTHEME; + + BaseObjectPtr m_Theme; }; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/THEME_bu.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/THEME_bu.cpp index 64efa4797e..33e2007d95 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/THEME_bu.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/THEME_bu.cpp @@ -30,6 +30,9 @@ const bool THEME::loadContent(BinProcessor& proc) { return false; } + m_Theme = elements_.back(); + elements_.pop_back(); + proc.repeated(0, 0); return true; } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/XFS.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/XFS.cpp index 7d179f22e2..c4fb6fc69b 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/XFS.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/XFS.cpp @@ -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) { //разделить style & complex XF* xfs = dynamic_cast(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(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(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(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(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(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(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(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) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.cpp index 1d50a7a662..983a86ffcd 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.cpp @@ -305,7 +305,7 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc) if (proc.optional()) { - m_Theme = elements_.back(); + m_THEME = elements_.back(); elements_.pop_back(); } proc.optional(); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.h index 83b7d9774d..8c772b8551 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.h @@ -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; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp index a447142e7b..049dc70ca8 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp @@ -200,8 +200,12 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) count--; } - proc.optional(); //BulletinSearch.xls ??? тута или ниже - + if (proc.optional())//BulletinSearch.xls ??? тута или ниже + { + m_SheetExt = elements_.back(); + elements_.pop_back(); + } + count = proc.repeated(0, 0); while(count > 0) { diff --git a/ASCOfficeXlsFile2/source/XlsXlsxConverter/XlsConverter.cpp b/ASCOfficeXlsFile2/source/XlsXlsxConverter/XlsConverter.cpp index 338e85223f..005bfa8544 100644 --- a/ASCOfficeXlsFile2/source/XlsXlsxConverter/XlsConverter.cpp +++ b/ASCOfficeXlsFile2/source/XlsXlsxConverter/XlsConverter.cpp @@ -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()); diff --git a/ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_conversion_context.cpp b/ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_conversion_context.cpp index 6e80ea5319..f1c1379a73 100644 --- a/ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_conversion_context.cpp +++ b/ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_conversion_context.cpp @@ -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_; + } } } }