Commit cf9d55e9 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

XlsFile2 bug 13912

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63941 954022d7-b5bf-4e40-9824-e11837661b57
parent 445b2fbc
......@@ -131,7 +131,7 @@ const size_t CFStreamCacheReader::readFromStream(const size_t num_of_records_min
return current_records_num;
}
while(records_cache.size() < num_of_records_min_necessary && !stream_->isEOF())
while(records_cache.size() < num_of_records_min_necessary && ((stream_) && (!stream_->isEOF())))
{
records_cache.push_back(CFRecordPtr(new CFRecord(stream_, global_info_)));
}
......@@ -170,6 +170,8 @@ void CFStreamCacheReader::checkAndAppendContinueData()
const bool CFStreamCacheReader::isEOF() const
{
if (stream_ == NULL) return true;
return !records_cache.size() && stream_->isEOF();
}
......@@ -177,7 +179,10 @@ const bool CFStreamCacheReader::isEOF() const
// Skip the specified number of unsigned chars without processing
void CFStreamCacheReader::skipNunBytes(const size_t n)
{
stream_->seekFromCurForward(n);
if (stream_)
{
stream_->seekFromCurForward(n);
}
}
......
......@@ -44,7 +44,10 @@ CompoundFile::CompoundFile(const std::wstring & file_path, const ReadWriteMode m
// Opens "Workbook" stream and returns the only reference
CFStreamPtr CompoundFile::getWorkbookStream()
{
return getNamedStream("Workbook");
CFStreamPtr stream = getNamedStream("Workbook");
if (stream == NULL) stream = getNamedStream("Book");
return stream;
}
......
......@@ -8,7 +8,7 @@ namespace Log
void info(const std::string& message)
{
#ifdef _DEBUG
Logger::getLogger().writeLine("Info", message);
Logger::getLogger().writeLine(" Info", message);
#endif
}
......@@ -16,7 +16,7 @@ void info(const std::string& message)
void event(const std::string& message)
{
#ifdef _DEBUG
Logger::getLogger().writeLine("Event", message);
Logger::getLogger().writeLine(" Event", message);
#endif
}
......@@ -24,7 +24,7 @@ void event(const std::string& message)
void message(const std::string& message)
{
#ifdef _DEBUG
Logger::getLogger().writeLine("Message", message);
Logger::getLogger().writeLine(" Message", message);
#endif
}
......@@ -32,13 +32,13 @@ void message(const std::string& message)
void warning(const std::string& message)
{
#ifdef _DEBUG
Logger::getLogger().writeLine("WARNING", message);
Logger::getLogger().writeLine(" WARNING", message);
#endif
}
void warning(const std::wstring& message)
{
#ifdef _DEBUG
Logger::getLogger().writeLine(L"WARNING", message);
Logger::getLogger().writeLine(L" WARNING", message);
#endif
}
......@@ -46,7 +46,7 @@ void warning(const std::wstring& message)
void error(const std::string& message)
{
#ifdef _DEBUG
Logger::getLogger().writeLine("!!ERROR", message);
Logger::getLogger().writeLine(" !!ERROR", message);
#endif
}
......
......@@ -53,27 +53,33 @@ void BOF::writeFields(CFRecord& record)
void BOF::readFields(CFRecord& record)
{
record >> vers >> dt >> rupBuild >> rupYear;
unsigned int flags;
record >> flags;
fWin = GETBIT(flags, 0);
fRisc = GETBIT(flags, 1);
fBeta = GETBIT(flags, 2);
fWinAny = GETBIT(flags, 3);
fMacAny = GETBIT(flags, 4);
fBetaAny = GETBIT(flags, 5);
fRiscAny = GETBIT(flags, 8);
fOOM = GETBIT(flags, 9);
fGlJmp = GETBIT(flags, 10);
fFontLimit = GETBIT(flags, 13);
verXLHigh = static_cast<unsigned char>(GETBITS(flags, 14, 17));
record >> verLowestBiff;
unsigned char flags2;
record >> flags2;
verLastXLSaved = GETBITS(flags2, 0, 3);
stream_ptr = record.getStreamPointer();
record.skipNunBytes(2); // reserved
if (vers == (_UINT16)0x600)
{
unsigned int flags;
record >> flags;
fWin = GETBIT(flags, 0);
fRisc = GETBIT(flags, 1);
fBeta = GETBIT(flags, 2);
fWinAny = GETBIT(flags, 3);
fMacAny = GETBIT(flags, 4);
fBetaAny = GETBIT(flags, 5);
fRiscAny = GETBIT(flags, 8);
fOOM = GETBIT(flags, 9);
fGlJmp = GETBIT(flags, 10);
fFontLimit = GETBIT(flags, 13);
verXLHigh = static_cast<unsigned char>(GETBITS(flags, 14, 17));
record >> verLowestBiff;
unsigned char flags2;
record >> flags2;
verLastXLSaved = GETBITS(flags2, 0, 3);
stream_ptr = record.getStreamPointer();
record.skipNunBytes(2); // reserved
}
else if (vers == (_UINT16)0x500)//testdoc01.xls
{
}
}
unsigned short BOF::getSubstreamType()
......
......@@ -61,141 +61,159 @@ int Font::serialize(std::wostream & stream)
{
CP_XML_NODE(L"font")
{
if ((bls.value()) && (*bls.value() == 700))
serialize_properties(CP_XML_STREAM());
}
}
return 0;
}
int Font::serialize_properties(std::wostream & stream, bool rPr)
{
CP_XML_WRITER(stream)
{
if ((bls.value()) && (*bls.value() == 700))
{
CP_XML_NODE(L"b")
{
CP_XML_NODE(L"b")
{
CP_XML_ATTR(L"val", true);
}
}
CP_XML_ATTR(L"val", true);
}
}
if (bCharSet.value())
if (bCharSet.value())
{
CP_XML_NODE(L"charset")
{
CP_XML_NODE(L"charset")
{
CP_XML_ATTR(L"val", bCharSet);
}
CP_XML_ATTR(L"val", bCharSet);
}
}
if ((icv.value()) && (icv < 0x7fff) )
{
CP_XML_NODE(L"color")
{
CP_XML_ATTR(L"indexed", icv);
}
}
if ((fCondense.value()) && (*fCondense.value()))
if ((icv.value()) && (icv < 0x7fff) )
{
CP_XML_NODE(L"color")
{
CP_XML_NODE(L"condense")
{
CP_XML_ATTR(L"val", (int)(*fCondense.value()));
}
CP_XML_ATTR(L"indexed", icv);
}
}
if ((fExtend.value()) && (fExtend))
if ((fCondense.value()) && (*fCondense.value()))
{
CP_XML_NODE(L"condense")
{
CP_XML_NODE(L"extend")
{
CP_XML_ATTR(L"val", fExtend);
}
CP_XML_ATTR(L"val", (int)(*fCondense.value()));
}
}
if (bFamily.value())
if ((fExtend.value()) && (fExtend))
{
CP_XML_NODE(L"extend")
{
CP_XML_NODE(L"family")
{
CP_XML_ATTR(L"val", bFamily);
}
CP_XML_ATTR(L"val", fExtend);
}
}
if ((fItalic.value()) && (fItalic))
if (bFamily.value())
{
CP_XML_NODE(L"family")
{
CP_XML_NODE(L"i")
{
CP_XML_ATTR(L"val", fItalic);
}
CP_XML_ATTR(L"val", bFamily);
}
}
if (!fontName.value().empty())
if ((fItalic.value()) && (fItalic))
{
CP_XML_NODE(L"i")
{
CP_XML_NODE(L"name")
{
CP_XML_ATTR(L"val", fontName.value());
}
CP_XML_ATTR(L"val", fItalic);
}
}
if (!fontName.value().empty())
{
if (rPr)
{
CP_XML_NODE(L"rFont")
{
CP_XML_ATTR(L"val", fontName.value());
}
}
else
{
CP_XML_NODE(L"name")
{
CP_XML_ATTR(L"val", fontName.value());
}
}
}
if ((fOutline.value()) && (fOutline))
if ((fOutline.value()) && (fOutline))
{
CP_XML_NODE(L"outline")
{
CP_XML_NODE(L"outline")
{
CP_XML_ATTR(L"val", fOutline);
}
CP_XML_ATTR(L"val", fOutline);
}
}
//if (font.scheme)
//{
// CP_XML_NODE(L"scheme")
// {
// CP_XML_ATTR(L"val", *font.scheme);
// }
//}
//if (font.scheme)
//{
// CP_XML_NODE(L"scheme")
// {
// CP_XML_ATTR(L"val", *font.scheme);
// }
//}
if ((fShadow.value()) && (fShadow))
if ((fShadow.value()) && (fShadow))
{
CP_XML_NODE(L"shadow")
{
CP_XML_NODE(L"shadow")
{
CP_XML_ATTR(L"val", fShadow);
}
CP_XML_ATTR(L"val", fShadow);
}
}
if ((fStrikeOut.value()) && (fStrikeOut))
if ((fStrikeOut.value()) && (fStrikeOut))
{
CP_XML_NODE(L"strike")
{
CP_XML_NODE(L"strike")
{
CP_XML_ATTR(L"val", fStrikeOut);
}
CP_XML_ATTR(L"val", fStrikeOut);
}
}
if (dyHeight.value())
if (dyHeight.value())
{
CP_XML_NODE(L"sz")
{
CP_XML_NODE(L"sz")
{
CP_XML_ATTR(L"val", dyHeight/20);
}
CP_XML_ATTR(L"val", dyHeight/20);
}
}
if ((uls.value()) && (*uls.value() > 0))
if ((uls.value()) && (*uls.value() > 0))
{
CP_XML_NODE(L"u")
{
CP_XML_NODE(L"u")
{
switch(uls)
{
case 1: CP_XML_ATTR(L"val", "single");break;
case 2: CP_XML_ATTR(L"val", "double");break;
case 33: CP_XML_ATTR(L"val", "singleAccounting");break;
case 34: CP_XML_ATTR(L"val", "doubleAccounting");break;
}
}
switch(uls)
{
case 1: CP_XML_ATTR(L"val", "single");break;
case 2: CP_XML_ATTR(L"val", "double");break;
case 33: CP_XML_ATTR(L"val", "singleAccounting");break;
case 34: CP_XML_ATTR(L"val", "doubleAccounting");break;
}
}
}
if ((sss.value()) && (*sss.value() > 0))
if ((sss.value()) && (*sss.value() > 0))
{
CP_XML_NODE(L"vertAlign")
{
CP_XML_NODE(L"vertAlign")
{
switch(*sss.value())
{
case 1: CP_XML_ATTR(L"val", L"superscript");break;
case 2: CP_XML_ATTR(L"val", L"subscript");break;
}
}
switch(*sss.value())
{
case 1: CP_XML_ATTR(L"val", L"superscript");break;
case 2: CP_XML_ATTR(L"val", L"subscript");break;
}
}
}
}
return 0;
}
return 0;
}
} // namespace XLS
......@@ -23,7 +23,8 @@ public:
static const ElementType type = typeFont;
int serialize(std::wostream & stream);
int serialize (std::wostream & stream);
int serialize_properties (std::wostream & stream, bool rPr = false);
//-----------------------------
BIFF_WORD dyHeight; // measured in twips (1/20 of of a printer's point)
......
......@@ -90,10 +90,19 @@ int SST::serialize(std::wostream & stream)
{
CP_XML_NODE(L"si")
{
CP_XML_NODE(L"t")
{
XLUnicodeRichExtendedString *richText = dynamic_cast<XLUnicodeRichExtendedString *>(rgb[i].get());
CP_XML_STREAM() << xml::utils::replace_text_to_xml(richText->str_);
XLUnicodeRichExtendedString *richText = dynamic_cast<XLUnicodeRichExtendedString *>(rgb[i].get());
// - r-rPr-t t
if (richText->rgRun.size() >0)
{
richText->serialize(CP_XML_STREAM());
}
else
{
CP_XML_NODE(L"t")
{
CP_XML_STREAM() << xml::utils::replace_text_to_xml(richText->str_);
}
}
}
}
......
......@@ -11,20 +11,6 @@ BiffStructurePtr FormatRun::clone()
return BiffStructurePtr(new FormatRun(*this));
}
//void FormatRun::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// xml_tag->setAttribute(L"ich", ich);
// ifnt.toXML(xml_tag, "ifnt");
//}
//
//void FormatRun::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// ich = getStructAttribute(xml_tag, L"ich");
// ifnt.fromXML(xml_tag, "ifnt");
//}
void FormatRun::store(CFRecord& record)
{
record << ich << ifnt;
......
......@@ -19,8 +19,8 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
unsigned short ich;
FontIndex ifnt;
unsigned short ich;
FontIndex ifnt;
};
typedef boost::shared_ptr<FormatRun> FormatRunPtr;
......
#include "XLUnicodeRichExtendedString.h"
#include <Logic/BaseObject.h>
#include <Logic/GlobalWorkbookInfo.h>
#include <Logic/Biff_records/Font.h>
#include <simple_xml_writer.h>
#include <utils.h>
namespace XLS
{;
XLUnicodeRichExtendedString XLUnicodeRichExtendedString::operator=(const XLUnicodeRichExtendedString& other)
{
XLUnicodeRichExtendedString tmp(other);
......@@ -13,15 +17,12 @@ XLUnicodeRichExtendedString XLUnicodeRichExtendedString::operator=(const XLUnico
return *this;
}
XLUnicodeRichExtendedString::XLUnicodeRichExtendedString(std::list<CFRecordPtr>& cont_recs)
: cont_recs_(cont_recs),
fHighByte(true)
{
}
const bool XLUnicodeRichExtendedString::appendNextContinue(CFRecord& record, const bool read_high_byte)
{
if(cont_recs_.empty())
......@@ -52,44 +53,54 @@ BiffStructurePtr XLUnicodeRichExtendedString::clone()
return BiffStructurePtr(new XLUnicodeRichExtendedString(*this));
}
//
//void XLUnicodeRichExtendedString::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// static std::wstring text_str(L"text");
// xml_tag->setAttribute(text_str, STR::escape_ST_Xstring(static_cast<wchar_t*>(str_)).c_str());
//
// std::for_each(rgRun.begin(), rgRun.end(), boost::bind(&FormatRun::toXML, _1, xml_tag));
// if(fExtSt)
// {
// extRst.toXML(xml_tag);
// }
//
//}
//
//void XLUnicodeRichExtendedString::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// static std::wstring text_str(L"text");
// static std::wstring mark_set_start_str(L"mark_set_start");
// str_ = getStructAttribute(xml_tag, text_str);
// str_ = STR::unescape_ST_Xstring(static_cast<wchar_t*>(str_)).c_str();
//
// fRichSt = false;
// FormatRun run;
// size_t number = 0;
// while(run.fromXML(xml_tag, ++number, false))
// {
// rgRun.push_back(run);
// fRichSt = true;
// }
//
// fExtSt = false;
// if(extRst.fromXML(xml_tag))
// {
// fExtSt = true;
// }
// mark_set_start = getStructAttribute(xml_tag, mark_set_start_str);
//
//}
int XLUnicodeRichExtendedString::serialize (std::wostream & _stream)
{
int start_string = 0;
int Fmt = 0;
CP_XML_WRITER(_stream)
{
for (int i = 0 ; i < rgRun.size(); i++)
{
CP_XML_NODE(L"r")
{
serialize_rPr(CP_XML_STREAM(), Fmt );
Fmt = rgRun[i].ifnt;
CP_XML_NODE(L"t")
{
CP_XML_ATTR(L"xml:space", L"preserve");
std::wstring str_part = str_.substr( start_string, rgRun[i].ich - start_string );
start_string = rgRun[i].ich;
CP_XML_STREAM() << xml::utils::replace_text_to_xml(str_part);
}
}
}
}
return 0;
}
int XLUnicodeRichExtendedString::serialize_rPr (std::wostream & _stream, int iFmt)
{
if (!pGlobalWorkbookInfoPtr) return 0;
if (!pGlobalWorkbookInfoPtr->fonts) return 0;
int sz = pGlobalWorkbookInfoPtr->fonts->size();
if (iFmt -1 > sz || iFmt < 1) return 0;
CP_XML_WRITER(_stream)
{
CP_XML_NODE(L"rPr")
{
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->fonts->at(iFmt-1).get());
if (font) font->serialize_properties(CP_XML_STREAM(), true);
}
}
return 0;
}
void XLUnicodeRichExtendedString::store(CFRecord& record)
{
......@@ -161,6 +172,8 @@ void XLUnicodeRichExtendedString::store(CFRecord& record)
void XLUnicodeRichExtendedString::load(CFRecord& record)
{
pGlobalWorkbookInfoPtr = record.getGlobalWorkbookInfo();
unsigned short cch;
unsigned char flags;
record >> cch >> flags;
......
......@@ -8,6 +8,9 @@
namespace XLS
{;
class GlobalWorkbookInfo;
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
class XLUnicodeRichExtendedString : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(XLUnicodeRichExtendedString)
......@@ -20,10 +23,13 @@ public:
BiffStructurePtr clone();
int serialize (std::wostream & _stream);
int serialize_rPr (std::wostream & _stream, int iFmt);
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
virtual void load (CFRecord& record);
virtual void store (CFRecord& record);
GlobalWorkbookInfoPtr pGlobalWorkbookInfoPtr;
void loadSymbols(CFRecord& record, const size_t cch, const bool is_wide);
void storeSymbols(CFRecord& record, const size_t start_pos, const size_t cch, const bool is_wide);
......
......@@ -17,7 +17,11 @@ class CELL_GROUP : public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(CELL_GROUP)
public:
CELL_GROUP(std::vector<CellRef>& shared_formulas_locations_ref) : shared_formulas_locations_ref_(shared_formulas_locations_ref) {}
CELL_GROUP(std::vector<CellRef>& shared_formulas_locations_ref) :
shared_formulas_locations_ref_(shared_formulas_locations_ref)
, m_count_rows (0)
{
}
BaseObjectPtr clone()
{
......@@ -26,22 +30,23 @@ public:
const bool loadContent(BinProcessor& proc)
{
int count = 0;
if(!proc.mandatory<Row>())
{
return false;
}
count = 1 + proc.repeated<Row>(0, 0);
while(count > 0)
int count, count_row = 0;
if(proc.mandatory<Row>() == true)
{
m_rows.insert(m_rows.begin(), elements_.back());
elements_.pop_back();
count--;
count_row = count = 1 + proc.repeated<Row>(0, 0);
while(count > 0)
{
m_rows.insert(m_rows.begin(), elements_.back());
elements_.pop_back();
count--;
m_count_rows++;
}
}
//------------------------------------------------------------------------------------------------------------------
count = proc.repeated(CELL(shared_formulas_locations_ref_), 0, 0);
int count_cells = proc.repeated(CELL(shared_formulas_locations_ref_), 0, 0);
count = proc.repeated<DBCell>(0, 0); // OpenOffice Calc stored files workaround (DBCell must be present at least once according to [MS-XLS])
......@@ -50,15 +55,17 @@ public:
m_DBCells.insert(m_DBCells.begin(), elements_.back());
elements_.pop_back();
count--;
}
return true;
}
if (count_cells > 0 || count_row > 0) return true;
else return false;
};
int serialize(std::wostream & stream);
static const ElementType type = typeCELL_GROUP;
int m_count_rows;
std::list<BaseObjectPtr> m_rows;
std::list<BaseObjectPtr> m_DBCells;
//elements_ = cells
private:
std::vector<CellRef>& shared_formulas_locations_ref_;
};
......@@ -69,7 +76,7 @@ int CELL_GROUP::serialize(std::wostream & stream)
{
std::list<XLS::BaseObjectPtr>::iterator current_cell_start = elements_.begin();
int current_row = 1;
int current_row = 0;
for (std::list<XLS::BaseObjectPtr>::iterator it_row = m_rows.begin(); it_row != m_rows.end(); it_row++)
{
......@@ -127,6 +134,44 @@ int CELL_GROUP::serialize(std::wostream & stream)
}
}
}
if (current_row < 1 )//order_history.xls - Row,
{
while(current_row ==0)
{
CP_XML_NODE(L"row")
{
std::list<XLS::BaseObjectPtr>::iterator it_cell = current_cell_start;
while(true)
{
if (it_cell == elements_.end())
{
current_cell_start = it_cell;
current_row = -1;
break;
}
CELL * cell = dynamic_cast<CELL *>(it_cell->get());
if (cell == NULL) continue;
if (current_row < 1)
{
current_row = cell->RowNumber + 1;
CP_XML_ATTR(L"r", current_row);
}
if (cell->RowNumber > current_row - 1)
{
current_cell_start = it_cell;
current_row = 0;
break;
}
cell->serialize(CP_XML_STREAM());
it_cell++;
}
}
}
}
}
return 0;
}
......@@ -134,8 +179,9 @@ int CELL_GROUP::serialize(std::wostream & stream)
//-----------------------------------------------------------------------------------------------------------------
CELLTABLE::CELLTABLE(std::vector<CellRef>& shared_formulas_locations_ref) : m_count_CELL_GROUP(0),
shared_formulas_locations_ref_(shared_formulas_locations_ref)
CELLTABLE::CELLTABLE(std::vector<CellRef>& shared_formulas_locations_ref) :
m_count_CELL_GROUP(0)
,shared_formulas_locations_ref_(shared_formulas_locations_ref)
{
}
......@@ -159,7 +205,7 @@ const bool CELLTABLE::loadContent(BinProcessor& proc)
}
m_count_CELL_GROUP = proc.repeated(CELL_GROUP(shared_formulas_locations_ref_), 0, 0);
proc.repeated<EntExU2>(0, 0);
return true;
......
......@@ -61,7 +61,7 @@ const bool CUSTOMVIEW::loadContent(BinProcessor& proc)
proc.optional<RightMargin>();
proc.optional<TopMargin>();
proc.optional<BottomMargin>();
//proc.optional(Pls(proc.getParent()));//??????
proc.optional(Pls(proc.getParent()));//??????
proc.optional<Setup>();
proc.optional<PrintSize>();
proc.optional<HeaderFooter>();
......
......@@ -41,8 +41,8 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
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();
m_Fonts.push_back(elements_.front());
elements_.pop_front();
count--;
}
//---------------------------------------------------------------------------------------------------
......@@ -55,9 +55,10 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
}
//----------------------------------------------------------------------------------------------------
count = proc.repeated<Font>(0, 510); // Wrong records sequence workaround (originally Font follows by Format)
int countFonts = m_Fonts.size();
while(count > 0)
{
m_Fonts.insert(m_Fonts.begin(), elements_.back());
m_Fonts.insert(m_Fonts.begin()+countFonts, elements_.back());
elements_.pop_back();
count--;
}
......
......@@ -96,16 +96,23 @@ int GLOBALS::serialize(std::wostream & stream)
if (m_DefaultRowHeight)
{
DefaultRowHeight* def_row = dynamic_cast<DefaultRowHeight*>(m_DefaultRowHeight.get());
if(!def_row->fDyZero.value() || ((def_row->fDyZero.value()) && (!def_row->fDyZero)))
CP_XML_ATTR(L"defaultRowHeight", def_row->miyRw / 20.);
else
if (def_row)
{
CP_XML_ATTR(L"zeroHeight", true);
CP_XML_ATTR(L"defaultRowHeight", def_row->miyRwHidden /20.);
if(!def_row->fDyZero.value() || ((def_row->fDyZero.value()) && (!def_row->fDyZero)))
CP_XML_ATTR(L"defaultRowHeight", def_row->miyRw / 20.);
else
{
CP_XML_ATTR(L"zeroHeight", true);
CP_XML_ATTR(L"defaultRowHeight", def_row->miyRwHidden /20.);
}
if ((def_row->fExAsc.value()) && (def_row->fExAsc)) CP_XML_ATTR(L"thickTop", true);
if ((def_row->fExDsc.value()) && (def_row->fExDsc)) CP_XML_ATTR(L"thickBottom", true);
}
if ((def_row->fExAsc.value()) && (def_row->fExAsc)) CP_XML_ATTR(L"thickTop", true);
if ((def_row->fExDsc.value()) && (def_row->fExDsc)) CP_XML_ATTR(L"thickBottom", true);
}
else
{
CP_XML_ATTR(L"defaultRowHeight", 14.4);
}
if (m_DefColWidth)
{
......
......@@ -77,8 +77,8 @@ const bool BinReaderProcessor::mandatory(BaseObject& object)
{
if(is_mandatory_) // if the composite object is mandatory, do as usual - log warning if the record is not found
{
readChild(object, true);
return true;
bool res = readChild(object, true);
return res;
}
else
{
......
......@@ -15,21 +15,6 @@ CompositeObject::~CompositeObject()
{
}
/*
const bool CompositeObject::doSomething(BinProcessor& proc)
{
MSXML2::IXMLDOMElementPtr own_tag = XMLSTUFF::createElement(getClassName(), parent);
BinReaderProcessor reader_proc(reader, own_tag, is_mandatory);
if(loadContent(reader_proc))
{
return true;
}
parent->removeChild(own_tag); // When nothing was read for this composite. For example, if loadFirstMandatory returns false
return false;
}
*/
const bool CompositeObject::read(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory)
{
......
......@@ -11,6 +11,9 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page)
fill_x_ids[FillInfo(17, 64, 65)] = 1;
last_AXES_id = initial_AXES_id;
Version = 0x0600; // xls
}
......
......@@ -10,6 +10,9 @@
namespace XLS
{;
class BaseObject;
typedef boost::shared_ptr<BaseObject> BaseObjectPtr;
class GlobalWorkbookInfo
{
public:
......@@ -20,14 +23,17 @@ public:
const unsigned int GenerateAXESId();
unsigned short CodePage;
CRYPT::DecryptorPtr decryptor;
std::vector<std::wstring> sheets_names;
std::vector<std::wstring> xti_parsed;
std::vector<std::wstring> AddinUdfs;
unsigned short CodePage;
CRYPT::DecryptorPtr decryptor;
std::vector<std::wstring> sheets_names;
std::vector<std::wstring> xti_parsed;
std::vector<std::wstring> AddinUdfs;
boost::unordered_map<BorderInfo, int> border_x_ids;
boost::unordered_map<FillInfo, int> fill_x_ids;
std::vector<BaseObjectPtr> *fonts;
unsigned int last_AXES_id;
const static unsigned int initial_AXES_id = 0;
......@@ -36,6 +42,9 @@ public:
std::vector<std::pair<boost::shared_array<char>, size_t> > bin_data;
int Version;
};
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
......
......@@ -116,6 +116,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
{
return false;
}
BOF* bof = dynamic_cast<BOF*>(elements_.back().get());
if (bof->vers != 0x0600) //testdoc01.xls
{
proc.getGlobalWorkbookInfo()->Version = bof->vers;
return false;
}
proc.optional<WriteProtect>();
proc.optional<FilePass>();
if (proc.optional<Template>())
......@@ -157,6 +165,12 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
{
m_Formating = elements_.back();
elements_.pop_back();
FORMATTING* fmts = dynamic_cast<FORMATTING*>(m_Formating.get());
if (fmts)
{
proc.getGlobalWorkbookInfo()->fonts = &fmts->m_Fonts;
}
}
proc.repeated<PIVOTCACHEDEFINITION>(0, 0);
......@@ -198,6 +212,7 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
elements_.pop_back();
count--;
}
proc.repeated<SUPBOOK>(0, 0);//order_history.xls
if (proc.optional(SHAREDSTRINGS(code_page_)))
{
......
......@@ -66,7 +66,7 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
return false;
}
Log::event("Globals substream detected");
if(proc.mandatory(GlobalsSubstream(code_page_)))
if((proc.mandatory(GlobalsSubstream(code_page_))) && (elements_.size() > 0))
{
GlobalsSubstream_found = true;
m_GlobalsSubstream = elements_.back();
......@@ -82,7 +82,7 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
return false;
}
Log::event("Worksheet or Dialog substream detected");
if(proc.mandatory(WorksheetSubstream(ws_index++)))
if ((proc.mandatory(WorksheetSubstream(ws_index++))) && (elements_.size() > 0))
{
WorksheetSubstream_found = true;
m_WorksheetSubstream.push_back(elements_.back());
......@@ -98,7 +98,7 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
return false;
}
Log::event("Chart substream detected");
if(proc.mandatory<ChartSheetSubstream>())
if ((proc.mandatory<ChartSheetSubstream>()) && (elements_.size() > 0))
{
WorksheetSubstream_found = true;
m_ChartSheetSubstream.push_back(elements_.back());
......@@ -114,7 +114,7 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
return false;
}
Log::event("Macro substream detected");
if(proc.mandatory<MacroSheetSubstream>())
if ((proc.mandatory<MacroSheetSubstream>()) && (elements_.size() > 0))
{
WorksheetSubstream_found = true;
m_MacroSheetSubstream.push_back(elements_.back());
......@@ -127,7 +127,6 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
" The substream is skipped! Sorry.");
proc.SeekToEOF();
proc.mandatory<EOF_T>();
//throw XLS::WrongBiffRecord("Substream of unsupported type " + STR::int2str(substream_type, 10), "BOF");
}
}
......
......@@ -95,6 +95,7 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
xls_global_info = boost::shared_ptr<XLS::GlobalWorkbookInfo>(new XLS::GlobalWorkbookInfo(workbook_code_page));
XLS::CFStreamCacheReader stream_reader(cfile.getWorkbookStream(), xls_global_info);
xls_document = boost::shared_ptr<XLS::WorkbookStreamObject>(new XLS::WorkbookStreamObject(workbook_code_page));
......
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