Esempio n. 1
0
/*
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;
}
/*
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;
}