/* GLOBALS = CalcMode CalcCount CalcRefMode CalcIter CalcDelta CalcSaveRecalc PrintRowCol PrintGrid GridSet Guts DefaultRowHeight WsBool [Sync] [LPr] [HorizontalPageBreaks] [VerticalPageBreaks] */ const bool GLOBALS::loadContent(BinProcessor& proc) { global_info_ = proc.getGlobalWorkbookInfo(); while (true) { CFRecordType::TypeId type = proc.getNextRecordType(); if (type == rt_NONE) break; switch(type) { case rt_CalcMode: proc.optional<CalcMode>(); break; case rt_CalcCount: proc.optional<CalcCount>(); break; case rt_CalcRefMode: proc.optional<CalcRefMode>(); break; case rt_CalcIter: proc.optional<CalcIter>(); break; case rt_CalcDelta: proc.optional<CalcDelta>(); break; case rt_CalcSaveRecalc: proc.optional<CalcSaveRecalc>(); break; case rt_PrintRowCol: proc.optional<PrintRowCol>(); break; case rt_PrintGrid: proc.optional<PrintGrid>(); break; case rt_GridSet: proc.optional<GridSet>(); break; case rt_Sync: proc.optional<Sync>(); break; case rt_LPr: proc.optional<LPr>(); break; case rt_Guts: { if (proc.optional<Guts>()) { m_Guts = elements_.back(); elements_.pop_back(); } }break; case rt_DefaultRowHeight: { if (proc.optional<DefaultRowHeight>()) { m_DefaultRowHeight = elements_.back(); elements_.pop_back(); } }break; case rt_WsBool: { WsBool wsbool(is_dialog); if (proc.optional(wsbool)) // The most interesting { m_WsBool = elements_.back(); elements_.pop_back(); } }break; case rt_HorizontalPageBreaks: proc.optional<HorizontalPageBreaks>(); break; case rt_VerticalPageBreaks: proc.optional<VerticalPageBreaks>(); break; default://unknown .... back upper return true; } } return true; }
// GELFRAME = 1*2GelFrame *Continue [PICF] const bool GELFRAME::loadContent(BinProcessor& proc) { global_info = proc.getGlobalWorkbookInfo(); if(!proc.mandatory<GelFrame>()) { return false; } m_GelFrame = elements_.back(); elements_.pop_back(); if (proc.optional<GelFrame>()) { GelFrame * base = dynamic_cast<GelFrame*>(m_GelFrame.get()); GelFrame * addit = dynamic_cast<GelFrame*>(elements_.back().get()); if (base && addit) { base->concatinate(addit); } elements_.pop_back(); } // int count = proc.repeated<Continue>(0, 0); if (proc.optional<PICF>()) { m_PICF = elements_.back(); elements_.pop_back(); } return true; }
// SXADDLSXDH = SXAddl_SXCSXDH_SXDId *SXAddl_SXCSXDH_SXDSxdh SXAddl_SXCSXDH_SXDEnd const bool SXADDLSXDH::loadContent(BinProcessor& proc) { bool result = false; while (true) { CFRecordType::TypeId type = proc.getNextRecordType(); if (type == rt_SXAddl) { result = true; proc.optional<SXAddl>(); SXAddl* addl = dynamic_cast<SXAddl*>(elements_.back().get()); if (!addl) continue; if (addl->bEndElement) break; } else { break; } } return result; }
// SXADDLQSI = SXAddl_SXCQsi_SXDId SXADDLDBQUERY *UNKNOWNFRT SXAddl_SXCQsi_SXDEnd const bool SXADDLQSI::loadContent(BinProcessor& proc) { bool result = false; int level = 0; while (true) { CFRecordType::TypeId type = proc.getNextRecordType(); if (type != rt_SXAddl) break; proc.optional<SXAddl>(); SXAddl* addl = dynamic_cast<SXAddl*>(elements_.back().get()); if (!addl) continue; if (result && addl->bStartElement) { level++; _sxAddl elm(current, level); current = ¤t->back().levels; current->push_back(elm); elements_.pop_back(); continue; } result = true; if (addl->bEndElement) { elements_.pop_back(); if (level == 0) break; else level--; current = current->back().prev; continue; } if (level == 0) { SXAddl_SXCQsi_SXDId* p0 = dynamic_cast<SXAddl_SXCQsi_SXDId*>(addl->content.get()); if (p0) { m_SXAddl_SXCQsi_SXDId = addl->content; } } current->back().elements.push_back(elements_.back()); elements_.pop_back(); } current = NULL; return result; }
// TEXTOBJECT = TxO *Continue const bool TEXTOBJECT::loadContent(BinProcessor& proc) { TxO TxO_(mso_drawing_); if(!proc.mandatory(TxO_)) { return false; } m_TxO = elements_.back(); elements_.pop_back(); //proc.repeated<Continue>(0, 0); return true; }
/* WORKSHEETCONTENT = [Uncalced] Index GLOBALS PAGESETUP [HeaderFooter] [BACKGROUND] *BIGNAME [PROTECTION] COLUMNS [SCENARIOS] SORTANDFILTER Dimensions [CELLTABLE] OBJECTS *HFPicture *Note *PIVOTVIEW [DCON] 1*WINDOW *CUSTOMVIEW *2SORT [DxGCol] *MergeCells [LRng] *QUERYTABLE [PHONETICINFO] CONDFMTS *HLINK [DVAL] [CodeName] *WebPub *CellWatch [SheetExt] *FEAT *FEAT11 *RECORD12 EOF WORKSHEET = BOF WORKSHEETCONTENT */ const bool WorksheetSubstream::loadContent(BinProcessor& proc) { GlobalWorkbookInfoPtr global_info = proc.getGlobalWorkbookInfo(); GlobalWorkbookInfo::_sheet_size_info sheet_size_info; global_info->sheet_size_info.push_back(sheet_size_info); global_info->current_sheet = global_info->sheet_size_info.size(); global_info->cmt_rules = 0; int count = 0; std::vector<CellRangeRef> shared_formulas_locations; if(!proc.mandatory<BOF>()) { return false; } while (true) { CFRecordType::TypeId type = proc.getNextRecordType(); if (type == rt_NONE || type == rt_BOF) //следующий пошел?? break; if (type == rt_EOF) { proc.mandatory<EOF_T>(); break; } switch(type) { case rt_Uncalced: proc.optional<Uncalced>(); break; case rt_Index: proc.optional<Index>(); break; case rt_CalcRefMode: case rt_CalcMode: { GLOBALS globals(false); if (proc.mandatory(globals)) { m_GLOBALS = elements_.back(); elements_.pop_back(); } }break; case rt_Dimensions: { if (proc.optional<Dimensions>()) { m_Dimensions = elements_.back(); elements_.pop_back(); } }break; case rt_Window2: { count = proc.repeated<WINDOW>(0, 0); while(count > 0) { m_arWINDOW.insert(m_arWINDOW.begin(), elements_.back()); elements_.pop_back(); count--; } }break; case rt_DefColWidth: case rt_ColInfo: { if (proc.optional<COLUMNS>()) { if (!m_COLUMNS)//??? m_COLUMNS = elements_.back(); elements_.pop_back(); } }break; case rt_DefaultRowHeight: { if (proc.optional<DefaultRowHeight>()) { m_DefaultRowHeight = elements_.back(); elements_.pop_back(); } }break; case rt_Header: case rt_Footer: case rt_BottomMargin: case rt_TopMargin: case rt_LeftMargin: case rt_RightMargin: { if (proc.mandatory<PAGESETUP>()) { if (!m_PAGESETUP) m_PAGESETUP = elements_.back(); elements_.pop_back(); } }break; case rt_BkHim: { if (proc.optional<BACKGROUND>()) { m_BACKGROUND = elements_.back(); elements_.pop_back(); } }break; case rt_BigName: proc.repeated<BIGNAME>(0, 0); break; case rt_Protect: proc.optional<PROTECTION_COMMON>(); break; case rt_ScenMan: proc.optional<SCENARIOS>(); break; case rt_Sort: case rt_AutoFilterInfo: { if (proc.optional<SORTANDFILTER>())// Let it be optional { m_SORTANDFILTER = elements_.back(); elements_.pop_back(); } }break; case rt_Label://file(6).xls case rt_Row: { CELLTABLE cell_table(shared_formulas_locations); if (proc.optional(cell_table)) { m_CELLTABLE = elements_.back(); elements_.pop_back(); } if(0 != shared_formulas_locations.size()) { SHFMLA_SET shfmla_set(shared_formulas_locations); if (proc.optional(shfmla_set)) { m_SHFMLA_SET = elements_.back(); elements_.pop_back(); } } }break; case rt_Obj: case rt_MsoDrawing: { OBJECTS objects(false); if (proc.optional(objects)) { if (!m_OBJECTS) m_OBJECTS = elements_.back(); else { Log::warning(L"Double set OBJECTS!!!"); } elements_.pop_back(); } }break; case rt_HFPicture: proc.repeated<HFPicture>(0, 0); break; case rt_CommentText: { count = proc.repeated<CommentText>(0, 0); while(count > 0) { m_arNote.insert(m_arNote.begin(), elements_.back()); elements_.pop_back(); count--; } }break; case rt_Note: { count = proc.repeated<Note>(0, 0); while(count > 0) { m_arNote.insert(m_arNote.begin(), elements_.back()); elements_.pop_back(); count--; } }break; case rt_SxView: proc.repeated<PIVOTVIEW>(0, 0); break; case rt_DCon: proc.optional<DCON> (); break; case rt_UserSViewBegin: { count = proc.repeated<CUSTOMVIEW>(0, 0); while(count > 0) { m_arCUSTOMVIEW.insert(m_arCUSTOMVIEW.begin(), elements_.back()); elements_.pop_back(); count--; } }break; case rt_RRSort: { count = proc.repeated<SORT>(0, 2); while(count > 0) { m_arSORT.insert(m_arSORT.begin(), elements_.back()); elements_.pop_back(); count--; } }break; case rt_DxGCol: { if (proc.optional<DxGCol>()) { m_DxGCol = elements_.back(); elements_.pop_back(); DxGCol* dx = dynamic_cast<DxGCol*>(m_DxGCol.get()); global_info->sheet_size_info.back().defaultColumnWidth = dx->dxgCol / 256.; } }break; case rt_MergeCells: { count = proc.repeated<MergeCells>(0, 0); while(count > 0) { MergeCells* m = dynamic_cast<MergeCells*>(elements_.back().get()); if ((m) && (m->rgref.size() > 0)) { m_arMergeCells.insert(m_arMergeCells.begin(), elements_.back()); } elements_.pop_back(); count--; } }break; case rt_LRng: proc.optional<LRng> (); break; case rt_Qsi: proc.repeated<QUERYTABLE> (0, 0); break; case rt_PhoneticInfo: proc.optional<PHONETICINFO> (); break; case rt_CondFmt: case rt_CondFmt12: { if (proc.optional<CONDFMTS>()) { m_CONDFMTS = elements_.back(); elements_.pop_back(); } }break; case rt_HLink: { count = proc.repeated<HLINK>(0, 0) ; while(count > 0) { m_arHLINK.insert(m_arHLINK.begin(), elements_.back()); elements_.pop_back(); count--; } }break; case rt_DVal: proc.optional<DVAL>(); break; case rt_CodeName: { if (proc.optional<CodeName> ()) { m_CodeName = elements_.back(); elements_.pop_back(); } }break; case rt_WebPub: proc.repeated<WebPub> (0, 0); break; case rt_CellWatch: proc.repeated<CellWatch>(0, 0); break; //case ExternCount:0x16 // { // }break; case rt_SheetExt: { if (proc.optional<SheetExt>()) { m_SheetExt = elements_.back(); elements_.pop_back(); } }break; case rt_FeatHdr: { count = proc.repeated<FEAT> (0, 0); while(count > 0) { m_arFEAT.insert(m_arFEAT.begin(), elements_.back()); elements_.pop_back(); count--; } }break; case rt_FeatHdr11: { count = proc.repeated<FEAT11> (0, 0); while(count > 0) { m_arFEAT11.insert(m_arFEAT11.begin(), elements_.back()); elements_.pop_back(); count--; } }break; case rt_HeaderFooter: proc.repeated<RECORD12> (0, 0); break; default://unknown .... skip { proc.SkipRecord(); }break; } } return true; }
const bool WorkbookStreamObject::loadContent(BinProcessor& proc) { GlobalWorkbookInfoPtr global_info_ = proc.getGlobalWorkbookInfo(); bool GlobalsSubstream_found = false; bool WorksheetSubstream_found = false; size_t ws_index = 0; GlobalWorkbookInfo::_sheet_info sheet_info; sheet_info.state = L"visible"; while(true) { unsigned short substream_type = 0; if (!proc.getNextSubstreamType(substream_type)) break; switch(substream_type) { case BOF::st_Workbook: { if(GlobalsSubstream_found) { Log::error("Multiple GLOBALS substreams found in intermediate XML."); return false; } Log::event("Globals substream detected"); GlobalsSubstream global_substream(code_page_); if((proc.mandatory(global_substream)) && (elements_.size() > 0)) { GlobalsSubstream_found = true; m_GlobalsSubstream = elements_.back(); elements_.pop_back(); } if (!GlobalsSubstream_found) return false; } break; case BOF::st_Worksheet: { if(!GlobalsSubstream_found) { Log::error("GLOBALS substream is not the first substream in intermediate XML."); return false; } Log::event("Worksheet or Dialog substream detected"); if (ws_index >= global_info_->sheets_info.size()) global_info_->sheets_info.push_back(sheet_info); WorksheetSubstream worksheet_substream(ws_index++); if ((proc.mandatory(worksheet_substream)) && (elements_.size() > 0)) { WorksheetSubstream_found = true; m_arWorksheetSubstream.push_back(elements_.back()); elements_.pop_back(); } } break; case BOF::st_Chart: { if(!GlobalsSubstream_found) { Log::error("GLOBALS substream is not the first substream in intermediate XML."); return false; } Log::event("Chart substream detected"); if (ws_index >= global_info_->sheets_info.size()) global_info_->sheets_info.push_back(sheet_info); ChartSheetSubstream chartsheet_substream(ws_index++); if ((proc.mandatory(chartsheet_substream)) && (elements_.size() > 0)) { WorksheetSubstream_found = true; m_arChartSheetSubstream.push_back(elements_.back()); elements_.pop_back(); } } break; case BOF::st_Macro: { if(!GlobalsSubstream_found) { Log::error("GLOBALS substream is not the first substream in intermediate XML."); return false; } Log::event("Macro substream detected"); if (ws_index >= global_info_->sheets_info.size()) global_info_->sheets_info.push_back(sheet_info); MacroSheetSubstream macrosheet_substream(ws_index++); if ((proc.mandatory(macrosheet_substream)) && (elements_.size() > 0)) { WorksheetSubstream_found = true; m_arMacroSheetSubstream.push_back(elements_.back()); elements_.pop_back(); } } break; default: if (substream_type != 0) { Log::warning("WARNING: Substream of unsupported type " + STR::int2str(substream_type, 10) + " The substream is skipped!"); } proc.SeekToEOF(); proc.optional<EOF_T>(); } } if(!GlobalsSubstream_found) { Log::error("GLOBALS substream hasn't been found in intermediate XML."); return false; } if(!WorksheetSubstream_found) { Log::error("There is no any sheet substream found in intermediate XML."); return false; } return true; }