Commit 9447c725 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormatReader - fix protection files

parent 21012285
......@@ -54,10 +54,10 @@ namespace CRYPT
return crypt->IsVerify();
}
bool RC4Decryptor::SetPassword(std::wstring password)
bool RC4Decryptor::SetPassword(std::wstring password, int type)
{
crypt.reset();
crypt = CryptPtr(new RC4Crypt(crypt_data, password, 1));
crypt = CryptPtr(new RC4Crypt(crypt_data, password, type));
if (crypt) return crypt->IsVerify();
else return false;
......
......@@ -46,7 +46,7 @@ namespace CRYPT
bool IsVerify();
bool SetPassword(std::wstring password);
bool SetPassword(std::wstring password, int type = 1);
private:
CryptPtr crypt;
......
......@@ -38,18 +38,18 @@
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;
CopyDWORDs2Bytes(data.Salt.b1, data.Salt.b2, data.Salt.b3, data.Salt.b4, pnSalt);
CopyDWORDs2Bytes(data.EncryptedVerifier.b1 , data.EncryptedVerifier.b2, data.EncryptedVerifier.b3, data.EncryptedVerifier.b4, pnVerifier);
CopyDWORDs2Bytes(data.EncryptedVerifierHash.b1, data.EncryptedVerifierHash.b2, data.EncryptedVerifierHash.b3, data.EncryptedVerifierHash.b4, pnVerifierHash);
int BlockSize = 1024;
if (type == 1) BlockSize = 512;
mxDecoder.reset(new BiffDecoder_RCF(pnSalt, pnVerifier, pnVerifierHash, BlockSize));
CopyDWORDs2Bytes(data.Salt.b1, data.Salt.b2, data.Salt.b3, data.Salt.b4, pnSalt);
CopyDWORDs2Bytes(data.EncryptedVerifier.b1 , data.EncryptedVerifier.b2, data.EncryptedVerifier.b3, data.EncryptedVerifier.b4, pnVerifier);
CopyDWORDs2Bytes(data.EncryptedVerifierHash.b1, data.EncryptedVerifierHash.b2, data.EncryptedVerifierHash.b3, data.EncryptedVerifierHash.b4, pnVerifierHash);
int BlockSize = 1024;
if (type == 1) BlockSize = 512;
mxDecoder.reset(new BiffDecoder_RCF(pnSalt, pnVerifier, pnVerifierHash, BlockSize));
m_VerifyPassword = mxDecoder->verifyPassword(password);
}
......
......@@ -71,7 +71,7 @@ const bool BiffRecordSplit::storeRecordAndDecideProceeding(CFRecordPtr record)
else if(stored_record == NULL)
{
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
{
......
......@@ -76,7 +76,7 @@ void BookBool::writeFields(CFRecord& record)
}
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);
SETBIT(flags, 8, fHideBorderUnselLists);
......@@ -107,7 +107,7 @@ void BookBool::readFields(CFRecord& record)
grUpdateLinks = std::wstring (L"always");
break;
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)
}
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_;
......
......@@ -69,7 +69,7 @@ void CalcMode::writeFields(CFRecord& record)
}
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;
}
......
......@@ -65,7 +65,7 @@ void CalcRefMode::writeFields(CFRecord& record)
}
else
{
throw;// EXCEPT::LE::AttributeDataWrong(L"fRefA1", record.getTypeString().c_str(), fRefA1);
// EXCEPT::LE::AttributeDataWrong(L"fRefA1", record.getTypeString().c_str(), fRefA1);
}
record << fRef;
}
......
......@@ -54,7 +54,7 @@ BaseObjectPtr EntExU2::clone()
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)
void Font::readFields(CFRecord& record)
{
correct = false;
global_info = record.getGlobalWorkbookInfo();
unsigned short flags;
......@@ -86,7 +88,13 @@ void Font::readFields(CFRecord& record)
fExtend = GETBIT(flags, 7);
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)
{
......
......@@ -82,6 +82,8 @@ public:
FillInfoExt color_ext;
ShortXLUnicodeString fontName;
bool correct;
};
......
......@@ -60,7 +60,7 @@ void HeaderFooter::writeFields(CFRecord& record)
_GUID_ 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;
unsigned short flags = 0;
......
......@@ -46,7 +46,7 @@ BaseObjectPtr LPr::clone()
void LPr::writeFields(CFRecord& record)
{
// 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)
}
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
......@@ -267,7 +267,9 @@ void Lbl::readFields(CFRecord& record)
Name = (L"_xlnm._FilterDatabase");
break;
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()
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;
}
void Password::readFields(CFRecord& record)
{
unsigned short 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
......
......@@ -54,7 +54,8 @@ public:
static const ElementType type = typePassword;
//-----------------------------
BIFF_BSTR wPassword;
unsigned short wPassword_num;
std::wstring wPassword;
};
......
......@@ -53,16 +53,16 @@ BaseObjectPtr Prot4RevPass::clone()
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;
}
void Prot4RevPass::readFields(CFRecord& record)
{
unsigned short 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
......
......@@ -54,7 +54,8 @@ public:
static const ElementType type = typeProt4RevPass;
//-----------------------------
BIFF_BSTR protPwdRev;
unsigned short protPwdRev_num;
std::wstring protPwdRev;
};
......
......@@ -63,7 +63,8 @@ void SST::writeFields(CFRecord& record)
XLUnicodeRichExtendedStringPtr element = boost::dynamic_pointer_cast<XLUnicodeRichExtendedString>(*it);
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'
......
......@@ -60,7 +60,7 @@ void UserBView::writeFields(CFRecord& record)
_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;
......@@ -82,7 +82,7 @@ void UserBView::writeFields(CFRecord& record)
}
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);
SETBIT(flags1, 4, fDspHScroll);
......@@ -106,7 +106,7 @@ void UserBView::writeFields(CFRecord& record)
}
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);
SETBIT(flags1, 10, fPrintIncl);
......
......@@ -58,7 +58,7 @@ void UserSViewBegin::writeFields(CFRecord& record)
_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.reserveNunBytes(2); // reserved
......
......@@ -79,7 +79,7 @@ const std::wstring Bes::toString()
case 0x2B:
return L"#GETTING_DATA";
default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of Bes.", "unknown");
// EXCEPT::RT::WrongBiffRecord("Unsupported type of Bes.", "unknown");
}
}
else
......@@ -144,7 +144,7 @@ void Bes::fromString(const std::wstring str)
}
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()
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)
{
throw;// EXCEPT::LE::WhatIsTheFuck("Wrong usage of BiffString. Stack overflow stopped.", __FUNCTION__);
// record >> *this; // :-)
// EXCEPT::LE::WhatIsTheFuck("Wrong usage of BiffString. Stack overflow stopped.", __FUNCTION__);
// record >> *this; // :-)
}
......@@ -185,7 +185,7 @@ const size_t BiffString::getSize() const
{
if(!cch_)
{
throw;// EXCEPT::LE::StructureSizeNotSet("BiffString", __FUNCTION__/*__FUNCDNAME__*/);
// EXCEPT::LE::StructureSizeNotSet("BiffString", __FUNCTION__/*__FUNCDNAME__*/);
}
return *cch_;
}
......
......@@ -47,7 +47,7 @@ void BiffStructure_NoVtbl::store(CFRecord& record)
// this function will never be called ( look at operator>>(CFRecord& record, T& val))
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
}
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
case 0x2A:
return L"#N/A";
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)
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)
{
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__);
}
......
......@@ -53,7 +53,7 @@ void FtNts::store(CFRecord& record)
_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;
}
......
......@@ -102,7 +102,7 @@ void HyperlinkMoniker::load(XLS::CFRecord& record)
}
else
{
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of HyperlinkMoniker.", record.getTypeString());
// EXCEPT::RT::WrongBiffRecord("Unsupported type of HyperlinkMoniker.", record.getTypeString());
}
record >> *data;
......
......@@ -86,7 +86,7 @@ void HyperlinkObject::store(XLS::CFRecord& record)
_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;
}
......
......@@ -206,12 +206,13 @@ void OfficeArtContainer::loadFields(XLS::CFRecord& record)
}
else // If the found record is not implemented or unknown
{
if (rh_child.size() > record.getDataSize() - container_beginning_ptr)
break;
try
{
size_t sz = rh_child.size();
record.skipNunBytes(rh_child.size()); // skip header
record.skipNunBytes(rh_child.recLen); // skip record data
record.skipNunBytes(rh_child.size()); // skip art record header + data
Log::warning(std::wstring(L"Unsupported OfficeArtRecord skipped (recType=0x") +
STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)) + std::wstring(L")"));
}
......
......@@ -57,6 +57,9 @@ public:
virtual void assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full_ref = false)
{
if (ptg_stack.empty())
return;
std::wstring operand2(ptg_stack.top());
ptg_stack.pop();
ptg_stack.top() += getOperatorSymbols() + operand2;
......@@ -74,6 +77,9 @@ public:
UOperatorPtg_T() : OperatorPtg(fixedType) {};
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();
};
virtual const unsigned short getPtgId() const {return fixedType;};
......
......@@ -90,7 +90,7 @@ const std::wstring ParsedFormula::getAssembledFormula(bool full_ref) const
if(1 != ptg_stack.size())
{
return L"";
//throw; EXCEPT::LE::WrongAPIUsage("Wrong formula assembling.", __FUNCTION__);
//EXCEPT::LE::WrongAPIUsage("Wrong formula assembling.", __FUNCTION__);
}
return ptg_stack.top();
}
......
......@@ -59,7 +59,7 @@ PtgBool::PtgBool(const std::wstring& word)
}
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)
{
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;
......@@ -155,7 +155,7 @@ void PtgExtraArray::fromString(const std::wstring& str)
}
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
int sz = ptg_stack.size();
if(nparams )
if(nparams && !ptg_stack.empty())
{
arguments += ptg_stack.top();
ptg_stack.pop();
......
......@@ -118,7 +118,7 @@ void RevLblName::load(CFRecord& record)
st = L"_xlnm._FilterDatabase";
break;
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)
return SerArPtr(new SerStr);
break;
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
// }
// 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;
// while(ptg_stack.size() && (operator_top = boost::dynamic_pointer_cast<OperatorPtg>(ptg_stack.top())) &&
......@@ -217,7 +217,7 @@ namespace XLS
// }
// 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
// last_ptg = left_p;
......@@ -232,7 +232,7 @@ namespace XLS
// size_t num_parameters = left_p->getParametersNum() + 1;
// 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));
// last_ptg = ptg_stack.top();
......@@ -267,7 +267,7 @@ namespace XLS
// }
// 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
// last_ptg = left_p; // PtgParen. Mostly to differ unary and binary minuses and pluses
......@@ -314,7 +314,7 @@ namespace XLS
// }
// 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
......@@ -377,7 +377,7 @@ namespace XLS
// func = PtgFuncVar::create(L"USER_DEFINED_FUNCTION", OperandPtg::pdt_VALUE);
// 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);
// rgce.addPtg(PtgPtr(new PtgNameX(operand_str, OperandPtg::pdt_VALUE)));
......@@ -385,7 +385,7 @@ namespace XLS
// }
// 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;
// operand_expected = false;
......
......@@ -140,7 +140,7 @@ void XFProp::load(CFRecord& record)
return;
}
default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of XFProp.", record.getTypeString());
// EXCEPT::RT::WrongBiffRecord("Unsupported type of XFProp.", record.getTypeString());
}
record >> *xfPropDataBlob;
}
......
......@@ -72,7 +72,11 @@ 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_arFonts.push_back(elements_.front());
Font *font = dynamic_cast<Font *>(elements_.front().get());
if ((font) && (font->correct))
{
m_arFonts.push_back(elements_.front());
}
elements_.pop_front();
count--;
}
......
......@@ -109,7 +109,7 @@ public:
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()
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()
// PROTECTION = WinProtect Protect Password Prot4Rev Prot4RevPass
const bool PROTECTION::loadContent(BinProcessor& proc)
{
proc.optional<WinProtect>();
proc.optional<Protect>();
proc.optional<Password>();
proc.optional<Prot4Rev>();
proc.optional<Prot4RevPass>();
if (proc.optional<WinProtect>())
{
m_WinProtect = elements_.back();
elements_.pop_back();
}
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;
}
......
......@@ -50,6 +50,12 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typePROTECTION;
BaseObjectPtr m_WinProtect;
BaseObjectPtr m_Protect;
BaseObjectPtr m_Password;
BaseObjectPtr m_Prot4Rev;
BaseObjectPtr m_Prot4RevPass;
};
} // namespace XLS
......
......@@ -210,7 +210,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
}
}
}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:
{
if (proc.optional<FilePass>())
......@@ -218,11 +225,8 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
if (( proc.getGlobalWorkbookInfo()->decryptor) &&
( proc.getGlobalWorkbookInfo()->decryptor->IsVerify() == false))
{
if (proc.getGlobalWorkbookInfo()->password.empty())
{
if (!proc.getGlobalWorkbookInfo()->decryptor->SetPassword(L"VelvetSweatshop"))
return false;
}else return false;
if (!proc.getGlobalWorkbookInfo()->decryptor->SetPassword(L"VelvetSweatshop", 2))
return false;
}
}
}break;
......@@ -245,7 +249,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
case rt_CodeName: proc.optional<CodeName>(); break;
case rt_BuiltInFnGroupCount:proc.optional<FNGROUPS>(); 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_CodePage:
{
......@@ -303,13 +314,15 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
{
if (proc.mandatory<FORMATTING>())
{
m_Formating = elements_.back();
elements_.pop_back();
FORMATTING* fmts = dynamic_cast<FORMATTING*>(m_Formating.get());
if (fmts)
if (!m_Formating )
{
proc.getGlobalWorkbookInfo()->m_arFonts = &fmts->m_arFonts;
m_Formating = elements_.back();
elements_.pop_back();
FORMATTING* fmts = dynamic_cast<FORMATTING*>(m_Formating.get());
if (fmts)
{
proc.getGlobalWorkbookInfo()->m_arFonts = &fmts->m_arFonts;
}
}
}
}break;
......
......@@ -63,6 +63,8 @@ public:
BaseObjectPtr m_ExtSST;
BaseObjectPtr m_CodePage;
BaseObjectPtr m_Country;
BaseObjectPtr m_WriteProtect;
BaseObjectPtr m_PROTECTION;
std::vector<BaseObjectPtr> m_arHFPicture;
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