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

XlsFile2

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63803 954022d7-b5bf-4e40-9824-e11837661b57
parent 152b2d8f
......@@ -29,7 +29,8 @@ const bool BiffRecordSplit::storeRecordAndDecideProceeding(CFRecordPtr record)
}
else if(stored_record == NULL)
{
throw;// EXCEPT::RT::WrongBiffRecord("Split records do not match", record->getTypeString());
stored_record = record;
//throw;// EXCEPT::RT::WrongBiffRecord("Split records do not match", record->getTypeString());
}
else
{
......
......@@ -7,6 +7,7 @@ namespace XLS
MsoDrawing::MsoDrawing(const bool is_inside_chart_sheet)
: rgChildRec(is_inside_chart_sheet ? ODRAW::OfficeArtRecord::CA_Chart : ODRAW::OfficeArtRecord::CA_Sheet)
{
isReading = false;
}
......@@ -26,10 +27,18 @@ void MsoDrawing::writeFields(CFRecord& record)
record << rgChildRec;
}
void MsoDrawing::readFields()
{
rgChildRec.rh_own.recLen = stored_record->getDataSize();
rgChildRec.loadFields(*stored_record);
}
void MsoDrawing::readFields(CFRecord& record)
{
record >> rgChildRec;
isReading = true;
}
......
......@@ -20,6 +20,7 @@ public:
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
void readFields();
//-----------------------------
virtual const bool isStartingRecord(CFRecord& record);
......@@ -29,6 +30,8 @@ public:
//-----------------------------
ODRAW::OfficeArtDgContainer rgChildRec;
bool isReading;
};
typedef boost::shared_ptr<MsoDrawing> MsoDrawingPtr;
......
#include "Obj.h"
#include <Logic/Biff_records/MsoDrawing.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtDgContainer.h>
namespace XLS
{;
Obj::Obj()
Obj::Obj(MsoDrawingPtr mso_drawing) : mso_drawing_(mso_drawing)
{
}
......@@ -163,6 +165,21 @@ void Obj::readFields(CFRecord& record)
{
record.skipNunBytes(4); // reserved
}
if (continue_records.size() > 0)
{
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
ODRAW::OfficeArtDgContainer dg(ODRAW::OfficeArtRecord::CA_Sheet);
while( !recs.empty() )
{
//dg.loadFields(*recs.front());
mso_drawing_->storeRecordAndDecideProceeding(recs.front());
recs.pop_front();
}
}
}
} // namespace XLS
......
......@@ -18,14 +18,16 @@
namespace XLS
{;
class MsoDrawing;
typedef boost::shared_ptr<MsoDrawing> MsoDrawingPtr;
// Logical representation of Obj record in BIFF8
class Obj: public BiffRecordContinued
class Obj : public BiffRecordContinued
{
BIFF_RECORD_DEFINE_TYPE_INFO(Obj)
BASE_OBJECT_DEFINE_CLASS_NAME(Obj)
public:
Obj();
Obj(MsoDrawingPtr mso_drawing);
~Obj();
BaseObjectPtr clone();
......@@ -35,6 +37,7 @@ public:
static const ElementType type = typeObj;
MsoDrawingPtr mso_drawing_;
//-----------------------------
FtCmo cmo;
FtCf pictFormat;
......
#include "SST.h"
#include <simple_xml_writer.h>
#include <utils.h>
namespace XLS
{;
......@@ -92,7 +93,7 @@ int SST::serialize(std::wostream & stream)
CP_XML_NODE(L"t")
{
XLUnicodeRichExtendedString *richText = dynamic_cast<XLUnicodeRichExtendedString *>(rgb[i].get());
CP_XML_STREAM() << richText->str_;
CP_XML_STREAM() << xml::utils::replace_text_to_xml(richText->str_);
}
}
}
......
......@@ -47,7 +47,8 @@ void TxO::readFields(CFRecord& record)
record >> ifntEmpty;
fmla.load(record);
if ( cbRuns ) {
if ( cbRuns )
{
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
if ( recs.size() )
{
......@@ -62,6 +63,8 @@ void TxO::readFields(CFRecord& record)
TxOruns.m_runCount = cbRuns / 8 - 1;
TxOruns.load(record);
///+120 byte ???
}
}
}
......
......@@ -46,7 +46,7 @@ void OfficeArtContainer::loadFields(XLS::CFRecord& record)
{
size_t container_beginning_ptr = record.getRdPtr();
while(record.getRdPtr() < container_beginning_ptr + rh_own.recLen)
while(record.getRdPtr() < container_beginning_ptr + rh_own.recLen - 8)
{
OfficeArtRecordHeader rh_child;
record >> rh_child;
......@@ -156,12 +156,18 @@ void OfficeArtContainer::loadFields(XLS::CFRecord& record)
}
else // If the found record is not implemented or unknown
{
size_t sz = rh_child.size();
try
{
size_t sz = rh_child.size();
record.skipNunBytes(rh_child.size()); // skip header
record.skipNunBytes(rh_child.recLen); // skip record data
Log::warning(std::wstring(L"Unsupported OfficeArtRecord skipped (recType=0x") +
STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)) + std::wstring(L")"));
record.skipNunBytes(rh_child.size()); // skip header
record.skipNunBytes(rh_child.recLen); // skip record data
Log::warning(std::wstring(L"Unsupported OfficeArtRecord skipped (recType=0x") +
STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)) + std::wstring(L")"));
}
catch(...)
{
}
}
}
......
......@@ -33,12 +33,19 @@ const bool OfficeArtDgContainer::CheckIfContainerSizeOK(XLS::CFRecord& record)
if(!record.checkFitReadSafe(rh.size())) return false;
record >> rh;
return 0xF002 == rh.recType && record.getDataSize() == rh.recLen + rh.size();
bool res = record.getDataSize() == rh.recLen + rh.size();
return 0xF002 == rh.recType && res;
}
void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
{
OfficeArtContainer::loadFields(record);
try
{
OfficeArtContainer::loadFields(record);
}catch(...)
{
}
for (long i = 0 ; i < child_records.size(); i++)
{
......@@ -61,7 +68,7 @@ void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
}break;
case ODRAW::OfficeArtRecord::SpContainer:
{
m_OfficeArtSpContainer = child_records[i];
m_OfficeArtSpContainer.push_back(child_records[i]);
child_records.erase(child_records.begin() + i,child_records.begin() + i + 1); i--;
}break;
//case ODRAW::OfficeArtRecord::SpgrContainerFileBlock:
......
......@@ -23,11 +23,11 @@ public:
void loadFields(XLS::CFRecord& record);
OfficeArtRecordPtr m_OfficeArtFDG;
OfficeArtRecordPtr m_OfficeArtFRITContainer;
OfficeArtRecordPtr m_OfficeArtSpgrContainer;
OfficeArtRecordPtr m_OfficeArtSpContainer; // todooo - one????
OfficeArtRecordPtr m_OfficeArtSpgrContainerFileBlock;
OfficeArtRecordPtr m_OfficeArtFDG;
OfficeArtRecordPtr m_OfficeArtFRITContainer;
OfficeArtRecordPtr m_OfficeArtSpgrContainer;
std::vector<OfficeArtRecordPtr> m_OfficeArtSpContainer;
OfficeArtRecordPtr m_OfficeArtSpgrContainerFileBlock;
};
typedef boost::shared_ptr<OfficeArtDgContainer> OfficeArtDgContainerPtr;
......
......@@ -64,7 +64,12 @@ int LBL::serialize(std::wostream & stream)
{
CP_XML_NODE(L"definedName")
{
CP_XML_ATTR(L"name", lbl->Name_bin.value());
std::wstring name;
if (lbl->fBuiltin) name = lbl->Name.value().get_value_or(L"");
if (name.empty()) name = lbl->Name_bin.value();
CP_XML_ATTR(L"name", xml::utils::replace_text_to_xml(name));
CP_XML_STREAM() << xml::utils::replace_text_to_xml(lbl->rgce.getAssembledFormula());
}
......
......@@ -2,12 +2,13 @@
#include "OBJ.h"
#include <Logic/Biff_records/Obj.h>
#include <Logic/Biff_records/Continue.h>
#include <Logic/Biff_records/MsoDrawing.h>
namespace XLS
{;
OBJ::OBJ()
OBJ::OBJ(MsoDrawingPtr mso_drawing) : mso_drawing_(mso_drawing)
{
}
......@@ -26,7 +27,8 @@ BaseObjectPtr OBJ::clone()
// OBJ = Obj *Continue
const bool OBJ::loadContent(BinProcessor& proc)
{
if(!proc.mandatory<Obj>())
Obj Obj_(mso_drawing_);
if(!proc.mandatory(Obj_))
{
return false;
}
......@@ -34,8 +36,6 @@ const bool OBJ::loadContent(BinProcessor& proc)
m_Obj = elements_.back();
elements_.pop_back();
proc.repeated<Continue>(0, 0);
return true;
}
......
......@@ -5,22 +5,27 @@
namespace XLS
{;
class MsoDrawing;
typedef boost::shared_ptr<MsoDrawing> MsoDrawingPtr;
// Logical representation of OBJ union of records
class OBJ: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(OBJ)
public:
OBJ();
OBJ(MsoDrawingPtr mso_drawing);
~OBJ();
BaseObjectPtr clone();
virtual const bool loadContent(BinProcessor& proc);
BaseObjectPtr m_Obj;
BaseObjectPtr m_Obj;
MsoDrawingPtr m_MsoDrawing;
static const ElementType type = typeOBJ;
MsoDrawingPtr mso_drawing_;
};
} // namespace XLS
......
......@@ -5,7 +5,7 @@
#include <Logic/Biff_unions/TEXTOBJECT.h>
#include <Logic/Biff_unions/OBJ.h>
#include <Logic/Biff_unions/CHART.h>
//#include <Exception/UnexpectedProgramPath.h>
#include <Logic/Biff_records/Continue.h>
namespace XLS
{;
......@@ -26,6 +26,10 @@ class Parenthesis_OBJECTS_2: public ABNFParenthesis
{
BASE_OBJECT_DEFINE_CLASS_NAME(Parenthesis_OBJECTS_2)
public:
Parenthesis_OBJECTS_2(MsoDrawingPtr mso_drawing) : mso_drawing_(mso_drawing)
{
}
BaseObjectPtr clone()
{
return BaseObjectPtr(new Parenthesis_OBJECTS_2(*this));
......@@ -33,10 +37,14 @@ public:
const bool loadContent(BinProcessor& proc)
{
return proc.optional<TEXTOBJECT>() ||
proc.optional<OBJ>() ||
proc.optional<CHART>();
OBJ OBJ_(mso_drawing_);
bool res = proc.optional<TEXTOBJECT>() ||
proc.optional(OBJ_)||
proc.optional<CHART>();
return res;
};
MsoDrawingPtr mso_drawing_;
};
......@@ -45,13 +53,13 @@ class Parenthesis_OBJECTS_1: public ABNFParenthesis
BASE_OBJECT_DEFINE_CLASS_NAME(Parenthesis_OBJECTS_1)
public:
Parenthesis_OBJECTS_1(MsoDrawingPtr mso_drawing) : mso_drawing_(mso_drawing)
Parenthesis_OBJECTS_1(MsoDrawingPtr mso_drawing,MsoDrawingPtr mso_drawing2) : mso_drawing_(mso_drawing), mso_drawing2_(mso_drawing2)
{
}
BaseObjectPtr clone()
{
return BaseObjectPtr(new Parenthesis_OBJECTS_1(mso_drawing_));
return BaseObjectPtr(new Parenthesis_OBJECTS_1(mso_drawing_, mso_drawing2_));
}
const bool loadContent(BinProcessor& proc)
......@@ -66,12 +74,13 @@ public:
{
return false;
}
int count1 = proc.repeated(Parenthesis_OBJECTS_2(mso_drawing2_), 0, 0);
proc.repeated(Parenthesis_OBJECTS_2(), 0, 0);
return true;
}
MsoDrawingPtr mso_drawing_;
MsoDrawingPtr mso_drawing2_;
};
......@@ -92,9 +101,22 @@ const bool OBJECTS::loadContent(BinProcessor& proc)
const bool OBJECTS::loadContentRead(BinReaderProcessor& proc)
{
m_MsoDrawing = boost::shared_ptr<MsoDrawing>(new MsoDrawing(is_inside_chart_sheet_));
m_MsoDrawingObjects = boost::shared_ptr<MsoDrawing>(new MsoDrawing(is_inside_chart_sheet_));
int count1 = proc.repeated(Parenthesis_OBJECTS_1(m_MsoDrawing), 0, 0);
int count1 = proc.repeated(Parenthesis_OBJECTS_1(m_MsoDrawing, m_MsoDrawingObjects), 0, 0);
if (m_MsoDrawing->isReading == false)
{
try
{
m_MsoDrawingObjects->readFields();
m_MsoDrawing = m_MsoDrawingObjects;
}
catch(...)
{
}
}
int i = 0 ;
for(std::list<BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end() ; it++)
{
......
......@@ -27,6 +27,7 @@ public:
bool is_inside_chart_sheet_;
MsoDrawingPtr m_MsoDrawing;
MsoDrawingPtr m_MsoDrawingObjects;
std::vector<std::pair<BaseObjectPtr, int>> m_OBJs;
std::vector<std::pair<BaseObjectPtr, int>> m_TEXTOBJECTs;
......
......@@ -2,6 +2,7 @@
#include "TEXTOBJECT.h"
#include <Logic/Biff_records/TxO.h>
#include <Logic/Biff_records/Continue.h>
#include <Logic/Biff_records/MsoDrawing.h>
namespace XLS
{;
......
......@@ -70,16 +70,31 @@ const bool XFS::loadContent(BinProcessor& proc)
}
}
int first_xf_ext = 0;
for (long i = 0 ; i < m_cell_styles.size(); i++)
for (_UINT16 i = 0 ; i < m_cell_styles.size(); i++)
{
XF *xfs = dynamic_cast<XF*>(m_cell_styles[i].get());
if (m_xf_ext.size() > 0)
{
XFExt *ext = dynamic_cast<XFExt*>(m_xf_ext[i].get());
XFExt *ext_find = NULL;
for (_UINT16 j = first_xf_ext ; j < m_xf_ext.size(); j++)
{
xfs->style.ext_props = ext->rgExt;
XFExt *ext = dynamic_cast<XFExt*>(m_xf_ext[j].get());
if (ext->ixfe > i)break;
if (ext->ixfe == i)
{
ext_find = ext;
first_xf_ext = j + 1;
break;
}
}
if (ext_find)
{
xfs->style.ext_props = ext_find->rgExt;
}
}
......
......@@ -440,23 +440,30 @@ void XlsConverter::convert(XLS::OBJECTS* objects)
{
if (objects == NULL) return;
ODRAW::OfficeArtSpgrContainer *spgr = dynamic_cast<ODRAW::OfficeArtSpgrContainer*>(objects->m_MsoDrawing.get()->rgChildRec.m_OfficeArtSpgrContainer.get());
ODRAW::OfficeArtSpgrContainer *spgr = dynamic_cast<ODRAW::OfficeArtSpgrContainer*>(objects->m_MsoDrawing.get()->rgChildRec.m_OfficeArtSpgrContainer.get());
//ODRAW::OfficeArtSpContainer *sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(objects->m_MsoDrawing.get()->rgChildRec.m_OfficeArtSpContainer.get());
if (spgr == NULL) return;
if (spgr == NULL && objects->m_MsoDrawing.get()->rgChildRec.m_OfficeArtSpContainer.size() < 1) return;
for (long i = 0 ; i < objects->m_OBJs.size(); i++)
{
int ind = objects->m_OBJs[i].second;
if (ind > spgr->child_records.size()-1) continue;
ODRAW::OfficeArtSpContainer *sp = NULL;
if ( (spgr) && (ind < spgr->child_records.size()))
{
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(spgr->child_records[ind+1].get());
}
else if (ind < objects->m_MsoDrawing.get()->rgChildRec.m_OfficeArtSpContainer.size())
{
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(objects->m_MsoDrawing.get()->rgChildRec.m_OfficeArtSpContainer[ind].get());
}
XLS::OBJ* OBJ = dynamic_cast<XLS::OBJ*>(objects->m_OBJs[i].first.get());
XLS::Obj *obj = dynamic_cast<XLS::Obj*>(OBJ->m_Obj.get());
if (xlsx_context->get_drawing_context().start_drawing(obj->cmo.ot))
{
ODRAW::OfficeArtSpContainer *sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(spgr->child_records[ind+1].get());
convert(sp);
xlsx_context->get_drawing_context().end_drawing();
......
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