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

XlsFile2 - "простое" описание картинки (новое), гиперлинки с картинок (новое)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63902 954022d7-b5bf-4e40-9824-e11837661b57
parent 574951a3
#include "Obj.h"
#include <Logic/Biff_records/MsoDrawing.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtDgContainer.h>
#include <Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.h>
namespace XLS
{;
Obj::Obj(MsoDrawingPtr mso_drawing) : mso_drawing_(mso_drawing)
Obj::Obj()
{
}
......@@ -171,12 +171,28 @@ void Obj::readFields(CFRecord& record)
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
ODRAW::OfficeArtDgContainer dg(ODRAW::OfficeArtRecord::CA_Sheet);
while( !recs.empty() )
if (recs.size())
{
//dg.loadFields(*recs.front());
mso_drawing_->storeRecordAndDecideProceeding(recs.front());
recs.pop_front();
m_OfficeArtSpContainer = ODRAW::OfficeArtRecordPtr(new ODRAW::OfficeArtSpContainer(ODRAW::OfficeArtRecord::CA_Sheet));
while( !recs.empty() )
{
record.appendRawData(recs.front());
recs.pop_front();
}
record >> *m_OfficeArtSpContainer;
BYTE* Add = NULL;
if (record.getRdPtr() < record.getDataSize())
{
int size = record.getDataSize() - record.getRdPtr();
Add = new BYTE [size];
memcpy(Add, record.getData(), size);
record.skipNunBytes(size);
}
if (Add)
{
delete []Add;
}
}
}
......
......@@ -15,11 +15,17 @@
#include <Logic/Biff_structures/FtLbsData.h>
#include <Logic/Biff_structures/FtGboData.h>
namespace ODRAW
{
class OfficeArtRecord;
typedef boost::shared_ptr<OfficeArtRecord> OfficeArtRecordPtr;
}
namespace XLS
{;
{
class MsoDrawing;
typedef boost::shared_ptr<MsoDrawing> MsoDrawingPtr;
//class MsoDrawing;
//typedef boost::shared_ptr<MsoDrawing> MsoDrawingPtr;
// Logical representation of Obj record in BIFF8
class Obj : public BiffRecordContinued
......@@ -27,7 +33,7 @@ class Obj : public BiffRecordContinued
BIFF_RECORD_DEFINE_TYPE_INFO(Obj)
BASE_OBJECT_DEFINE_CLASS_NAME(Obj)
public:
Obj(MsoDrawingPtr mso_drawing);
Obj();
~Obj();
BaseObjectPtr clone();
......@@ -37,7 +43,6 @@ public:
static const ElementType type = typeObj;
MsoDrawingPtr mso_drawing_;
//-----------------------------
FtCmo cmo;
FtCf pictFormat;
......@@ -54,8 +59,7 @@ public:
FtLbsData list;
FtGboData gbo;
public:
ODRAW::OfficeArtRecordPtr m_OfficeArtSpContainer;
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_COMPLEX(cmo)
//if(0x08 == cmo.ot)
......
......@@ -64,7 +64,24 @@ void TxO::readFields(CFRecord& record)
TxOruns.m_runCount = cbRuns / 8 - 1;
TxOruns.load(record);
///+120 byte ???
///+120 byte ???
/*BYTE* Add = NULL;*/
int size = 0;
if (record.getRdPtr() < record.getDataSize())
{
//XLUnicodeStringNoCch add;
//record >> add;
size = record.getDataSize() - record.getRdPtr();
//Add = new BYTE [size];
//memcpy(Add, record.getData(), size);
record.skipNunBytes(size);
}
//if (Add)
//{
// delete []Add;
//}
}
}
}
......
......@@ -141,15 +141,15 @@ void OfficeArtContainer::loadFields(XLS::CFRecord& record)
if(record.getRdPtr() != child_beginning_ptr + rh_child.recLen)
{
if(record.getRdPtr() < child_beginning_ptr + rh_child.recLen)
if(record.getRdPtr() < child_beginning_ptr + rh_child.recLen - 8)
{
Log::warning(STR::int2wstr(child_beginning_ptr + rh_child.recLen - record.getRdPtr(), 10) +
L" unsigned chars were not processed while reading from OfficeArt record of type 0x" +
STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)));
}
else
else if(record.getRdPtr() > child_beginning_ptr + rh_child.recLen)
{
throw;// EXCEPT::RT::WrongBiffRecord("Wrong data parsed in OfficeArt record of type 0x" +
throw;// EXCEPT::RT::WrongBiffRecord("Wrong data parsed in OfficeArt record of type 0x" +
//STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)), record.getTypeString());
}
}
......
......@@ -244,6 +244,9 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
fopte = OfficeArtFOPTEPtr(new ShadowStyleBooleanProperties);
break;
case 0x0382:
fopte = OfficeArtFOPTEPtr(new pihlShape);
break;
default:
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);
break;
......@@ -486,5 +489,20 @@ void fillShadeColors::ReadComplexData(XLS::CFRecord& record)
// own_tag->setAttribute(L"fUsefshadowObscured", fUsefshadowObscured);
// own_tag->setAttribute(L"fUsefShadow", fUsefShadow);
//}
XLS::BiffStructurePtr IHlink::clone()
{
return XLS::BiffStructurePtr(new IHlink(*this));
}
void IHlink::load(XLS::CFRecord& record)
{
record >> CLSID_StdHlink;
record >> hyperlink;
}
void pihlShape::ReadComplexData(XLS::CFRecord& record)
{
record >> IHlink_complex;
}
} // namespace XLS
}
......@@ -7,6 +7,7 @@
#include "IMsoArray.h"
#include "MSOSHADECOLOR.h"
#include "MSO_enums.h"
#include <Logic/Biff_structures/HyperlinkObject.h>
namespace XLS
{
......@@ -61,7 +62,6 @@ class TextBooleanProperties : public OfficeArtFOPTE
BASE_STRUCTURE_DEFINE_CLASS_NAME(TextBooleanProperties)
public:
//virtual void setXMLAttributes(MSXML2::IXMLDOMElementPtr own_tag);
};
......@@ -384,7 +384,7 @@ class fillShadeColors : public OfficeArtFOPTE
public:
//virtual void setXMLAttributes(MSXML2::IXMLDOMElementPtr own_tag);
virtual void ReadComplexData(XLS::CFRecord& record);
private:
IMsoArray<MSOSHADECOLOR> fillShadeColors_complex;
};
......@@ -572,6 +572,35 @@ public:
//}
};
class IHlink;
typedef boost::shared_ptr<IHlink> IHlinkPtr;
class IHlink : public XLS::BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(IHlink)
public:
IHlink(){}
XLS::BiffStructurePtr clone();
void load(XLS::CFRecord& record);
void store(XLS::CFRecord& record){}
static const XLS::ElementType type = XLS::typeIHLink;
_GUID_ CLSID_StdHlink;
OSHARED::HyperlinkObject hyperlink;
};
class pihlShape : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(pihlShape)
public:
virtual void ReadComplexData(XLS::CFRecord& record);
IHlink IHlink_complex;
};
} // namespace XLS
}
......@@ -6,6 +6,10 @@
namespace ODRAW
{;
OfficeArtRecordHeader::OfficeArtRecordHeader()
{
recVer = recInstance = recType = recLen = 0;
}
XLS::BiffStructurePtr OfficeArtRecordHeader::clone()
{
......
......@@ -15,6 +15,7 @@ class OfficeArtRecordHeader : public XLS::BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(OfficeArtRecordHeader)
public:
OfficeArtRecordHeader();
XLS::BiffStructurePtr clone();
virtual void load(XLS::CFRecord& record);
......
......@@ -20,15 +20,6 @@ TxORuns::~TxORuns()
{
}
//void TxORuns::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// std::for_each(rgTxoRuns.begin(), rgTxoRuns.end(), boost::bind(&Run::toXML, _1, xml_tag));
// lastRun.toXML(xml_tag);
//}
//
//void TxORuns::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
//}
void TxORuns::store(CFRecord& record)
{
......
......@@ -2,13 +2,12 @@
#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(MsoDrawingPtr mso_drawing) : mso_drawing_(mso_drawing)
OBJ::OBJ()
{
}
......@@ -27,8 +26,7 @@ BaseObjectPtr OBJ::clone()
// OBJ = Obj *Continue
const bool OBJ::loadContent(BinProcessor& proc)
{
Obj Obj_(mso_drawing_);
if(!proc.mandatory(Obj_))
if(!proc.mandatory<Obj>())
{
return false;
}
......
......@@ -5,27 +5,22 @@
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(MsoDrawingPtr mso_drawing);
OBJ();
~OBJ();
BaseObjectPtr clone();
virtual const bool loadContent(BinProcessor& proc);
BaseObjectPtr m_Obj;
MsoDrawingPtr m_MsoDrawing;
BaseObjectPtr m_Obj;
static const ElementType type = typeOBJ;
MsoDrawingPtr mso_drawing_;
};
} // namespace XLS
......
......@@ -26,10 +26,6 @@ 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));
......@@ -37,14 +33,12 @@ public:
const bool loadContent(BinProcessor& proc)
{
OBJ OBJ_(mso_drawing_);
bool res = proc.optional<TEXTOBJECT>() ||
proc.optional(OBJ_)||
proc.optional<CHART>();
bool res = proc.optional<TEXTOBJECT>() ||
proc.optional<OBJ>() ||
proc.optional<CHART>();
return res;
};
MsoDrawingPtr mso_drawing_;
};
......@@ -53,13 +47,13 @@ class Parenthesis_OBJECTS_1: public ABNFParenthesis
BASE_OBJECT_DEFINE_CLASS_NAME(Parenthesis_OBJECTS_1)
public:
Parenthesis_OBJECTS_1(MsoDrawingPtr mso_drawing,MsoDrawingPtr mso_drawing2) : mso_drawing_(mso_drawing), mso_drawing2_(mso_drawing2)
Parenthesis_OBJECTS_1(MsoDrawingPtr mso_drawing) : mso_drawing_(mso_drawing)
{
}
BaseObjectPtr clone()
{
return BaseObjectPtr(new Parenthesis_OBJECTS_1(mso_drawing_, mso_drawing2_));
return BaseObjectPtr(new Parenthesis_OBJECTS_1(mso_drawing_));
}
const bool loadContent(BinProcessor& proc)
......@@ -74,13 +68,12 @@ public:
{
return false;
}
int count1 = proc.repeated(Parenthesis_OBJECTS_2(mso_drawing2_), 0, 0);
proc.repeated(Parenthesis_OBJECTS_2(), 0, 0);
proc.repeated<Continue>(0,0);
return true;
}
MsoDrawingPtr mso_drawing_;
MsoDrawingPtr mso_drawing2_;
};
......@@ -101,22 +94,9 @@ 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, m_MsoDrawingObjects), 0, 0);
int count1 = proc.repeated(Parenthesis_OBJECTS_1(m_MsoDrawing), 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++)
{
......
......@@ -147,6 +147,7 @@ enum ElementType
typeHFPicture,
typeHideObj,
typeHLink,
typeIHLink,
typeHLinkTooltip,
typeHorizontalPageBreaks,
typeIFmtRecord,
......
......@@ -32,6 +32,7 @@
#include <Logic/Biff_structures/ODRAW/OfficeArtBStoreContainer.h>
#include <Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtFOPT.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtFOPTE.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtFSP.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtBlip.h>
......@@ -443,24 +444,25 @@ void XlsConverter::convert(XLS::OBJECTS* objects)
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 && objects->m_MsoDrawing.get()->rgChildRec.m_OfficeArtSpContainer.size() < 1) 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;
XLS::OBJ* OBJ = dynamic_cast<XLS::OBJ*>(objects->m_OBJs[i].first.get());
XLS::Obj *obj = dynamic_cast<XLS::Obj*>(OBJ->m_Obj.get());
ODRAW::OfficeArtSpContainer *sp = NULL;
if ( (spgr) && (ind < spgr->child_records.size()))
if (obj->m_OfficeArtSpContainer)
{
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(spgr->child_records[ind+1].get());
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(obj->m_OfficeArtSpContainer.get());
}
else if (ind < objects->m_MsoDrawing.get()->rgChildRec.m_OfficeArtSpContainer.size())
else if ( (spgr) && (ind < spgr->child_records.size()))
{
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(objects->m_MsoDrawing.get()->rgChildRec.m_OfficeArtSpContainer[ind].get());
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(spgr->child_records[ind+1].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))
{
......@@ -539,8 +541,16 @@ void XlsConverter::convert(ODRAW::OfficeArtFOPT * fort)
std::wstring rId = xlsx_context->get_mediaitems().find_image(fort->fopt.rgfopte[i]->op , target, isIternal);
xlsx_context->get_drawing_context().set_image(target);
}break;
case 0x0382:
{
ODRAW::pihlShape *pihlShape = dynamic_cast<ODRAW::pihlShape*>(fort->fopt.rgfopte[i].get());
if (pihlShape)
{
std::wstring target = GetTargetMoniker(pihlShape->IHlink_complex.hyperlink.oleMoniker.data.get());
xlsx_context->get_drawing_context().set_hyperlink(target);
}
}break;
}
}
}
......
......@@ -5,7 +5,7 @@
#include "xlsx_drawing_context.h"
#include <simple_xml_writer.h>
#include <utils.h>
namespace oox {
......@@ -150,6 +150,7 @@ void xlsx_drawing_context::set_shape_id(int id)
if (drawing_state.size() < 1 )return;
drawing_state.back().shape_id = id;
}
void xlsx_drawing_context::end_drawing()
{
if (drawing_state.size() < 1 )return;
......@@ -188,6 +189,17 @@ void xlsx_drawing_context::serialize_pic(std::wstring rId)
{
if (drawing_state.back().id >= 0) CP_XML_ATTR(L"id", drawing_state.back().id);
CP_XML_ATTR(L"name", L"Picture_" + rId.substr(5));
if (!drawing_state.back().hyperlink.empty())
{
CP_XML_NODE(L"a:hlinkClick")
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"r:id", drawing_state.back().hyperlink);
}
}
}
CP_XML_NODE(L"xdr:cNvPicPr")
{
......@@ -266,6 +278,23 @@ void xlsx_drawing_context::set_image(std::wstring & str)
if (drawing_state.size() < 1 )return;
drawing_state.back().image_target = str;
}
void xlsx_drawing_context::set_hyperlink(std::wstring & str)
{
if (drawing_state.size() < 1 )return;
std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_.size()+1);
std::wstring href_correct = xml::utils::replace_text_to_xml(str);
_hlink_desc desc = {hId, href_correct};
hlinks_.push_back(desc);
drawing_state.back().hyperlink = hId;
xlsx_drawings_->add( false, hId , href_correct, external_items::typeHyperlink);
}
void xlsx_drawing_context::set_properties(std::wstring & str)
{
if (drawing_state.size() < 1 )return;
......
......@@ -39,9 +39,15 @@ public:
int shape_id;
bool flipV;
bool flipH;
std::wstring hyperlink;
bool isInternal;
};
struct _hlink_desc
{
std::wstring hId;
std::wstring hRef;
};
class xlsx_drawing_context
{
......@@ -67,6 +73,7 @@ public:
void set_image(std::wstring & str);
void set_anchor(std::wstring & str);
void set_properties(std::wstring & str);
void set_hyperlink(std::wstring & str);
void serialize(std::wostream & stream);
......@@ -79,6 +86,8 @@ private:
xlsx_drawing_context_handle & handle_;
xlsx_drawings_ptr xlsx_drawings_;
int count_object;
std::vector<_hlink_desc> hlinks_;
};
}
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