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

XlsFile2 расширения автофигур, пути-полиномы ....

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@64023 954022d7-b5bf-4e40-9824-e11837661b57
parent 97a926a6
......@@ -67,6 +67,11 @@ int Font::serialize(std::wostream & stream)
return 0;
}
void Font::set_color_ext(FillInfoExt & color_ext_)
{
color_ext = color_ext_;
}
int Font::serialize_properties(std::wostream & stream, bool rPr)
{
CP_XML_WRITER(stream)
......@@ -87,11 +92,31 @@ int Font::serialize_properties(std::wostream & stream, bool rPr)
}
}
if ((icv.value()) && (icv < 0x7fff) )
if (((icv.value()) && (icv < 0x7fff)) || color_ext.enabled )
{
CP_XML_NODE(L"color")
{
CP_XML_ATTR(L"indexed", icv);
if (color_ext.enabled )
{
switch(color_ext.xclrType)
{
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
CP_XML_ATTR(L"indexed", color_ext.icv); break;
case 2://rgb
CP_XML_ATTR(L"rgb", STR::toARGB(color_ext.xclrValue)); break;
case 3://theme color
CP_XML_ATTR(L"theme", color_ext.xclrValue + 1);
CP_XML_ATTR(L"tint", color_ext.nTintShade / 32767.0); break;
case 4://not set
break;
}
}
else
{
CP_XML_ATTR(L"indexed", icv);
}
}
}
......
......@@ -2,6 +2,7 @@
#include "BiffRecord.h"
#include <Logic/Biff_structures/BiffString.h>
#include <Logic/Biff_structures/BorderFillInfo.h>
namespace XLS
{;
......@@ -26,6 +27,8 @@ public:
int serialize (std::wostream & stream);
int serialize_properties (std::wostream & stream, bool rPr = false);
void set_color_ext (FillInfoExt & color_ext);
//-----------------------------
BIFF_WORD dyHeight; // measured in twips (1/20 of of a printer's point)
......@@ -43,27 +46,9 @@ public:
BIFF_BYTE bFamily;
BIFF_BYTE bCharSet;
ShortXLUnicodeString fontName;
FillInfoExt color_ext;
ShortXLUnicodeString fontName;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(dyHeight)
//BO_ATTRIB_MARKUP_ATTRIB(fItalic)
//BO_ATTRIB_MARKUP_ATTRIB(fStrikeOut)
//BO_ATTRIB_MARKUP_ATTRIB(fOutline)
//BO_ATTRIB_MARKUP_ATTRIB(fShadow)
//BO_ATTRIB_MARKUP_ATTRIB(fCondense)
//BO_ATTRIB_MARKUP_ATTRIB(fExtend)
//BO_ATTRIB_MARKUP_ATTRIB(icv)
//BO_ATTRIB_MARKUP_ATTRIB(bls)
//BO_ATTRIB_MARKUP_ATTRIB(sss)
//BO_ATTRIB_MARKUP_ATTRIB(uls)
//BO_ATTRIB_MARKUP_ATTRIB(bFamily)
//BO_ATTRIB_MARKUP_ATTRIB(bCharSet)
//BO_ATTRIB_MARKUP_ATTRIB(fontName)
//BO_ATTRIB_MARKUP_END
};
} // namespace XLS
......
......@@ -170,21 +170,21 @@ void Obj::readFields(CFRecord& record)
{
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
ODRAW::OfficeArtDgContainer dg(ODRAW::OfficeArtRecord::CA_Sheet);
if (recs.size())
{
m_OfficeArtSpContainer = ODRAW::OfficeArtRecordPtr(new ODRAW::OfficeArtSpContainer(ODRAW::OfficeArtRecord::CA_Sheet));
while( !recs.empty() )
{
record.appendRawData(recs.front());
recs.pop_front();
}
record >> *m_OfficeArtSpContainer;
m_OfficeArtSpContainer = ODRAW::OfficeArtRecordPtr(new ODRAW::OfficeArtSpContainer(ODRAW::OfficeArtRecord::CA_Sheet));
record >> *m_OfficeArtSpContainer; //todooo !!!
BYTE* Add = NULL;
BYTE* Add = NULL;
int size = 0;
if (record.getRdPtr() < record.getDataSize())
{
int size = record.getDataSize() - record.getRdPtr();
size = record.getDataSize() - record.getRdPtr();
Add = new BYTE [size];
memcpy(Add, record.getData(), size);
record.skipNunBytes(size);
......
#include "TxO.h"
#include <Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.h>
namespace XLS
{;
......@@ -63,25 +64,14 @@ void TxO::readFields(CFRecord& record)
TxOruns.m_runCount = cbRuns / 8 - 1;
TxOruns.load(record);
///+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);
m_OfficeArtSpContainer = ODRAW::OfficeArtRecordPtr(new ODRAW::OfficeArtSpContainer(ODRAW::OfficeArtRecord::CA_Sheet));
record >> *m_OfficeArtSpContainer; //todooo !!!
}
//if (Add)
//{
// delete []Add;
//}
}
}
}
......
......@@ -6,6 +6,12 @@
#include <Logic/Biff_structures/ObjFmla.h>
#include <Logic/Biff_structures/TxORuns.h>
namespace ODRAW
{
class OfficeArtRecord;
typedef boost::shared_ptr<OfficeArtRecord> OfficeArtRecordPtr;
}
namespace XLS
{;
......@@ -26,28 +32,21 @@ public:
static const ElementType type = typeTxO;
BIFF_BYTE hAlignment;
BIFF_BYTE vAlignment;
BIFF_BYTE fLockText;
BIFF_BYTE fJustLast;
BIFF_BYTE fSecretEdit;
BIFF_WORD rot;
ControlInfo controlInfo;
BIFF_WORD cchText;
BIFF_WORD cbRuns;
FontIndex ifntEmpty;
ObjFmla fmla;
TxORuns TxOruns;
XLUnicodeStringNoCch commentText;
//if (cchText == BIFF_WORD(0)) {
// //BO_ATTRIB_MARKUP_ATTRIB(ifntEmpty)
//}
//if ( cbRuns )
//{
// //BO_ATTRIB_MARKUP_COMPLEX(TxOruns)
//}
BIFF_BYTE hAlignment;
BIFF_BYTE vAlignment;
BIFF_BYTE fLockText;
BIFF_BYTE fJustLast;
BIFF_BYTE fSecretEdit;
BIFF_WORD rot;
ControlInfo controlInfo;
BIFF_WORD cchText;
BIFF_WORD cbRuns;
FontIndex ifntEmpty;
ObjFmla fmla;
TxORuns TxOruns;
XLUnicodeStringNoCch commentText;
ODRAW::OfficeArtRecordPtr m_OfficeArtSpContainer;
};
......
......@@ -76,9 +76,7 @@ int XF::serialize(std::wostream & stream)
{
CP_XML_NODE(L"xf")
{
if (style.font_scheme >=0) CP_XML_ATTR(L"fontId" , style.font_scheme);
else if (cell.font_scheme >=0) CP_XML_ATTR(L"fontId" , cell.font_scheme);
else if (ifnt.value()) CP_XML_ATTR(L"fontId" , ifnt.getValue());
if (ifnt.value()) CP_XML_ATTR(L"fontId" , ifnt.getValue());
if (ifmt.value())
{
......
......@@ -10,7 +10,7 @@ namespace XLS
CellXF::CellXF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_scheme(-1)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_id(0xFFFF)
{
}
......@@ -170,20 +170,25 @@ void CellXF::RegisterFillBorder()
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
//case 0x000D: //text color
// extPropData.color.toXML(own_tag);
// break;
case 0x000D:
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
font_scheme = ext_prop->extPropData.font_scheme;
font_id = ext_prop->extPropData.font_scheme;
break;
case 0x000F:
cIndent = ext_prop->extPropData.indent_level;
break;
}
}
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
}
......
......@@ -46,7 +46,8 @@ public:
BiffStructurePtrVector ext_props;
int font_scheme;
FillInfoExt font_color;
size_t font_id;
bool fHasXFExt;
bool fsxButton;
......
......@@ -25,10 +25,10 @@ public:
struct extPropData_Tag
{
FullColorExt color;
XFExtGradient gradient_fill;
unsigned char font_scheme;
unsigned short indent_level;
FullColorExt color;
XFExtGradient gradient_fill;
unsigned char font_scheme;
unsigned short indent_level;
} extPropData;
};
......
......@@ -12,23 +12,6 @@ BiffStructurePtr FontIndex::clone()
}
//void FontIndex::toXML(BiffStructurePtr & parent, const std::wstring & attrib_name)
//{
// parent->setAttribute(attrib_name, getValue());
//}
//
//
//const bool FontIndex::fromXML(MSXML2::IXMLDOMElementPtr xml_tag, const std::wstring & attrib_name)
//{
// unsigned short index = getStructAttribute(xml_tag, attrib_name);
// if(index >= 4)
// {
// ++index;
// }
// val = index;
// return true;
//}
FontIndex::operator const _variant_t () const
{
return getValue();
......@@ -39,6 +22,12 @@ const unsigned short FontIndex::getValue() const
unsigned short index = static_cast<unsigned short>(val.get_value_or(0));
return index < 4 ? index : index - 1;
}
void FontIndex::setValue(unsigned short val_)
{
if (val_ < 4) val = val_;
else val = val_;
}
} // namespace XLS
......
......@@ -14,10 +14,9 @@ class FontIndex : public BiffAttributeSimple<unsigned short>
public:
BiffStructurePtr clone();
//virtual void toXML(BiffStructurePtr & parent, const std::wstring & attrib_name);
//virtual const bool fromXML(MSXML2::IXMLDOMElementPtr xml_tag, const std::wstring & attrib_name);
operator const _variant_t () const;
const unsigned short getValue() const;
const unsigned short getValue() const;
void setValue(unsigned short val);
};
} // namespace XLS
......
......@@ -14,18 +14,6 @@ XLS::BiffStructurePtr MSOSHADECOLOR::clone()
return XLS::BiffStructurePtr(new MSOSHADECOLOR(*this));
}
//
//void MSOSHADECOLOR::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// color.toXML(xml_tag);
// position.toXML(xml_tag, L"position");
//}
//
//void MSOSHADECOLOR::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// // We don't support xlsx to xls conversion
//}
void MSOSHADECOLOR::store(XLS::CFRecord& record)
{
......
......@@ -2,10 +2,31 @@
#include "OfficeArtFOPTE.h"
#include <Binary/CFRecord.h>
#include "OfficeArtBlip.h"
#include <bitset>
namespace ODRAW
{;
static int BitmaskToInt( int value, int mask )
{
int ret = value & mask;
//shift for all trailing zeros
std::bitset<sizeof(int)*8> bits( mask );
for ( unsigned int i = 0; i < bits.size(); i++ )
{
if ( !bits[i] )
{
ret >>= 1;
}
else
{
break;
}
}
return ret;
}
XLS::BiffStructurePtr OfficeArtFOPTE::clone()
{
......@@ -90,16 +111,20 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
case 0x013F:
fopte = OfficeArtFOPTEPtr(new BlipBooleanProperties);
break;
/*todo*/case 0x0140: //geoLeft
case 0x0141: //geoTop
case 0x0142: //geoRight
case 0x0143: //geoBottom
case 0x0144: //shapePath
case 0x0140:
case 0x0141:
case 0x0142:
case 0x0143:
fopte = OfficeArtFOPTEPtr(new OfficeArtShapeRectCoord);
break;
case 0x0144:
fopte = OfficeArtFOPTEPtr(new ShapePath);
break;
case 0x0145: //pVertices
case 0x0146: //pSegmentInfo
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);
case 0x0145:
fopte = OfficeArtFOPTEPtr(new PVertices);
break;
case 0x0146:
fopte = OfficeArtFOPTEPtr(new PSegmentInfo);
break;
case 0x0147: //adjustValue .... //adjust8Value
case 0x0148:
......@@ -492,4 +517,51 @@ void pihlShape::ReadComplexData(XLS::CFRecord& record)
record >> IHlink_complex;
}
XLS::BiffStructurePtr MSOPOINT::clone()
{
return XLS::BiffStructurePtr(new MSOPOINT(*this));
}
void MSOPOINT::load(XLS::CFRecord& record)
{
record >> x >> y;
}
XLS::BiffStructurePtr MSOPATHINFO::clone()
{
return XLS::BiffStructurePtr(new MSOPATHINFO(*this));
}
void MSOPATHINFO::load(XLS::CFRecord& record)
{
unsigned short val;
record >> val;
typeSegment = (MSOPATHTYPE)BitmaskToInt (val, 0xE000);
EscapeCode = msopathEscapeExtension;
VertexCount = 0;
if (msopathEscape == typeSegment)
{
EscapeCode = (MSOPATHESCAPE) BitmaskToInt (val, 0x1F00);
VertexCount = BitmaskToInt (val, 0x00FF);
}
else
{
Segments = BitmaskToInt (val, 0x1FFF);
}
}
void PVertices::ReadComplexData(XLS::CFRecord& record)
{
record >> path_complex;
}
void PSegmentInfo::ReadComplexData(XLS::CFRecord& record)
{
record >> path_complex;
}
}
......@@ -16,6 +16,44 @@ namespace XLS
namespace ODRAW
{;
enum MSOPATHTYPE
{
msopathLineTo,
msopathCurveTo,
msopathMoveTo,
msopathClose,
msopathEnd,
msopathEscape,
msopathClientEscape,
msopathInvalid
};
enum MSOPATHESCAPE
{
msopathEscapeExtension = 0x00000000,
msopathEscapeAngleEllipseTo = 0x00000001,
msopathEscapeAngleEllipse = 0x00000002,
msopathEscapeArcTo = 0x00000003,
msopathEscapeArc = 0x00000004,
msopathEscapeClockwiseArcTo = 0x00000005,
msopathEscapeClockwiseArc = 0x00000006,
msopathEscapeEllipticalQuadrantX = 0x00000007,
msopathEscapeEllipticalQuadrantY = 0x00000008,
msopathEscapeQuadraticBezier = 0x00000009,
msopathEscapeNoFill = 0x0000000A,
msopathEscapeNoLine = 0x0000000B,
msopathEscapeAutoLine = 0x0000000C,
msopathEscapeAutoCurve = 0x0000000D,
msopathEscapeCornerLine = 0x0000000E,
msopathEscapeCornerCurve = 0x0000000F,
msopathEscapeSmoothLine = 0x00000010,
msopathEscapeSmoothCurve = 0x00000011,
msopathEscapeSymmetricLine = 0x00000012,
msopathEscapeSymmetricCurve = 0x00000013,
msopathEscapeFreeform = 0x00000014,
msopathEscapeFillColor = 0x00000015,
msopathEscapeLineColor = 0x00000016
};
class OfficeArtFOPTE;
typedef boost::shared_ptr<OfficeArtFOPTE> OfficeArtFOPTEPtr;
......@@ -460,10 +498,85 @@ class Rotation : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(Rotation)
};
class OfficeArtShapeRectCoord : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(OfficeArtShapeRectCoord)
};
class MSOPOINT : public XLS::BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(MSOPOINT)
MSOPOINT(){}
XLS::BiffStructurePtr clone();
virtual void load(XLS::CFRecord& record);
virtual void store(XLS::CFRecord& record){}
static const XLS::ElementType type = XLS::typeOfficeArtRecord;
long x;
long y;
};
class MSOPATHINFO : public XLS::BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(MSOPATHINFO)
MSOPATHINFO(){}
XLS::BiffStructurePtr clone();
virtual void load(XLS::CFRecord& record);
virtual void store(XLS::CFRecord& record){}
static const XLS::ElementType type = XLS::typeOfficeArtRecord;
//enum msoPathSegmentType
//{
// msopathLineTo = 0,
// msopathCurveTo,
// msopathMoveTo,
// msopathClose,
// msopathEnd,
// msopathEscape,
// msopathClientEscape
//};
MSOPATHTYPE typeSegment;
short Segments;
short VertexCount;
MSOPATHESCAPE EscapeCode;
};
class ShapePath : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(ShapePath)
enum msoShapePathType
{
msoshapeLines =0,
msoshapeLinesClosed,
msoshapeCurves,
msoshapeCurvesClosed,
msoshapeComplex
};
};
class PVertices : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(PVertices)
virtual void ReadComplexData(XLS::CFRecord& record);
IMsoArray<MSOPOINT> path_complex;
};
class PSegmentInfo : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(PSegmentInfo)
virtual void ReadComplexData(XLS::CFRecord& record);
IMsoArray<MSOPATHINFO> path_complex;
};
class AdjustValue : public OfficeArtFOPTE
......@@ -501,7 +614,7 @@ typedef boost::shared_ptr<IHlink> IHlinkPtr;
class IHlink : public XLS::BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(IHlink)
public:
IHlink(){}
XLS::BiffStructurePtr clone();
......@@ -518,7 +631,7 @@ public:
class pihlShape : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(pihlShape)
public:
void ReadComplexData(XLS::CFRecord& record);
IHlink IHlink_complex;
......
......@@ -20,8 +20,6 @@ void OfficeArtRGFOPTE::store(XLS::CFRecord& record)
void OfficeArtRGFOPTE::load(XLS::CFRecord& record)
{
// size_t end = record.getRdPtr() + data_size;
for(int i = 0; i < options_num; ++i)
{
OfficeArtFOPTEPtr fopte = OfficeArtFOPTE::load_and_create(record);
......@@ -53,7 +51,7 @@ void OfficeArtRGFOPTE::load(XLS::CFRecord& record)
{
FillStyle_props.push_back(fopte);
}
else if (type_prop >= 0x01C0 && type_prop < 0x0540) //2.3.8 Line Style
else if (type_prop >= 0x01C0 && type_prop < 0x0200) //2.3.8 Line Style
{
LineStyle_props.push_back(fopte);
}
......@@ -99,6 +97,8 @@ void OfficeArtRGFOPTE::load(XLS::CFRecord& record)
(*it)->ReadComplexData(record);
}
}
rgfopte.clear();
}
void OfficeArtRGFOPTE::SetOptionsNumber(const unsigned short number)
......
......@@ -75,7 +75,8 @@ public:
SplitMenuColorContainer = 0xF11E, // Implemented
SecondaryFOPT = 0xF121,
TertiaryFOPT = 0xF122, // Implemented
SpgrContainerFileBlock
};
enum OfficeArtClientAnchorType
......
......@@ -10,8 +10,11 @@ namespace XLS
StyleXF::StyleXF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_scheme(-1)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_id(0xFFFF)
{
font_id = -1;
border_x_id = -1;
fill_x_id = -1;
}
......@@ -66,7 +69,9 @@ void StyleXF::load(CFRecord& record)
unsigned int flags2;
unsigned int flags3;
unsigned short flags4;
record >> flags1 >> flags2 >> flags3 >> flags4;
alc = static_cast<unsigned char>(GETBITS(flags1, 0, 2));
fWrap = GETBIT(flags1, 3);
alcV = static_cast<unsigned char>(GETBITS(flags1, 4, 6));
......@@ -83,11 +88,11 @@ void StyleXF::load(CFRecord& record)
border.dgDiag = static_cast<unsigned char>(GETBITS(flags3, 21, 24));
border.grbitDiag = static_cast<unsigned char>(GETBITS(flags2, 30, 31));
border.icvLeft = 0 != border.dgLeft ? static_cast<unsigned char>(GETBITS(flags2, 16, 22)) : 0;
border.icvLeft = 0 != border.dgLeft ? static_cast<unsigned char>(GETBITS(flags2, 16, 22)) : 0;
border.icvRight = 0 != border.dgRight ? static_cast<unsigned char>(GETBITS(flags2, 23, 29)) : 0;
border.icvTop = 0 != border.dgTop ? static_cast<unsigned char>(GETBITS(flags3, 0, 6)) : 0;
border.icvTop = 0 != border.dgTop ? static_cast<unsigned char>(GETBITS(flags3, 0, 6)) : 0;
border.icvBottom = 0 != border.dgBottom ? static_cast<unsigned char>(GETBITS(flags3, 7, 13)) : 0;
border.icvDiag = 0 != border.dgDiag ? static_cast<unsigned char>(GETBITS(flags3, 14, 20)) : 0;
border.icvDiag = 0 != border.dgDiag ? static_cast<unsigned char>(GETBITS(flags3, 14, 20)) : 0;
fill.fls = static_cast<unsigned char>(GETBITS(flags3, 26, 31));
fill.icvFore = GETBITS(flags4, 0, 6);
......@@ -153,21 +158,24 @@ void StyleXF::RegisterFillBorder()
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
//case 0x000D: //text color
// extPropData.color.toXML(own_tag);
// break;
case 0x000D:
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
font_scheme = ext_prop->extPropData.font_scheme;
font_id = ext_prop->extPropData.font_scheme;
break;
case 0x000F:
cIndent = ext_prop->extPropData.indent_level;
break;
}
}
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
......
......@@ -39,11 +39,12 @@ public:
BorderInfo border;
FillInfo fill;
FillInfoExt font_color;
size_t font_id;
BiffStructurePtrVector ext_props;
int font_scheme;
size_t border_x_id;
size_t fill_x_id;
......
......@@ -35,7 +35,8 @@ BaseObjectPtr FORMATTING::clone()
//FORMATTING = 1*510Font 8*218Format XFS *DXF STYLES [TABLESTYLES] [Palette] [ClrtClient]
const bool FORMATTING::loadContent(BinProcessor& proc)
{
//todooo - 2
global_info = proc.getGlobalWorkbookInfo();
int count = 0;
count = proc.repeated<Font>(0, 510); // Wrong records sequence workaround (originally at least one Font is mandatory)
while(count > 0)
......@@ -113,6 +114,12 @@ int FORMATTING::serialize1(std::wostream & stream)
CP_XML_ATTR(L"count", m_Fonts.size());
for (long i = 0 ; i < m_Fonts.size(); i++)
{
Font * font = dynamic_cast<Font*>(m_Fonts[i].get());
std::map<int, FillInfoExt>::iterator it = global_info->fonts_color_ext.find(i);
if (font && (it!=global_info->fonts_color_ext.end()))
{
font->set_color_ext(it->second);
}
m_Fonts[i]->serialize(CP_XML_STREAM());
}
}
......
......@@ -29,6 +29,9 @@ public:
std::vector<BaseObjectPtr> m_Fonts;
BaseObjectPtr m_Palette;
BaseObjectPtr m_ClrtClient;
GlobalWorkbookInfoPtr global_info;
};
} // namespace XLS
......
......@@ -64,13 +64,14 @@ public:
const bool loadContentRead(BinReaderProcessor& proc)
{
if(!proc.mandatory(*mso_drawing_))
{
return false;
}
proc.repeated(Parenthesis_OBJECTS_2(), 0, 0);
bool res = proc.mandatory(*mso_drawing_);
//if(!res)
//{
// return false;
//}
int count = proc.repeated(Parenthesis_OBJECTS_2(), 0, 0);
proc.repeated<Continue>(0,0);
return true;
return res || count>0;
}
MsoDrawingPtr mso_drawing_;
......
......@@ -31,6 +31,8 @@ const bool TEXTOBJECT::loadContent(BinProcessor& proc)
{
return false;
}
m_TxO = elements_.back();
elements_.pop_back();
proc.repeated<Continue>(0, 0);
return true;
......
......@@ -20,6 +20,7 @@ public:
static const ElementType type = typeTEXTOBJECT;
BaseObjectPtr m_TxO;
};
} // namespace XLS
......
......@@ -32,6 +32,8 @@ BaseObjectPtr XFS::clone()
// XFS = 16*XF [XFCRC 16*4050XFExt]
const bool XFS::loadContent(BinProcessor& proc)
{
GlobalWorkbookInfoPtr global_info = proc.getGlobalWorkbookInfo();
cellStyleXfs_count = 0;
int count = proc.repeated(XF(cell_xf_current_id, style_xf_current_id) ,16, 0);
......@@ -76,7 +78,7 @@ const bool XFS::loadContent(BinProcessor& proc)
{
XF *xfs = dynamic_cast<XF*>(m_cell_styles[i].get());
if (m_xf_ext.size() > 0)
if (m_xf_ext.size() > 0 && xfs->cell.fHasXFExt)
{
XFExt *ext_find = NULL;
......@@ -97,8 +99,19 @@ const bool XFS::loadContent(BinProcessor& proc)
xfs->style.ext_props = ext_find->rgExt;
}
}
xfs->style.RegisterFillBorder();
//if (xfs->cell.font_id < 0xFFFF)
//{
// xfs->ifnt.setValue((unsigned short) xfs->style.font_id);
//}
/* if (xfs->style.font_color.enabled)
{
int font_id = xfs->ifnt;
global_info->RegisterFontColorId(font_id, xfs->style.font_color);
}*/
}
for (long i = 0 ; i < m_cell_xfs.size(); i++)
......@@ -115,6 +128,17 @@ const bool XFS::loadContent(BinProcessor& proc)
}
xfs->cell.RegisterFillBorder();
//if (xfs->cell.font_id < 0xFFFF)
//{
// xfs->ifnt.setValue( (unsigned short) xfs->cell.font_id);
//}
//if (xfs->cell.font_color.enabled)
//{
// int font_id = xfs->ifnt;
// global_info->RegisterFontColorId(font_id, xfs->cell.font_color);
//}
}
return true;
......
......@@ -54,6 +54,11 @@ const size_t GlobalWorkbookInfo::RegisterFillId(const FillInfo& fill)
}
}
void GlobalWorkbookInfo::RegisterFontColorId (int id, const FillInfoExt & font_color)
{
fonts_color_ext.insert(std::pair<int, FillInfoExt>(id,font_color));
}
const unsigned int GlobalWorkbookInfo::GenerateAXESId()
{
return last_AXES_id += 1;
......
......@@ -21,8 +21,9 @@ public:
const size_t RegisterBorderId (const BorderInfo& border);
const size_t RegisterFillId (const FillInfo& fill);
const unsigned int GenerateAXESId();
void RegisterFontColorId (int id, const FillInfoExt & font_color);
const unsigned int GenerateAXESId();
unsigned short CodePage;
CRYPT::DecryptorPtr decryptor;
......@@ -33,6 +34,7 @@ public:
boost::unordered_map<BorderInfo, int> border_x_ids;
boost::unordered_map<FillInfo, int> fill_x_ids;
std::map<int, FillInfoExt> fonts_color_ext;
std::vector<BaseObjectPtr> *fonts;
......
......@@ -20,11 +20,13 @@
#include "../XlsFormat/Logic/Biff_unions/OBJECTS.h"
#include "../XlsFormat/Logic/Biff_unions/MSODRAWINGGROUP.h"
#include "../XlsFormat/Logic/Biff_unions/OBJ.h"
#include "../XlsFormat/Logic/Biff_unions/TEXTOBJECT.h"
#include <Logic/Biff_records/HLink.h>
#include <Logic/Biff_records/MsoDrawingGroup.h>
#include <Logic/Biff_records/MsoDrawing.h>
#include <Logic/Biff_records/Obj.h>
#include <Logic/Biff_records/TxO.h>
#include <Logic/Biff_structures/URLMoniker.h>
#include <Logic/Biff_structures/FileMoniker.h>
......@@ -486,7 +488,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects)
{
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(spgr->child_records[ind+1].get());
}
else continue;
//else continue;
if (xlsx_context->get_drawing_context().start_drawing(obj->cmo.ot))//тут тип шейпа ВРАНЬЕ !!! пример - 7.SINIF I.DÖNEM III.YAZILI SINAV.xls
......@@ -497,6 +499,34 @@ void XlsConverter::convert(XLS::OBJECTS* objects)
}
}
for (long i = 0; i <objects->m_TEXTOBJECTs.size(); i++)
{
int ind = objects->m_OBJs[i].second;
XLS::TEXTOBJECT* textObject = dynamic_cast<XLS::TEXTOBJECT*>(objects->m_TEXTOBJECTs[i].first.get());
if (textObject == NULL) continue;
XLS::TxO * txO = dynamic_cast<XLS::TxO *>(textObject->m_TxO.get());
if (txO == NULL) continue;
ODRAW::OfficeArtSpContainer *sp = NULL;
if (txO->m_OfficeArtSpContainer)
{
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(txO->m_OfficeArtSpContainer.get());
}
else if ( (spgr) && (ind < spgr->child_records.size()))
{
sp = dynamic_cast<ODRAW::OfficeArtSpContainer*>(spgr->child_records[ind+1].get());
}
if (xlsx_context->get_drawing_context().start_drawing(0x0006))
{
convert(sp);
xlsx_context->get_drawing_context().end_drawing();
}
}
for (long i = 0 ; i < objects->m_CHARTs.size(); i++)
{
int ind = objects->m_OBJs[i].second;
......@@ -578,6 +608,10 @@ void XlsConverter::convert_line_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
case 0x01C5: //blip
{
}break;
case 0x01CB:
xlsx_context->get_drawing_context().set_line_width(props[i]->op);
{
}break;
case 0x01CD:
{
xlsx_context->get_drawing_context().set_line_style(props[i]->op);
......@@ -619,8 +653,87 @@ void XlsConverter::convert_blip(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
}
void XlsConverter::convert_geometry(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
std::vector<ODRAW::MSOPOINT> points;
std::vector<ODRAW::MSOPATHINFO> command;
ODRAW::ShapePath::msoShapePathType shapeType;
oox::_rect rect;
for (int i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
case 0x0140: rect.left = props[i]->op; break;
case 0x0141: rect.top = props[i]->op; break;
case 0x0142: rect.right = props[i]->op; break;
case 0x0143: rect.bottom = props[i]->op; break;
case 0x0144: shapeType = (ODRAW::ShapePath::msoShapePathType)props[i]->op; break;
case 0x0145:
{
ODRAW::PVertices * v = (ODRAW::PVertices *)(props[i].get());
points = v->path_complex.data;
}break;
case 0x0146:
{
ODRAW::PSegmentInfo * s = (ODRAW::PSegmentInfo *)(props[i].get());
command = s->path_complex.data;
}break;
}
}
if (points.size() > 0 || command.size() > 0)
{
std::wstringstream strm;
CP_XML_WRITER(strm)
{
if (command.size() == 0)
{
for (int i = 0 ; i < points.size(); i++)
{
CP_XML_NODE(L"a:lnTo")
{
CP_XML_NODE(L"a:pt")
{
CP_XML_ATTR(L"x", points[i].x);
CP_XML_ATTR(L"y", points[i].y);
}
}
}
}
else
{
int ind_point = 0;
std::wstring comm[] =
{
L"a:lnTo", L"a:cubicBezTo", L"a:moveTo", L"a:close"
};
for (int i = 0 ; i < command.size(); i++)
{
if (command[i].typeSegment == ODRAW::msopathEnd) break;
if (command[i].typeSegment > 4) continue;
if (command[i].typeSegment < 3 && command[i+1].Segments < 1)
continue;
CP_XML_NODE(comm[command[i].typeSegment])
{
for (int j=0 ; j < command[i+1].Segments; j ++)
{
if (ind_point > points.size())
break;
CP_XML_NODE(L"a:pt")
{
CP_XML_ATTR(L"x", points[ind_point].x);
CP_XML_ATTR(L"y", points[ind_point].y);
ind_point++;
}
}
}
}
}
}
//xlsx_context->get_drawing_context().set_shapeType
xlsx_context->get_drawing_context().set_path_rect(rect);
xlsx_context->get_drawing_context().set_path(strm.str());
}
}
void XlsConverter::convert_geometry_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
......
......@@ -87,14 +87,14 @@ bool xlsx_drawing_context::start_drawing(int type)
case 0x0002: // Rectangle
case 0x0003: // Oval
case 0x0004: // Arc
//case 0x0009: // Polygon:
start_shape(type); return true;
case 0x0005: // Chart
case 0x0006: // Text
case 0x0007: // Button
break;
case 0x001E: // OfficeArt object
case 0x0009: // Polygon:
start_shape(type); return true;
case 0x0008: // Picture
start_image(); return true;
case 0x0005: // Chart
case 0x0007: // Button
case 0x000B: // Checkbox
case 0x000C: // Radio button
case 0x000D: // Edit box
......@@ -106,7 +106,6 @@ bool xlsx_drawing_context::start_drawing(int type)
case 0x0013: // Group box
case 0x0014: // Dropdown list
case 0x0019: // Note
case 0x001E: // OfficeArt object
break;
}
return false;
......@@ -131,6 +130,16 @@ void xlsx_drawing_context::start_shape(int type)
drawing_state.back().type = external_items::typeShape;
drawing_state.back().shape_type = type;
if (0x0006 == type)
{
drawing_state.back().shape_type = msosptTextBox;
drawing_state.back().bTextBox = true;
}
if (0x001E == type)
{
drawing_state.back().shape_type = msosptTextBox;
//drawing_state.back().bWordArt = true;
}
count_object++;
}
......@@ -151,7 +160,10 @@ void xlsx_drawing_context::set_FlipV()
}
void xlsx_drawing_context::set_shape_id(int id)
{
if (drawing_state.size() < 1 )return;
if (drawing_state.size() < 1 ) return;
if (drawing_state.back().bTextBox) return;
drawing_state.back().shape_id = (MSOSPT)id;
}
......@@ -198,14 +210,29 @@ void xlsx_drawing_context::serialize_shape()
{
std::wstringstream strm;
std::wstring prstGeom = Spt2ShapeType(drawing_state.back().shape_id);
std::wstring prstTxWarp;
std::wstring prstGeom = Spt2ShapeType(drawing_state.back().shape_id);
if (prstGeom.empty())
{
prstGeom = L"custom";
prstTxWarp = Spt2WordArtShapeType(drawing_state.back().shape_id);
if (prstTxWarp.empty() == false)
{
drawing_state.back().bWordArt = true;
drawing_state.back().bTextBox = true;
prstGeom = L"rect";
}
else if (drawing_state.back().path.empty())
{
//error !!!
prstGeom = L"rect";
}
}
else
{
if (drawing_state.back().shape_id == msosptTextBox) drawing_state.back().bTextBox = true;
}
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"xdr:sp")
......@@ -233,33 +260,53 @@ void xlsx_drawing_context::serialize_shape()
}
}
}
CP_XML_NODE(L"xdr:cNvSpPr");
CP_XML_NODE(L"xdr:cNvSpPr")
{
if (drawing_state.back().bTextBox)CP_XML_ATTR(L"txBox", 1);
}
}
CP_XML_NODE(L"xdr:spPr")
{
CP_XML_NODE(L"a:xfrm")
serialize_xfrm(CP_XML_STREAM());
if (prstGeom.empty() == false)
{
CP_XML_NODE(L"a:off")
{
CP_XML_ATTR(L"y", 0);
CP_XML_ATTR(L"x", 0);
}
CP_XML_NODE(L"a:ext")
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"cy", 0);
CP_XML_ATTR(L"cx", 0);
CP_XML_ATTR(L"prst", prstGeom);
if (!drawing_state.back().bWordArt) CP_XML_NODE(L"a:avLst");
}
}
CP_XML_NODE(L"a:prstGeom")
else
{
CP_XML_ATTR(L"prst", prstGeom);
CP_XML_NODE(L"a:avLst");
CP_XML_NODE(L"a:custGeom")
{
CP_XML_NODE(L"a:avLst");
//oox_serialize_aLst(CP_XML_STREAM(),val.additional);
CP_XML_NODE(L"a:ahLst");
//CP_XML_NODE(L"a:gdLst");
CP_XML_NODE(L"a:rect")
{
CP_XML_ATTR(L"b",L"b");
CP_XML_ATTR(L"l",0);
CP_XML_ATTR(L"r",L"r");
CP_XML_ATTR(L"t",0);
}
CP_XML_NODE(L"a:pathLst")
{
CP_XML_NODE(L"a:path")
{
CP_XML_ATTR(L"w", drawing_state.back().path_rect.right - drawing_state.back().path_rect.left);
CP_XML_ATTR(L"h", drawing_state.back().path_rect.bottom- drawing_state.back().path_rect.top);
CP_XML_STREAM() << drawing_state.back().path;
}
}
}
}
serialize_fill(CP_XML_STREAM());
serialize_line(CP_XML_STREAM());
//serialize_fill(CP_XML_STREAM());
serialize_line(CP_XML_STREAM());
}
}
}
......@@ -291,6 +338,32 @@ void xlsx_drawing_context::serialize_none_fill(std::wostream & stream)
CP_XML_NODE(L"a:noFill");
}
}
void xlsx_drawing_context::serialize_xfrm(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"a:xfrm")
{
if (drawing_state.back().flipV) CP_XML_ATTR(L"flipV", true);
if (drawing_state.back().flipH) CP_XML_ATTR(L"flipH", true);
if (drawing_state.back().rotation != 0) CP_XML_ATTR(L"rot", drawing_state.back().rotation);
CP_XML_NODE(L"a:off")
{
CP_XML_ATTR(L"x", 0);
CP_XML_ATTR(L"y", 0);
}
CP_XML_NODE(L"a:ext")
{
CP_XML_ATTR(L"cx", 0);
CP_XML_ATTR(L"cy", 0);
}
}
}
}
void xlsx_drawing_context::serialize_color (std::wostream & stream, const _color &color)
{
CP_XML_WRITER(stream)
......@@ -320,6 +393,8 @@ void xlsx_drawing_context::serialize_line(std::wostream & stream)
{
CP_XML_NODE(L"a:ln")
{
if (drawing_state.back().line.width > 0)
CP_XML_ATTR(L"w", drawing_state.back().line.width);//in emu (1 pt = 12700) ???
CP_XML_NODE(L"a:" + drawing_state.back().line.type)
{
serialize_color(CP_XML_STREAM(), drawing_state.back().line.color);
......@@ -401,19 +476,8 @@ void xlsx_drawing_context::serialize_pic(std::wstring rId)
CP_XML_NODE(L"xdr:spPr")
{
CP_XML_NODE(L"a:xfrm")
{
CP_XML_NODE(L"a:off")
{
CP_XML_ATTR(L"y", 0);
CP_XML_ATTR(L"x", 0);
}
CP_XML_NODE(L"a:ext")
{
CP_XML_ATTR(L"cy", 0);
CP_XML_ATTR(L"cx", 0);
}
}
serialize_xfrm(CP_XML_STREAM());
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"prst", "rect");
......@@ -525,6 +589,13 @@ void xlsx_drawing_context::set_line_style (long val)
case 4: drawing_state.back().line.style = L"triple"; break;
}
}
void xlsx_drawing_context::set_line_width (long val)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().line.width = val;
}
void xlsx_drawing_context::set_hyperlink(std::wstring & str)
{
if (drawing_state.size() < 1 )return;
......@@ -541,6 +612,18 @@ void xlsx_drawing_context::set_hyperlink(std::wstring & str)
xlsx_drawings_->add( false, hId , href_correct, external_items::typeHyperlink);
}
void xlsx_drawing_context::set_path (const std::wstring & path)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().path = path;
}
void xlsx_drawing_context::set_path_rect(_rect & rect)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().path_rect = rect;
}
void xlsx_drawing_context::set_properties(std::wstring & str)
{
if (drawing_state.size() < 1 )return;
......
......@@ -35,17 +35,29 @@ struct _color
bool bPalette;
};
struct _rect
{
_rect() : left(0), top(0), right(0),bottom(0){}
int left;
int top;
int right;
int bottom;
};
class _drawing_state
{
public:
_drawing_state()
_drawing_state() : isInternal(false), shape_id(msosptNotPrimitive), flipH(false), flipV(false), bTextBox(false), bWordArt(false)
{
isInternal = false; id = -1; shape_id = msosptNotPrimitive;
flipV = flipH = false;
id = -1;
memset(image_crop, 0, 4 * sizeof(int));
rotation = 0;
}
int shape_type;
external_items::Type type;
std::wstring name;
std::wstring description;
......@@ -64,16 +76,22 @@ public:
bool flipH;
std::wstring hyperlink;
int rotation;
std::wstring path;
_rect path_rect;
bool isInternal;
bool bTextBox;
bool bWordArt;
struct _line
{
_line() {opacity = 0; type = L"solidFill"; style = L"simple";}
_line() {opacity = 0; type = L"solidFill"; style = L"simple"; width = 0;}
_color color;
int opacity;
std::wstring type;
std::wstring style;
long width;
}line;
};
......@@ -115,22 +133,26 @@ public:
void set_line_color (int index, int type);
void set_line_type (long val);
void set_line_style (long val);
void set_line_width (long val);
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);
void serialize_pic(std::wstring rId);
void serialize_shape();
void set_path_rect (_rect & rect);
void set_path (const std::wstring & path);
//------------------------------------------------------------------------------
void serialize (std::wostream & stream);
void serialize_pic (std::wstring rId);
void serialize_shape();
void serialize_color (std::wostream & stream, const _color &color);
void serialize_line (std::wostream & stream);
void serialize_fill (std::wostream & stream);
void serialize_bitmap_fill (std::wostream & stream, std::wstring rId, const std::wstring ns = L"a:");
void serialize_none_fill (std::wostream & stream);
void serialize_xfrm (std::wostream & stream);
void end_drawing();
private:
......
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