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

XlsFile2

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63799 954022d7-b5bf-4e40-9824-e11837661b57
parent c8670cf3
......@@ -404,7 +404,6 @@ ASCOfficeXlsFile2/source/XlsFormat/Auxiliary svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat/Binary svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat/Crypt svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat/Document svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat/Logging svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat/Logic svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records svnc_tsvn_003alogminsize=5
#include <Logic/BaseObjectDocument.h>
#include <../../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h>
#include "Document.h"
std::map<std::wstring, Document*> Document::all_documents;
Document::Document(const std::wstring & root_name)
{
objectDoc = boost::shared_ptr<XLS::BaseObjectDocument>(new XLS::BaseObjectDocument());
newDoc(L"root");
}
Document::~Document()
{
all_documents[uniq_] = NULL;
}
//
//BiffStructurePtr & Document::getRoot() const
//{
// return xmlDoc->GetdocumentElement(); // current root independent on its name
//}
//
//BiffStructurePtr & Document::getDoc() const
//{
// return this;
//}
void Document::newDoc(const std::wstring & root_name)
{
if(!uniq_.empty())
{
all_documents.erase(uniq_);
}
#if defined(_WIN32) || defined (_WIN64)
UUID uuid;
RPC_WSTR str_uuid;
UuidCreate (&uuid);
UuidToString (&uuid, &str_uuid);
uniq_ = (TCHAR *) str_uuid;
RpcStringFree (&str_uuid);
#else
char pcRes[MAX_PATH] = "XXXXXX";
pcRes[6] = '\0';
int res = mkstemp( pcRes);
std::string sRes = pcRes;
uniq_ = stringUtf8ToWString(sRes);
#endif
XLS::BaseObjectDocument * doc = dynamic_cast<XLS::BaseObjectDocument *>(objectDoc.get());
if (doc)
{
doc->set_document_uniq(uniq_);
doc->set_document_name(root_name);
}
//xmlDoc->loadXML(L"<?xml version=\"1.0\" encoding=\"utf-8\" ?> <" + root_name + L" id=\"" + guid_ + L"\"/>"); // Initial tag;
all_documents[uniq_] = this;
}
const int Document::appendBinaryData(XLS::BaseObject * elem, const char * data, const size_t size)
{
if (elem == NULL)
return 0;
boost::shared_array<char> buffer(new char[size]);
memcpy_s(buffer.get(), size, data, size);
return appendBinaryData(elem, buffer, size);
}
const int Document::appendBinaryData(XLS::BaseObject * elem, boost::shared_array<char>& pre_allocated_data, const size_t size)
{
if (elem == NULL)
return 0;
std::wstring name = elem->getClassName();
Document* doc = findDocumentByElement(elem);
if(!doc)
{
return -1;
}
doc->bin_data.push_back(std::pair<boost::shared_array<char>, size_t>(pre_allocated_data, size));
return doc->bin_data.size() - 1;
}
const std::pair<char*, size_t> Document::getBinaryData(const int index) const
{
if(index < 0 || static_cast<size_t>(index) > bin_data.size() - 1)
{
return std::pair<char*, size_t>(NULL, 0);
}
return std::pair<char*, size_t>(bin_data[index].first.get(), bin_data[index].second);
}
Document* Document::findDocumentByElement(XLS::BaseObject* elem)
{
XLS::BaseObjectDocument * doc = dynamic_cast<XLS::BaseObjectDocument *>(elem);
if (doc)
{
return all_documents[doc->m_document_uniq];
}
else
return NULL;
}
#pragma once
#include <string>
#include <map>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/smart_ptr/shared_array.hpp>
class Document;
typedef boost::shared_ptr<Document> DocumentPtr;
namespace XLS
{
class BaseObject;
typedef boost::shared_ptr<BaseObject> BaseObjectPtr;
};
class Document
{
public:
Document(const std::wstring & root_name);
~Document();
void newDoc(const std::wstring & root_name);
static const int appendBinaryData(XLS::BaseObject* elem, const char * data, const size_t size);
static const int appendBinaryData(XLS::BaseObject* elem, boost::shared_array<char>& pre_allocated_data, const size_t size);
static Document* findDocumentByElement(XLS::BaseObject* elem);
const std::pair<char*, size_t> getBinaryData(const int index) const;
//-------------------------------------------------------------
std::wstring uniq_;
XLS::BaseObjectPtr objectDoc;
std::vector<std::pair<boost::shared_array<char>, size_t> > bin_data;
static std::map<std::wstring, Document*> all_documents;
};
......@@ -21,12 +21,6 @@ public:
BaseObjectPtr clone() {return BaseObjectPtr(new BaseObjectDocument(*this));}
virtual const bool read(CFStreamCacheReader& reader, BaseObject* parent, const bool mandatory){return false;}
void set_document_uniq(const std::wstring & uniq) {m_document_uniq = uniq;}
void set_document_name(const std::wstring & name) {m_document_name = name;}
std::wstring m_document_uniq;
std::wstring m_document_name;
};
typedef boost::shared_ptr<BaseObjectDocument> BaseObjectDocumentPtr;
......
......@@ -20,7 +20,7 @@ public:
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
static const ElementType type = typeAxis;;
static const ElementType type = typeAxis;
//-----------------------------
BIFF_WORD wType;
......
......@@ -2,7 +2,6 @@
#include <Logic/BaseObject.h>
#include <Logic/Biff_structures/BitMarkedStructs.h>
//#include <Logic/Biff_structures/BiffAttribute.h>
#include <Logic/BinProcessor.h>
namespace XLS
......@@ -17,7 +16,6 @@ public:
BiffRecord();
~BiffRecord();
// virtual const bool doSomething(BinProcessor& proc);
virtual const bool read(CFStreamCacheReader& reader, BaseObject* parent, const bool is_mandatory); // Read self and children
//virtual const bool write(BinWriterProcessor& proc, const bool is_mandatory); // Write self and children
......
#include "Pls.h"
#include <Document/Document.h>
namespace XLS
{;
......@@ -24,37 +23,37 @@ BaseObjectPtr Pls::clone()
void Pls::writeFields(CFRecord& record)
{
record.reserveNunBytes(2); // reserved
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
Document* doc = Document::findDocumentByElement(parent_);
const std::pair<char*, size_t> bin_data = doc->getBinaryData(bin_data_id);
if(record.checkFitWriteSafe(bin_data.second))
{
record.storeLongData(bin_data.first, bin_data.second);
}
else
{
char* buffer = bin_data.first;
size_t size = bin_data.second;
while(size)
{
CFRecord& current_record = recs.size() ? *recs.back() : record; // Points to the original 'record' or the last created 'Continue'
size_t space_left = current_record.getMaxRecordSize() - current_record.getDataSize();
size_t write_size = min(size, space_left);
current_record.storeLongData(buffer, write_size);
buffer += write_size;
size -= write_size;
current_record.commitData();
if(size)
{
CFRecordPtr cont(new CFRecord(rt_Continue, record.getGlobalWorkbookInfo()));
recs.push_back(cont);
}
}
}
//record.reserveNunBytes(2); // reserved
//std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
//Document* doc = Document::findDocumentByElement(parent_);
//const std::pair<char*, size_t> bin_data = doc->getBinaryData(bin_data_id);
//if(record.checkFitWriteSafe(bin_data.second))
//{
// record.storeLongData(bin_data.first, bin_data.second);
//}
//else
//{
// char* buffer = bin_data.first;
// size_t size = bin_data.second;
// while(size)
// {
// CFRecord& current_record = recs.size() ? *recs.back() : record; // Points to the original 'record' or the last created 'Continue'
// size_t space_left = current_record.getMaxRecordSize() - current_record.getDataSize();
// size_t write_size = min(size, space_left);
// current_record.storeLongData(buffer, write_size);
// buffer += write_size;
// size -= write_size;
// current_record.commitData();
// if(size)
// {
// CFRecordPtr cont(new CFRecord(rt_Continue, record.getGlobalWorkbookInfo()));
// recs.push_back(cont);
// }
// }
//}
}
......@@ -62,7 +61,23 @@ void Pls::readFields(CFRecord& record)
{
record.skipNunBytes(2); // reserved
record.loadAnyData(rgb);
bin_data_id = Document::appendBinaryData(parent_, record.getData() + 2, record.getDataSize() - 2);
int size = record.getDataSize() - 2;
const char* data = record.getData() + 2;
boost::shared_array<char> buffer(new char[size]);
memcpy_s(buffer.get(), size, data, size);
bin_data_id = -1;
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));
bin_data_id = globla_info->bin_data.size() - 1;
}
record.skipNunBytes(record.getDataSize() - record.getRdPtr()); // avoid size inconsistency warning
}
......
#include "BiffStructure.h"
#include <Binary/CFRecord.h>
#include <Document/Document.h>
namespace XLS
{;
Document* BiffStructure::get_document()
{
return document_;
}
void BiffStructure::set_document(Document* d)
{
document_ = d;
}
// this function will never be called ( look at operator>>(CFRecord& record, T& val))
void BiffStructure_NoVtbl::store(CFRecord& record)
{
......
......@@ -2,15 +2,13 @@
#include <vector>
#include <sstream>
#include <boost/shared_ptr.hpp>
#include "../XlsElementsType.h"
#include <Auxiliary/BetterVariantT.h>
#include <Logging/Log.h>
//#include <Logic/Biff_structures/BitMarkedStructs.h>
class Document;
namespace XLS
{;
......@@ -24,8 +22,6 @@ public:
void load(CFRecord& record); // this function will never be called ( look at operator>>(CFRecord& record, T& val))
void store(CFRecord& record); // this function will never be called ( look at operator>>(CFRecord& record, T& val))
// protected:
// static MSXML2::IXMLDOMElementPtr createElement(BiffStructurePtr & parent, const std::wstring tag_name);
};
class BiffStructure;
......@@ -38,19 +34,12 @@ public:
virtual BiffStructurePtr clone() = 0;
Document* get_document();
void set_document(Document* d);
//// Makes XML data
////virtual void toXML(BiffStructurePtr & parent);
//// Reads XML data
////virtual const bool fromXML(BiffStructurePtr & parent, const size_t position, const bool is_mandatory);
////virtual const bool fromXML(BiffStructurePtr & parent);
virtual void load(CFRecord& record) = 0;
virtual void store(CFRecord& record) = 0;
static const ElementType type = typeBiffStructure;
virtual ElementType get_type() const { return type; }
virtual int serialize(std::wostream & _stream)
{
std::wstringstream s;
......@@ -61,11 +50,6 @@ public:
virtual const std::wstring & getClassName() const = 0; // Must be overridden in every deriver. The return value must be a reference to a static variable inside the getter
std::wstring tagName_;
protected:
Document * document_;
//const AUX::BetterVariantT getStructAttribute(BiffStructurePtr & parent, const std::wstring & attrib_name);
//MSXML2::IXMLDOMElementPtr getStructNode(BiffStructurePtr & parent, const std::wstring & tag_name);
};
#define BASE_STRUCTURE_DEFINE_CLASS_NAME(class_name)\
......
......@@ -27,6 +27,8 @@ public:
}
}
static const XLS::ElementType type = XLS::typeOfficeArtBStoreContainer;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
......
#include "OfficeArtBStoreContainerFileBlock.h"
#include <Document/Document.h>
#include "../../../ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h"
......
......@@ -23,7 +23,8 @@ public:
static OfficeArtBlipPtr load_blip(XLS::CFRecord& record);
public:
static const XLS::ElementType type = XLS::typeOfficeArtBlip;
unsigned int csp;
unsigned int spidCur;
};
......
......@@ -18,12 +18,12 @@ public:
OfficeArtClientAnchorChart();
XLS::BiffStructurePtr clone();
static const XLS::ElementType type = XLS::typeOfficeArtClientAnchorChart;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
private:
// bool fMove; // This attribute is ignored for chart sheets
bool fSize;
......
......@@ -18,12 +18,11 @@ public:
OfficeArtClientAnchorHF();
XLS::BiffStructurePtr clone();
static const XLS::ElementType type = XLS::typeOfficeArtClientAnchorHF;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
private:
long width;
long height;
};
......
......@@ -19,12 +19,11 @@ public:
OfficeArtClientAnchorSheet();
XLS::BiffStructurePtr clone();
static const XLS::ElementType type = XLS::typeOfficeArtClientAnchorSheet;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
private:
bool fMove;
bool fSize;
......
......@@ -125,8 +125,8 @@ void OfficeArtContainer::loadFields(XLS::CFRecord& record)
art_record = OfficeArtRecordPtr(new OfficeArtSplitMenuColorContainer);
break;
case BStoreContainer:
Log::event("OfficeArtBStoreContainer record found. OfficeArtBStoreContainerFileBlock records count = " + STR::int2str(rh_child.recInstance) +
". RecLen = " + STR::int2str(rh_child.recLen));
//Log::event("OfficeArtBStoreContainer record found. OfficeArtBStoreContainerFileBlock records count = " + STR::int2str(rh_child.recInstance) +
// ". RecLen = " + STR::int2str(rh_child.recLen));
art_record = OfficeArtRecordPtr(new OfficeArtBStoreContainer);
break;
case TertiaryFOPT:
......
......@@ -17,6 +17,7 @@ class OfficeArtContainer : public OfficeArtRecord
public:
OfficeArtContainer(const unsigned char recVer, const unsigned short recType, const OfficeArtClientAnchorType anchor_type);
static const XLS::ElementType type = XLS::typeOfficeArtContainer;
// overridden:
virtual void loadFields(XLS::CFRecord& record);
......@@ -24,8 +25,9 @@ public:
static OfficeArtRecordPtr loadAnyArtRecord(XLS::CFRecord& record);
std::vector<OfficeArtRecordPtr> child_records;
OfficeArtClientAnchorType anchor_type_;
std::vector<OfficeArtRecordPtr> child_records;
};
typedef boost::shared_ptr<OfficeArtContainer> OfficeArtContainerPtr;
......
......@@ -36,5 +36,44 @@ const bool OfficeArtDgContainer::CheckIfContainerSizeOK(XLS::CFRecord& record)
return 0xF002 == rh.recType && record.getDataSize() == rh.recLen + rh.size();
}
void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
{
OfficeArtContainer::loadFields(record);
for (long i = 0 ; i < child_records.size(); i++)
{
switch(child_records[i]->rh_own.recType)
{
case ODRAW::OfficeArtRecord::FDG:
{
m_OfficeArtFDG = child_records[i];
child_records.erase(child_records.begin() + i, child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::FRITContainer:
{
m_OfficeArtFRITContainer = child_records[i];
child_records.erase(child_records.begin() + i, child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::SpgrContainer:
{
m_OfficeArtSpgrContainer = child_records[i];
child_records.erase(child_records.begin() + i, child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::SpContainer:
{
m_OfficeArtSpContainer = child_records[i];
child_records.erase(child_records.begin() + i,child_records.begin() + i + 1); i--;
}break;
//case ODRAW::OfficeArtRecord::SpgrContainerFileBlock:
// {
// m_OfficeArtSpgrContainerFileBlock = OfficeArtContainerPtr(art_container);
// child_records.erase(child_records.begin() + i,child_records.begin() + i + 1);
// }break;
}
}
}
} // namespace ODRAW
......@@ -21,6 +21,13 @@ public:
static const bool CheckIfContainerStartFound(XLS::CFRecord& record);
static const bool CheckIfContainerSizeOK(XLS::CFRecord& record);
void loadFields(XLS::CFRecord& record);
OfficeArtRecordPtr m_OfficeArtFDG;
OfficeArtRecordPtr m_OfficeArtFRITContainer;
OfficeArtRecordPtr m_OfficeArtSpgrContainer;
OfficeArtRecordPtr m_OfficeArtSpContainer; // todooo - one????
OfficeArtRecordPtr m_OfficeArtSpgrContainerFileBlock;
};
typedef boost::shared_ptr<OfficeArtDgContainer> OfficeArtDgContainerPtr;
......
......@@ -21,7 +21,8 @@ public:
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
public:
static const XLS::ElementType type = XLS::typeOfficeArtFDG;
unsigned int csp;
unsigned int spidCur;
};
......
......@@ -19,12 +19,12 @@ public:
OfficeArtFDGGBlock();
XLS::BiffStructurePtr clone();
static const XLS::ElementType type = XLS::typeOfficeArtFDGGBlock;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
public:
unsigned int spidMax;
unsigned int cspSaved;
unsigned int cdgSaved;
......
......@@ -19,7 +19,7 @@ public:
OfficeArtFOPT();
XLS::BiffStructurePtr clone();
static const XLS::ElementType type = XLS::typeOfficeArtFOPT;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
......@@ -27,7 +27,6 @@ public:
// overriden
const unsigned short GetInstanceToStore();
private:
OfficeArtRGFOPTE fopt;
};
......
......@@ -19,7 +19,7 @@ public:
OfficeArtFRITContainer();
XLS::BiffStructurePtr clone();
static const XLS::ElementType type = XLS::typeOfficeArtFRITContainer;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
......@@ -27,7 +27,6 @@ public:
// overriden
const unsigned short GetInstanceToStore();
public:
std::vector<OfficeArtFRIT> rgfrit;
};
......
......@@ -22,7 +22,8 @@ public:
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
// overriden
static const XLS::ElementType type = XLS::typeOfficeArtFSP;
const unsigned short GetInstanceToStore();
unsigned short shape_id;
......
......@@ -18,12 +18,11 @@ public:
OfficeArtFSPGR();
XLS::BiffStructurePtr clone();
static const XLS::ElementType type = XLS::typeOfficeArtFSPGR;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
private:
long xLeft;
long yTop;
long xRight;
......
......@@ -27,6 +27,7 @@ public:
virtual void loadFields(XLS::CFRecord& record) = 0;
virtual void storeFields(XLS::CFRecord& record) = 0;
static const XLS::ElementType type = XLS::typeOfficeArtRecord;
OfficeArtRecordHeader rh_own;
enum OfficeArtRecordType
......@@ -71,6 +72,7 @@ public:
SplitMenuColorContainer = 0xF11E, // Implemented
SecondaryFOPT = 0xF121,
TertiaryFOPT = 0xF122, // Implemented
SpgrContainerFileBlock
};
enum OfficeArtClientAnchorType
......
......@@ -19,15 +19,13 @@ public:
OfficeArtSplitMenuColorContainer();
XLS::BiffStructurePtr clone();
static const XLS::ElementType type = XLS::typeOfficeArtSplitMenuColorContainer;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
// overriden
const unsigned short GetInstanceToStore();
public:
std::vector<MSOCR> smca;
};
......
......@@ -19,7 +19,7 @@ public:
OfficeArtTertiaryFOPT();
XLS::BiffStructurePtr clone();
static const XLS::ElementType type = XLS::typeOfficeArtTertiaryFOPT;
virtual void loadFields(XLS::CFRecord& record);
virtual void storeFields(XLS::CFRecord& record);
......@@ -27,7 +27,6 @@ public:
// overriden
const unsigned short GetInstanceToStore();
private:
OfficeArtRGFOPTE fopt;
};
......
#include "SimpleOfficeArtContainers.h"
#include <Binary/CFRecord.h>
namespace ODRAW
{;
void OfficeArtDggContainer::loadFields(XLS::CFRecord& record)
{
OfficeArtContainer::loadFields(record);
for (long i = 0 ; i < child_records.size(); i++)
{
switch(child_records[i]->rh_own.recType)
{
case ODRAW::OfficeArtRecord::BStoreContainer:
{
m_OfficeArtBStoreContainer = child_records[i];
child_records.erase(child_records.begin() + i,child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::ColorMRUContainer:
{
m_OfficeArtColorMRUContainer = child_records[i];
child_records.erase(child_records.begin() + i,child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::SplitMenuColorContainer:
{
m_OfficeArtSplitMenuColorContainer = child_records[i];
child_records.erase(child_records.begin() + i,child_records.begin() + i + 1); i--;
}break;
case ODRAW::OfficeArtRecord::FDGGBlock:
{
m_OfficeArtFDGGBlock = child_records[i];
child_records.erase(child_records.begin() + i,child_records.begin() + i + 1); i--;
}break;
//case ODRAW::OfficeArtRecord::SpgrContainerFileBlock:
// {
// m_OfficeArtSpgrContainerFileBlock = OfficeArtContainerPtr(art_container);
// child_records.erase(child_records.begin() + i,child_records.begin() + i + 1);
// }break;
}
}
}
void OfficeArtSpgrContainer::loadFields(XLS::CFRecord& record)
{
OfficeArtContainer::loadFields(record);
//for (long i = 0 ; i < child_records.size(); i++)
//{
// switch(child_records[i]->rh_own.recType)
// {
// case ODRAW::OfficeArtRecord::SpgrContainerFileBlock:
// {
// m_OfficeArtSpgrContainerFileBlock.push_back(child_records[i]);
// child_records.erase(child_records.begin() + i,child_records.begin() + i + 1);
// }break;
// }
//}
}
} // namespace ODRAW
......@@ -12,6 +12,13 @@ public:
OfficeArtDggContainer(const OfficeArtClientAnchorType anchor_type) : OfficeArtContainer(0x0F, DggContainer, anchor_type) {}
XLS::BiffStructurePtr clone() { return XLS::BiffStructurePtr(new OfficeArtDggContainer(*this)); }
void loadFields(XLS::CFRecord& record);
OfficeArtRecordPtr m_OfficeArtBStoreContainer;
OfficeArtRecordPtr m_OfficeArtColorMRUContainer;
OfficeArtRecordPtr m_OfficeArtSplitMenuColorContainer;
OfficeArtRecordPtr m_OfficeArtFDGGBlock;
//+ OfficeArtFOPT + OfficeArtTertiaryFOPT
};
class OfficeArtSpgrContainer : public OfficeArtContainer
......@@ -21,6 +28,9 @@ public:
OfficeArtSpgrContainer(const OfficeArtClientAnchorType anchor_type) : OfficeArtContainer(0x0F, SpgrContainer, anchor_type) {}
XLS::BiffStructurePtr clone() { return XLS::BiffStructurePtr(new OfficeArtSpgrContainer(*this)); }
void loadFields(XLS::CFRecord& record);
std::vector<OfficeArtContainerPtr> m_OfficeArtSpgrContainerFileBlock;
};
class OfficeArtSpContainer : public OfficeArtContainer
......@@ -41,6 +51,8 @@ public:
virtual void loadFields(XLS::CFRecord& record) {}
virtual void storeFields(XLS::CFRecord& record) {}
static const ElementType type = XLS::typeOfficeArtClientData;
};
class OfficeArtClientTextbox : public OfficeArtRecord
......@@ -52,6 +64,9 @@ public:
virtual void loadFields(XLS::CFRecord& record) {}
virtual void storeFields(XLS::CFRecord& record) {}
static const XLS::ElementType type = XLS::typeOfficeArtClientTextbox;
};
......
......@@ -95,15 +95,16 @@ const bool OBJECTS::loadContentRead(BinReaderProcessor& proc)
int count1 = proc.repeated(Parenthesis_OBJECTS_1(m_MsoDrawing), 0, 0);
int i = 0 ;
for(std::list<BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end() ; it++)
{
XLS::ElementType type = (*it)->get_type();
switch (type)
{
case XLS::typeOBJ: m_OBJs.push_back(*it); break;
case XLS::typeTEXTOBJECT: m_TEXTOBJECTs.push_back(*it); break;
case XLS::typeCHART: m_CHARTs.push_back(*it); break;
case XLS::typeOBJ: m_OBJs.push_back(std::pair<BaseObjectPtr, int>(*it, i)); i++; break;
case XLS::typeTEXTOBJECT: m_TEXTOBJECTs.push_back(std::pair<BaseObjectPtr, int>(*it, i)); i++; break;
case XLS::typeCHART: m_CHARTs.push_back(std::pair<BaseObjectPtr, int>(*it, i)); i++; break;
}
}
elements_.clear();
......
......@@ -28,9 +28,9 @@ public:
MsoDrawingPtr m_MsoDrawing;
std::vector<BaseObjectPtr> m_OBJs;
std::vector<BaseObjectPtr> m_TEXTOBJECTs;
std::vector<BaseObjectPtr> m_CHARTs;
std::vector<std::pair<BaseObjectPtr, int>> m_OBJs;
std::vector<std::pair<BaseObjectPtr, int>> m_TEXTOBJECTs;
std::vector<std::pair<BaseObjectPtr, int>> m_CHARTs;
};
} // namespace XLS
......
......@@ -9,6 +9,7 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page)
{
fill_x_ids[FillInfo(0, 0, 0)] = 0;
fill_x_ids[FillInfo(17, 64, 65)] = 1;
last_AXES_id = initial_AXES_id;
}
......
#pragma once
#include <boost/unordered_map.hpp>
#include <boost/smart_ptr/shared_array.hpp>
#include <vector>
#include "../Crypt/Decryptor.h"
......@@ -32,6 +33,9 @@ public:
const static unsigned int initial_AXES_id = 0;
std::vector<std::wstring> defineNames;
std::vector<std::pair<boost::shared_array<char>, size_t> > bin_data;
};
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
......
......@@ -460,8 +460,28 @@ enum ElementType
typeGlobalsSubstream,
typeMacroSheetSubstream,
typeWorkbookStreamObject,
typeWorksheetSubstream
typeWorksheetSubstream,
typeBiffStructure = 2000,
typeOfficeArtRecord = 3000,
typeOfficeArtBlip,
typeOfficeArtBStoreContainer,
typeOfficeArtClientAnchorChart,
typeOfficeArtClientAnchorHF,
typeOfficeArtClientAnchorSheet,
typeOfficeArtColorMRUContainer,
typeOfficeArtContainer,
typeOfficeArtFDG,
typeOfficeArtFDGGBlock,
typeOfficeArtFOPT,
typeOfficeArtFRITContainer,
typeOfficeArtFSP,
typeOfficeArtFSPGR,
typeOfficeArtSplitMenuColorContainer,
typeOfficeArtTertiaryFOPT,
typeOfficeArtClientData,
typeOfficeArtClientTextbox
};
......
......@@ -30,6 +30,7 @@
#include <Logic/Biff_structures/FileMoniker.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtBStoreContainer.h>
#include <Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.h>
#include "xlsx_conversion_context.h"
#include "xlsx_package.h"
......@@ -367,24 +368,9 @@ void XlsConverter::convert(XLS::MSODRAWINGGROUP * mso_drawing)
XLS::MsoDrawingGroup * mso_group = dynamic_cast<XLS::MsoDrawingGroup*>(mso_drawing->m_MsoDrawingGroup.get());
if (mso_group == NULL) return;
//files
convert (dynamic_cast<ODRAW::OfficeArtBStoreContainer*>(mso_group->rgChildRec.m_OfficeArtBStoreContainer.get()));
for (long i = 0 ; i < mso_group->rgChildRec.child_records.size(); i++)
{
ODRAW::OfficeArtRecord * art_record = dynamic_cast<ODRAW::OfficeArtRecord*>(mso_group->rgChildRec.child_records[i].get());
if (art_record == NULL) return;
switch(art_record->rh_own.recType)
{
case ODRAW::OfficeArtRecord::BStoreContainer:
{
convert((ODRAW::OfficeArtBStoreContainer*)art_record);
}break;
case ODRAW::OfficeArtRecord::BlipPICT:
{
}break;
}
}
}
......@@ -447,15 +433,24 @@ 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());
if (spgr == NULL) return;
for (long i = 0 ; i < objects->m_OBJs.size(); i++)
{
XLS::OBJ* OBJ = dynamic_cast<XLS::OBJ*>(objects->m_OBJs[i].get());
int ind = objects->m_OBJs[i].second;
if (ind > spgr->child_records.size()-1) continue;
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 (obj->cmo.ot == 0x08)//image
if (xlsx_context->get_drawing_context().start_drawing(obj->cmo.ot))
{
xlsx_context->get_drawing_context().start_drawing(L"", obj->cmo.id);
ODRAW::OfficeArtSpContainer *sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(spgr->child_records[ind+1].get());
convert(sp);
xlsx_context->get_drawing_context().end_drawing();
}
......@@ -463,6 +458,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects)
for (long i = 0 ; i < objects->m_CHARTs.size(); i++)
{
int ind = objects->m_OBJs[i].second;
//xlsx_context->get_chart_context().start_drawing();
......@@ -470,6 +466,31 @@ void XlsConverter::convert(XLS::OBJECTS* objects)
}
}
void XlsConverter::convert(ODRAW::OfficeArtSpContainer *sp)
{
if (sp == NULL) return;
for (int i = 0; i < sp->child_records.size(); i++)
{
convert(sp->child_records[i].get());
}
}
void XlsConverter::convert(ODRAW::OfficeArtRecord * art)
{
if (art == NULL) return;
std::wstringstream strm;
art->serialize(strm);
switch(art->rh_own.recType)
{
break;
}
}
void XlsConverter::convert(XLS::SHAREDSTRINGS* sharedstrings)
{
if (sharedstrings == NULL) return;
......
......@@ -39,7 +39,9 @@ namespace XLS
namespace ODRAW
{
class OfficeArtRecord;
class OfficeArtBStoreContainer;
class OfficeArtSpContainer;
}
class XlsConverter
......@@ -75,7 +77,10 @@ private:
void convert(XLS::LBL * def_name);
void convert(XLS::OBJECTS * objects);
void convert(XLS::MSODRAWINGGROUP * mso_drawing);
void convert(ODRAW::OfficeArtRecord * art);
void convert(ODRAW::OfficeArtBStoreContainer* art_bstore);
void convert(ODRAW::OfficeArtSpContainer * sp);
std::wstring GetTargetMoniker(XLS::BiffStructure *moniker);
......
......@@ -79,27 +79,76 @@ xlsx_drawing_context::xlsx_drawing_context(xlsx_drawing_context_handle & h)
{
}
void xlsx_drawing_context::start_drawing(std::wstring const & name, int type)
bool xlsx_drawing_context::start_drawing(int type)
{
count_object++;
switch(type)
{
case 0x0000: // Group
case 0x0001: // Line
case 0x0002: // Rectangle
case 0x0003: // Oval
case 0x0004: // Arc
start_shape(type); return true;
case 0x0005: // Chart
case 0x0006: // Text
case 0x0007: // Button
break;
case 0x0008: // Picture
start_image(); return true;
case 0x0009: // Polygon:
case 0x000B: // Checkbox
case 0x000C: // Radio button
case 0x000D: // Edit box
case 0x000E: // Label
case 0x000F: // Dialog box
case 0x0010: // Spin control
case 0x0011: // Scrollbar
case 0x0012: // List
case 0x0013: // Group box
case 0x0014: // Dropdown list
case 0x0019: // Note
case 0x001E: // OfficeArt object
break;
}
return false;
//count_object++;
bool isIternal = false;
std::wstring target;
std::wstring rId = handle_.impl_->get_mediaitems().find_image(type, target, isIternal);
//bool isIternal = false;
//std::wstring target;
//std::wstring rId = handle_.impl_->get_mediaitems().find_image(type, target, isIternal);
if (!rId.empty())
{
xlsx_drawings_->add(stream_.str(), isIternal, rId , target, external_items::typeImage);
}
//if (!rId.empty())
//{
// xlsx_drawings_->add(stream_.str(), isIternal, rId , target, external_items::typeImage);
//}
}
void xlsx_drawing_context::start_image()
{
_drawing_state st;
drawing_state.push_back(st);
drawing_state.back().type = external_items::typeImage;
}
void xlsx_drawing_context::start_shape(int type)
{
_drawing_state st;
drawing_state.push_back(st);
drawing_state.back().type = external_items::typeShape;
}
void xlsx_drawing_context::end_drawing()
{
bool isMediaInternal = true;
if (drawing_state.size() < 1 )return;
std::wstringstream strm;
//serialize
//xlsx_drawings_->add(stream_.str(), isMediaInternal, rId , ref, external_items::typeImage);
stream_.clear();
xlsx_drawings_->add(strm.str(), drawing_state.back().isMediaInternal,
drawing_state.back().rId , drawing_state.back().target, drawing_state.back().type);
}
......
#pragma once
#include <vector>
#include <iosfwd>
#include "xlsx_drawings.h"
......@@ -23,25 +24,43 @@ private:
_CP_PTR(Impl) impl_;
};
class _drawing_state
{
public:
_drawing_state() {isMediaInternal = false;}
external_items::Type type;
std::wstring rId;
std::wstring target;
std::wstring anchor;
std::wstring shape;
bool isMediaInternal;
};
class xlsx_drawing_context
{
public:
xlsx_drawing_context(xlsx_drawing_context_handle & h);
~xlsx_drawing_context(){}
void start_drawing(std::wstring const & name, int type);
bool start_drawing(int type);
void end_drawing();
std::wostream & drawing_stream() {return stream_;}
xlsx_drawings_ptr get_drawings();
bool empty();
void start_image();
void start_shape(int type);
private:
std::wstringstream stream_;
std::vector<_drawing_state> drawing_state;
xlsx_drawing_context_handle & handle_;
xlsx_drawings_ptr xlsx_drawings_;
int count_object;
......
......@@ -5012,6 +5012,10 @@
RelativePath="..\XlsFormat\Logic\Biff_structures\ODRAW\OfficeArtTertiaryFOPT.h"
>
</File>
<File
RelativePath="..\XlsFormat\Logic\Biff_structures\ODRAW\SimpleOfficeArtContainers.cpp"
>
</File>
<File
RelativePath="..\XlsFormat\Logic\Biff_structures\ODRAW\SimpleOfficeArtContainers.h"
>
......@@ -7463,18 +7467,6 @@
>
</File>
</Filter>
<Filter
Name="Document"
>
<File
RelativePath="..\XlsFormat\Document\Document.cpp"
>
</File>
<File
RelativePath="..\XlsFormat\Document\Document.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
......
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