Commit 9447c725 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormatReader - fix protection files

parent 21012285
...@@ -54,10 +54,10 @@ namespace CRYPT ...@@ -54,10 +54,10 @@ namespace CRYPT
return crypt->IsVerify(); return crypt->IsVerify();
} }
bool RC4Decryptor::SetPassword(std::wstring password) bool RC4Decryptor::SetPassword(std::wstring password, int type)
{ {
crypt.reset(); crypt.reset();
crypt = CryptPtr(new RC4Crypt(crypt_data, password, 1)); crypt = CryptPtr(new RC4Crypt(crypt_data, password, type));
if (crypt) return crypt->IsVerify(); if (crypt) return crypt->IsVerify();
else return false; else return false;
......
...@@ -46,7 +46,7 @@ namespace CRYPT ...@@ -46,7 +46,7 @@ namespace CRYPT
bool IsVerify(); bool IsVerify();
bool SetPassword(std::wstring password); bool SetPassword(std::wstring password, int type = 1);
private: private:
CryptPtr crypt; CryptPtr crypt;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
namespace CRYPT namespace CRYPT
{ {
RC4Crypt::RC4Crypt(CRYPT::CryptRC4Data & data, std::wstring password, int type) RC4Crypt::RC4Crypt(CRYPT::CryptRC4Data & data, std::wstring password, int type)
{ {
m_VerifyPassword = false; m_VerifyPassword = false;
......
...@@ -71,7 +71,7 @@ const bool BiffRecordSplit::storeRecordAndDecideProceeding(CFRecordPtr record) ...@@ -71,7 +71,7 @@ const bool BiffRecordSplit::storeRecordAndDecideProceeding(CFRecordPtr record)
else if(stored_record == NULL) else if(stored_record == NULL)
{ {
stored_record = record; stored_record = record;
//throw;// EXCEPT::RT::WrongBiffRecord("Split records do not match", record->getTypeString()); // EXCEPT::RT::WrongBiffRecord("Split records do not match", record->getTypeString());
} }
else else
{ {
......
...@@ -76,7 +76,7 @@ void BookBool::writeFields(CFRecord& record) ...@@ -76,7 +76,7 @@ void BookBool::writeFields(CFRecord& record)
} }
else else
{ {
throw;// EXCEPT::LE::AttributeDataWrong(L"grUpdateLinks", record.getTypeString().c_str(), grUpdateLinks); // EXCEPT::LE::AttributeDataWrong(L"grUpdateLinks", record.getTypeString().c_str(), grUpdateLinks);
} }
SETBITS(flags, 5, 6, grUpdateLinks_num); SETBITS(flags, 5, 6, grUpdateLinks_num);
SETBIT(flags, 8, fHideBorderUnselLists); SETBIT(flags, 8, fHideBorderUnselLists);
...@@ -107,7 +107,7 @@ void BookBool::readFields(CFRecord& record) ...@@ -107,7 +107,7 @@ void BookBool::readFields(CFRecord& record)
grUpdateLinks = std::wstring (L"always"); grUpdateLinks = std::wstring (L"always");
break; break;
default: default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported value of grUpdateLinks.", record.getTypeString()); // EXCEPT::RT::WrongBiffRecord("Unsupported value of grUpdateLinks.", record.getTypeString());
} }
......
...@@ -72,7 +72,7 @@ void BoundSheet8::writeFields(CFRecord& record) ...@@ -72,7 +72,7 @@ void BoundSheet8::writeFields(CFRecord& record)
} }
else else
{ {
throw;// EXCEPT::LE::AttributeDataWrong(L"hsState", record.getTypeString().c_str(), hsState); // EXCEPT::LE::AttributeDataWrong(L"hsState", record.getTypeString().c_str(), hsState);
} }
ShortXLUnicodeString stName = name_; ShortXLUnicodeString stName = name_;
......
...@@ -69,7 +69,7 @@ void CalcMode::writeFields(CFRecord& record) ...@@ -69,7 +69,7 @@ void CalcMode::writeFields(CFRecord& record)
} }
else else
{ {
throw;// EXCEPT::LE::AttributeDataWrong(L"fAutoRecalc", record.getTypeString().c_str(), fAutoRecalc); // EXCEPT::LE::AttributeDataWrong(L"fAutoRecalc", record.getTypeString().c_str(), fAutoRecalc);
} }
record << fAutoRecalc_num; record << fAutoRecalc_num;
} }
......
...@@ -65,7 +65,7 @@ void CalcRefMode::writeFields(CFRecord& record) ...@@ -65,7 +65,7 @@ void CalcRefMode::writeFields(CFRecord& record)
} }
else else
{ {
throw;// EXCEPT::LE::AttributeDataWrong(L"fRefA1", record.getTypeString().c_str(), fRefA1); // EXCEPT::LE::AttributeDataWrong(L"fRefA1", record.getTypeString().c_str(), fRefA1);
} }
record << fRef; record << fRef;
} }
......
...@@ -54,7 +54,7 @@ BaseObjectPtr EntExU2::clone() ...@@ -54,7 +54,7 @@ BaseObjectPtr EntExU2::clone()
void EntExU2::writeFields(CFRecord& record) void EntExU2::writeFields(CFRecord& record)
{ {
throw;// EXCEPT::LE::UnexpectedProgramPath("EntExU2 record is skipped.", __FUNCTION__); // EXCEPT::LE::UnexpectedProgramPath("EntExU2 record is skipped.", __FUNCTION__);
} }
......
...@@ -73,6 +73,8 @@ void Font::writeFields(CFRecord& record) ...@@ -73,6 +73,8 @@ void Font::writeFields(CFRecord& record)
void Font::readFields(CFRecord& record) void Font::readFields(CFRecord& record)
{ {
correct = false;
global_info = record.getGlobalWorkbookInfo(); global_info = record.getGlobalWorkbookInfo();
unsigned short flags; unsigned short flags;
...@@ -86,7 +88,13 @@ void Font::readFields(CFRecord& record) ...@@ -86,7 +88,13 @@ void Font::readFields(CFRecord& record)
fExtend = GETBIT(flags, 7); fExtend = GETBIT(flags, 7);
record >> icv >> bls >> sss >> uls >> bFamily >> bCharSet; record >> icv >> bls >> sss >> uls >> bFamily >> bCharSet;
record.skipNunBytes(1);
unsigned char reserved;
record >> reserved;
if (bls >=100 && bls <= 1000)
correct = true;
if (record.getGlobalWorkbookInfo()->Version < 0x0600) if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{ {
......
...@@ -83,6 +83,8 @@ public: ...@@ -83,6 +83,8 @@ public:
FillInfoExt color_ext; FillInfoExt color_ext;
ShortXLUnicodeString fontName; ShortXLUnicodeString fontName;
bool correct;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -60,7 +60,7 @@ void HeaderFooter::writeFields(CFRecord& record) ...@@ -60,7 +60,7 @@ void HeaderFooter::writeFields(CFRecord& record)
_GUID_ guid_num; _GUID_ guid_num;
if(!STR::bstr2guid(guidSView, guid_num)) if(!STR::bstr2guid(guidSView, guid_num))
{ {
throw;// EXCEPT::LE::AttributeDataWrong(L"guid", L"HeaderFooter", guidSView); // EXCEPT::LE::AttributeDataWrong(L"guid", L"HeaderFooter", guidSView);
} }
record << guid_num; record << guid_num;
unsigned short flags = 0; unsigned short flags = 0;
......
...@@ -46,7 +46,7 @@ BaseObjectPtr LPr::clone() ...@@ -46,7 +46,7 @@ BaseObjectPtr LPr::clone()
void LPr::writeFields(CFRecord& record) void LPr::writeFields(CFRecord& record)
{ {
// The record is unused // The record is unused
throw;// EXCEPT::LE::WhatIsTheFuck("LPr must appears in the intermediate XML file while it must not.", __FUNCTION__); // EXCEPT::LE::WhatIsTheFuck("LPr must appears in the intermediate XML file while it must not.", __FUNCTION__);
} }
......
...@@ -153,7 +153,7 @@ void Lbl::writeFields(CFRecord& record) ...@@ -153,7 +153,7 @@ void Lbl::writeFields(CFRecord& record)
} }
else else
{ {
throw;// EXCEPT::RT::WrongBiffRecord(L"Unsupported value of built-in name.", record.getTypeString()); // EXCEPT::RT::WrongBiffRecord(L"Unsupported value of built-in name.", record.getTypeString());
} }
// fix // fix
...@@ -267,7 +267,9 @@ void Lbl::readFields(CFRecord& record) ...@@ -267,7 +267,9 @@ void Lbl::readFields(CFRecord& record)
Name = (L"_xlnm._FilterDatabase"); Name = (L"_xlnm._FilterDatabase");
break; break;
default: default:
throw;// EXCEPT::RT::WrongBiffRecord(L"Unsupported value of built-in name.", record.getTypeString()); Name;
break;
// EXCEPT::RT::WrongBiffRecord(L"Unsupported value of built-in name.", record.getTypeString());
} }
} }
} }
......
...@@ -53,16 +53,16 @@ BaseObjectPtr Password::clone() ...@@ -53,16 +53,16 @@ BaseObjectPtr Password::clone()
void Password::writeFields(CFRecord& record) void Password::writeFields(CFRecord& record)
{ {
unsigned short wPassword_num = static_cast<unsigned short>(STR::hex_str2int(wPassword)); wPassword_num = static_cast<unsigned short>(STR::hex_str2int(wPassword));
record << wPassword_num; record << wPassword_num;
} }
void Password::readFields(CFRecord& record) void Password::readFields(CFRecord& record)
{ {
unsigned short wPassword_num;
record >> wPassword_num; record >> wPassword_num;
wPassword = std::wstring (STR::int2hex_wstr(wPassword_num, sizeof(wPassword_num)).c_str());
wPassword = STR::int2hex_wstr(wPassword_num, sizeof(wPassword_num));
} }
} // namespace XLS } // namespace XLS
......
...@@ -54,7 +54,8 @@ public: ...@@ -54,7 +54,8 @@ public:
static const ElementType type = typePassword; static const ElementType type = typePassword;
//----------------------------- //-----------------------------
BIFF_BSTR wPassword; unsigned short wPassword_num;
std::wstring wPassword;
}; };
......
...@@ -53,16 +53,16 @@ BaseObjectPtr Prot4RevPass::clone() ...@@ -53,16 +53,16 @@ BaseObjectPtr Prot4RevPass::clone()
void Prot4RevPass::writeFields(CFRecord& record) void Prot4RevPass::writeFields(CFRecord& record)
{ {
unsigned short protPwdRev_num = static_cast<unsigned short>(STR::hex_str2int(protPwdRev)); protPwdRev_num = static_cast<unsigned short>(STR::hex_str2int(protPwdRev));
record << protPwdRev_num; record << protPwdRev_num;
} }
void Prot4RevPass::readFields(CFRecord& record) void Prot4RevPass::readFields(CFRecord& record)
{ {
unsigned short protPwdRev_num;
record >> protPwdRev_num; record >> protPwdRev_num;
protPwdRev = std::wstring (STR::int2hex_wstr(protPwdRev_num, sizeof(protPwdRev_num)).c_str());
protPwdRev = STR::int2hex_wstr(protPwdRev_num, sizeof(protPwdRev_num));
} }
} // namespace XLS } // namespace XLS
......
...@@ -54,7 +54,8 @@ public: ...@@ -54,7 +54,8 @@ public:
static const ElementType type = typeProt4RevPass; static const ElementType type = typeProt4RevPass;
//----------------------------- //-----------------------------
BIFF_BSTR protPwdRev; unsigned short protPwdRev_num;
std::wstring protPwdRev;
}; };
......
...@@ -63,7 +63,8 @@ void SST::writeFields(CFRecord& record) ...@@ -63,7 +63,8 @@ void SST::writeFields(CFRecord& record)
XLUnicodeRichExtendedStringPtr element = boost::dynamic_pointer_cast<XLUnicodeRichExtendedString>(*it); XLUnicodeRichExtendedStringPtr element = boost::dynamic_pointer_cast<XLUnicodeRichExtendedString>(*it);
if(!element) if(!element)
{ {
throw;// EXCEPT::LE::WrongAPIUsage("boost::shared_dynamic_cast failed to cast to XLUnicodeRichExtendedStringPtr", __FUNCTION__); // EXCEPT::LE::WrongAPIUsage("boost::shared_dynamic_cast failed to cast to XLUnicodeRichExtendedStringPtr", __FUNCTION__);
return;
} }
CFRecord& current_record = recs.size() ? *recs.back() : record; // Points to the original 'record' or the last created 'Continue' CFRecord& current_record = recs.size() ? *recs.back() : record; // Points to the original 'record' or the last created 'Continue'
......
...@@ -60,7 +60,7 @@ void UserBView::writeFields(CFRecord& record) ...@@ -60,7 +60,7 @@ void UserBView::writeFields(CFRecord& record)
_GUID_ guid_num; _GUID_ guid_num;
if(!STR::bstr2guid(guid, guid_num)) if(!STR::bstr2guid(guid, guid_num))
{ {
throw;// EXCEPT::LE::AttributeDataWrong(L"guid", L"UserBView", guid); // EXCEPT::LE::AttributeDataWrong(L"guid", L"UserBView", guid);
} }
record << guid_num << x << y << dx << dy << wTabRatio; record << guid_num << x << y << dx << dy << wTabRatio;
...@@ -82,7 +82,7 @@ void UserBView::writeFields(CFRecord& record) ...@@ -82,7 +82,7 @@ void UserBView::writeFields(CFRecord& record)
} }
else else
{ {
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported value of mdNoteDisp.", record.getTypeString()); // EXCEPT::RT::WrongBiffRecord("Unsupported value of mdNoteDisp.", record.getTypeString());
} }
SETBITS(flags1, 2, 3, mdNoteDisp_num); SETBITS(flags1, 2, 3, mdNoteDisp_num);
SETBIT(flags1, 4, fDspHScroll); SETBIT(flags1, 4, fDspHScroll);
...@@ -106,7 +106,7 @@ void UserBView::writeFields(CFRecord& record) ...@@ -106,7 +106,7 @@ void UserBView::writeFields(CFRecord& record)
} }
else else
{ {
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported value of fHideObj.", record.getTypeString()); // EXCEPT::RT::WrongBiffRecord("Unsupported value of fHideObj.", record.getTypeString());
} }
SETBITS(flags1, 8, 9, fHideObj_num); SETBITS(flags1, 8, 9, fHideObj_num);
SETBIT(flags1, 10, fPrintIncl); SETBIT(flags1, 10, fPrintIncl);
......
...@@ -58,7 +58,7 @@ void UserSViewBegin::writeFields(CFRecord& record) ...@@ -58,7 +58,7 @@ void UserSViewBegin::writeFields(CFRecord& record)
_GUID_ guid_num; _GUID_ guid_num;
if(!STR::bstr2guid(guid, guid_num)) if(!STR::bstr2guid(guid, guid_num))
{ {
throw;// EXCEPT::LE::AttributeDataWrong(L"guid", L"UserSViewBegin", guid); // EXCEPT::LE::AttributeDataWrong(L"guid", L"UserSViewBegin", guid);
} }
record << guid_num << iTabid; record << guid_num << iTabid;
record.reserveNunBytes(2); // reserved record.reserveNunBytes(2); // reserved
......
...@@ -79,7 +79,7 @@ const std::wstring Bes::toString() ...@@ -79,7 +79,7 @@ const std::wstring Bes::toString()
case 0x2B: case 0x2B:
return L"#GETTING_DATA"; return L"#GETTING_DATA";
default: default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of Bes.", "unknown"); // EXCEPT::RT::WrongBiffRecord("Unsupported type of Bes.", "unknown");
} }
} }
else else
...@@ -144,7 +144,7 @@ void Bes::fromString(const std::wstring str) ...@@ -144,7 +144,7 @@ void Bes::fromString(const std::wstring str)
} }
else else
{ {
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of Bes.", "unknown"); // EXCEPT::RT::WrongBiffRecord("Unsupported type of Bes.", "unknown");
} }
} }
......
...@@ -85,14 +85,14 @@ BiffStructurePtr BiffString::clone() ...@@ -85,14 +85,14 @@ BiffStructurePtr BiffString::clone()
void BiffString::store(CFRecord& record) void BiffString::store(CFRecord& record)
{ {
throw;// EXCEPT::LE::WhatIsTheFuck("Wrong usage of BiffString. The function must not be called.", __FUNCTION__); // EXCEPT::LE::WhatIsTheFuck("Wrong usage of BiffString. The function must not be called.", __FUNCTION__);
} }
void BiffString::load(CFRecord& record) void BiffString::load(CFRecord& record)
{ {
throw;// EXCEPT::LE::WhatIsTheFuck("Wrong usage of BiffString. Stack overflow stopped.", __FUNCTION__); // EXCEPT::LE::WhatIsTheFuck("Wrong usage of BiffString. Stack overflow stopped.", __FUNCTION__);
// record >> *this; // :-) // record >> *this; // :-)
} }
...@@ -185,7 +185,7 @@ const size_t BiffString::getSize() const ...@@ -185,7 +185,7 @@ const size_t BiffString::getSize() const
{ {
if(!cch_) if(!cch_)
{ {
throw;// EXCEPT::LE::StructureSizeNotSet("BiffString", __FUNCTION__/*__FUNCDNAME__*/); // EXCEPT::LE::StructureSizeNotSet("BiffString", __FUNCTION__/*__FUNCDNAME__*/);
} }
return *cch_; return *cch_;
} }
......
...@@ -47,7 +47,7 @@ void BiffStructure_NoVtbl::store(CFRecord& record) ...@@ -47,7 +47,7 @@ void BiffStructure_NoVtbl::store(CFRecord& record)
// this function will never be called ( look at operator>>(CFRecord& record, T& val)) // this function will never be called ( look at operator>>(CFRecord& record, T& val))
void BiffStructure_NoVtbl::load(CFRecord& record) void BiffStructure_NoVtbl::load(CFRecord& record)
{ {
throw;// EXCEPT::LE::HowCouldItHappen("Unexpected behaviour.", __FUNCTION__); // EXCEPT::LE::HowCouldItHappen("Unexpected behaviour.", __FUNCTION__);
} }
......
...@@ -162,7 +162,7 @@ struct BErr : public BiffStructure_NoVtbl ...@@ -162,7 +162,7 @@ struct BErr : public BiffStructure_NoVtbl
} }
else else
{ {
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of BErr.", "unknown"); // EXCEPT::RT::WrongBiffRecord("Unsupported type of BErr.", "unknown");
} }
}; };
...@@ -185,7 +185,7 @@ struct BErr : public BiffStructure_NoVtbl ...@@ -185,7 +185,7 @@ struct BErr : public BiffStructure_NoVtbl
case 0x2A: case 0x2A:
return L"#N/A"; return L"#N/A";
default: default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of BErr.", "unknown"); // EXCEPT::RT::WrongBiffRecord("Unsupported type of BErr.", "unknown");
} }
} }
}; };
......
...@@ -58,7 +58,7 @@ void CFParsedFormulaNoCCE::store(CFRecord& record) ...@@ -58,7 +58,7 @@ void CFParsedFormulaNoCCE::store(CFRecord& record)
void CFParsedFormulaNoCCE::load(CFRecord& record) void CFParsedFormulaNoCCE::load(CFRecord& record)
{ {
throw;// EXCEPT::LE::WhatIsTheFuck("Unexpected stub function call.", __FUNCTION__); // EXCEPT::LE::WhatIsTheFuck("Unexpected stub function call.", __FUNCTION__);
} }
......
...@@ -181,7 +181,7 @@ void CellRangeRef::fromString(const std::wstring& str) ...@@ -181,7 +181,7 @@ void CellRangeRef::fromString(const std::wstring& str)
{ {
if(-1 == columnFirst || -1 == columnLast) // no correct data found in the supplied string if(-1 == columnFirst || -1 == columnLast) // no correct data found in the supplied string
{ {
throw;// EXCEPT::LE::WrongIntermediateXMLFormat(std::string("CellRangeRef failed to initialize from \"") + // EXCEPT::LE::WrongIntermediateXMLFormat(std::string("CellRangeRef failed to initialize from \"") +
//static_cast<char*>(std::wstring (str.c_str())) + "\".", __FUNCTION__); //static_cast<char*>(std::wstring (str.c_str())) + "\".", __FUNCTION__);
} }
......
...@@ -53,7 +53,7 @@ void FtNts::store(CFRecord& record) ...@@ -53,7 +53,7 @@ void FtNts::store(CFRecord& record)
_GUID_ guid_num; _GUID_ guid_num;
if(!STR::bstr2guid(guid, guid_num)) if(!STR::bstr2guid(guid, guid_num))
{ {
throw;// EXCEPT::LE::AttributeDataWrong(L"guid", L"FtNts", guid); // EXCEPT::LE::AttributeDataWrong(L"guid", L"FtNts", guid);
} }
record << guid_num << fSharedNote; record << guid_num << fSharedNote;
} }
......
...@@ -102,7 +102,7 @@ void HyperlinkMoniker::load(XLS::CFRecord& record) ...@@ -102,7 +102,7 @@ void HyperlinkMoniker::load(XLS::CFRecord& record)
} }
else else
{ {
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of HyperlinkMoniker.", record.getTypeString()); // EXCEPT::RT::WrongBiffRecord("Unsupported type of HyperlinkMoniker.", record.getTypeString());
} }
record >> *data; record >> *data;
......
...@@ -86,7 +86,7 @@ void HyperlinkObject::store(XLS::CFRecord& record) ...@@ -86,7 +86,7 @@ void HyperlinkObject::store(XLS::CFRecord& record)
_GUID_ guid_num; _GUID_ guid_num;
if(!STR::bstr2guid(guid, guid_num)) if(!STR::bstr2guid(guid, guid_num))
{ {
throw;// EXCEPT::LE::AttributeDataWrong(L"guid", L"HyperlinkObject", guid); // EXCEPT::LE::AttributeDataWrong(L"guid", L"HyperlinkObject", guid);
} }
record << guid_num; record << guid_num;
} }
......
...@@ -206,12 +206,13 @@ void OfficeArtContainer::loadFields(XLS::CFRecord& record) ...@@ -206,12 +206,13 @@ void OfficeArtContainer::loadFields(XLS::CFRecord& record)
} }
else // If the found record is not implemented or unknown else // If the found record is not implemented or unknown
{ {
if (rh_child.size() > record.getDataSize() - container_beginning_ptr)
break;
try try
{ {
size_t sz = rh_child.size(); size_t sz = rh_child.size();
record.skipNunBytes(rh_child.size()); // skip header record.skipNunBytes(rh_child.size()); // skip art record header + data
record.skipNunBytes(rh_child.recLen); // skip record data
Log::warning(std::wstring(L"Unsupported OfficeArtRecord skipped (recType=0x") + Log::warning(std::wstring(L"Unsupported OfficeArtRecord skipped (recType=0x") +
STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)) + std::wstring(L")")); STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)) + std::wstring(L")"));
} }
......
...@@ -57,6 +57,9 @@ public: ...@@ -57,6 +57,9 @@ public:
virtual void assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full_ref = false) virtual void assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full_ref = false)
{ {
if (ptg_stack.empty())
return;
std::wstring operand2(ptg_stack.top()); std::wstring operand2(ptg_stack.top());
ptg_stack.pop(); ptg_stack.pop();
ptg_stack.top() += getOperatorSymbols() + operand2; ptg_stack.top() += getOperatorSymbols() + operand2;
...@@ -74,6 +77,9 @@ public: ...@@ -74,6 +77,9 @@ public:
UOperatorPtg_T() : OperatorPtg(fixedType) {}; UOperatorPtg_T() : OperatorPtg(fixedType) {};
void assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full_ref = false) void assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full_ref = false)
{ {
if (ptg_stack.empty())
return;
ptg_stack.top() = T::getSymbols() + ptg_stack.top(); ptg_stack.top() = T::getSymbols() + ptg_stack.top();
}; };
virtual const unsigned short getPtgId() const {return fixedType;}; virtual const unsigned short getPtgId() const {return fixedType;};
......
...@@ -90,7 +90,7 @@ const std::wstring ParsedFormula::getAssembledFormula(bool full_ref) const ...@@ -90,7 +90,7 @@ const std::wstring ParsedFormula::getAssembledFormula(bool full_ref) const
if(1 != ptg_stack.size()) if(1 != ptg_stack.size())
{ {
return L""; return L"";
//throw; EXCEPT::LE::WrongAPIUsage("Wrong formula assembling.", __FUNCTION__); //EXCEPT::LE::WrongAPIUsage("Wrong formula assembling.", __FUNCTION__);
} }
return ptg_stack.top(); return ptg_stack.top();
} }
......
...@@ -59,7 +59,7 @@ PtgBool::PtgBool(const std::wstring& word) ...@@ -59,7 +59,7 @@ PtgBool::PtgBool(const std::wstring& word)
} }
else else
{ {
throw;// EXCEPT::LE::FormulaParsingError("Wrong boolean format.", __FUNCTION__); // EXCEPT::LE::FormulaParsingError("Wrong boolean format.", __FUNCTION__);
} }
} }
......
...@@ -117,7 +117,7 @@ void PtgExtraArray::fromString(const std::wstring& str) ...@@ -117,7 +117,7 @@ void PtgExtraArray::fromString(const std::wstring& str)
{ {
if(str.length() <= 2) if(str.length() <= 2)
{ {
throw;// EXCEPT::LE::WhatIsTheFuck("Unknown PtgExtraArray format extracted from formula.", __FUNCTION__); // EXCEPT::LE::WhatIsTheFuck("Unknown PtgExtraArray format extracted from formula.", __FUNCTION__);
} }
std::wstring::const_iterator first = str.begin() + 1; std::wstring::const_iterator first = str.begin() + 1;
...@@ -155,7 +155,7 @@ void PtgExtraArray::fromString(const std::wstring& str) ...@@ -155,7 +155,7 @@ void PtgExtraArray::fromString(const std::wstring& str)
} }
else else
{ {
throw;// EXCEPT::LE::WhatIsTheFuck("Unknown operand format in PtgArray.", __FUNCTION__); // EXCEPT::LE::WhatIsTheFuck("Unknown operand format in PtgArray.", __FUNCTION__);
} }
} }
......
...@@ -83,7 +83,7 @@ void PtgFuncVar::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool ...@@ -83,7 +83,7 @@ void PtgFuncVar::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool
int sz = ptg_stack.size(); int sz = ptg_stack.size();
if(nparams ) if(nparams && !ptg_stack.empty())
{ {
arguments += ptg_stack.top(); arguments += ptg_stack.top();
ptg_stack.pop(); ptg_stack.pop();
......
...@@ -118,7 +118,7 @@ void RevLblName::load(CFRecord& record) ...@@ -118,7 +118,7 @@ void RevLblName::load(CFRecord& record)
st = L"_xlnm._FilterDatabase"; st = L"_xlnm._FilterDatabase";
break; break;
default: default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported value of built-in name.", record.getTypeString()); // EXCEPT::RT::WrongBiffRecord("Unsupported value of built-in name.", record.getTypeString());
} }
} }
......
...@@ -63,7 +63,7 @@ SerArPtr SerAr::createSerAr(const unsigned char type) ...@@ -63,7 +63,7 @@ SerArPtr SerAr::createSerAr(const unsigned char type)
return SerArPtr(new SerStr); return SerArPtr(new SerStr);
break; break;
default: default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of SerAr.", "SerAr container"); // EXCEPT::RT::WrongBiffRecord("Unsupported type of SerAr.", "SerAr container");
} }
} }
......
...@@ -171,7 +171,7 @@ namespace XLS ...@@ -171,7 +171,7 @@ namespace XLS
// } // }
// else // else
// { // {
// throw;// EXCEPT::RT::WrongFormulaString("Unknown operator format in formula.", assembled_formula); // // EXCEPT::RT::WrongFormulaString("Unknown operator format in formula.", assembled_formula);
// } // }
// OperatorPtgPtr operator_top; // OperatorPtgPtr operator_top;
// while(ptg_stack.size() && (operator_top = boost::dynamic_pointer_cast<OperatorPtg>(ptg_stack.top())) && // while(ptg_stack.size() && (operator_top = boost::dynamic_pointer_cast<OperatorPtg>(ptg_stack.top())) &&
...@@ -217,7 +217,7 @@ namespace XLS ...@@ -217,7 +217,7 @@ namespace XLS
// } // }
// if(!ptg_stack.size() || !left_p) // if(!ptg_stack.size() || !left_p)
// { // {
// throw;// EXCEPT::RT::WrongParenthesisSequence(assembled_formula); // // EXCEPT::RT::WrongParenthesisSequence(assembled_formula);
// } // }
// ptg_stack.pop(); // pop PtgParen that is now stored in left_p // ptg_stack.pop(); // pop PtgParen that is now stored in left_p
// last_ptg = left_p; // last_ptg = left_p;
...@@ -232,7 +232,7 @@ namespace XLS ...@@ -232,7 +232,7 @@ namespace XLS
// size_t num_parameters = left_p->getParametersNum() + 1; // size_t num_parameters = left_p->getParametersNum() + 1;
// if(num_parameters > 255) // if(num_parameters > 255)
// { // {
// throw;// EXCEPT::RT::WrongFormulaString("Too many parameters to a function", assembled_formula); // // EXCEPT::RT::WrongFormulaString("Too many parameters to a function", assembled_formula);
// } // }
// func_var->setParamsNum(static_cast<unsigned char>(num_parameters)); // func_var->setParamsNum(static_cast<unsigned char>(num_parameters));
// last_ptg = ptg_stack.top(); // last_ptg = ptg_stack.top();
...@@ -267,7 +267,7 @@ namespace XLS ...@@ -267,7 +267,7 @@ namespace XLS
// } // }
// if(!ptg_stack.size() || !left_p) // if(!ptg_stack.size() || !left_p)
// { // {
// throw;// EXCEPT::RT::WrongParenthesisSequence(assembled_formula); // // EXCEPT::RT::WrongParenthesisSequence(assembled_formula);
// } // }
// left_p->incrementParametersNum(); // The count of parameters will be transferred to PtgFuncVar // left_p->incrementParametersNum(); // The count of parameters will be transferred to PtgFuncVar
// last_ptg = left_p; // PtgParen. Mostly to differ unary and binary minuses and pluses // last_ptg = left_p; // PtgParen. Mostly to differ unary and binary minuses and pluses
...@@ -314,7 +314,7 @@ namespace XLS ...@@ -314,7 +314,7 @@ namespace XLS
// } // }
// else // else
// { // {
// throw;// EXCEPT::RT::WrongFormulaString("Unknown format of 3D reference in formula.", assembled_formula); // // EXCEPT::RT::WrongFormulaString("Unknown format of 3D reference in formula.", assembled_formula);
// } // }
// } // }
// else if(SyntaxPtg::extract_PtgName(it, itEnd, number))// Shall be placed strongly before PtgArea and PtgRef // else if(SyntaxPtg::extract_PtgName(it, itEnd, number))// Shall be placed strongly before PtgArea and PtgRef
...@@ -377,7 +377,7 @@ namespace XLS ...@@ -377,7 +377,7 @@ namespace XLS
// func = PtgFuncVar::create(L"USER_DEFINED_FUNCTION", OperandPtg::pdt_VALUE); // func = PtgFuncVar::create(L"USER_DEFINED_FUNCTION", OperandPtg::pdt_VALUE);
// if(!func) // if(!func)
// { // {
// throw;// EXCEPT::LE::WhatIsTheFuck("Ftab_Cetab doesn't contain info about user-defined function (0xFF).", __FUNCTION__); // // EXCEPT::LE::WhatIsTheFuck("Ftab_Cetab doesn't contain info about user-defined function (0xFF).", __FUNCTION__);
// } // }
// ptg_stack.push(func); // ptg_stack.push(func);
// rgce.addPtg(PtgPtr(new PtgNameX(operand_str, OperandPtg::pdt_VALUE))); // rgce.addPtg(PtgPtr(new PtgNameX(operand_str, OperandPtg::pdt_VALUE)));
...@@ -385,7 +385,7 @@ namespace XLS ...@@ -385,7 +385,7 @@ namespace XLS
// } // }
// else // else
// { // {
// throw;// EXCEPT::RT::WrongFormulaString("Unknown operand format in formula.", assembled_formula); // // EXCEPT::RT::WrongFormulaString("Unknown operand format in formula.", assembled_formula);
// } // }
// last_ptg = found_operand; // last_ptg = found_operand;
// operand_expected = false; // operand_expected = false;
......
...@@ -140,7 +140,7 @@ void XFProp::load(CFRecord& record) ...@@ -140,7 +140,7 @@ void XFProp::load(CFRecord& record)
return; return;
} }
default: default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of XFProp.", record.getTypeString()); // EXCEPT::RT::WrongBiffRecord("Unsupported type of XFProp.", record.getTypeString());
} }
record >> *xfPropDataBlob; record >> *xfPropDataBlob;
} }
......
...@@ -71,8 +71,12 @@ const bool FORMATTING::loadContent(BinProcessor& proc) ...@@ -71,8 +71,12 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
int count = 0; int count = 0;
count = 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) while(count > 0)
{
Font *font = dynamic_cast<Font *>(elements_.front().get());
if ((font) && (font->correct))
{ {
m_arFonts.push_back(elements_.front()); m_arFonts.push_back(elements_.front());
}
elements_.pop_front(); elements_.pop_front();
count--; count--;
} }
......
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
const bool loadContent(BinProcessor& proc) const bool loadContent(BinProcessor& proc)
{ {
throw;// EXCEPT::LE::UnexpectedProgramPath("Wrong loadContent usage", __FUNCTION__); // EXCEPT::LE::UnexpectedProgramPath("Wrong loadContent usage", __FUNCTION__);
} }
...@@ -137,7 +137,7 @@ BaseObjectPtr OBJECTS::clone() ...@@ -137,7 +137,7 @@ BaseObjectPtr OBJECTS::clone()
const bool OBJECTS::loadContent(BinProcessor& proc) const bool OBJECTS::loadContent(BinProcessor& proc)
{ {
throw;// EXCEPT::LE::UnexpectedProgramPath("Wrong loadContent usage", __FUNCTION__); // EXCEPT::LE::UnexpectedProgramPath("Wrong loadContent usage", __FUNCTION__);
} }
......
...@@ -60,11 +60,31 @@ BaseObjectPtr PROTECTION::clone() ...@@ -60,11 +60,31 @@ BaseObjectPtr PROTECTION::clone()
// PROTECTION = WinProtect Protect Password Prot4Rev Prot4RevPass // PROTECTION = WinProtect Protect Password Prot4Rev Prot4RevPass
const bool PROTECTION::loadContent(BinProcessor& proc) const bool PROTECTION::loadContent(BinProcessor& proc)
{ {
proc.optional<WinProtect>(); if (proc.optional<WinProtect>())
proc.optional<Protect>(); {
proc.optional<Password>(); m_WinProtect = elements_.back();
proc.optional<Prot4Rev>(); elements_.pop_back();
proc.optional<Prot4RevPass>(); }
if (proc.optional<Protect>())
{
m_Protect = elements_.back();
elements_.pop_back();
}
if (proc.optional<Password>())
{
m_Password = elements_.back();
elements_.pop_back();
}
if (proc.optional<Prot4Rev>())
{
m_Prot4Rev = elements_.back();
elements_.pop_back();
}
if (proc.optional<Prot4RevPass>())
{
m_Prot4RevPass = elements_.back();
elements_.pop_back();
}
return true; return true;
} }
......
...@@ -50,6 +50,12 @@ public: ...@@ -50,6 +50,12 @@ public:
virtual const bool loadContent(BinProcessor& proc); virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typePROTECTION; static const ElementType type = typePROTECTION;
BaseObjectPtr m_WinProtect;
BaseObjectPtr m_Protect;
BaseObjectPtr m_Password;
BaseObjectPtr m_Prot4Rev;
BaseObjectPtr m_Prot4RevPass;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -210,7 +210,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc) ...@@ -210,7 +210,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
} }
} }
}break; }break;
case rt_WriteProtect: proc.optional<WriteProtect>(); break; case rt_WriteProtect:
{
if (proc.optional<WriteProtect>())
{
m_WriteProtect = elements_.back();
elements_.pop_back();
}
}break;
case rt_FilePass: case rt_FilePass:
{ {
if (proc.optional<FilePass>()) if (proc.optional<FilePass>())
...@@ -218,11 +225,8 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc) ...@@ -218,11 +225,8 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
if (( proc.getGlobalWorkbookInfo()->decryptor) && if (( proc.getGlobalWorkbookInfo()->decryptor) &&
( proc.getGlobalWorkbookInfo()->decryptor->IsVerify() == false)) ( proc.getGlobalWorkbookInfo()->decryptor->IsVerify() == false))
{ {
if (proc.getGlobalWorkbookInfo()->password.empty()) if (!proc.getGlobalWorkbookInfo()->decryptor->SetPassword(L"VelvetSweatshop", 2))
{
if (!proc.getGlobalWorkbookInfo()->decryptor->SetPassword(L"VelvetSweatshop"))
return false; return false;
}else return false;
} }
} }
}break; }break;
...@@ -245,7 +249,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc) ...@@ -245,7 +249,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
case rt_CodeName: proc.optional<CodeName>(); break; case rt_CodeName: proc.optional<CodeName>(); break;
case rt_BuiltInFnGroupCount:proc.optional<FNGROUPS>(); break; case rt_BuiltInFnGroupCount:proc.optional<FNGROUPS>(); break;
case rt_OleObjectSize: proc.optional<OleObjectSize>(); break; case rt_OleObjectSize: proc.optional<OleObjectSize>(); break;
case rt_WinProtect: proc.optional<PROTECTION>(); break; case rt_WinProtect:
{
if (proc.optional<PROTECTION>())
{
m_PROTECTION = elements_.back();
elements_.pop_back();
}
}break;
case rt_FileSharing: proc.optional<FileSharing>(); break; case rt_FileSharing: proc.optional<FileSharing>(); break;
case rt_CodePage: case rt_CodePage:
{ {
...@@ -302,16 +313,18 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc) ...@@ -302,16 +313,18 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
case rt_XFCRC: case rt_XFCRC:
{ {
if (proc.mandatory<FORMATTING>()) if (proc.mandatory<FORMATTING>())
{
if (!m_Formating )
{ {
m_Formating = elements_.back(); m_Formating = elements_.back();
elements_.pop_back(); elements_.pop_back();
FORMATTING* fmts = dynamic_cast<FORMATTING*>(m_Formating.get()); FORMATTING* fmts = dynamic_cast<FORMATTING*>(m_Formating.get());
if (fmts) if (fmts)
{ {
proc.getGlobalWorkbookInfo()->m_arFonts = &fmts->m_arFonts; proc.getGlobalWorkbookInfo()->m_arFonts = &fmts->m_arFonts;
} }
} }
}
}break; }break;
case rt_SXStreamID: proc.repeated<PIVOTCACHEDEFINITION>(0, 0); break; case rt_SXStreamID: proc.repeated<PIVOTCACHEDEFINITION>(0, 0); break;
case rt_DocRoute: proc.repeated<DOCROUTE>(0, 0); break; case rt_DocRoute: proc.repeated<DOCROUTE>(0, 0); break;
......
...@@ -63,6 +63,8 @@ public: ...@@ -63,6 +63,8 @@ public:
BaseObjectPtr m_ExtSST; BaseObjectPtr m_ExtSST;
BaseObjectPtr m_CodePage; BaseObjectPtr m_CodePage;
BaseObjectPtr m_Country; BaseObjectPtr m_Country;
BaseObjectPtr m_WriteProtect;
BaseObjectPtr m_PROTECTION;
std::vector<BaseObjectPtr> m_arHFPicture; std::vector<BaseObjectPtr> m_arHFPicture;
std::vector<BaseObjectPtr> m_arLBL; std::vector<BaseObjectPtr> m_arLBL;
......
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