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

XlsFile2

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63984 954022d7-b5bf-4e40-9824-e11837661b57
parent 13af039c
......@@ -8,6 +8,7 @@ namespace ODRAW
OfficeArtCOLORREF::OfficeArtCOLORREF()
{
index = -1;
}
OfficeArtCOLORREF::OfficeArtCOLORREF(const long raw_data)
......@@ -21,6 +22,23 @@ OfficeArtCOLORREF::OfficeArtCOLORREF(const long raw_data)
fSystemRGB = GETBIT(raw_data, 26);
fSchemeIndex = GETBIT(raw_data, 27);
fSysIndex = GETBIT(raw_data, 28);
if(!fSchemeIndex && !fPaletteIndex && !fSysIndex)
{
colorRGB = STR::toRGB(red, green, blue);
}
else if(fSchemeIndex)
{
index = red;
}
else if(fPaletteIndex)
{
index = ((green) << 8) + red;
}
else if(fSysIndex)
{
index = ((green) << 8) + red;
}
}
XLS::BiffStructurePtr OfficeArtCOLORREF::clone()
......
......@@ -33,6 +33,9 @@ public:
bool fSchemeIndex;
bool fSysIndex;
std::wstring colorRGB;
short index;
};
typedef boost::shared_ptr<OfficeArtCOLORREF> OfficeArtCOLORREFPtr;
......
......@@ -38,9 +38,28 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
OfficeArtFOPTEPtr fopte;
switch(opid)
{
case 0x0004:
fopte = OfficeArtFOPTEPtr(new Rotation);
break;
case 0x007F:
fopte = OfficeArtFOPTEPtr(new ProtectionBooleanProperties);
break;
/*todo*/case 0x0080://lTxid
case 0x0081://dxTextLeft
case 0x0082://dyTextTop
case 0x0083://dxTextRight
case 0x0084://dyTextBottom
case 0x0085://WrapText
case 0x0086://unused134
case 0x0087://anchorText
case 0x0088://txflTextFlow
case 0x0089://cdirFont
case 0x008a://hspNext
case 0x008b://txdir
case 0x008c://unused140
case 0x008d://unused141
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);
break;
case 0x00BF:
fopte = OfficeArtFOPTEPtr(new TextBooleanProperties);
break;
......@@ -71,6 +90,42 @@ 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
fopte = OfficeArtFOPTEPtr(new ShapePath);
break;
case 0x0145: //pVertices
case 0x0146: //pSegmentInfo
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);
break;
case 0x0147: //adjustValue .... //adjust8Value
case 0x0148:
case 0x0149:
case 0x014A:
case 0x014B:
case 0x014C:
case 0x014D:
case 0x014E:
fopte = OfficeArtFOPTEPtr(new AdjustValue);
break;
case 0x0151:
fopte = OfficeArtFOPTEPtr(new pAdjustHandles);
break;
case 0x0152:
case 0x0153:
case 0x0154:
case 0x0155:
case 0x0156:
case 0x0157:
case 0x0158:
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);
break;
case 0x017f:
fopte = OfficeArtFOPTEPtr(new GeometryBooleanProperties);
break;
case 0x0180:
fopte = OfficeArtFOPTEPtr(new fillType);
break;
......@@ -194,6 +249,21 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
case 0x01C0:
fopte = OfficeArtFOPTEPtr(new lineColor);
break;
case 0x01C1:
fopte = OfficeArtFOPTEPtr(new lineOpacity);
break;
case 0x01C2:
fopte = OfficeArtFOPTEPtr(new lineBackColor);
break;
case 0x01C3:
fopte = OfficeArtFOPTEPtr(new lineCrMod);
break;
case 0x01C4:
fopte = OfficeArtFOPTEPtr(new lineType);
break;
case 0x01C5:
fopte = OfficeArtFOPTEPtr(new fillBlip);
break;
case 0x01CB:
fopte = OfficeArtFOPTEPtr(new lineWidth);
break;
......@@ -258,14 +328,26 @@ void TextBooleanProperties::load(XLS::CFRecord& record)
fUsefSelectText = GETBIT(op, 20);
}
void lineColor::load(XLS::CFRecord& record)
{
unsigned short flags;
record >> flags >> op;
OfficeArtCOLORREF c(op);
color = c;
opid = GETBITS(flags, 0, 13);
fBid = GETBIT(flags, 14);
fComplex = GETBIT(flags, 15);
}
//void fillShadeType::setXMLAttributes(MSXML2::IXMLDOMElementPtr own_tag)
//{
// bool msoshadeNone = GETBIT(op, 0);
// bool msoshadeGamma = GETBIT(op, 1);
// bool msoshadeSigma = GETBIT(op, 2);
// bool msoshadeBand = GETBIT(op, 3);
// bool msoshadeOneColor = GETBIT(op, 4);
// msoshadeNone = GETBIT(op, 0);
// msoshadeGamma = GETBIT(op, 1);
// msoshadeSigma = GETBIT(op, 2);
// msoshadeBand = GETBIT(op, 3);
// msoshadeOneColor = GETBIT(op, 4);
//}
void FillStyleBooleanProperties::load(XLS::CFRecord& record)
......@@ -388,6 +470,25 @@ void ShadowStyleBooleanProperties::load(XLS::CFRecord& record)
fUsefshadowObscured = GETBIT(op, 16);
fUsefShadow = GETBIT(op, 17);
}
void GeometryBooleanProperties::load(XLS::CFRecord& record)
{
OfficeArtFOPTE::load(record);
fUsefShadowOK = GETBIT(op, 8);
fUsef3DOK = GETBIT(op, 9);
fUsefLineOK = GETBIT(op, 10);
fUsefGtextOK = GETBIT(op, 11);
fUsefFillShadeShapeOK = GETBIT(op, 12);
fUsefFillOK = GETBIT(op, 13);
fShadowOK = GETBIT(op, 22);
f3DOK = GETBIT(op, 23);
fLineOK = GETBIT(op, 24);
fGtextOK = GETBIT(op, 25);
fFillShadeShapeOK = GETBIT(op, 26);
fFillOK = GETBIT(op, 27);
}
XLS::BiffStructurePtr IHlink::clone()
{
return XLS::BiffStructurePtr(new IHlink(*this));
......
......@@ -67,26 +67,14 @@ class TextBooleanProperties : public OfficeArtFOPTE
class lineColor : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(lineColor)
virtual void load(XLS::CFRecord& record);
OfficeArtCOLORREF color;
};
class fillType : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(fillType)
//virtual void setXMLAttributes(MSXML2::IXMLDOMElementPtr own_tag)
//{
// static std::wstring fills[10] = {L"msofillSolid", L"msofillPattern", L"msofillTexture", L"msofillPicture", L"msofillShade", L"msofillShadeCenter", L"msofillShadeShape", L"msofillShadeScale", L"msofillShadeTitle", L"msofillBackground"};
// if(op >= 0 && op < 10)
// {
// own_tag->setAttribute(L"type", fills[op]);
// }
// else
// {
// own_tag->setAttribute(L"type", L"unknown");
// }
//}
};
class pib : public OfficeArtFOPTE
......@@ -411,6 +399,27 @@ class ShadowStyleBooleanProperties : public OfficeArtFOPTE
bool fUsefShadow ;
};
class GeometryBooleanProperties : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(GeometryBooleanProperties)
virtual void load(XLS::CFRecord& record);
bool fUsefShadowOK;
bool fUsef3DOK ;
bool fUsefLineOK ;
bool fUsefGtextOK ;
bool fUsefFillShadeShapeOK ;
bool fUsefFillOK ;
bool fShadowOK;
bool f3DOK;
bool fLineOK;
bool fGtextOK;
bool fFillShadeShapeOK;
bool fFillOK;
};
class lineWidth : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(lineWidth)
......@@ -450,6 +459,45 @@ class cropFromRight : public OfficeArtFOPTE
BASE_STRUCTURE_DEFINE_CLASS_NAME(cropFromRight)
};
class Rotation : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(Rotation)
};
class ShapePath : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(ShapePath)
};
class AdjustValue : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(AdjustValue)
};
class pAdjustHandles : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(pAdjustHandles)
};
class lineOpacity : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(lineOpacity)
};
class lineBackColor : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(lineBackColor)
};
class lineCrMod : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(lineCrMod)
};
class lineType : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(lineType)
};
class IHlink;
typedef boost::shared_ptr<IHlink> IHlinkPtr;
......
......@@ -11,17 +11,6 @@ XLS::BiffStructurePtr OfficeArtRGFOPTE::clone()
return XLS::BiffStructurePtr(new OfficeArtRGFOPTE(*this));
}
//
//void OfficeArtRGFOPTE::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// std::for_each(rgfopte.begin(), rgfopte.end(), boost::bind(&OfficeArtFOPTE::toXML, _1, xml_tag));
//}
//
//void OfficeArtRGFOPTE::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// // We don't support xlsx to xls conversion
//}
void OfficeArtRGFOPTE::store(XLS::CFRecord& record)
{
......@@ -32,9 +21,74 @@ 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);
if (!fopte)continue;
int type_prop = fopte->opid;
if (type_prop >= 0x0000 && type_prop < 0x0080)//2.3.18 Transform
{
Transform_props.push_back(fopte);
}
else if (type_prop >= 0x0080 && type_prop < 0x00C0) //2.3.21 Text
{
Text_props.push_back(fopte);
}
else if (type_prop >= 0x00C0 && type_prop < 0x0100) //2.3.22 Geometry Text - word art
{
GeometryText_props.push_back(fopte);
}
else if (type_prop >= 0x0100 && type_prop < 0x0140) //2.3.23 Blip
{
Blip_props.push_back(fopte);
}
else if (type_prop >= 0x0140 && type_prop < 0x0180) //2.3.6 Geometry
{
Geometry_props.push_back(fopte);
}
else if (type_prop >= 0x0180 && type_prop < 0x01C0) //2.3.7 Fill Style
{
FillStyle_props.push_back(fopte);
}
else if (type_prop >= 0x01C0 && type_prop < 0x0540) //2.3.8 Line Style
{
LineStyle_props.push_back(fopte);
}
//2.3.9 Left line style
//2.3.10 Top Line Style
//2.3.11 Right Line Style
//2.3.12 Bottom Line Style
else if (type_prop >= 0x0200 && type_prop < 0x0240)
{
Shadow_props.push_back(fopte);
}
//2.3.3 Callout
//2.3.14 Perspective Style
//2.3.15 3D Object
//2.3.16 3D Style
//2.3.17 Diagram
//2.3.19 Relative Transform
//2.3.20 Protection
//2.3.24 Unknown HTML
//2.3.25 Web Component
//2.3.26 Ink
//2.3.27 Signature Line
else if (type_prop >= 0x0300 && type_prop < 0x0340) // 2.3.2 Shape
{
Shape_props.push_back(fopte);
}
else if (type_prop >= 0x0380 && type_prop < 0x07C0) //2.3.4 Group Shape
{
GroupShape_props.push_back(fopte);
}
else if (type_prop >= 0x07C0 && type_prop < 0x07C6) //2.3.5 Group Shape 2
{
GroupShape_props.push_back(fopte);
}
rgfopte.push_back(fopte);
}
......
......@@ -26,6 +26,17 @@ public:
const unsigned short GetOptionsNumber();
std::vector<OfficeArtFOPTEPtr> rgfopte;
std::vector<OfficeArtFOPTEPtr> GroupShape_props;
std::vector<OfficeArtFOPTEPtr> Shape_props;
std::vector<OfficeArtFOPTEPtr> Blip_props;
std::vector<OfficeArtFOPTEPtr> Text_props;
std::vector<OfficeArtFOPTEPtr> Geometry_props;
std::vector<OfficeArtFOPTEPtr> GeometryText_props;
std::vector<OfficeArtFOPTEPtr> FillStyle_props;
std::vector<OfficeArtFOPTEPtr> LineStyle_props;
std::vector<OfficeArtFOPTEPtr> Shadow_props;
std::vector<OfficeArtFOPTEPtr> Transform_props;
unsigned short options_num;
};
......
#include "XlsConverter.h"
#include "XlsConverter.h"
#include "../XlsFormat/Binary/CompoundFile.h"
#include "../XlsFormat/Binary/CFStreamCacheReader.h"
......@@ -306,7 +306,7 @@ void XlsConverter::convert(XLS::FORMATTING* formating)
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
formating->serialize1(CP_XML_STREAM()); // styles
formating->serialize1(CP_XML_STREAM()); //важен порядок в styles
CP_XML_NODE(L"fills")
{
......@@ -489,7 +489,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects)
else continue;
if (xlsx_context->get_drawing_context().start_drawing(obj->cmo.ot))
if (xlsx_context->get_drawing_context().start_drawing(obj->cmo.ot))//тут тип шейпа ВРАНЬЕ !!! пример - 7.SINIF I.DÖNEM III.YAZILI SINAV.xls
{
convert(sp);
......@@ -551,51 +551,117 @@ void XlsConverter::convert(ODRAW::OfficeArtFSP * fsp)
xlsx_context->get_drawing_context().set_id(fsp->spid);
xlsx_context->get_drawing_context().set_shape_id(fsp->shape_id);
}
void XlsConverter::convert(ODRAW::OfficeArtFOPT * fort)
void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
if (fort == NULL) return;
for (long i = 0 ; i < fort->fopt.rgfopte.size(); i++)
for (int i = 0 ; i < props.size() ; i++)
{
}
}
void XlsConverter::convert_line_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
case 0x01C0:
{
ODRAW::lineColor * color = (ODRAW::lineColor *)props[i].get();
if (!color->color.colorRGB.empty())
xlsx_context->get_drawing_context().set_line_color(color->color.colorRGB);
}break;
case 0x01C4:
{
xlsx_context->get_drawing_context().set_line_type(props[i]->op);
}break;
case 0x01C5: //blip
{
}break;
case 0x01CD:
{
switch(fort->fopt.rgfopte[i]->opid)
xlsx_context->get_drawing_context().set_line_style(props[i]->op);
}break;
}
}
}
void XlsConverter::convert_blip(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
case 0x100:
{
xlsx_context->get_drawing_context().set_crop_top(fort->fopt.rgfopte[i]->op);
xlsx_context->get_drawing_context().set_crop_top(props[i]->op);
}break;
case 0x101:
{
xlsx_context->get_drawing_context().set_crop_bottom(fort->fopt.rgfopte[i]->op);
xlsx_context->get_drawing_context().set_crop_bottom(props[i]->op);
}break;
case 0x102:
{
xlsx_context->get_drawing_context().set_crop_left(fort->fopt.rgfopte[i]->op);
xlsx_context->get_drawing_context().set_crop_left(props[i]->op);
}break;
case 0x103:
{
xlsx_context->get_drawing_context().set_crop_right(fort->fopt.rgfopte[i]->op);
xlsx_context->get_drawing_context().set_crop_right(props[i]->op);
}break;
case 0x104:
{
bool isIternal = false;
std::wstring target;
std::wstring rId = xlsx_context->get_mediaitems().find_image(fort->fopt.rgfopte[i]->op , target, isIternal);
std::wstring rId = xlsx_context->get_mediaitems().find_image(props[i]->op , target, isIternal);
xlsx_context->get_drawing_context().set_image(target);
}break;
case 0x105://
}
}
}
void XlsConverter::convert_geometry(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
{
}
}
void XlsConverter::convert_geometry_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
{
}
}
void XlsConverter::convert_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
}
void XlsConverter::convert_shadow(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
{
}
}
void XlsConverter::convert_shape(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
{
}
}
void XlsConverter::convert_group_shape(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
case 0x380:
{
ODRAW::anyString *str = dynamic_cast<ODRAW::anyString*>(fort->fopt.rgfopte[i].get());
ODRAW::anyString *str = dynamic_cast<ODRAW::anyString*>(props[i].get());
xlsx_context->get_drawing_context().set_name(str->string_);
}break;
case 0x381:
{
ODRAW::anyString *str = dynamic_cast<ODRAW::anyString*>(fort->fopt.rgfopte[i].get());
ODRAW::anyString *str = dynamic_cast<ODRAW::anyString*>(props[i].get());
xlsx_context->get_drawing_context().set_description(str->string_);
}break;
case 0x0382:
{
ODRAW::pihlShape *pihlShape = dynamic_cast<ODRAW::pihlShape*>(fort->fopt.rgfopte[i].get());
ODRAW::pihlShape *pihlShape = dynamic_cast<ODRAW::pihlShape*>(props[i].get());
if (pihlShape)
{
std::wstring target = GetTargetMoniker(pihlShape->IHlink_complex.hyperlink.oleMoniker.data.get());
......@@ -605,6 +671,34 @@ void XlsConverter::convert(ODRAW::OfficeArtFOPT * fort)
}
}
}
void XlsConverter::convert_transform(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
case 0x0004:
{
xlsx_context->get_drawing_context().set_rotation(props[i]->op);
}break;
}
}
}
void XlsConverter::convert(ODRAW::OfficeArtFOPT * fort)
{
if (fort == NULL) return;
convert_shape (fort->fopt.Shape_props);
convert_group_shape (fort->fopt.GroupShape_props);
convert_transform (fort->fopt.Shape_props);
convert_blip (fort->fopt.Blip_props);
convert_geometry (fort->fopt.Geometry_props);
convert_fill_style (fort->fopt.FillStyle_props);
convert_line_style (fort->fopt.LineStyle_props);
convert_shadow (fort->fopt.Shadow_props);
convert_text (fort->fopt.Text_props);
convert_geometry_text (fort->fopt.GeometryText_props);
}
void XlsConverter::convert(XLS::SHAREDSTRINGS* sharedstrings)
{
......
#pragma once
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "progressCallback.h"
......@@ -44,6 +45,9 @@ namespace ODRAW
class OfficeArtSpContainer;
class OfficeArtFOPT;
class OfficeArtFSP;
class OfficeArtFOPTE;
typedef boost::shared_ptr<OfficeArtFOPTE> OfficeArtFOPTEPtr;
}
class XlsConverter
......@@ -86,6 +90,17 @@ private:
void convert(ODRAW::OfficeArtFOPT * fort);
void convert(ODRAW::OfficeArtFSP * fsp);
void convert_shape (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
void convert_group_shape (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
void convert_blip (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
void convert_text (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
void convert_geometry (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
void convert_geometry_text (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
void convert_fill_style (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
void convert_line_style (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
void convert_shadow (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
void convert_transform (std::vector<ODRAW::OfficeArtFOPTEPtr> & fort);
std::wstring GetTargetMoniker(XLS::BiffStructure *moniker);
};
......@@ -6,6 +6,7 @@
#include <simple_xml_writer.h>
#include <utils.h>
#include <Auxiliary/HelpFunc.h>
namespace oox {
......@@ -149,18 +150,26 @@ void xlsx_drawing_context::set_FlipV()
void xlsx_drawing_context::set_shape_id(int id)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().shape_id = id;
drawing_state.back().shape_id = (MSOSPT)id;
}
void xlsx_drawing_context::end_drawing()
{
if (drawing_state.size() < 1 )return;
if (drawing_state.back().anchor.empty())
{
drawing_state.pop_back();
return;
}
std::wstringstream strm;
switch(drawing_state.back().type)
if ( drawing_state.back().type == external_items::typeImage ||
drawing_state.back().shape_id == msosptPictureFrame )
{
case external_items::typeImage:
drawing_state.back().type = external_items::typeImage;
if (!drawing_state.back().image_target.empty())
{
bool isIternal = false;
......@@ -171,18 +180,13 @@ void xlsx_drawing_context::end_drawing()
xlsx_drawings_->add(strm.str(), isIternal, rId , drawing_state.back().image_target, drawing_state.back().type);
}
else
{
serialize_shape();
serialize(strm);
xlsx_drawings_->add(strm.str(), true, L"" , L"", drawing_state.back().type);
drawing_state.back().type = external_items::typeShape;
}
break;
case external_items::typeShape:
if ( drawing_state.back().type == external_items::typeShape)
{
serialize_shape();
serialize(strm);
xlsx_drawings_->add(strm.str(), true, L"" , L"", drawing_state.back().type);
}break;
}
drawing_state.pop_back();
......@@ -192,18 +196,14 @@ void xlsx_drawing_context::serialize_shape()
{
std::wstringstream strm;
std::wstring prstGeom;
std::wstring prstGeom = Spt2ShapeType(drawing_state.back().shape_id);
switch(drawing_state.back().shape_type)
if (prstGeom.empty())
{
case 1: prstGeom = L"line"; break;
case 2: prstGeom = L"rect"; break;
case 3: prstGeom = L"ellipse"; break;
case 4: prstGeom = L"arc"; break;
case 9: prstGeom = L"polygon"; break;
default: prstGeom = L"custom"; break;
prstGeom = L"custom";
}
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"xdr:sp")
......@@ -256,20 +256,11 @@ void xlsx_drawing_context::serialize_shape()
}
serialize_fill(CP_XML_STREAM());
CP_XML_NODE(L"a:ln")
{
CP_XML_NODE(L"a:solidFill")
{
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val", "000000");
}
serialize_line(CP_XML_STREAM());
}
}
}
}
}
drawing_state.back().shape = strm.str();
}
......@@ -298,7 +289,24 @@ void xlsx_drawing_context::serialize_none_fill(std::wostream & stream)
CP_XML_NODE(L"a:noFill");
}
}
void xlsx_drawing_context::serialize_line(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"a:ln")
{
CP_XML_NODE(L"a:" + drawing_state.back().line.type)
{
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val", drawing_state.back().line.color);
}
}
}
}
}
void xlsx_drawing_context::serialize_bitmap_fill(std::wostream & stream, std::wstring rId, const std::wstring ns)
{
CP_XML_WRITER(stream)
......@@ -456,6 +464,38 @@ void xlsx_drawing_context::set_crop_right (long val)
if (drawing_state.size() < 1 )return;
drawing_state.back().image_crop[2] = val* 1.5;
}
void xlsx_drawing_context::set_rotation (long val)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().rotation = val;
}
void xlsx_drawing_context::set_line_color (std::wstring color)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().line.color = color;
}
void xlsx_drawing_context::set_line_type (long val)
{
if (drawing_state.size() < 1 )return;
switch(val)
{
case 0: drawing_state.back().line.type = L"solidFill"; break;
case 1: drawing_state.back().line.type = L"patternFill"; break;
case 2: drawing_state.back().line.type = L"blipFill"; break;
}
}
void xlsx_drawing_context::set_line_style (long val)
{
if (drawing_state.size() < 1 )return;
switch(val)
{
case 0: drawing_state.back().line.style = L"simple"; break;
case 1: drawing_state.back().line.style = L"double"; break;
case 2: drawing_state.back().line.style = L"thickThin"; break;
case 3: drawing_state.back().line.style = L"thinThick"; break;
case 4: drawing_state.back().line.style = L"triple"; break;
}
}
void xlsx_drawing_context::set_hyperlink(std::wstring & str)
{
if (drawing_state.size() < 1 )return;
......
......@@ -5,6 +5,8 @@
#include "xlsx_drawings.h"
#include "ShapeType.h"
namespace oox {
class external_items;
......@@ -29,7 +31,7 @@ class _drawing_state
public:
_drawing_state()
{
isInternal = false; id = shape_id = -1;
isInternal = false; id = -1; shape_id = msosptNotPrimitive;
flipV = flipH = false;
memset(image_crop, 0, 4 * sizeof(int));
}
......@@ -47,13 +49,24 @@ public:
bool image_crop_enabled;
int id;
int shape_id;
MSOSPT shape_id;
bool flipV;
bool flipH;
std::wstring hyperlink;
int rotation;
bool isInternal;
struct _line
{
_line() {opacity = 0; type = L"solid"; style = L"simple";}
std::wstring color;
int opacity;
std::wstring type;
std::wstring style;
}line;
};
struct _hlink_desc
{
......@@ -87,6 +100,12 @@ public:
void set_crop_left (long val);
void set_crop_right (long val);
void set_rotation (long val);
void set_line_color (std::wstring val);
void set_line_type (long val);
void set_line_style (long val);
void set_image (std::wstring & str);
void set_anchor (std::wstring & str);
void set_properties (std::wstring & str);
......@@ -97,6 +116,7 @@ public:
void serialize_pic(std::wstring rId);
void serialize_shape();
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);
......
......@@ -348,6 +348,10 @@
RelativePath="..\XlsXlsxConverter\oox_rels.h"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\ShapeType.h"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_conversion_context.cpp"
>
......
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