Compare commits

...

14 Commits

Author SHA1 Message Date
8fe1eb7525 XlsFormat - activeX, controls & ole embedded & links 2017-10-16 11:28:46 +03:00
1deb2a6905 Merge 2017-10-13 14:44:53 +03:00
69a787411c xml string as second command-line param(first - path to xml) 2017-10-13 13:51:27 +03:00
22f986295f . 2017-10-12 18:17:16 +03:00
86d2bde83b x2t version up 2017-10-12 12:01:44 +03:00
07041d60f6 . 2017-10-12 11:54:47 +03:00
a5466ab740 XlsFormatReader - external data (dde, workbook, ..) 2017-10-12 11:41:21 +03:00
dfd54ff53f _MSC_VER >= 1900 build 2017-10-11 16:30:37 +03:00
3813be21c7 --all-fonts-path param 2017-10-09 15:11:30 +03:00
68c8c0cb29 Merge pull request #42 from ONLYOFFICE/feature/docbuilder
Feature/docbuilder
2017-10-06 11:57:57 +03:00
ab0c5703a5 Added empty files 2017-10-06 11:04:59 +03:00
e22b63347f v8 (windows correct) 2017-10-05 18:13:52 +03:00
438ba3aded v5.0.1 2017-10-05 14:46:28 +03:00
29b002ca80 Added docbuilder target 2017-10-04 14:56:03 +03:00
140 changed files with 2192 additions and 800 deletions

View File

@ -501,7 +501,7 @@ namespace DocFileFormat
facet.widen((char*)bytes, (char*)bytes + size, &result[0]);
for (long i=0; i < result.length(); i++)
for (size_t i=0; i < result.length(); i++)
{
STLCollection->push_back(result[i]);
}
@ -536,7 +536,7 @@ namespace DocFileFormat
delete [] pStrUtf16;
return GetSTLCollectionFromLocale(STLCollection, bytes,size);
}
for (long i=0; i < nLength; i++)
for (unsigned int i = 0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf16[i]);
}
@ -566,7 +566,7 @@ namespace DocFileFormat
delete [] pStrUtf32;
return GetSTLCollectionFromLocale(STLCollection, bytes, size);
}
for (long i=0; i < nLength; i++)
for (unsigned int i = 0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf32[i]);
}
@ -652,7 +652,7 @@ namespace DocFileFormat
NSUnicodeConverter::CUnicodeConverter oConverter;
std::wstring unicode_string = oConverter.toUnicode((char*)bytes, size, sCodePage.c_str());
for (long i=0; i < unicode_string.size(); i++)
for (size_t i = 0; i < unicode_string.size(); i++)
{
STLCollection->push_back(unicode_string[i]);
}

View File

@ -154,7 +154,7 @@ namespace cpdoccore
if (val)
{
std::wstring tmp = *val;
XmlUtils::GetLower(tmp);
tmp = XmlUtils::GetLower(tmp);
return optional<bool>::Type((tmp == xml_char_value_type::trueVal));
}
else

View File

@ -55,8 +55,8 @@ public:
void add_format(std::wstring const & condition, std::wstring const & format)
{
std::wstring c = condition;
XmlUtils::GetLower(c);
std::wstring c = XmlUtils::GetLower(condition);
XmlUtils::replace_all( c, L" ", L"");
XmlUtils::replace_all( c, L"\t", L"");

View File

@ -46,8 +46,7 @@ std::wostream & operator << (std::wostream & _Wostream, const Bool & _Val)
}
Bool Bool::parse(const std::wstring & Str)
{
std::wstring tmp = Str;
XmlUtils::GetLower(tmp);
std::wstring tmp = XmlUtils::GetLower(Str);
if (tmp == L"0" || tmp == L"false") return Bool(false);
else return Bool(true);

View File

@ -104,8 +104,7 @@ void styles_container::add_style( const std::wstring & Name,
map_[n] = pos;
// TODO: как правильно??
std::wstring lName = Name;
XmlUtils::GetLower(lName);
std::wstring lName = XmlUtils::GetLower(Name);
//if ( boost::algorithm::contains(lName, L"internet_20_link") )
if (lName == L"internet_20_link")///???????????????
hyperlink_style_pos_ = pos;

View File

@ -514,49 +514,31 @@ const std::wstring tab2sheet_name(const short tabid, std::vector<std::wstring>&
return L"#REF";
}
//
const std::wstring xti2sheets(const unsigned short ixti, std::vector<std::wstring>& xti_parsed)
const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabLast, std::vector<std::wstring>& names, const std::wstring prefix)
{
if(ixti >= 0 && static_cast<unsigned short>(ixti) < xti_parsed.size())
{
return xti_parsed[ixti];
}
return L"#REF!";
}
//
const std::wstring xti_indexes2sheet_name(const short itabFirst, const short itabLast, std::vector<std::wstring>& sheets_names)
{
if(-1 == itabFirst)
if(-1 == tabFirst)
{
return L"#REF";
}
static boost::wregex correct_sheet_name(L"^\\'.+?\\'$");
static boost::wregex test_sheet_name(L"[\\s)(\\':.-]+");
static boost::wregex test_sheet_name(L"[\\s)(\\'&:-]+"); //.??? 6442946.xls
std::wstring sheet_first = prefix + tab2sheet_name(tabFirst, names);
std::wstring sheet_first = tab2sheet_name(itabFirst, sheets_names);
if(!boost::regex_search(sheet_first.begin(), sheet_first.end(), correct_sheet_name))
{
if(boost::regex_search(sheet_first.begin(), sheet_first.end(), test_sheet_name))
{
sheet_first = boost::algorithm::replace_all_copy(sheet_first, L"'", L"''");
sheet_first = std::wstring(L"\'") + sheet_first + std::wstring(L"\'");
sheet_first = std::wstring(L"'") + sheet_first + std::wstring(L"'");
}
}
else
{
//todooo найти хоть один файл где в апострофах уже есть внутренний не экранированный апостроф
//static boost::wregex test_sheet_name1(L"[\']+");
//if(boost::regex_search(sheet_first.begin() + 1, sheet_first.end() - 1, test_sheet_name1))
//{
// sheet_first = boost::algorithm::replace_all_copy(sheet_first.begin()+1, sheet_first.end() - 1 , L"'", L"''");
// sheet_first = std::wstring(L"\'") + sheet_first + std::wstring(L"\'");
//}
}
std::wstring sheet_last;
if (itabLast != itabFirst)
if (tabLast != tabFirst)
{
sheet_last = tab2sheet_name(itabLast, sheets_names);
sheet_last = prefix + tab2sheet_name(tabLast, names);
if(!boost::regex_search(sheet_last.begin(), sheet_last.end(), correct_sheet_name))
{
@ -572,20 +554,6 @@ const std::wstring xti_indexes2sheet_name(const short itabFirst, const short ita
return sheet_first + sheet_last;
}
const std::wstring make3dRef(const unsigned short ixti, const std::wstring cell_ref, std::vector<std::wstring>& xti_parsed, bool full_ref)
{
std::wstring sheets_prefix = xti2sheets(ixti, xti_parsed);
if(L"#REF!" == sheets_prefix)
{
return sheets_prefix;
}
else if (!sheets_prefix.empty()) sheets_prefix += L"!";
else if (sheets_prefix.empty() && full_ref) sheets_prefix += L"#REF!";
return sheets_prefix + cell_ref;
}
} //namespace XMLSTUFF

View File

@ -95,13 +95,7 @@ namespace STR
namespace XMLSTUFF
{;
// Makes a new tag and append it to parent (no attributes set)
//BiffStructurePtr createElement(const std::wstring & tag_name, BiffStructurePtr & parent);
const std::wstring make3dRef(const unsigned short ixti, const std::wstring cell_ref, std::vector<std::wstring>& xti_parsed, bool full_ref = false);
//const unsigned short sheetsnames2ixti(const std::wstring str, MSXML2::IXMLDOMDocumentPtr doc);
const std::wstring xti_indexes2sheet_name(const short itabFirst, const short itabLast, std::vector<std::wstring>& sheets_names);
const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabLast, std::vector<std::wstring>& names, const std::wstring prefix = L"");
}

View File

@ -245,7 +245,7 @@ const bool CFRecord::isEOF() const
{
if(rdPtr > size_)
{
throw;// EXCEPT::LE::WrongFormatInterpretation(__FUNCTION__);
true;//throw;
}
return rdPtr >= size_;
}

View File

@ -77,6 +77,8 @@ private:
std::map<std::string, CFStreamPtr> streams;
ReadWriteMode rwMode;
};
typedef boost::shared_ptr<CompoundFile> CompoundFilePtr;
} // namespace XLS

View File

@ -32,14 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/BookExt_Conditional11.h>
#include <Logic/Biff_structures/BookExt_Conditional12.h>
#include "../Biff_structures/BookExt_Conditional11.h"
#include "../Biff_structures/BookExt_Conditional12.h"
namespace XLS
{
// Logical representation of BookExt record in BIFF8
class BookExt: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(BookExt)
@ -49,13 +47,11 @@ public:
~BookExt();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeBookExt;
static const ElementType type = typeBookExt;
//-----------------------------
_UINT32 cb;
bool fDontAutoRecover;

View File

@ -31,7 +31,6 @@
*/
#include "CRN.h"
#include <Logic/Biff_structures/SerAr.h>
namespace XLS
{
@ -40,12 +39,10 @@ CRN::CRN()
{
}
CRN::~CRN()
{
}
BaseObjectPtr CRN::clone()
{
return BaseObjectPtr(new CRN(*this));
@ -55,10 +52,12 @@ BaseObjectPtr CRN::clone()
void CRN::readFields(CFRecord& record)
{
record >> colLast >> colFirst >> row;
for(int i = 0; i < colLast - colFirst + 1; ++i)
{
unsigned char rec_type;
record >> rec_type;
SerArPtr ser(SerAr::createSerAr(rec_type));
record >> *ser;
crnOper.push_back(ser);

View File

@ -32,13 +32,11 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/SerAr.h>
#include "../Biff_structures/SerAr.h"
namespace XLS
{
// Logical representation of CRN record in BIFF8
class CRN: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(CRN)
@ -48,18 +46,16 @@ public:
~CRN();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeCRN;
static const ElementType type = typeCRN;
//-----------------------------
unsigned char colLast;
unsigned char colFirst;
_UINT16 row;
BiffStructurePtrVector crnOper;
};
} // namespace XLS

View File

@ -53,7 +53,10 @@ BaseObjectPtr CodeName::clone()
void CodeName::readFields(CFRecord& record)
{
XLUnicodeString codeName;
record >> codeName;
value = codeName.value();
}
} // namespace XLS

View File

@ -37,8 +37,6 @@
namespace XLS
{
// Logical representation of CodeName record in BIFF8
class CodeName: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(CodeName)
@ -49,14 +47,11 @@ public:
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeCodeName;
//-----------------------------
XLUnicodeString codeName;
static const ElementType type = typeCodeName;
std::wstring value;
};
} // namespace XLS

View File

@ -35,8 +35,8 @@
namespace XLS
{
ExternName::ExternName(const unsigned short supporting_link_type)
: supbook_cch(supporting_link_type), cf(0)
ExternName::ExternName(const unsigned short supporting_link_type, bool bOle)
: supbook_cch(supporting_link_type), cf(-1), bOleVirtualPath(bOle)
{
}
@ -70,53 +70,40 @@ void ExternName::readFields(CFRecord& record)
}
else
{
if(fOle && !fOleLink) // DDE data item
if(fOle && !fOleLink)
{
body = BiffStructurePtr(new ExternDdeLinkNoOper);
}
if(!fOle && fOleLink) // DDE data item
if(!fOle && fOleLink)
{
body = BiffStructurePtr(new ExternOleDdeLink);
}
// Nu i kak ya dolzhen opredelit', DDE eto ili OLE?!!!
// V Mikrosofte vse ebanutye - pust' sami parsyat, debily
if(!fOle && !fOleLink)
{
body = BiffStructurePtr(new ExternDocName);
}
// This fills in the gaps between AddinUdfs if the body is not AddinUdf. The simplest way to maintain indexing from my point of view.
}
body->load(record);
if(0x3A01 != supbook_cch)
{
std::wstring name;
if(!fOle && !fOleLink)
{
ExternDocName* n = dynamic_cast<ExternDocName*>(body.get());
if (n->ixals > 0)
if (bOleVirtualPath)
{
//from SupBook
body = BiffStructurePtr(new ExternOleDdeLink);
}
else
{
name = n->nameDefinition.getAssembledFormula();
if (name.empty())
name = n->extName.value();
body = BiffStructurePtr(new ExternDocName);
}
}
if(fOle && !fOleLink) // DDE data item
{
ExternDdeLinkNoOper* n = dynamic_cast<ExternDdeLinkNoOper*>(body.get());
name = n->linkName.value();
}
if(!fOle && fOleLink)
{
ExternOleDdeLink* n = dynamic_cast<ExternOleDdeLink*>(body.get());
name = n->linkName.value();
}
record.getGlobalWorkbookInfo()->arExternalNames.push_back(name);
}
body->load(record);
//cache
switch(cf)
{
case 0: // is text
break;
case 5: //csv (,)
case 6: //Microsoft Symbolic Link (SYLK).
case 8: //biff8
case 44: //unicode text
case 63: //biff12
break;
}
}

View File

@ -48,11 +48,10 @@ class ExternName: public BiffRecord
BIFF_RECORD_DEFINE_TYPE_INFO(ExternName)
BASE_OBJECT_DEFINE_CLASS_NAME(ExternName)
public:
ExternName(const unsigned short supporting_link_type);
ExternName(const unsigned short supporting_link_type, bool bOle);
~ExternName();
BaseObjectPtr clone();
void readFields(CFRecord& record);
@ -64,24 +63,13 @@ public:
bool fWantPict;
bool fOle;
bool fOleLink;
_UINT16 cf;
short cf;
bool fIcon;
BiffStructurePtr body;
//-----------------------------
_UINT16 supbook_cch;
//if(0x3A01 == supbook_cch)
//{
// if(!body)
// {
// body = BiffStructurePtr(new AddinUdf);
// }
//}
//else
//{
//}
_UINT16 supbook_cch;
bool bOleVirtualPath;
};
typedef boost::shared_ptr<ExternName> ExternNamePtr;

View File

@ -58,14 +58,14 @@ void ExternSheet::readFields(CFRecord& record)
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
unsigned char type;
//record.skipNunBytes(record.getDataSize() - record.getRdPtr());
ShortXLAnsiString stName;
record >> type >> stName;
std::wstring name = stName.value();
//int type = stName.value().substr(0, 1).c_str()[0];
if (!name.empty())
record.getGlobalWorkbookInfo()->arExternalNames.push_back(name);
name = stName.value();
//int type = stName.value().substr(0, 1).c_str()[0];
//if (!name.empty())
// record.getGlobalWorkbookInfo()->arExternalNames.push_back(name);
}
else

View File

@ -32,13 +32,11 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/XTI.h>
#include "../Biff_structures/XTI.h"
namespace XLS
{
// Logical representation of ExternSheet record in BIFF8
class ExternSheet: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(ExternSheet)
@ -48,15 +46,15 @@ public:
~ExternSheet();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeExternSheet;
static const ElementType type = typeExternSheet;
//-----------------------------
ForwardOnlyParam<_UINT16> cXTI;
BiffStructurePtrVector rgXTI;
_UINT16 cXTI;
BiffStructurePtrVector rgXTI;
//------------------------------------------------
std::wstring name; //biff5
};
} // namespace XLS

View File

@ -67,8 +67,12 @@ void MsoDrawing::readFields()
rgChildRec.rh_own.recLen = stored_record->getDataSize();
rgChildRec.loadFields(*stored_record);
if (stored_record->getRdPtr() < stored_record->getDataSize())
{
int g = 0;
}
}
isReading = true;
}
@ -77,6 +81,11 @@ void MsoDrawing::readFields(CFRecord& record)
record >> rgChildRec;
isReading = true;
if (record.getRdPtr() < record.getDataSize())
{
int g = 0;
}
}

View File

@ -52,7 +52,7 @@ BaseObjectPtr ObProj::clone()
void ObProj::readFields(CFRecord& record)
{
// the tag doesn't contain data
//vba present in file .. выше .. по наличию собствено стороджа
}
} // namespace XLS

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of ObProj record in BIFF8
class ObProj: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(ObProj)
@ -47,13 +45,10 @@ public:
~ObProj();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeObProj;
};
} // namespace XLS

View File

@ -57,9 +57,9 @@
#define OBJ_Label 0x000E
#define OBJ_DialogBox 0x000F
#define OBJ_SpinControl 0x0010
#define OBJ_Scrollbar 0x0011
#define OBJ_List 0x0012
#define OBJ_GroupBox 0x0013
#define OBJ_Scrollbar 0x0011
#define OBJ_DropdownList 0x0014
#define OBJ_Note 0x0019
@ -80,7 +80,6 @@ BaseObjectPtr Obj::clone()
void Obj::readFields(CFRecord& record)
{
record >> cmo;
size_t rdPtr = record.getRdPtr();
if (record.getGlobalWorkbookInfo()->Version >= 0x0600)
{
@ -88,62 +87,74 @@ void Obj::readFields(CFRecord& record)
{
record.skipNunBytes(6); // Skip FtGmo (obsolete)
}
if(OBJ_Picture == cmo.ot)
if( OBJ_Picture == cmo.ot)
{
record >> pictFormat;
record >> pictFlags;
}
if(0x0B == cmo.ot || 0x0C == cmo.ot)
if( OBJ_CheckBox == cmo.ot ||
OBJ_RadioButton == cmo.ot)
{
record.skipNunBytes(16); // Skip FtCbls (obsolete)
}
if(0x0C == cmo.ot)
if( OBJ_RadioButton == cmo.ot)
{
record.skipNunBytes(10); // Skip FtRbo (obsolete)
}
if(0x10 == cmo.ot || 0x11 == cmo.ot || 0x12 == cmo.ot || 0x14 == cmo.ot)
if( OBJ_SpinControl == cmo.ot ||
OBJ_Scrollbar == cmo.ot ||
OBJ_List == cmo.ot ||
OBJ_DropdownList == cmo.ot)
{
record >> sbs;
}
if(0x19 == cmo.ot)
if( OBJ_Note == cmo.ot)
{
record >> nts;
}
//if(false) // TODO: Find out the condition
//{
// macro.load(record);
//}
if(0x0B == cmo.ot || 0x0C == cmo.ot || 0x10 == cmo.ot || 0x11 == cmo.ot || 0x12 == cmo.ot /*|| 0x14 == cmo.ot*/)
macro.load(record);
if( OBJ_Picture == cmo.ot)
{
pictFmla.load(record, pictFlags);
}
if( OBJ_CheckBox == cmo.ot ||
OBJ_RadioButton == cmo.ot ||
OBJ_SpinControl == cmo.ot ||
OBJ_Scrollbar == cmo.ot ||
OBJ_List == cmo.ot /*|| OBJ_DropdownList == cmo.ot*/)
{
linkFmla.load(record);
}
if(0x0B == cmo.ot || 0x0C == cmo.ot)
if( OBJ_CheckBox == cmo.ot ||
OBJ_RadioButton == cmo.ot)
{
checkBox.load(record);
}
if(0x0C == cmo.ot)
if( OBJ_RadioButton == cmo.ot)
{
radioButton.load(record);
}
if(0x0D == cmo.ot)
if( OBJ_EditBox == cmo.ot)
{
edit.load(record);
}
if(0x12 == cmo.ot || 0x14 == cmo.ot)
if( OBJ_List == cmo.ot ||
OBJ_DropdownList == cmo.ot)
{
list.load(record, cmo.ot);
}
if(0x13 == cmo.ot)
if( OBJ_GroupBox == cmo.ot)
{
gbo.load(record);
}
if(0x12 != cmo.ot && 0x14 != cmo.ot)
}
if( OBJ_List != cmo.ot && OBJ_DropdownList != cmo.ot)
{
record.skipNunBytes(4); // reserved
}
//------------------------------------------------------------------------------------------------------
if (continue_records.size() > 0)
{
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];

View File

@ -32,27 +32,25 @@
#pragma once
#include "BiffRecordContinued.h"
#include "MsoDrawing.h"
#include <Logic/Biff_structures/FtCmo.h>
#include <Logic/Biff_structures/FtCf.h>
#include <Logic/Biff_structures/FtPioGrbit.h>
#include <Logic/Biff_structures/FtSbs.h>
#include <Logic/Biff_structures/FtNts.h>
#include <Logic/Biff_structures/FtMacro.h>
#include <Logic/Biff_structures/FtPictFmla.h>
#include <Logic/Biff_structures/ObjLinkFmla.h>
#include <Logic/Biff_structures/FtCblsData.h>
#include <Logic/Biff_structures/FtRboData.h>
#include <Logic/Biff_structures/FtEdoData.h>
#include <Logic/Biff_structures/FtLbsData.h>
#include <Logic/Biff_structures/FtGboData.h>
#include <Logic/Biff_records/MsoDrawing.h>
#include "../Biff_structures/FtCmo.h"
#include "../Biff_structures/FtCf.h"
#include "../Biff_structures/FtPioGrbit.h"
#include "../Biff_structures/FtSbs.h"
#include "../Biff_structures/FtNts.h"
#include "../Biff_structures/FtMacro.h"
#include "../Biff_structures/FtPictFmla.h"
#include "../Biff_structures/ObjLinkFmla.h"
#include "../Biff_structures/FtCblsData.h"
#include "../Biff_structures/FtRboData.h"
#include "../Biff_structures/FtEdoData.h"
#include "../Biff_structures/FtLbsData.h"
#include "../Biff_structures/FtGboData.h"
namespace XLS
{
// Logical representation of Obj record in BIFF8
class Obj : public BiffRecordContinued
{
BIFF_RECORD_DEFINE_TYPE_INFO(Obj)
@ -65,11 +63,10 @@ public:
~Obj();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeObj;
static const ElementType type = typeObj;
//-----------------------------
FtCmo cmo;
@ -104,8 +101,6 @@ public:
_UINT16 flag;
_UINT16 flag2;
}old_version;
};
} // namespace XLS

View File

@ -39,12 +39,10 @@ Pls::Pls()
{
}
Pls::~Pls()
{
}
BaseObjectPtr Pls::clone()
{
return BaseObjectPtr(new Pls());
@ -71,9 +69,9 @@ void Pls::readFields(CFRecord& record)
}
int size = record.getDataSize() - 2;
const char* data = record.getData() + 2;
const BYTE* data = (BYTE*)record.getData() + 2;
boost::shared_array<char> buffer(new char[size]);
boost::shared_array<BYTE> buffer(new BYTE[size]);
memcpy(buffer.get(), data, size);
bin_data_id = -1;
@ -81,7 +79,7 @@ void Pls::readFields(CFRecord& record)
GlobalWorkbookInfo* globla_info = record.getGlobalWorkbookInfo().get();
if (globla_info)
{
globla_info->bin_data.push_back(std::pair<boost::shared_array<char>, size_t>(buffer, size));
globla_info->bin_data.push_back(std::pair<boost::shared_array<BYTE>, size_t>(buffer, size));
bin_data_id = globla_info->bin_data.size() - 1;
}

View File

@ -31,7 +31,7 @@
*/
#pragma once
#include <Logic/Biff_records/BiffRecordContinued.h>
#include "BiffRecordContinued.h"
#if !defined(_WIN32) && !defined(_WIN64)
@ -109,9 +109,7 @@
namespace XLS
{
// Logical representation of Pls record in BIFF8
class Pls : public BiffRecordContinued
class Pls : public BiffRecordContinued
{
BIFF_RECORD_DEFINE_TYPE_INFO(Pls)
BASE_OBJECT_DEFINE_CLASS_NAME(Pls)

View File

@ -32,14 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/RkRec.h>
#include <Logic/Biff_structures/Cell.h>
#include "../Biff_structures/RkRec.h"
#include "../Biff_structures/Cell.h"
namespace XLS
{
// Logical representation of RK record in BIFF8
class RK: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(RK)
@ -49,7 +47,6 @@ public:
~RK();
BaseObjectPtr clone();
void readFields(CFRecord& record);

View File

@ -32,13 +32,10 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/SheetId.h>
#include "../Biff_structures/SheetId.h"
namespace XLS
{
// Logical representation of RRTabId record in BIFF8
class RRTabId: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(RRTabId)
@ -48,7 +45,6 @@ public:
~RRTabId();
BaseObjectPtr clone();
void readFields(CFRecord& record);

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of RecalcId record in BIFF8
class RecalcId: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(RecalcId)
@ -47,16 +45,12 @@ public:
~RecalcId();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeRecalcId;
//-----------------------------
_UINT32 dwBuild;
};
} // namespace XLS

View File

@ -35,7 +35,7 @@
namespace XLS
{
SupBook::SupBook()
SupBook::SupBook() : bOleLink(false), bSimple(false), bPath(false)
{
}
@ -55,22 +55,133 @@ void SupBook::readFields(CFRecord& record)
record >> ctab >> cch;
if(0x0001 <= cch && 0x00ff >= cch)
{
virtPath.setSize(cch);
record >> virtPath;
//virtPath.EscapeUrlW(); //todooo проверить спец символы !!!
//if(virtPath.isConformToVirtPath() && !virtPath.isConformToOleLink())
XLUnicodeStringNoCch temp;
temp.setSize(cch);
record >> temp;
origin = temp.value();
while(!record.isEOF())
{
record >> rgst;
XLUnicodeString temp2;
record >> temp2;
rgst.push_back(temp2.value());
}
}
//virt-path = volume / unc-volume / rel-volume / transfer-protocol / startup / alt-startup / library / simple-file-path / ole-link
//ole-link = path-string %x0003 path-string
//simple-file-path = [%x0001]
//file-path startup = %x0001 %x0006 file-path
//alt-startup = %x0001 %x0007 file-path
//library = %x0001 %x0008 file-path
//transfer-protocol = %x0001 %x0005 count transfer-path
//transfer-path = transfer-base-path / "[" transfer-base-path "]" sheet-name
//transfer-base-path = transfer-type "://" file-path
//transfer-type = "ftp" / "http" / "https"
//rel-volume = %x0001 %x0002 file-path
//...
bool bFilePathType = false;
if (!origin.empty())
{
std::wstring sTmp = origin;
while(true)
{
int pos = sTmp.find(L"\x0001");
if (pos >= 0)
{
if (bSimple)
{
bFilePathType = true;
bPath = true; //xls_result.xls
}
else bSimple = true; //file name or file path
virtPath.push_back(sTmp.substr(0, pos));
sTmp = sTmp.substr(pos + 1);
continue;
}
pos = sTmp.find(L"\x0002");
if (pos >= 0)
{
if (bSimple)
bPath = true;
virtPath.push_back(sTmp.substr(0, pos));
sTmp = sTmp.substr(pos + 1);
continue;
}
pos = sTmp.find(L"\x0003");
if (pos >= 0)
{
if (bPath)
{
if (bFilePathType)
{
virtPath.back() += L"file:///" + sTmp.substr(0, 1) + L":\\" + sTmp.substr(1, pos - 1);
bFilePathType = false;
}
else
virtPath.back() += L"/" + sTmp.substr(0, pos);
}
else
{
bOleLink = true;
virtPath.push_back(sTmp.substr(0, pos));
}
sTmp = sTmp.substr(pos + 1);
continue;
}
pos = sTmp.find(L"\x0004");
if (pos >= 0)
{
virtPath.push_back(sTmp.substr(0, pos));
sTmp = sTmp.substr(pos + 1);
continue;
}
pos = sTmp.find(L"\x0005");
if (pos >= 0)
{
virtPath.push_back(sTmp.substr(0, pos));
//skip http size
sTmp = sTmp.substr(pos + 2);
continue;
}
pos = sTmp.find(L"\x0006");
if (pos >= 0)
{
virtPath.push_back(sTmp.substr(0, pos));
sTmp = sTmp.substr(pos + 1);
continue;
}
pos = sTmp.find(L"\x0007");
if (pos >= 0)
{
virtPath.push_back(sTmp.substr(0, pos));
sTmp = sTmp.substr(pos + 1);
continue;
}
pos = sTmp.find(L"\x0008");
if (pos >= 0)
{
virtPath.push_back(sTmp.substr(0, pos));
sTmp = sTmp.substr(pos + 1);
continue;
}
break;
}
if (bPath)
{
virtPath.back() += L"/" + sTmp;
}
else
{
virtPath.push_back(sTmp);
}
}
}
const unsigned short SupBook::getSupportingLinkType() const
{
return cch;
}
} // namespace XLS

View File

@ -37,8 +37,6 @@
namespace XLS
{
// Logical representation of SupBook record in BIFF8
class SupBook: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(SupBook)
@ -47,22 +45,23 @@ public:
SupBook();
~SupBook();
const unsigned short getSupportingLinkType() const;
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeSupBook;
_UINT16 ctab;
_UINT16 cch;
std::wstring origin;
std::vector<std::wstring> rgst;
//-----------------------------
_UINT16 ctab;
_UINT16 cch;
XLUnicodeStringNoCch virtPath;
XLUnicodeString rgst;
std::vector<std::wstring> virtPath;
bool bOleLink;
bool bSimple;
bool bPath;
};
typedef boost::shared_ptr<SupBook> SupBookPtr;

View File

@ -31,7 +31,7 @@
*/
#include "Sync.h"
#include <Logic/Biff_structures/CellRef.h>
#include "../Biff_structures/CellRef.h"
namespace XLS
{

View File

@ -35,9 +35,6 @@
namespace XLS
{
// Logical representation of UsesELFs record in BIFF8
class UsesELFs: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(UsesELFs)
@ -47,15 +44,12 @@ public:
~UsesELFs();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeUsesELFs;
static const ElementType type = typeUsesELFs;
//-----------------------------
Boolean<unsigned short> useselfs;
};
} // namespace XLS

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of XCT record in BIFF8
class XCT: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(XCT)
@ -50,9 +48,8 @@ public:
void readFields(CFRecord& record);
static const ElementType type = typeXCT;
static const ElementType type = typeXCT;
//-----------------------------
_UINT16 ccrn;
_UINT16 itab;
bool itab_exist;

View File

@ -46,7 +46,6 @@ void AddinUdf::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
record >> udfName;
record.getGlobalWorkbookInfo()->AddinUdfs.push_back(udfName);
unsigned short cb;
record >> cb;

View File

@ -32,7 +32,7 @@
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/BiffString.h>
#include "BiffString.h"
namespace XLS
{
@ -47,8 +47,7 @@ public:
virtual void load(CFRecord& record);
static const ElementType type = typeAddinUdf;
static const ElementType type = typeAddinUdf;
ShortXLUnicodeString udfName;
};

View File

@ -33,7 +33,7 @@
#include "BiffStructure.h"
#include "CellRef.h"
#include <Logic/Biff_structures/BitMarkedStructs.h>
#include "BitMarkedStructs.h"
namespace XLS
{
@ -51,7 +51,6 @@ public:
virtual void load(CFRecord& record);
const CellRef getLocation() const;
static const ElementType type = typeCell;

View File

@ -32,7 +32,7 @@
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/BiffString.h>
#include "BiffString.h"
namespace XLS
{
@ -47,7 +47,6 @@ public:
virtual void load(CFRecord& record);
static const ElementType type = typeExternDdeLinkNoOper;
ShortXLUnicodeString linkName;

View File

@ -48,6 +48,7 @@ void ExternDocName::load(CFRecord& record)
record >> ixals;
record.skipNunBytes(2); // reserved
record >> extName;
nameDefinition.load(record);
}

View File

@ -31,9 +31,8 @@
*/
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/ExtNameParsedFormula.h>
#include <Logic/Biff_structures/BiffString.h>
#include "ExtNameParsedFormula.h"
#include "BiffString.h"
namespace XLS
{
@ -50,7 +49,6 @@ public:
virtual void load(CFRecord& record);
unsigned short ixals;
ShortXLUnicodeString extName;
ExtNameParsedFormula nameDefinition;

View File

@ -32,8 +32,8 @@
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/MOper.h>
#include <Logic/Biff_structures/BiffString.h>
#include "MOper.h"
#include "BiffString.h"
namespace XLS
{
@ -48,7 +48,6 @@ public:
virtual void load(CFRecord& record);
static const ElementType type = typeExternOleDdeLink;
_UINT32 lStgName;

View File

@ -37,16 +37,22 @@
namespace XLS
{
BiffStructurePtr FtCblsData::clone()
{
return BiffStructurePtr(new FtCblsData(*this));
}
void FtCblsData::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x000a && cb != 0x000c)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record >> fChecked >> accel;
record.skipNunBytes(2); // reserved

View File

@ -42,16 +42,20 @@ class FtCblsData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtCblsData)
public:
FtCblsData() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtCblsData;
static const ElementType type = typeFtCblsData;
virtual void load(CFRecord& record);
unsigned short fChecked;
unsigned short accel;
bool fNo3d;
bool fExist;
};
} // namespace XLS

View File

@ -46,8 +46,7 @@ public:
virtual void load(CFRecord& record);
static const ElementType type = typeFtCmo;
static const ElementType type = typeFtCmo;
unsigned short ot;
unsigned short id;
@ -60,7 +59,6 @@ public:
bool fUIObj;
bool fRecalcObj;
bool fRecalcObjAlways;
};
} // namespace XLS

View File

@ -36,16 +36,22 @@
namespace XLS
{
BiffStructurePtr FtEdoData::clone()
{
return BiffStructurePtr(new FtEdoData(*this));
}
void FtEdoData::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x0010 && cb != 0x0008)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record >> ivtEdit >> fMultiLine >> fVScroll >> id;
}

View File

@ -43,17 +43,21 @@ class FtEdoData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtEdoData)
public:
FtEdoData() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtEdoData;
static const ElementType type = typeFtEdoData;
virtual void load(CFRecord& record);
unsigned short ivtEdit;
Boolean<unsigned short> fMultiLine;
unsigned short fVScroll;
unsigned short id;
bool fExist;
};
} // namespace XLS

View File

@ -36,7 +36,6 @@
namespace XLS
{
BiffStructurePtr FtGboData::clone()
{
return BiffStructurePtr(new FtGboData(*this));
@ -44,7 +43,15 @@ BiffStructurePtr FtGboData::clone()
void FtGboData::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x000F && cb != 0x0006)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record >> accel;
record.skipNunBytes(2); // reserved

View File

@ -43,15 +43,19 @@ class FtGboData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtGboData)
public:
FtGboData() : fExist(false)
{
}
BiffStructurePtr clone();
virtual void load(CFRecord& record);
static const ElementType type = typeFtGboData;
static const ElementType type = typeFtGboData;
unsigned short accel;
bool fNo3d;
bool fExist;
};
} // namespace XLS

View File

@ -36,12 +36,6 @@
namespace XLS
{
FtLbsData::FtLbsData()
: fmla(false)
{
}
BiffStructurePtr FtLbsData::clone()
{
return BiffStructurePtr(new FtLbsData(*this));
@ -49,19 +43,27 @@ BiffStructurePtr FtLbsData::clone()
void FtLbsData::load(CFRecord& record, const unsigned short ot)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x0013)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
fmla.load(record);
unsigned short flags;
record >> cLines >> iSel >> flags >> idEdit;
fUseCB = GETBIT(flags, 0);
fValidPlex = GETBIT(flags, 1);
fValidIds = GETBIT(flags, 2);
fNo3d = GETBIT(flags, 3);
fUseCB = GETBIT(flags, 0);
fValidPlex = GETBIT(flags, 1);
fValidIds = GETBIT(flags, 2);
fNo3d = GETBIT(flags, 3);
wListSelType = GETBITS(flags, 4, 5);
lct = GETBITS(flags, 8, 15);
lct = GETBITS(flags, 8, 15);
if(0x0014 == ot)
{

View File

@ -46,10 +46,12 @@ class FtLbsData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtLbsData)
public:
FtLbsData();
FtLbsData() : fmla(false), fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtLbsData;
static const ElementType type = typeFtLbsData;
virtual void load(CFRecord& record, const unsigned short ot);
@ -72,6 +74,7 @@ public:
std::vector<XLUnicodeString> rgLines;
std::vector<Boolean<unsigned char>> bsels;
bool fExist;
};
} // namespace XLS

View File

@ -36,9 +36,7 @@
namespace XLS
{
FtMacro::FtMacro()
: fmla(false)
FtMacro::FtMacro() : fmla(false), fExist(false)
{
}
@ -48,14 +46,18 @@ BiffStructurePtr FtMacro::clone()
}
void FtMacro::load(CFRecord& record)
{
record.skipNunBytes(2); // reserved
short ft;
record >> ft;
if (ft != 0x0004)
{
record.RollRdPtrBack(2);
return;
}
fExist = true;
fmla.load(record);
}
} // namespace XLS

View File

@ -50,8 +50,8 @@ public:
virtual void load(CFRecord& record);
ObjFmla fmla;
bool fExist;
};
} // namespace XLS

View File

@ -37,16 +37,22 @@
namespace XLS
{
BiffStructurePtr FtNts::clone()
{
return BiffStructurePtr(new FtNts(*this));
}
void FtNts::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x000d && cb != 0x0016)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
_GUID_ guid_num;
record >> guid_num >> fSharedNote;

View File

@ -43,15 +43,19 @@ class FtNts : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtNts)
public:
FtNts() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtNts;
static const ElementType type = typeFtNts;
virtual void load(CFRecord& record);
std::wstring guid;
Boolean<unsigned short> fSharedNote;
bool fExist;
};
} // namespace XLS

View File

@ -36,18 +36,11 @@
namespace XLS
{
FtPictFmla::FtPictFmla()
: fmla(true)
{
}
BiffStructurePtr FtPictFmla::clone()
{
return BiffStructurePtr(new FtPictFmla(*this));
}
void FtPictFmla::load(CFRecord& record, int linkSize)
{
bool bLinked = false;
@ -74,11 +67,8 @@ void FtPictFmla::load(CFRecord& record, int linkSize)
record >> nNameIdx;
record.skipNunBytes(12);
//const ExtName* pExtName = GetOldRoot().pExtNameBuff->GetNameByIndex( nRefIdx, nNameIdx );
// if( pExtName && pExtName->IsOLE() )
// mnStorageId = pExtName->nStorageId;
}
else if( nToken == 2)//XclTokenArrayHelper::GetTokenId( EXC_TOKID_TBL, EXC_TOKCLASS_NONE ) )
else if( nToken == 2)
{
bEmbedded = true;
@ -103,7 +93,17 @@ void FtPictFmla::load(CFRecord& record, int linkSize)
void FtPictFmla::load(CFRecord& record, FtPioGrbit& pictFlags)
{
record.skipNunBytes(4); // reserved
short ft, size;
record >> ft; // must be
if (ft != 0x0009)
{
record.RollRdPtrBack(2);
return;
}
fExist = true;
record >> size;
if (size < 1) return;
fmla.load(record);
@ -111,12 +111,11 @@ void FtPictFmla::load(CFRecord& record, FtPioGrbit& pictFlags)
{
record >> lPosInCtlStm;
}
record >> lPosInCtlStm;
if(pictFlags.fPrstm)
{
record >> cbBufInCtlStm;
}
if(pictFlags.fPrstm)
if(pictFlags.fCtl)
{
key.load(record);
}

View File

@ -45,20 +45,25 @@ class FtPictFmla : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtPictFmla)
public:
FtPictFmla();
BiffStructurePtr clone();
FtPictFmla() : fmla(true), cbBufInCtlStm(0xffffffff), lPosInCtlStm(0xffffffff), fExist(false)
{
}
BiffStructurePtr clone();
virtual void load(CFRecord& record){}
//biff5
virtual void load(CFRecord& record, int linkSize);
//biff8
virtual void load(CFRecord& record, FtPioGrbit& pictFlags);
static const ElementType type = typeFtPictFmla;
virtual void load(CFRecord& record){}
ObjFmla fmla;
_UINT32 lPosInCtlStm;
_UINT32 cbBufInCtlStm;
PictFmlaKey key;
PictFmlaKey key;
ObjFmla fmla;
bool fExist;
};
} // namespace XLS

View File

@ -44,28 +44,28 @@ BiffStructurePtr FtPioGrbit::clone()
void FtPioGrbit::load(CFRecord& record)
{
//record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft;
record >> cb;
record >> ft >> cb;
if (record.getDataSize() == record.getRdPtr())
if ( ft != 0x0008 || cb != 2)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
unsigned short flags;
record >> flags;
fAutoPict = GETBIT(flags, 0);
fDde = GETBIT(flags, 1);
fPrintCalc = GETBIT(flags, 2);
fIcon = GETBIT(flags, 3);
fCtl = GETBIT(flags, 4);
fPrstm = GETBIT(flags, 5);
fCamera = GETBIT(flags, 7);
fAutoPict = GETBIT(flags, 0);
fDde = GETBIT(flags, 1);
fPrintCalc = GETBIT(flags, 2);
fIcon = GETBIT(flags, 3);
fCtl = GETBIT(flags, 4);
fPrstm = GETBIT(flags, 5);
fCamera = GETBIT(flags, 7);
fDefaultSize = GETBIT(flags, 8);
fAutoLoad = GETBIT(flags, 9);
fAutoLoad = GETBIT(flags, 9);
}

View File

@ -42,13 +42,15 @@ class FtPioGrbit : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtPioGrbit)
public:
FtPioGrbit() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtPioGrbit;
virtual void load(CFRecord& record);
bool fAutoPict;
bool fDde;
bool fPrintCalc;
@ -58,6 +60,8 @@ public:
bool fCamera;
bool fDefaultSize;
bool fAutoLoad;
bool fExist;
};
} // namespace XLS

View File

@ -45,7 +45,15 @@ BiffStructurePtr FtRboData::clone()
void FtRboData::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x000b && cb != 0x0006)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record >> idRadNext >> fFirstBtn;
}

View File

@ -43,15 +43,19 @@ class FtRboData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtRboData)
public:
FtRboData() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtRboData;
static const ElementType type = typeFtRboData;
virtual void load(CFRecord& record);
unsigned short idRadNext;
Boolean<unsigned short> fFirstBtn;
bool fExist;
};
} // namespace XLS

View File

@ -36,7 +36,6 @@
namespace XLS
{
BiffStructurePtr FtSbs::clone()
{
return BiffStructurePtr(new FtSbs(*this));
@ -44,10 +43,15 @@ BiffStructurePtr FtSbs::clone()
void FtSbs::load(CFRecord& record)
{
//record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
record >> ft;
record >> cb;
if ( ft != 0x000c && cb != 0x0014)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record.skipNunBytes(4); // unused1
@ -55,10 +59,10 @@ void FtSbs::load(CFRecord& record)
record >> iVal >> iMin >> iMax >> dInc >> dPage >> fHoriz >> dxScroll >> flags;
fDraw = GETBIT(flags, 0);
fDraw = GETBIT(flags, 0);
fDrawSliderOnly = GETBIT(flags, 1);
fTrackElevator = GETBIT(flags, 2);
fNo3d = GETBIT(flags, 3);
fTrackElevator = GETBIT(flags, 2);
fNo3d = GETBIT(flags, 3);
}

View File

@ -43,16 +43,15 @@ class FtSbs : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtSbs)
public:
FtSbs() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtSbs;
static const ElementType type = typeFtSbs;
virtual void load(CFRecord& record);
unsigned short ft;
unsigned short cb;
short iVal;
short iMin;
short iMax;
@ -65,6 +64,8 @@ public:
bool fDrawSliderOnly;
bool fTrackElevator;
bool fNo3d;
bool fExist;
};
} // namespace XLS

View File

@ -32,11 +32,11 @@
#include "MOper.h"
#include <Binary/CFRecord.h>
#include <simple_xml_writer.h>
namespace XLS
{
BiffStructurePtr MOper::clone()
{
return BiffStructurePtr(new MOper(*this));
@ -45,16 +45,52 @@ BiffStructurePtr MOper::clone()
void MOper::load(CFRecord& record)
{
record >> colLast >> rowLast;
for(int i = 0; i < (colLast + 1) * (rowLast + 1); ++i)
{
unsigned char rec_type;
record >> rec_type;
SerArPtr ser(SerAr::createSerAr(rec_type));
record >> *ser;
extOper.push_back(ser);
}
}
int MOper::serialize(std::wostream & strm)
{
if (extOper.empty()) return 0;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"values")
{
for(size_t i = 0; i < extOper.size(); ++i)
{
CP_XML_NODE(L"value")
{
switch(extOper[i]->fixed_type)
{
case SerAr::typeSerNil: CP_XML_ATTR(L"t", L"nil"); break;
case SerAr::typeSerNum: CP_XML_ATTR(L"t", L"n"); break;
case SerAr::typeSerStr: CP_XML_ATTR(L"t", L"str"); break;
case SerAr::typeSerBool: CP_XML_ATTR(L"t", L"b"); break;
case SerAr::typeSerErr: CP_XML_ATTR(L"t", L"e"); break;
}
CP_XML_NODE(L"val")
{
if (extOper[i]->fixed_type == SerAr::typeSerStr)
{
CP_XML_ATTR(L"xml:space", L"preserve");
}
CP_XML_STREAM() << extOper[i]->toString();
}
}
}
}
}
return 0;
}
} // namespace XLS

View File

@ -32,8 +32,8 @@
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/SerAr.h>
#include <Logic/Biff_structures/BitMarkedStructs.h>
#include "SerAr.h"
#include "BitMarkedStructs.h"
namespace XLS
{
@ -49,7 +49,7 @@ public:
static const ElementType type = typeMOper;
virtual void load(CFRecord& record);
int serialize(std::wostream & strm);
ColunByteU colLast;
RwU rowLast;

View File

@ -126,7 +126,8 @@ void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
// m_OfficeArtSpgrContainerFileBlock = OfficeArtContainerPtr(art_container);
// child_records.erase(child_records.begin() + i,child_records.begin() + i + 1);
// }break;
default:
break;
}
}

View File

@ -49,6 +49,8 @@ void OfficeArtRecord::load(XLS::CFRecord& record)
record >> rh_own;
loadFields(record);
//Log::warning(STR::int2str(rh_own.recType, 16));
}

View File

@ -37,8 +37,7 @@ namespace XLS
{
ObjFmla::ObjFmla(const bool is_part_of_FtPictFmla)
: is_part_of_FtPictFmla_(is_part_of_FtPictFmla)
ObjFmla::ObjFmla(const bool is_part_of_FtPictFmla) : is_part_of_FtPictFmla_(is_part_of_FtPictFmla), bFmlaExist(false), bInfoExist(false)
{
}
@ -47,7 +46,6 @@ BiffStructurePtr ObjFmla::clone()
return BiffStructurePtr(new ObjFmla(*this));
}
void ObjFmla::load(CFRecord& record)
{
unsigned short cbFmla;
@ -56,15 +54,17 @@ void ObjFmla::load(CFRecord& record)
if(0 != cbFmla)
{
bFmlaExist = true;
fmla.load(record);
if(is_part_of_FtPictFmla_ && fmla.HasPtgTbl())
{
record >> embedInfo;
bInfoExist = true;
}
}
size_t data_size = record.getRdPtr() - start_ptr;
size_t padding_size = cbFmla - data_size;
if(0 != padding_size && (record.getRdPtr() + padding_size) <= record.getDataSize())

View File

@ -47,17 +47,18 @@ public:
ObjFmla(const bool is_part_of_FtPictFmla);
BiffStructurePtr clone();
static const ElementType type = typeObjFmla;
static const ElementType type = typeObjFmla;
virtual void load(CFRecord& record);
ObjectParsedFormula fmla;
bool is_part_of_FtPictFmla_;
bool fmla_found;
PictFmlaEmbedInfo embedInfo;
bool bFmlaExist;
bool bInfoExist;
PictFmlaEmbedInfo embedInfo;
private:
bool is_part_of_FtPictFmla_;
};
} // namespace XLS

View File

@ -35,13 +35,6 @@
namespace XLS
{
ObjLinkFmla::ObjLinkFmla()
: fmla(false)
{
}
BiffStructurePtr ObjLinkFmla::clone()
{
return BiffStructurePtr(new ObjLinkFmla(*this));
@ -49,8 +42,15 @@ BiffStructurePtr ObjLinkFmla::clone()
void ObjLinkFmla::load(CFRecord& record)
{
record.skipNunBytes(2); // reserved
unsigned short ft;
record >> ft;
if ( ft != 0x0014)
{
record.RollRdPtrBack(2);
return;
}
fExist = true;
fmla.load(record);
}

View File

@ -43,7 +43,9 @@ class ObjLinkFmla : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(ObjLinkFmla)
public:
ObjLinkFmla();
ObjLinkFmla(): fmla(false), fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeObjLinkFmla;
@ -51,6 +53,7 @@ public:
virtual void load(CFRecord& record);
ObjFmla fmla;
bool fExist;
};
} // namespace XLS

View File

@ -45,8 +45,6 @@ public:
ObjectParsedFormula();
BiffStructurePtr clone();
virtual void load(CFRecord& record);
};
} // namespace XLS

View File

@ -32,7 +32,7 @@
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/BiffString.h>
#include "BiffString.h"
namespace XLS
{
@ -49,7 +49,6 @@ public:
virtual void load(CFRecord& record);
XLUnicodeStringNoCch strClass;
};

View File

@ -36,9 +36,7 @@
namespace XLS
{
PictFmlaKey::PictFmlaKey()
: fmlaLinkedCell(false), fmlaListFillRange(false)
PictFmlaKey::PictFmlaKey() : fmlaLinkedCell(false), fmlaListFillRange(false)
{
}
@ -49,10 +47,16 @@ BiffStructurePtr PictFmlaKey::clone()
void PictFmlaKey::load(CFRecord& record)
{
_UINT32 cbKey;
record >> cbKey;
record.skipNunBytes(cbKey); // ActiveX license key is here
if (cbKey > 0)
{
char *buf = new char[cbKey];
memcpy(buf, record.getCurData<char>(), cbKey);
keyBuf = std::string(buf, cbKey);
record.skipNunBytes(cbKey);
delete []buf;
}
fmlaLinkedCell.load(record);
fmlaListFillRange.load(record);

View File

@ -47,13 +47,15 @@ public:
PictFmlaKey();
BiffStructurePtr clone();
static const ElementType type = typePictFmlaKey;
static const ElementType type = typePictFmlaKey;
virtual void load(CFRecord& record);
_UINT32 cbKey;
std::string keyBuf; // ActiveX license key
ObjFmla fmlaLinkedCell;
ObjFmla fmlaListFillRange;
ObjFmla fmlaLinkedCell;
ObjFmla fmlaListFillRange;
};
} // namespace XLS

View File

@ -111,6 +111,7 @@ void PtgArea3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
if (global_info->Version < 0x0600)
{
ixti = ixals;
if (ixals == 0xffff)
{
std::wstring prefix = XMLSTUFF::xti_indexes2sheet_name(itabFirst, itabLast, global_info->sheets_names);
@ -118,14 +119,14 @@ void PtgArea3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
ptg_stack.push(prefix + range_ref);
}
else
{//external !!
ptg_stack.push(XMLSTUFF::make3dRef(ixals, range_ref, global_info->xti_parsed, full_ref));
}
}
else
if (ixti != 0xffff)
{
ptg_stack.push(XMLSTUFF::make3dRef(ixti, range_ref, global_info->xti_parsed, full_ref));
std::wstring link = global_info->arXti[ixti].link;
if (!link.empty() && !range_ref.empty())
link += L"!";
ptg_stack.push(link + range_ref); // full_ref ???
}
}

View File

@ -46,9 +46,10 @@ BiffStructurePtr PtgAreaErr3d::clone()
void PtgAreaErr3d::loadFields(CFRecord& record)
{
global_info = record.getGlobalWorkbookInfo();
record >> ixti;
record.skipNunBytes(8); // unused
global_info = record.getGlobalWorkbookInfo();
}
@ -62,9 +63,11 @@ void PtgAreaErr3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, boo
extra_data.pop();
return;
}
ptg_stack.push(XMLSTUFF::make3dRef(ixti, L"#REF!", global_info->xti_parsed));
std::wstring link = global_info->arXti[ixti].link;
if (!link.empty())
link += L"!";
ptg_stack.push(link + L"#REF!"); // full_ref ???
}

View File

@ -79,6 +79,7 @@ void PtgNameX::loadFields(CFRecord& record)
void PtgNameX::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full_ref)
{
RevNamePtr tab_id;
if(!extra_data.empty() && (tab_id = boost::dynamic_pointer_cast<RevName>(extra_data.front())))
{
Log::error("PtgNameX struct for revisions is not assemble.");
@ -87,39 +88,32 @@ void PtgNameX::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool fu
return;
}
std::wstring _Name;
if(nameindex > 0 && nameindex <= global_info->AddinUdfs.size() && !(_Name = global_info->AddinUdfs[nameindex - 1]).empty())
if(ixti >= 0 && ixti < global_info->arXti.size())
{
ptg_stack.push(_Name);
}
else if(ixti > 0 && ixti <= global_info->xti_parsed.size())
{
std::wstring sheet = global_info->xti_parsed[ixti-1];
std::wstring link = global_info->arXti[ixti].link;
std::wstring name;
if (!sheet.empty()) sheet += L"!";
if (nameindex > 0 && nameindex <= global_info->arDefineNames.size())
if (global_info->arXti[ixti].pNames && nameindex > 0)
{
_Name = global_info->arDefineNames[nameindex - 1];
name = global_info->arXti[ixti].pNames->at(nameindex - 1);
}
if (sheet.empty() && _Name.empty() && nameindex <= global_info->arExternalNames.size() && nameindex > 0)
if (!link.empty() && !name.empty())
{
_Name = global_info->arExternalNames[nameindex - 1];
ptg_stack.push(link + L"!" + name);
}
ptg_stack.push(sheet + _Name);
else if (!name.empty())
{
ptg_stack.push(name);
}
else
ptg_stack.push(link);
}
else
{
Log::warning("PtgNameX structure is not assemble.");
//ptg_stack.push(L"#UNDEFINED_EXTERN_NAME(" + STR::int2wstr(nameindex) + L")!");
ptg_stack.push(L""); // This would let us to continue without an error
ptg_stack.push(L"");
}
// Example of result: "[1]!range"
// in the formula window it looks like: "'D:\Projects\AVSWorksheetConverter\bin\InFiles\Blank2003_range.xls'!range"
}

View File

@ -106,6 +106,7 @@ void PtgRef3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool fu
if (global_info->Version < 0x0600)
{
ixti = ixals;
if (ixals == 0xffff)
{
std::wstring prefix = XMLSTUFF::xti_indexes2sheet_name(itabFirst, itabLast, global_info->sheets_names);
@ -113,15 +114,14 @@ void PtgRef3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool fu
ptg_stack.push(prefix + cell_ref);
}
else
{
ptg_stack.push(XMLSTUFF::make3dRef(ixals, cell_ref, global_info->xti_parsed, full_ref)); // from External !
}
}
else
if (ixti != 0xffff)
{
cell_ref = XMLSTUFF::make3dRef(ixti, cell_ref, global_info->xti_parsed, full_ref);
ptg_stack.push(cell_ref);
std::wstring link = global_info->arXti[ixti].link;
if (!link.empty() && !cell_ref.empty())
link += L"!";
ptg_stack.push(link + cell_ref); // full_ref ???
}
}

View File

@ -57,9 +57,10 @@ BiffStructurePtr PtgRefErr3d::clone()
void PtgRefErr3d::loadFields(CFRecord& record)
{
global_info = record.getGlobalWorkbookInfo();
record >> ixti;
record.skipNunBytes(4); // unused
global_info = record.getGlobalWorkbookInfo();
}
@ -75,7 +76,14 @@ void PtgRefErr3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool
return;
}
ptg_stack.push(XMLSTUFF::make3dRef(ixti, L"#REF!", global_info->xti_parsed));
if (ixti != 0xffff)
{
std::wstring link = global_info->arXti[ixti].link;
if (!link.empty())
link += L"!";
ptg_stack.push(link + L"#REF!"); // full_ref ???
}
}

View File

@ -36,9 +36,7 @@
namespace XLS
{
PtgTbl::PtgTbl()
: Ptg(fixed_id)
PtgTbl::PtgTbl() : Ptg(fixed_id)
{
}
@ -59,7 +57,11 @@ void PtgTbl::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full
{
// The reference coordinates shall be obtained from row/column values.
// No textual form need but the empty line.
ptg_stack.push(L"");
//CellRef ref(row, col, true, true);
//ptg_stack.push(ref.toString());
}

View File

@ -56,7 +56,7 @@ public:
virtual const std::wstring toString() const = 0;
static const ElementType type = typeSerAr;
static const ElementType type = typeSerAr;
SerType fixed_type;
};

View File

@ -32,7 +32,7 @@
#pragma once
#include "SerAr.h"
#include <Logic/Biff_structures/BiffString.h>
#include "BiffString.h"
namespace XLS
{

View File

@ -31,6 +31,10 @@
*/
#include "XTI.h"
#include "../GlobalsSubstream.h"
#include "../Biff_unions/SUPBOOK.h"
#include "../Biff_records/SupBook.h"
#include <Binary/CFRecord.h>
namespace XLS
@ -48,17 +52,6 @@ void XTI::load(CFRecord& record)
return;
record >> iSupBook >> itabFirst >> itabLast;
if (itabFirst < 0 && itabLast < 0)
{
record.getGlobalWorkbookInfo()->xti_parsed.push_back(L"");
}
else
{
std::wstring name = XMLSTUFF::xti_indexes2sheet_name(itabFirst, itabLast, record.getGlobalWorkbookInfo()->sheets_names);
if (name == L"#REF") name += L"!";
record.getGlobalWorkbookInfo()->xti_parsed.push_back( name );
}
}

View File

@ -48,7 +48,6 @@ public:
virtual void load(CFRecord& record);
unsigned short iSupBook;
short itabFirst;
short itabLast;

View File

@ -302,8 +302,13 @@ const bool CELLTABLE::loadContent(BinProcessor& proc)
CELL_GROUP cell_group2(shared_formulas_locations_ref_);
m_count_CELL_GROUP = proc.repeated(cell_group2, 0, 0);
proc.repeated<EntExU2>(0, 0);
int count = proc.repeated<EntExU2>(0, 0);
while(count > 0)
{
m_arEntExU2.insert(m_arEntExU2.begin(), elements_.back());
elements_.pop_back();
count--;
}
return true;
}

View File

@ -38,7 +38,6 @@ namespace XLS
class CellRef;
// Logical representation of CELLTABLE union of records
class CELLTABLE: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(CELLTABLE)
@ -50,13 +49,13 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeCELLTABLE;
static const ElementType type = typeCELLTABLE;
int serialize(std::wostream & stream);
std::vector<CellRangeRef>& shared_formulas_locations_ref_;
int m_count_CELL_GROUP;
int m_count_CELL_GROUP;
std::vector<BaseObjectPtr> m_arEntExU2;
};
} // namespace XLS

View File

@ -72,7 +72,7 @@ const bool DVAXIS::loadContentRead(BinReaderProcessor& proc)
bool ok = loadContent(proc);
if(ok)
{
id = proc.getGlobalWorkbookInfo()->GenerateAXESId();
id = proc.getGlobalWorkbookInfo()->last_Axes_id++;
}
return ok;
}

View File

@ -67,7 +67,6 @@ public:
BaseObjectPtr m_TABLESTYLES;
BaseObjectPtr m_THEME;
GlobalWorkbookInfoPtr global_info;
};

View File

@ -105,7 +105,7 @@ const bool FORMULA::loadContent(BinProcessor& proc)
m_sharedIndex = shared_formulas_locations_ref_.size();
shared_formulas_locations_ref_.push_back(shr_formula.ref_);
}
//proc.optional<SUB>(); // I haven't found any mention about SUB in the docs
//proc.optional<SUB>();
}
if ((formula) && (formula->fShrFmla))

View File

@ -67,7 +67,7 @@ const bool IVAXIS::loadContentRead(BinReaderProcessor& proc)
bool ok = loadContent(proc);
if(ok)
{
id = proc.getGlobalWorkbookInfo()->GenerateAXESId();
id = proc.getGlobalWorkbookInfo()->last_Axes_id++;
}
return ok;
}

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of LBL union of records
class LBL: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(LBL)
@ -51,13 +49,14 @@ public:
int serialize(std::wostream & stream);
static const ElementType type = typeLBL;
static const ElementType type = typeLBL;
BaseObjectPtr m_Lbl;
BaseObjectPtr m_Lbl;
BaseObjectPtr m_NamePublish;
BaseObjectPtr m_NameCmt;
BaseObjectPtr m_NameFnGrp12;
//-------------------------------------------------------
bool isSerialize;
};
} // namespace XLS

View File

@ -76,65 +76,26 @@ const bool LBL::loadContent(BinProcessor& proc)
if (!lbl) return false;
std::wstring name;
std::wstring comment;
if (lbl->fBuiltin) name = lbl->Name.value().get_value_or(L"");
if (name.empty()) name = lbl->Name_bin.value();
std::wstring value = lbl->rgce.getAssembledFormula(lbl->fWorkbookParam/*lbl->itab == 0 ? true : false*/);
NameCmt namecmt(name);
if (proc.optional(namecmt))
{
if (name.empty())
name = namecmt.name.value();
comment = namecmt.comment.value();
m_NameCmt = elements_.back();
elements_.pop_back();
}
if (proc.optional<NameFnGrp12>())
{
m_NameFnGrp12 = elements_.back();
elements_.pop_back();
}
if (proc.optional<NamePublish>())
{
m_NamePublish = elements_.back();
elements_.pop_back();
}
GlobalWorkbookInfoPtr global_info_ = proc.getGlobalWorkbookInfo();
if (!value.empty() && !name.empty())
{
int ind_sheet = lbl->itab;
std::map<std::wstring, std::vector<std::wstring>>::iterator it = global_info_->mapDefineNames.find(name);
if (it != global_info_->mapDefineNames.end())
{
while ( it->second.size() <= ind_sheet)
{
it->second.push_back(L"");
}
it->second[ind_sheet] = value;
//it->second.push_back(value);
}
else
{
std::vector<std::wstring> ar(ind_sheet + 1);
ar[ind_sheet] = value;
//ar.push_back(value);
global_info_->mapDefineNames.insert(std::make_pair(name, ar));
}
isSerialize = true;
}
else
{
if (lbl->fFunc)
{
if (name == L"FORMULA") //"general_formulas.xls"
name = L"_xludf." + name;
}
}
global_info_->arDefineNames.push_back(name);// для имен функций - todooo ... не все функции корректны !! БДИ !!
return true;
}
int LBL::serialize(std::wostream & stream)
@ -149,7 +110,7 @@ int LBL::serialize(std::wostream & stream)
int res = 0;
if ((lbl->itab == 0) && (res = value.find(L"#REF!")) >= 0)
if ((lbl->itab == 0) && (res = value.find(L"#REF")) >= 0)
{
for (size_t i = 0 ; i < lbl->rgce.rgce.sequence.size(); i++)
{
@ -171,6 +132,8 @@ int LBL::serialize(std::wostream & stream)
}
}
if (value == L"#REF") value = L"#REF!";
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"definedName")
@ -189,6 +152,10 @@ int LBL::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"localSheetId", lbl->itab - 1);
}
if (lbl->fHidden)
{
CP_XML_ATTR(L"hidden", 1);
}
CP_XML_STREAM() << xml::utils::replace_text_to_xml(value);
}

View File

@ -83,6 +83,7 @@ int PIVOTPI::serialize(std::wostream & strm)
}
}
}
return 0;
}
} // namespace XLS

View File

@ -64,7 +64,7 @@ const bool SERIESAXIS::loadContentRead(BinReaderProcessor& proc)
bool ok = loadContent(proc);
if(ok)
{
id = proc.getGlobalWorkbookInfo()->GenerateAXESId();
id = proc.getGlobalWorkbookInfo()->last_Axes_id++;
}
return ok;
}

View File

@ -31,17 +31,21 @@
*/
#pragma once
#include <Logic/CompositeObject.h>
#include "../CompositeObject.h"
namespace XLS
{
// Logical representation of SUPBOOK union of records
class SUPBOOK: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(SUPBOOK)
public:
struct _xct
{
BaseObjectPtr m_XCT;
std::vector<BaseObjectPtr> m_arCRN;
};
SUPBOOK();
~SUPBOOK();
@ -49,11 +53,27 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeSUPBOOK;
int serialize(std::wostream & strm);
BaseObjectPtr m_SupBook;
BaseObjectPtr m_ExternSheet;
static const ElementType type = typeSUPBOOK;
BaseObjectPtr m_SupBook;
BaseObjectPtr m_ExternSheet;
std::vector<BaseObjectPtr> m_arExternName;
std::vector<_xct> m_arXCT;
GlobalWorkbookInfoPtr global_info;
std::vector<std::wstring> arNames;
bool IsExternal();
std::wstring sExternPathLink;
int nExternIndex;
private:
int serialize_book(std::wostream & strm);
int serialize_dde(std::wostream & strm);
};
} // namespace XLS

View File

@ -31,25 +31,22 @@
*/
#include "SUPBOOK.h"
#include <Logic/Biff_records/SupBook.h>
#include <Logic/Biff_records/ExternName.h>
#include <Logic/Biff_records/ExternSheet.h>
#include <Logic/Biff_records/Continue.h>
#include <Logic/Biff_records/XCT.h>
#include <Logic/Biff_records/CRN.h>
#include "../Biff_records/SupBook.h"
#include "../Biff_records/ExternName.h"
#include "../Biff_records/ExternSheet.h"
#include "../Biff_records/Continue.h"
#include "../Biff_records/XCT.h"
#include "../Biff_records/CRN.h"
namespace XLS
{
SUPBOOK::SUPBOOK()
{
}
SUPBOOK::SUPBOOK() : nExternIndex(-1)
{}
SUPBOOK::~SUPBOOK()
{
}
{}
class Parenthesis_SUPBOOK_1: public ABNFParenthesis
{
@ -82,6 +79,8 @@ BaseObjectPtr SUPBOOK::clone()
// SUPBOOK = SupBook [*ExternName *(XCT *CRN)] [ExternSheet] *Continue
const bool SUPBOOK::loadContent(BinProcessor& proc)
{
global_info = proc.getGlobalWorkbookInfo();
SupBook supbook;
if(!proc.mandatory(supbook))
{
@ -90,30 +89,292 @@ const bool SUPBOOK::loadContent(BinProcessor& proc)
m_SupBook = elements_.back();
elements_.pop_back();
if (supbook.cch != 0x0401 && supbook.cch != 0x3A01 )
if(0x3A01 != supbook.cch && 0x0401 != supbook.cch)
{
proc.getGlobalWorkbookInfo()->arExternalNames.clear();
nExternIndex = global_info->last_Extern_id++;
}
while(true)
{
ExternName extern_name(supbook.getSupportingLinkType());
ExternName extern_name(supbook.cch, supbook.bOleLink);
if(!proc.optional(extern_name))
{
break;
}
m_arExternName.push_back(elements_.front()); elements_.pop_front();
//--------------------------------------------------------------------------------------------
std::wstring name;
ExternDocName* docName = dynamic_cast<ExternDocName*>(extern_name.body.get());
if(docName)
{
if (docName->ixals > 0 && !supbook.rgst.empty())
{
name = supbook.rgst[docName->ixals];
}
else
{
name = docName->nameDefinition.getAssembledFormula();
if (name.empty())
{
name = docName->extName.value();
}
}
}
ExternDdeLinkNoOper* ddeLink = dynamic_cast<ExternDdeLinkNoOper*>(extern_name.body.get());
if (ddeLink)
{
name = ddeLink->linkName.value();
}
ExternOleDdeLink* oleDdeLink = dynamic_cast<ExternOleDdeLink*>(extern_name.body.get());
if (oleDdeLink)
{
name = oleDdeLink->linkName.value();
}
AddinUdf *addinUdf = dynamic_cast<AddinUdf*>(extern_name.body.get());
if (addinUdf)
{
name = addinUdf->udfName.value(); //_xll.name(
}
if ( std::wstring::npos != name.find(L";") )
name = L"'" + name + L"'";
arNames.push_back(name);
}
int count = proc.repeated<Parenthesis_SUPBOOK_1>(0, 0);
while(!elements_.empty())
{
if ("XCT" == elements_.front()->getClassName())
{
_xct xcf;
xcf.m_XCT = elements_.front();
count--;
m_arXCT.push_back(xcf);
}
else
{
if (m_arXCT.empty())
{
break; // error !!!
}
m_arXCT.back().m_arCRN.push_back(elements_.front());
}
elements_.pop_front();
}
if (proc.optional<ExternSheet>())
{
m_ExternSheet = elements_.back();
elements_.pop_back();
}
//proc.repeated<Continue>(0, 0);
return true;
}
bool SUPBOOK::IsExternal()
{
SupBook *book = dynamic_cast<SupBook*>(m_SupBook.get());
if (!book) return false;
if(0x3A01 == book->cch || 0x0401 == book->cch)
{
return false;
}
return true;
}
int SUPBOOK::serialize(std::wostream & strm)
{
SupBook *book = dynamic_cast<SupBook*>(m_SupBook.get());
if (!book) return 0;
if(0x3A01 == book->cch || 0x0401 == book->cch)
{
return 0;
}
if (book->bOleLink)
{
serialize_dde(strm);
}
else
{
serialize_book(strm);
}
return 0;
}
int SUPBOOK::serialize_book(std::wostream & strm)
{
SupBook *book = dynamic_cast<SupBook*>(m_SupBook.get());
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"externalBook")
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", L"rId1");
sExternPathLink = book->virtPath.back();
if (!m_arXCT.empty() && !book->rgst.empty())
{
CP_XML_NODE(L"sheetNames")
{
for (size_t i = 0; i < m_arXCT.size(); i++)
{
CP_XML_NODE(L"sheetName")
{
std::wstring sheet;
XCT * name = dynamic_cast<XCT*>(m_arXCT[i].m_XCT.get());
if ((name) && (name->itab_exist))
sheet = book->rgst[name->itab];
else
sheet = L"Sheet " + std::to_wstring(i + 1);
CP_XML_ATTR(L"val", sheet);
}
}
}
CP_XML_NODE(L"sheetDataSet")
{
for (size_t i = 0; i < m_arXCT.size(); i++)
{
XCT * name = dynamic_cast<XCT*>(m_arXCT[i].m_XCT.get());
if (!name) continue;
CP_XML_NODE(L"sheetData")
{
CP_XML_ATTR(L"sheetId", i);
int current_row = -1;
for (size_t j = 0; j < m_arXCT[i].m_arCRN.size(); j++)
{
CRN * cell = dynamic_cast<CRN*>(m_arXCT[i].m_arCRN[j].get());
if (!cell) continue;
if (cell->row != current_row)
{
CP_XML_NODE(L"row")
{
current_row = cell->row;
CP_XML_ATTR(L"r", cell->row + 1);
for (size_t k = j; k < m_arXCT[i].m_arCRN.size(); k++)
{
cell = dynamic_cast<CRN*>(m_arXCT[i].m_arCRN[k].get());
if (cell->row != current_row)
{
j = k - 1;
break;
}
for (unsigned char col = cell->colFirst, v = 0; col <= cell->colLast; col++, v++)
{
CP_XML_NODE(L"cell")
{
SerAr* val = dynamic_cast<SerAr*>(cell->crnOper[v].get());
CellRef ref(cell->row, col, true, true);
CP_XML_ATTR(L"r", ref.toString());
std::wstring strVal = val->toString();
if (val->fixed_type == SerAr::typeSerStr)
{
if (0 == strVal.find(L"\""))
strVal = strVal.substr(1, strVal.length() - 2);
}
switch (val->fixed_type)
{
case SerAr::typeSerNil: CP_XML_ATTR(L"t", L"nil"); break;
case SerAr::typeSerNum: CP_XML_ATTR(L"t", L"n"); break;
case SerAr::typeSerStr: CP_XML_ATTR(L"t", L"str"); break;
case SerAr::typeSerBool: CP_XML_ATTR(L"t", L"b"); break;
case SerAr::typeSerErr: CP_XML_ATTR(L"t", L"e"); break;
}
CP_XML_NODE(L"v")
{
CP_XML_STREAM() << strVal;
}
}
}
}
}
}
}
}
}
}
}
else if (!book->rgst.empty())
{
CP_XML_NODE(L"sheetNames")
{
for (size_t i = 0; i < book->rgst.size(); i++)
{
CP_XML_NODE(L"sheetName")
{
CP_XML_ATTR(L"val", book->rgst[i]);
}
}
}
CP_XML_NODE(L"sheetDataSet")
{
for (size_t i = 0; i < book->rgst.size(); i++)
{
CP_XML_NODE(L"sheetData")
{
CP_XML_ATTR(L"sheetId", i);
CP_XML_ATTR(L"refreshError", 1);
}
}
}
}
}
}
return 0;
}
int SUPBOOK::serialize_dde(std::wostream & strm)
{
SupBook *book = dynamic_cast<SupBook*>(m_SupBook.get());
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"ddeLink")
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"ddeService", book->virtPath[0]);
CP_XML_ATTR(L"ddeTopic", book->virtPath[1]);
CP_XML_NODE(L"ddeItems")
{
for (size_t i = 0; i < m_arExternName.size(); i++)
{
ExternName * external_name = dynamic_cast<ExternName*>(m_arExternName[i].get());
if (!external_name) continue;
ExternOleDdeLink *oleDdeLink = dynamic_cast<ExternOleDdeLink*>(external_name->body.get());
if ((oleDdeLink) && (oleDdeLink->lStgName == 0))
{
CP_XML_NODE(L"ddeItem")
{
CP_XML_ATTR(L"name", oleDdeLink->linkName.value());
CP_XML_ATTR(L"advise", external_name->fWantAdvise);
oleDdeLink->moper.serialize(CP_XML_STREAM());
}
}
//ole items in oleLink
}
}
}
}
return 0;
}
} // namespace XLS

View File

@ -100,7 +100,8 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
fill_x_ids[FillInfo(0, 0, 0)] = 0;
fill_x_ids[FillInfo(17, 64, 65)] = 1;
last_AXES_id = initial_AXES_id;
last_Axes_id = 0x2000000;
last_Extern_id = 1;
Version = 0x0600;
@ -119,7 +120,10 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
defaultDigitFontSize = std::pair<float, float>(0, 0);
applicationFonts = NULL;
idPivotCache = 0;
bVbaProjectExist = false;
bMacrosExist = false;
idPivotCache = 0;
}
GlobalWorkbookInfo::~GlobalWorkbookInfo()
@ -173,11 +177,6 @@ void GlobalWorkbookInfo::RegisterPaletteColor(int id, const std::wstring & rgb)
colors_palette.insert(std::make_pair(id, rgb));
}
unsigned int GlobalWorkbookInfo::GenerateAXESId()
{
return last_AXES_id += 1;
}
void GlobalWorkbookInfo::GetDigitFontSizePixels()
{
if (defaultDigitFontSize.first > 0.01) return;

View File

@ -81,81 +81,92 @@ public:
void GetDigitFontSizePixels();
unsigned int GenerateAXESId();
bool bVbaProjectExist;
bool bMacrosExist;
unsigned short CodePage;
CRYPT::DecryptorPtr decryptor;
std::wstring password;
unsigned short CodePage;
CRYPT::DecryptorPtr decryptor;
std::wstring password;
std::vector<std::wstring> sheets_state;
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<std::wstring> sheets_state;
std::vector<std::wstring> sheets_names;
std::map<int, FillInfoExt> fonts_color_ext;
std::map<int, int> fonts_charsets;
std::map<int, std::wstring> colors_palette;
std::vector<BaseObjectPtr> *m_arFonts;
boost::unordered_map<BorderInfo, int> border_x_ids;
boost::unordered_map<FillInfo, int> fill_x_ids;
unsigned int current_sheet;
std::map<int, FillInfoExt> fonts_color_ext;
std::map<int, int> fonts_charsets;
std::map<int, std::wstring> colors_palette;
unsigned int last_AXES_id;
const static unsigned int initial_AXES_id = 0x2000000;
std::vector<BaseObjectPtr> *m_arFonts;
unsigned int current_sheet;
short idPivotCache;
std::map<int, int> mapPivotCacheIndex; //streamIdCache, write index order
std::unordered_map<int, BaseObjectPtr> mapPivotCacheStream;//streamIdCache, object
std::vector<int> arPivotCacheStream; //order streamIdCache = iCache
unsigned int last_Axes_id;
unsigned int last_Extern_id;
std::vector<bool> arPivotCacheFields;
std::vector<bool> arPivotCacheFieldShortSize;
short idPivotCache;
std::map<int, int> mapPivotCacheIndex; //streamIdCache, write index order
std::unordered_map<int, BaseObjectPtr> mapPivotCacheStream;//streamIdCache, object
std::vector<int> arPivotCacheStream; //order streamIdCache = iCache
std::vector<_sx_name> arPivotSxNames;
std::vector<std::wstring> arPivotCacheSxNames;
std::vector<bool> arPivotCacheFields;
std::vector<bool> arPivotCacheFieldShortSize;
std::vector<_sx_name> arPivotSxNames;
std::vector<std::wstring> arPivotCacheSxNames;
std::unordered_map<std::wstring, std::wstring> mapPivotCacheExternal;
std::map<std::wstring, std::vector<std::wstring>> mapDefineNames;
std::vector<std::wstring> arDefineNames;
std::vector<std::wstring> arExternalNames;
std::vector<std::pair<boost::shared_array<unsigned char>, size_t> > bin_data;
std::pair<boost::shared_array<unsigned char>, size_t> listdata_data;
std::pair<boost::shared_array<unsigned char>, size_t> controls_data;
unsigned int startAddedSharedStrings;
std::vector<std::wstring> arAddedSharedStrings;
std::map<int, std::pair<boost::shared_array<unsigned char>, size_t> > embeddings_data; //parsing ???
std::map<int, std::pair<boost::shared_array<unsigned char>, size_t> > link_data;
struct _xti
{
int iSup;
std::wstring link;
std::vector<std::wstring>* pNames = NULL;
};
std::vector<_xti> arXti;
unsigned int startAddedSharedStrings;
std::vector<std::wstring> arAddedSharedStrings;
std::vector<std::pair<boost::shared_array<char>, size_t> > bin_data;
struct _sheet_size_info
{
_sheet_size_info() : defaultColumnWidth(8.), defaultRowHeight (14.4) {}
std::map<int, double> customColumnsWidth;
std::map<int, double> customRowsHeight;
std::map<int, double> customColumnsWidth;
std::map<int, double> customRowsHeight;
double defaultColumnWidth;
double defaultRowHeight;
double defaultColumnWidth = 8.0;
double defaultRowHeight = 14.4;
};
std::vector<_sheet_size_info> sheet_size_info;
std::vector<_sheet_size_info> sheet_size_info;
std::pair<float, float> defaultDigitFontSize;
CApplicationFonts *applicationFonts;
std::wstring fontsDirectory;
std::pair<float, float> defaultDigitFontSize;
CApplicationFonts *applicationFonts;
std::wstring fontsDirectory;
int Version;
int Version;
int cmt_rules;
int cellXfs_count;
int cellStyleXfs_count;
int cellStyleDxfs_count;
int cmt_rules;
int cellXfs_count;
int cellStyleXfs_count;
int cellStyleDxfs_count;
std::wstringstream users_Dxfs_stream;
std::wstringstream connections_stream;
std::wstringstream users_Dxfs_stream;
std::wstringstream connections_stream;
int connectionId;
int connectionId;
XlsConverter *xls_converter;
XlsConverter *xls_converter;
};

View File

@ -31,69 +31,73 @@
*/
#include "GlobalsSubstream.h"
#include <Logic/AnyObject.h>
#include <Logic/Biff_records/BOF.h>
#include <Logic/Biff_records/WriteProtect.h>
#include <Logic/Biff_records/FilePass.h>
#include <Logic/Biff_records/Template.h>
#include <Logic/Biff_unions/INTERFACE.h>
#include <Logic/Biff_records/WriteAccess.h>
#include <Logic/Biff_records/FileSharing.h>
#include <Logic/Biff_records/CodePage.h>
#include <Logic/Biff_records/Lel.h>
#include <Logic/Biff_records/DSF.h>
#include <Logic/Biff_records/Excel9File.h>
#include <Logic/Biff_records/RRTabId.h>
#include <Logic/Biff_records/ObProj.h>
#include <Logic/Biff_records/ObNoMacros.h>
#include <Logic/Biff_records/CodeName.h>
#include <Logic/Biff_unions/FNGROUPS.h>
#include <Logic/Biff_records/Lbl.h>
#include <Logic/Biff_records/OleObjectSize.h>
#include <Logic/Biff_unions/PROTECTION.h>
#include <Logic/Biff_records/Window1.h>
#include <Logic/Biff_records/Backup.h>
#include <Logic/Biff_records/HideObj.h>
#include <Logic/Biff_records/Date1904.h>
#include <Logic/Biff_records/CalcPrecision.h>
#include <Logic/Biff_records/RefreshAll.h>
#include <Logic/Biff_records/BookBool.h>
#include <Logic/Biff_unions/FORMATTING.h>
#include <Logic/Biff_unions/PIVOTCACHEDEFINITION.h>
#include <Logic/Biff_unions/DOCROUTE.h>
#include <Logic/Biff_records/UserBView.h>
#include <Logic/Biff_records/UsesELFs.h>
#include <Logic/Biff_unions/BUNDLESHEET.h>
#include <Logic/Biff_unions/METADATA.h>
#include <Logic/Biff_records/MTRSettings.h>
#include <Logic/Biff_records/ForceFullCalculation.h>
#include <Logic/Biff_records/Country.h>
#include <Logic/Biff_unions/SUPBOOK.h>
#include <Logic/Biff_unions/LBL.h>
#include <Logic/Biff_unions/RTD.h>
#include <Logic/Biff_records/RecalcId.h>
#include <Logic/Biff_records/HFPicture.h>
#include <Logic/Biff_unions/MSODRAWINGGROUP.h>
#include <Logic/Biff_unions/SHAREDSTRINGS.h>
#include <Logic/Biff_records/ExtSST.h>
#include <Logic/Biff_records/WebPub.h>
#include <Logic/Biff_records/WOpt.h>
#include <Logic/Biff_records/CrErr.h>
#include <Logic/Biff_records/BookExt.h>
#include <Logic/Biff_records/FeatHdr.h>
#include <Logic/Biff_records/DConn.h>
#include <Logic/Biff_unions/THEME.h>
#include <Logic/Biff_records/CompressPictures.h>
#include <Logic/Biff_records/Compat12.h>
#include <Logic/Biff_records/GUIDTypeLib.h>
#include <Logic/Biff_records/EOF.h>
#include <Logic/Biff_records/BOF.h>
#include <Logic/Biff_records/MDTInfo.h>
#include <Logic/Biff_records/ExternSheet.h>
#include <Logic/Biff_records/XFExt.h>
#include <Logic/Biff_records/XFCRC.h>
#include <Logic/Biff_records/DXF.h>
#include <Logic/Biff_unions/STYLES.h>
#include "AnyObject.h"
#include "Biff_unions/INTERFACE.h"
#include "Biff_unions/PROTECTION.h"
#include "Biff_unions/FNGROUPS.h"
#include "Biff_unions/FORMATTING.h"
#include "Biff_unions/PIVOTCACHEDEFINITION.h"
#include "Biff_unions/DOCROUTE.h"
#include "Biff_unions/BUNDLESHEET.h"
#include "Biff_unions/METADATA.h"
#include "Biff_unions/SUPBOOK.h"
#include "Biff_unions/LBL.h"
#include "Biff_unions/RTD.h"
#include "Biff_unions/MSODRAWINGGROUP.h"
#include "Biff_unions/SHAREDSTRINGS.h"
#include "Biff_unions/THEME.h"
#include "Biff_unions/STYLES.h"
#include "Biff_records/BOF.h"
#include "Biff_records/WriteProtect.h"
#include "Biff_records/FilePass.h"
#include "Biff_records/Template.h"
#include "Biff_records/WriteAccess.h"
#include "Biff_records/FileSharing.h"
#include "Biff_records/CodePage.h"
#include "Biff_records/Lel.h"
#include "Biff_records/DSF.h"
#include "Biff_records/Excel9File.h"
#include "Biff_records/RRTabId.h"
#include "Biff_records/ObProj.h"
#include "Biff_records/ObNoMacros.h"
#include "Biff_records/CodeName.h"
#include "Biff_records/Lbl.h"
#include "Biff_records/OleObjectSize.h"
#include "Biff_records/Window1.h"
#include "Biff_records/Backup.h"
#include "Biff_records/HideObj.h"
#include "Biff_records/Date1904.h"
#include "Biff_records/CalcPrecision.h"
#include "Biff_records/RefreshAll.h"
#include "Biff_records/BookBool.h"
#include "Biff_records/UserBView.h"
#include "Biff_records/UsesELFs.h"
#include "Biff_records/MTRSettings.h"
#include "Biff_records/ForceFullCalculation.h"
#include "Biff_records/Country.h"
#include "Biff_records/RecalcId.h"
#include "Biff_records/HFPicture.h"
#include "Biff_records/ExtSST.h"
#include "Biff_records/WebPub.h"
#include "Biff_records/WOpt.h"
#include "Biff_records/CrErr.h"
#include "Biff_records/BookExt.h"
#include "Biff_records/FeatHdr.h"
#include "Biff_records/DConn.h"
#include "Biff_records/CompressPictures.h"
#include "Biff_records/Compat12.h"
#include "Biff_records/GUIDTypeLib.h"
#include "Biff_records/EOF.h"
#include "Biff_records/BOF.h"
#include "Biff_records/MDTInfo.h"
#include "Biff_records/ExternSheet.h"
#include "Biff_records/XFExt.h"
#include "Biff_records/XFCRC.h"
#include "Biff_records/DXF.h"
#include "Biff_records/SupBook.h"
#include "Biff_records/NameCmt.h"
#include "Biff_structures/ODRAW/OfficeArtDgContainer.h"
@ -214,13 +218,47 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
case rt_InterfaceHdr: proc.optional<INTERFACE_T>(); break;
case rt_WriteAccess: proc.optional<WriteAccess>(); break;
case rt_Lel: proc.repeated<Lel>(0, 2047); break;
case rt_DSF: proc.optional<DSF>(); break;
case rt_DSF: proc.optional<DSF>(); break; //resered record
case rt_Excel9File: proc.optional<Excel9File>(); break;
case rt_RRTabId: proc.optional<RRTabId>(); break;
case rt_ObProj: proc.optional<ObProj>(); break;
case rt_ObNoMacros: proc.optional<ObNoMacros>(); break;
case rt_CodeName: proc.optional<CodeName>(); break;
case rt_BuiltInFnGroupCount:proc.optional<FNGROUPS>(); break;
case rt_RRTabId:
{
if (proc.optional<RRTabId>())
{
m_RRTabId = elements_.back();
elements_.pop_back();
}
}break;
case rt_ObProj:
{
if (proc.optional<ObProj>())
{
global_info_->bVbaProjectExist = true;
global_info_->bMacrosExist = true;
}
}break;
case rt_ObNoMacros:
{
if (proc.optional<ObNoMacros>())
{
global_info_->bMacrosExist = false; //empty VbaProject
}
}break;
case rt_CodeName:
{
if (proc.optional<CodeName>())
{
m_CodeName = elements_.back();
elements_.pop_back();
}
}break;
case rt_BuiltInFnGroupCount:
{
if (proc.optional<FNGROUPS>())
{
m_FNGROUPS = elements_.back();
elements_.pop_back();
}
}break;
case rt_OleObjectSize: proc.optional<OleObjectSize>(); break;
case rt_WinProtect:
{
@ -339,7 +377,16 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
count--;
}
}break;
case rt_BoundSheet8: proc.repeated<BUNDLESHEET>(1, 0); break;
case rt_BoundSheet8:
{
count = proc.repeated<BUNDLESHEET>(1, 0);
while(count > 0)
{
m_arBUNDLESHEET.insert(m_arBUNDLESHEET.begin(), elements_.back());
elements_.pop_back();
count--;
}
}break;
case rt_MDTInfo: proc.optional<METADATA>(); break;
case rt_MTRSettings: proc.optional<MTRSettings>(); break;
case rt_ForceFullCalculation: proc.optional<ForceFullCalculation>(); break;
@ -408,7 +455,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
case rt_WebPub: proc.repeated<WebPub>(0, 0); break;
case rt_WOpt: proc.repeated<WOpt>(0, 0); break;
case rt_CrErr: proc.optional<CrErr>(); break;
case rt_BookExt: proc.optional<BookExt>(); break;
case rt_BookExt:
{
if (proc.optional<BookExt>())
{
m_BookExt = elements_.back();
elements_.pop_back();
}
}break;
case rt_FeatHdr:
{
FeatHdr feat_hdr(true);
@ -482,6 +536,8 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
}
}
LoadHFPicture();
UpdateXti();
UpdateDefineNames();
return true;
}
@ -527,4 +583,140 @@ void GlobalsSubstream::LoadHFPicture()
}
}
void GlobalsSubstream::UpdateXti()
{
for (size_t s = 0; s < m_arSUPBOOK.size(); s++)
{
SUPBOOK* SUPP = dynamic_cast<SUPBOOK*>(m_arSUPBOOK[s].get());
if (!SUPP) continue;
ExternSheet* extern_sheet = dynamic_cast<ExternSheet*>(SUPP->m_ExternSheet.get());
if (!extern_sheet) continue;
for (size_t i = 0; i < extern_sheet->rgXTI.size(); i++)
{
XTI* xti = dynamic_cast<XTI*>(extern_sheet->rgXTI[i].get());
if (!xti) continue;
SUPBOOK* index_book = dynamic_cast<SUPBOOK*>(m_arSUPBOOK[xti->iSupBook].get());
if (!index_book) continue;
SupBook *info = dynamic_cast<SupBook*>(index_book->m_SupBook.get());
if (!info) continue;
GlobalWorkbookInfo::_xti val;
val.iSup = xti->iSupBook;
val.pNames = &index_book->arNames;
if( index_book->nExternIndex > 0 )
{
val.link = L"[" + std::to_wstring(index_book->nExternIndex) + L"]";
}
if (xti->itabFirst >= 0 /*|| itabLast >= 0*/)
{
if (info->rgst.empty() && index_book->nExternIndex < 0)
{
val.link = XMLSTUFF::xti_indexes2sheet_name(xti->itabFirst, xti->itabLast, global_info_->sheets_names);
}
else
{
val.link = XMLSTUFF::xti_indexes2sheet_name(xti->itabFirst, xti->itabLast, info->rgst, val.link);
}
}
global_info_->arXti.push_back(val);
}
}
}
void GlobalsSubstream::UpdateDefineNames()
{
for (size_t s = 0; s < m_arLBL.size(); s++)
{
LBL* LBL_ = dynamic_cast<LBL*>(m_arLBL[s].get());
if (!LBL_) continue;
Lbl *lbl = dynamic_cast<Lbl*>(LBL_->m_Lbl.get());
if (!lbl) continue;
std::wstring name;
std::wstring comment;
if (lbl->fBuiltin) name = lbl->Name.value().get_value_or(L"");
if (name.empty()) name = lbl->Name_bin.value();
NameCmt *namecmt = dynamic_cast<NameCmt*>(LBL_->m_NameCmt.get());
if (namecmt)
{
if (name.empty())
name = namecmt->name.value();
comment = namecmt->comment.value();
}
std::wstring value = lbl->rgce.getAssembledFormula(lbl->fWorkbookParam/*lbl->itab == 0 ? true : false*/);
if (!value.empty() && !name.empty())
{
int ind_sheet = lbl->itab;
std::map<std::wstring, std::vector<std::wstring>>::iterator it = global_info_->mapDefineNames.find(name);
if (it != global_info_->mapDefineNames.end())
{
while ( it->second.size() <= ind_sheet)
{
it->second.push_back(L"");
}
it->second[ind_sheet] = value;
//it->second.push_back(value);
}
else
{
std::vector<std::wstring> ar(ind_sheet + 1);
ar[ind_sheet] = value;
//ar.push_back(value);
global_info_->mapDefineNames.insert(std::make_pair(name, ar));
}
LBL_->isSerialize = true;
}
else
{
if (lbl->fFunc)
{
if (name == L"FORMULA") //"general_formulas.xls"
name = L"_xludf." + name;
}
}
global_info_->arDefineNames.push_back(name);// для имен функций - todooo ... не все функции корректны !! БДИ !!
}
}
int GlobalsSubstream::serialize_format(std::wostream & _stream)
{
BookExt *book_ext = dynamic_cast<BookExt*>(m_BookExt.get());
CodeName *code_name = dynamic_cast<CodeName*>(m_CodeName.get());
CP_XML_WRITER(_stream)
{
CP_XML_NODE(L"workbookPr")
{
if (code_name)
{
CP_XML_ATTR(L"codeName", code_name->value);
}
if (book_ext)
{
CP_XML_ATTR(L"hidePivotFieldList", book_ext->fHidePivotList);
CP_XML_ATTR(L"filterPrivacy", book_ext->fFilterPrivacy);
}
}
}
return 0;
}
} // namespace XLS

View File

@ -53,7 +53,9 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeGlobalsSubstream;
static const ElementType type = typeGlobalsSubstream;
int serialize_format(std::wostream & _stream);
BaseObjectPtr m_THEME;
BaseObjectPtr m_Formating;
@ -64,12 +66,17 @@ public:
BaseObjectPtr m_Country;
BaseObjectPtr m_WriteProtect;
BaseObjectPtr m_PROTECTION;
BaseObjectPtr m_RRTabId;
BaseObjectPtr m_FNGROUPS;
BaseObjectPtr m_BookExt;
BaseObjectPtr m_CodeName;
std::vector<BaseObjectPtr> m_arHFPicture;
std::vector<BaseObjectPtr> m_arLBL;
std::vector<BaseObjectPtr> m_arMSODRAWINGGROUP;
std::vector<BaseObjectPtr> m_arWindow1;
std::vector<BaseObjectPtr> m_arUserBView;
std::vector<BaseObjectPtr> m_arBUNDLESHEET;
std::vector<BaseObjectPtr> m_arSUPBOOK;
std::vector<BaseObjectPtr> m_arPIVOTCACHEDEFINITION;
@ -80,6 +87,8 @@ public:
private:
void LoadHFPicture();
void UpdateXti();
void UpdateDefineNames();
};
} // namespace XLS

View File

@ -82,7 +82,6 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
bool WorksheetSubstream_found = false;
size_t ws_index = 0;
// Find all substreams in this stream
while(to_continue)
{
unsigned short substream_type = 0;
@ -102,8 +101,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
if((proc.mandatory(global_substream)) && (elements_.size() > 0))
{
GlobalsSubstream_found = true;
m_GlobalsSubstream = elements_.back();
elements_.pop_back();
m_GlobalsSubstream = elements_.back(); elements_.pop_back();
}
if (!GlobalsSubstream_found) return false;
}
@ -120,8 +119,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
if ((proc.mandatory(worksheet_substream)) && (elements_.size() > 0))
{
WorksheetSubstream_found = true;
m_arWorksheetSubstream.push_back(elements_.back());
elements_.pop_back();
m_arWorksheetSubstream.push_back(elements_.back()); elements_.pop_back();
}
}
break;
@ -136,8 +135,8 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
if ((proc.mandatory<ChartSheetSubstream>()) && (elements_.size() > 0))
{
WorksheetSubstream_found = true;
m_arWorksheetSubstream.push_back(elements_.back());
elements_.pop_back();
m_arWorksheetSubstream.push_back(elements_.back()); elements_.pop_back();
}
}
break;
@ -152,14 +151,17 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
if ((proc.mandatory<MacroSheetSubstream>()) && (elements_.size() > 0))
{
WorksheetSubstream_found = true;
m_arMacroSheetSubstream.push_back(elements_.back());
elements_.pop_back();
m_arMacroSheetSubstream.push_back(elements_.back()); elements_.pop_back();
}
}
break;
default:
Log::warning("WARNING: Substream of unsupported type " + STR::int2str(substream_type, 10) +
" The substream is skipped! Sorry.");
if (substream_type != 0)
{
Log::warning("WARNING: Substream of unsupported type " + STR::int2str(substream_type, 10) +
" The substream is skipped!");
}
proc.SeekToEOF();
proc.optional<EOF_T>();

Some files were not shown because too many files have changed in this diff Show More