Commit c2c384d8 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov
parent 4d3c7799
...@@ -33,33 +33,51 @@ BaseObjectPtr FORMATTING::clone() ...@@ -33,33 +33,51 @@ BaseObjectPtr FORMATTING::clone()
//FORMATTING = 1*510Font 8*218Format XFS *DXF STYLES [TABLESTYLES] [Palette] [ClrtClient] //FORMATTING = 1*510Font 8*218Format XFS *DXF STYLES [TABLESTYLES] [Palette] [ClrtClient]
const bool FORMATTING::loadContent(BinProcessor& proc) const bool FORMATTING::loadContent(BinProcessor& proc)
{ {
//todooo - 2
int count = 0; int count = 0;
proc.repeated<Font>(0, 510); // Wrong records sequence workaround (originally at least one Font is mandatory) count = proc.repeated<Font>(0, 510); // Wrong records sequence workaround (originally at least one Font is mandatory)
while(count > 0)
{
m_Fonts.insert(m_Fonts.begin(), elements_.back());
elements_.pop_back();
count--;
}
//---------------------------------------------------------------------------------------------------
count = proc.repeated<Format>(0, 218); // Originally: proc.repeated<Format>(8, 218); count = proc.repeated<Format>(0, 218); // Originally: proc.repeated<Format>(8, 218);
while(count > 0) while(count > 0)
{ {
m_Formats.insert(m_Formats.begin(), elements_.back()); m_Formats.insert(m_Formats.begin(), elements_.back());
elements_.pop_back(); elements_.pop_back();
count--; count--;
} }
proc.repeated<Font>(0, 510); // Wrong records sequence workaround (originally Font follows by Format) //----------------------------------------------------------------------------------------------------
count = proc.repeated<Font>(0, 510); // Wrong records sequence workaround (originally Font follows by Format)
while(count > 0)
{
m_Fonts.insert(m_Fonts.begin(), elements_.back());
elements_.pop_back();
count--;
}
//----------------------------------------------------------------------------------------------------
if (proc.mandatory<XFS>()) if (proc.mandatory<XFS>())
{ {
m_XFS = elements_.back(); m_XFS = elements_.back();
elements_.pop_back(); elements_.pop_back();
} }
proc.repeated<DXF>(0, 0); proc.repeated<DXF>(0, 0);
//----------------------------------------------------------------------------------------------------
if (proc.optional<STYLES>()) if (proc.optional<STYLES>())
{ {
m_Styles = elements_.back(); m_Styles = elements_.back();
elements_.pop_back(); elements_.pop_back();
} }
//----------------------------------------------------------------------------------------------------
proc.optional<TABLESTYLES>(); proc.optional<TABLESTYLES>();
proc.optional<Palette>(); if (proc.optional<Palette>())
{
m_Palette = elements_.back();
elements_.pop_back();
}
proc.optional<ClrtClient>(); proc.optional<ClrtClient>();
return true; return true;
......
...@@ -23,6 +23,8 @@ public: ...@@ -23,6 +23,8 @@ public:
BaseObjectPtr m_Styles; BaseObjectPtr m_Styles;
BaseObjectPtr m_XFS; BaseObjectPtr m_XFS;
std::vector<BaseObjectPtr> m_Formats; std::vector<BaseObjectPtr> m_Formats;
std::vector<BaseObjectPtr> m_Fonts;
BaseObjectPtr m_Palette;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -42,9 +42,8 @@ const int BinProcessor::repeated(BaseObject& object, const int fromN, const int ...@@ -42,9 +42,8 @@ const int BinProcessor::repeated(BaseObject& object, const int fromN, const int
if(!optional(*object.clone())) if(!optional(*object.clone()))
{ {
break; break;
} }else count++;
at_least_one_read = true; at_least_one_read = true;
if (count == 0) count = -1;
} }
return count; return count;
} }
......
...@@ -45,20 +45,6 @@ BaseObjectPtr WorkbookStreamObject::clone() ...@@ -45,20 +45,6 @@ BaseObjectPtr WorkbookStreamObject::clone()
const bool WorkbookStreamObject::loadContent(BinProcessor& proc) const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
{ {
/*try
{
while(1)
{
proc.mandatory<AnyObject>();
}
}
catch(EXCEPT::RT::EndOfStreamReached&)
{
}
return true;*/
bool to_continue = true; bool to_continue = true;
unsigned __int16 substream_type; unsigned __int16 substream_type;
...@@ -83,6 +69,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc) ...@@ -83,6 +69,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
if(proc.mandatory(GlobalsSubstream(code_page_))) if(proc.mandatory(GlobalsSubstream(code_page_)))
{ {
GlobalsSubstream_found = true; GlobalsSubstream_found = true;
m_GlobalsSubstream = elements_.back();
elements_.pop_back();
} }
} }
break; break;
...@@ -97,6 +85,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc) ...@@ -97,6 +85,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
if(proc.mandatory(WorksheetSubstream(ws_index++))) if(proc.mandatory(WorksheetSubstream(ws_index++)))
{ {
WorksheetSubstream_found = true; WorksheetSubstream_found = true;
m_WorksheetSubstream.push_back(elements_.back());
elements_.pop_back();
} }
} }
break; break;
...@@ -111,6 +101,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc) ...@@ -111,6 +101,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
if(proc.mandatory<ChartSheetSubstream>()) if(proc.mandatory<ChartSheetSubstream>())
{ {
WorksheetSubstream_found = true; WorksheetSubstream_found = true;
m_ChartSheetSubstream.push_back(elements_.back());
elements_.pop_back();
} }
} }
break; break;
...@@ -125,6 +117,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc) ...@@ -125,6 +117,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
if(proc.mandatory<MacroSheetSubstream>()) if(proc.mandatory<MacroSheetSubstream>())
{ {
WorksheetSubstream_found = true; WorksheetSubstream_found = true;
m_MacroSheetSubstream.push_back(elements_.back());
elements_.pop_back();
} }
} }
break; break;
......
...@@ -7,6 +7,17 @@ ...@@ -7,6 +7,17 @@
namespace XLS namespace XLS
{; {;
class GlobalsSubstream;
class WorksheetSubstream;
class ChartSheetSubstream;
class MacroSheetSubstream;
typedef boost::shared_ptr<GlobalsSubstream> GlobalsSubstreamPtr;
typedef boost::shared_ptr<WorksheetSubstream> WorksheetSubstreamPtr;
typedef boost::shared_ptr<ChartSheetSubstream> ChartSheetSubstreamPtr;
typedef boost::shared_ptr<BaseObject> MacroSheetSubstreamPtr;
// Logical representation of Workbook stream // Logical representation of Workbook stream
class WorkbookStreamObject: public CompositeObject class WorkbookStreamObject: public CompositeObject
{ {
...@@ -27,7 +38,12 @@ public: ...@@ -27,7 +38,12 @@ public:
static const ElementType type = typeWorkbookStreamObject; static const ElementType type = typeWorkbookStreamObject;
BaseObjectPtr m_GlobalsSubstream;
std::vector<BaseObjectPtr> m_WorksheetSubstream;
std::vector<BaseObjectPtr> m_ChartSheetSubstream;
std::vector<BaseObjectPtr> m_MacroSheetSubstream;
unsigned __int16 code_page_; unsigned __int16 code_page_;
}; };
......
...@@ -185,7 +185,7 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet) ...@@ -185,7 +185,7 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
void XlsConverter::convert(XLS::GlobalsSubstream* elem) void XlsConverter::convert(XLS::GlobalsSubstream* elem)
{ {
for (std::list<XLS::BaseObjectPtr>::iterator it = woorkbook->elements_.begin(); it != woorkbook->elements_.end(); it++) for (std::list<XLS::BaseObjectPtr>::iterator it = elem->elements_.begin(); it != elem->elements_.end(); it++)
{ {
convert(it->get()); convert(it->get());
} }
......
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