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

XlsFormat - выравнивания текста а автофигурах

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@67782 954022d7-b5bf-4e40-9824-e11837661b57
parent bc0c0643
......@@ -30,10 +30,12 @@ void TxO::readFields(CFRecord& record)
unsigned short flags;
record >> flags;
hAlignment = static_cast<unsigned char>(GETBITS(flags, 1, 3));
vAlignment = static_cast<unsigned char>(GETBITS(flags, 4, 6)); // reserved2 (2 bits)
fLockText = GETBIT(flags, 9); // reserved3 (4 bits)
fJustLast = GETBIT(flags, 14);
hAlignment = static_cast<unsigned char>(GETBITS(flags, 1, 3));
vAlignment = static_cast<unsigned char>(GETBITS(flags, 4, 6)); // reserved2 (2 bits)
fLockText = GETBIT(flags, 9); // reserved3 (4 bits)
fJustLast = GETBIT(flags, 14);
fSecretEdit = GETBIT(flags, 15);
record >> rot;
......
......@@ -38,11 +38,15 @@ public:
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;
......
......@@ -81,10 +81,12 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
case NSOfficeDrawing::gtextRTF:
case NSOfficeDrawing::gtextAlign:
case NSOfficeDrawing::gtextSize:
case NSOfficeDrawing::gtextSpacing:
case NSOfficeDrawing::gtextCSSFont:
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);
break;
case NSOfficeDrawing::gtextSpacing:
fopte = OfficeArtFOPTEPtr(new FixedPoint);
break;
case NSOfficeDrawing::fFitTextToShape:
fopte = OfficeArtFOPTEPtr(new TextBooleanProperties);
break;
......@@ -348,15 +350,17 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
fopte->load(record);
FixedPoint * fixpoint = dynamic_cast<FixedPoint *>(fopte.get());
if (fixpoint)
{
fixpoint->dVal = (short)(fixpoint->op >> 16) + ((short)(fixpoint->op) / 65536.0);
}
return fopte;
}
void FixedPoint::load(XLS::CFRecord& record)
{
OfficeArtFOPTE::load(record);
short Integral = op >> 16;
unsigned short Fractional = op - (Integral << 16);
dVal = Integral + (Fractional / 65536.0);
}
void OfficeArtFOPTE::ReadComplexData(XLS::CFRecord& record)
{
record.skipNunBytes(op); // default is to skip complex data
......@@ -365,52 +369,52 @@ void OfficeArtFOPTE::ReadComplexData(XLS::CFRecord& record)
void TextBooleanProperties::load(XLS::CFRecord& record)
{
OfficeArtFOPTE::load(record);
fFitShapeToText = GETBIT(op, 1);
fAutoTextMargin = GETBIT(op, 3);
fSelectText = GETBIT(op, 4);
fUsefFitShapeToText = GETBIT(op, 17);
fUsefAutoTextMargin = GETBIT(op, 19);
fUsefSelectText = GETBIT(op, 20);
fFitShapeToText = GETBIT(op, 1);
fAutoTextMargin = GETBIT(op, 3);
fSelectText = GETBIT(op, 4);
}
void GeometryTextBooleanProperties::load(XLS::CFRecord& record)
{
OfficeArtFOPTE::load(record);
bool fUsegFReverseRows = GETBIT(op, 31);
bool fUsefGtext = GETBIT(op, 30);
bool fUsegFVertical = GETBIT(op, 29);
bool fUsegtextFKern = GETBIT(op, 28);
bool fUsegTight = GETBIT(op, 27);
bool fUsegFStretch = GETBIT(op, 26);
bool fUsegFShrinkFit = GETBIT(op, 25);
bool fUsegFBestFit = GETBIT(op, 24);
bool fUsegFNormalize = GETBIT(op, 23);
bool fUsegFDxMeasure = GETBIT(op, 22);
bool fUsegFBold = GETBIT(op, 21);
bool fUsegFItalic = GETBIT(op, 20);
bool fUsegFUnderline = GETBIT(op, 19);
bool fUsegFShadow = GETBIT(op, 18);
bool fUsegFSmallcaps = GETBIT(op, 17);
bool fUsegFStrikethrough= GETBIT(op, 16);
fUsegFReverseRows = GETBIT(op, 31);
fUsefGtext = GETBIT(op, 30);
fUsegFVertical = GETBIT(op, 29);
fUsegtextFKern = GETBIT(op, 28);
fUsegTight = GETBIT(op, 27);
fUsegFStretch = GETBIT(op, 26);
fUsegFShrinkFit = GETBIT(op, 25);
fUsegFBestFit = GETBIT(op, 24);
fUsegFNormalize = GETBIT(op, 23);
fUsegFDxMeasure = GETBIT(op, 22);
fUsegFBold = GETBIT(op, 21);
fUsegFItalic = GETBIT(op, 20);
fUsegFUnderline = GETBIT(op, 19);
fUsegFShadow = GETBIT(op, 18);
fUsegFSmallcaps = GETBIT(op, 17);
fUsegFStrikethrough = GETBIT(op, 16);
gFReverseRows = fUsegFReverseRows ? GETBIT(op, 15) : false;
fGtext = fUsefGtext ? GETBIT(op, 14) : false;
fVertical = fUsegFVertical ? GETBIT(op, 13) : false;
fKern = fUsegtextFKern ? GETBIT(op, 12) : false;
fTight = fUsegTight ? GETBIT(op, 11) : false;
fStretch = fUsegFStretch ? GETBIT(op, 10) : false;
fShrinkFit = fUsegFShrinkFit ? GETBIT(op, 9) : false;
fBestFit = fUsegFBestFit ? GETBIT(op, 8) : false;
fNormalize = fUsegFNormalize ? GETBIT(op, 7) : false;
fDxMeasure = fUsegFDxMeasure ? GETBIT(op, 6) : false;
fBold = fUsegFBold ? GETBIT(op, 5) : false;
fItalic = fUsegFItalic ? GETBIT(op, 4) : false;
fUnderline = fUsegFUnderline ? GETBIT(op, 3) : false;
fShadow = fUsegFShadow ? GETBIT(op, 2) : false;
fSmallcaps = fUsegFSmallcaps ? GETBIT(op, 1) : false;
fStrikethrough = fUsegFStrikethrough? GETBIT(op, 0) : false;
gFReverseRows = GETBIT(op, 15);
fGtext = GETBIT(op, 14);
fVertical = GETBIT(op, 13);
fKern = GETBIT(op, 12);
fTight = GETBIT(op, 11);
fStretch = GETBIT(op, 10);
fShrinkFit = GETBIT(op, 9);
fBestFit = GETBIT(op, 8);
fNormalize = GETBIT(op, 7);
fDxMeasure = GETBIT(op, 6);
fBold = GETBIT(op, 5);
fItalic = GETBIT(op, 4);
fUnderline = GETBIT(op, 3);
fShadow = GETBIT(op, 2);
fSmallcaps = GETBIT(op, 1);
fStrikethrough = GETBIT(op, 0);
}
void FillStyleBooleanProperties::load(XLS::CFRecord& record)
......
......@@ -93,6 +93,8 @@ class fillColor : public OfficeArtFOPTE
class FixedPoint : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(fillColor)
virtual void load(XLS::CFRecord& record);
double dVal;
};
class TextBooleanProperties : public OfficeArtFOPTE
......@@ -104,6 +106,7 @@ class TextBooleanProperties : public OfficeArtFOPTE
bool fFitShapeToText;
bool fAutoTextMargin;
bool fSelectText;
bool fUsefFitShapeToText;
bool fUsefAutoTextMargin;
bool fUsefSelectText;
......@@ -131,6 +134,23 @@ class GeometryTextBooleanProperties : public OfficeArtFOPTE
bool fShadow;
bool fSmallcaps;
bool fStrikethrough;
bool fUsegFReverseRows;
bool fUsefGtext ;
bool fUsegFVertical ;
bool fUsegtextFKern ;
bool fUsegTight ;
bool fUsegFStretch ;
bool fUsegFShrinkFit;
bool fUsegFBestFit ;
bool fUsegFNormalize;
bool fUsegFDxMeasure;
bool fUsegFBold ;
bool fUsegFItalic ;
bool fUsegFUnderline ;
bool fUsegFShadow ;
bool fUsegFSmallcaps ;
bool fUsegFStrikethrough;
};
class lineColor : public OfficeArtFOPTE
......
......@@ -820,10 +820,10 @@ void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
}break;
case NSOfficeDrawing::fNoFillHitTest:
{
ODRAW::FillStyleBooleanProperties * fill = (ODRAW::FillStyleBooleanProperties *)(props[i].get());
if (fill)
ODRAW::FillStyleBooleanProperties * bools = (ODRAW::FillStyleBooleanProperties *)(props[i].get());
if (bools)
{
if (fill->fUsefFilled && fill->fFilled == false)
if (bools->fUsefFilled && bools->fFilled == false)
xlsx_context->get_drawing_context().set_fill_type(0);
}
}break;
......@@ -837,7 +837,7 @@ void XlsConverter::convert_line_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
{
switch(props[i]->opid)
{
case 0x01C0:
case NSOfficeDrawing::lineColor:
{
ODRAW::OfficeArtCOLORREF color(props[i]->op);
if (!color.sColorRGB.empty())
......@@ -854,25 +854,34 @@ void XlsConverter::convert_line_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
else
xlsx_context->get_drawing_context().set_line_color(color.index, color.fSchemeIndex ? 1 : 3 );
}break;
case 0x01C4:
case NSOfficeDrawing::lineType:
{
xlsx_context->get_drawing_context().set_line_type(props[i]->op);
}break;
case 0x01C5: //blip
case NSOfficeDrawing::lineFillBlip: //blip
{
}break;
case 0x01CB:
case NSOfficeDrawing::lineWidth:
xlsx_context->get_drawing_context().set_line_width(props[i]->op);
{
}break;
case 0x01CD:
case NSOfficeDrawing::lineStyle:
{
xlsx_context->get_drawing_context().set_line_style(props[i]->op);
}break;
case 0x01CE:
case NSOfficeDrawing::lineDashing:
{
xlsx_context->get_drawing_context().set_line_dash(props[i]->op);
}break;
case NSOfficeDrawing::fNoLineDrawDash:
{
ODRAW::LineStyleBooleanProperties * bools = (ODRAW::LineStyleBooleanProperties *)(props[i].get());
if (bools)
{
if (bools->fUsefLine && bools->fLine == false)
xlsx_context->get_drawing_context().set_line_type(5); //no line
}
}break;
}
}
}
......@@ -1025,18 +1034,25 @@ void XlsConverter::convert_geometry_text(std::vector<ODRAW::OfficeArtFOPTEPtr> &
{
xlsx_context->get_drawing_context().set_wordart_size((INT)((props[i]->op >> 16) & 0x0000FFFF));
}break;
case NSOfficeDrawing::gtextSpacing:
{
ODRAW::FixedPoint *val = dynamic_cast<ODRAW::FixedPoint*>(props[i].get());
if (val) xlsx_context->get_drawing_context().set_wordart_spacing(val->dVal);
}break;
case NSOfficeDrawing::gtextAlign:
{
switch (props[i]->op)
{
case NSOfficeDrawing::alignTextLeft:
xlsx_context->get_drawing_context().set_wordart_align(0); break;
xlsx_context->get_drawing_context().set_text_align(1); break;
case NSOfficeDrawing::alignTextCenter:
xlsx_context->get_drawing_context().set_wordart_align(1); break;
xlsx_context->get_drawing_context().set_text_align(2); break;
case NSOfficeDrawing::alignTextRight:
xlsx_context->get_drawing_context().set_wordart_align(2); break;
default:
xlsx_context->get_drawing_context().set_wordart_align(1); break;
xlsx_context->get_drawing_context().set_text_align(3); break;
case NSOfficeDrawing::alignTextWordJust:
xlsx_context->get_drawing_context().set_text_align(4); break;
case NSOfficeDrawing::alignTextLetterJust:
xlsx_context->get_drawing_context().set_text_align(5); break;
}
}break;
case 0xff:
......@@ -1044,10 +1060,11 @@ void XlsConverter::convert_geometry_text(std::vector<ODRAW::OfficeArtFOPTEPtr> &
ODRAW::GeometryTextBooleanProperties *bools = dynamic_cast<ODRAW::GeometryTextBooleanProperties*>(props[i].get());
if (bools)
{
if (bools->fBold) xlsx_context->get_drawing_context().set_wordart_bold (true);
if (bools->fItalic) xlsx_context->get_drawing_context().set_wordart_italic (true);
if (bools->fVertical) xlsx_context->get_drawing_context().set_wordart_vertical(true);
if (bools->fUnderline) xlsx_context->get_drawing_context().set_wordart_underline(true);
if (bools->fUsegFBold && bools->fBold) xlsx_context->get_drawing_context().set_wordart_bold (true);
if (bools->fUsegFItalic && bools->fItalic) xlsx_context->get_drawing_context().set_wordart_italic (true);
if (bools->fUsegFVertical && bools->fVertical) xlsx_context->get_drawing_context().set_wordart_vertical(true);
if (bools->fUsegFUnderline && bools->fUnderline) xlsx_context->get_drawing_context().set_wordart_underline(true);
if (bools->fStrikethrough && bools->fStrikethrough)xlsx_context->get_drawing_context().set_wordart_strike(true);
}
}break;
}
......@@ -1059,9 +1076,6 @@ void XlsConverter::convert_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
switch(props[i]->opid)
{
case NSOfficeDrawing::lTxid:
break;
case NSOfficeDrawing::dxTextLeft:
//pParentShape->m_dTextMarginX = (double)pProperty->m_lValue / EMU_MM; break;
case NSOfficeDrawing::dxTextRight:
......@@ -1074,36 +1088,56 @@ void XlsConverter::convert_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
xlsx_context->get_drawing_context().set_text_wrap(props[i]->op);
}break;
case NSOfficeDrawing::txflTextFlow:
{
xlsx_context->get_drawing_context().set_text_vertical(props[i]->op);
}break;
case NSOfficeDrawing::fFitTextToShape:
{
ODRAW::TextBooleanProperties *bools = dynamic_cast<ODRAW::TextBooleanProperties*>(props[i].get());
if (bools)
{
}
}break;
case NSOfficeDrawing::anchorText:
{
//switch (props[i]->op)
//{
//case NSOfficeDrawing::anchorTop:
//case NSOfficeDrawing::anchorTopBaseline:
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0; break;
//case NSOfficeDrawing::anchorMiddle:
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; break;
//
//case NSOfficeDrawing::anchorBottom:
//case NSOfficeDrawing::anchorBottomBaseline:
// {
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2;
// }break;
//case NSOfficeDrawing::anchorTopCentered:
//case NSOfficeDrawing::anchorTopCenteredBaseline:
// {
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0;
// }break;
//case NSOfficeDrawing::anchorMiddleCentered:
// {
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1;
// }break;
//case NSOfficeDrawing::anchorBottomCentered:
//case NSOfficeDrawing::anchorBottomCenteredBaseline:
// {
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2;
// }break;
//}
switch (props[i]->op)
{
case NSOfficeDrawing::anchorTop:
case NSOfficeDrawing::anchorTopBaseline:
{
xlsx_context->get_drawing_context().set_text_align (1);
xlsx_context->get_drawing_context().set_text_vert_align (1);
}break;
case NSOfficeDrawing::anchorMiddle:
{
xlsx_context->get_drawing_context().set_text_align (1);
xlsx_context->get_drawing_context().set_text_vert_align (2);
}break;
case NSOfficeDrawing::anchorBottom:
case NSOfficeDrawing::anchorBottomBaseline:
{
xlsx_context->get_drawing_context().set_text_align (1);
xlsx_context->get_drawing_context().set_text_vert_align (3);
}break;
case NSOfficeDrawing::anchorTopCentered:
case NSOfficeDrawing::anchorTopCenteredBaseline:
{
xlsx_context->get_drawing_context().set_text_align (2);
xlsx_context->get_drawing_context().set_text_vert_align (1);
}break;
case NSOfficeDrawing::anchorMiddleCentered:
{
xlsx_context->get_drawing_context().set_text_align (2);
xlsx_context->get_drawing_context().set_text_vert_align (2);
}break;
case NSOfficeDrawing::anchorBottomCentered:
case NSOfficeDrawing::anchorBottomCenteredBaseline:
{
xlsx_context->get_drawing_context().set_text_align (2);
xlsx_context->get_drawing_context().set_text_vert_align (3);
}break;
}
}break;
}
}
......@@ -1213,6 +1247,23 @@ void XlsConverter::convert(XLS::TxO * text_obj)
std::wstringstream strm;
text_obj->serialize(strm);
int rot = text_obj->rot;
if (rot > 0)
{
xlsx_context->get_drawing_context().set_text_align (text_obj->vAlignment);
if (rot==3)
{
if (text_obj->hAlignment == (unsigned char)1) text_obj->hAlignment = 3;
else if (text_obj->hAlignment == (unsigned char)3) text_obj->hAlignment = 1;
}
xlsx_context->get_drawing_context().set_text_vert_align (text_obj->hAlignment);
}
else
{
xlsx_context->get_drawing_context().set_text_align (text_obj->hAlignment);
xlsx_context->get_drawing_context().set_text_vert_align (text_obj->vAlignment);
}
xlsx_context->get_drawing_context().set_text(strm.str());
}
......
......@@ -559,7 +559,7 @@ void xlsx_drawing_context::serialize_shape(_drawing_state_ptr & drawing_state)
prstTxWarp = Spt2WordArtShapeType(drawing_state->shape_id);
if (prstTxWarp.empty() == false)
{
drawing_state->wordart.bEnabled = true;
drawing_state->wordart.is = true;
drawing_state->bTextBox = true;
prstGeom = L"rect";
}
......@@ -586,7 +586,7 @@ void xlsx_drawing_context::serialize_shape(_drawing_state_ptr & drawing_state)
if (drawing_state->name.empty())
{
if (drawing_state->wordart.bEnabled)
if (drawing_state->wordart.is)
drawing_state->name = L"WordArt_" + boost::lexical_cast<std::wstring>(count_object);
else
drawing_state->name = L"Shape_" + boost::lexical_cast<std::wstring>(count_object);
......@@ -623,7 +623,7 @@ void xlsx_drawing_context::serialize_shape(_drawing_state_ptr & drawing_state)
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"prst", prstGeom);
if (!drawing_state->wordart.bEnabled) CP_XML_NODE(L"a:avLst");
if (!drawing_state->wordart.is) CP_XML_NODE(L"a:avLst");
}
}
else
......@@ -743,15 +743,16 @@ void xlsx_drawing_context::serialize_fill(std::wostream & stream, _drawing_state
if (drawing_state->fill.type == fillPattern)
reset_fill_pattern(drawing_state);
if (drawing_state->wordart.bEnabled)
if (drawing_state->wordart.is)
serialize_none_fill(stream);
else
serialize_fill(stream, drawing_state->fill);
}
void xlsx_drawing_context::serialize_line(std::wostream & stream, _drawing_state_ptr & drawing_state)
{
if (!drawing_state->wordart.bEnabled)
serialize_line(stream, drawing_state->line);
if (drawing_state->wordart.is) return;
serialize_line(stream, drawing_state->line);
}
void xlsx_drawing_context::serialize_none_fill(std::wostream & stream)
{
......@@ -778,6 +779,8 @@ void xlsx_drawing_context::serialize_gradient_fill(std::wostream & stream, _draw
{
CP_XML_NODE(L"a:gradFill")
{
CP_XML_ATTR(L"rotWithShape", 0);
CP_XML_NODE(L"a:gsLst")
{
if (fill.colorsPosition.empty() && fill.focus != 0)
......@@ -921,23 +924,23 @@ void xlsx_drawing_context::serialize_color (std::wostream & stream, const _color
void xlsx_drawing_context::serialize_text(std::wostream & stream, _drawing_state_ptr & drawing_state)
{
if (drawing_state->text_content.empty() && drawing_state->wordart.text.empty()) return;
if (drawing_state->text.content.empty() && drawing_state->wordart.text.empty()) return;
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"xdr:txBody")
{
CP_XML_NODE(L"a:bodyPr")
CP_XML_NODE(L"a:bodyPr")//todooo rtl
{
if (drawing_state->text_wrap == 2)
if (drawing_state->text.wrap == 2 || drawing_state->wordart.is)
CP_XML_ATTR(L"wrap", L"none" );
if (drawing_state->wordart.bEnabled)
if (drawing_state->wordart.is)
{
CP_XML_ATTR(L"fromWordArt", 1);
if (drawing_state->wordart.vertical)
CP_XML_ATTR(L"vert", L"wordArtVert"); //todooo rtl
CP_XML_ATTR(L"vert", L"wordArtVert");
std::wstring prstTxWarp = Spt2WordArtShapeType(drawing_state->shape_id);
CP_XML_NODE(L"a:prstTxWarp")
......@@ -946,35 +949,60 @@ void xlsx_drawing_context::serialize_text(std::wostream & stream, _drawing_state
CP_XML_NODE(L"a:avLst");//
}
}
else
{
switch (drawing_state->text.vert_align)
{
case 1: CP_XML_ATTR(L"anchor", L"t"); break;
case 2: CP_XML_ATTR(L"anchor", L"ctr"); break;
case 3: CP_XML_ATTR(L"anchor", L"b"); break;
}
switch(drawing_state->text.vertical)
{
case 1:
case 3: CP_XML_ATTR(L"vert", L"vert"); break;
case 2: CP_XML_ATTR(L"vert", L"vert270"); break;
case 5: CP_XML_ATTR(L"vert", L"wordArtVert"); break;
}
}
}
CP_XML_NODE(L"a:lstStyle");
CP_XML_NODE(L"a:p")
{
if (drawing_state->wordart.bEnabled)
CP_XML_NODE(L"a:pPr")
{
CP_XML_NODE(L"a:pPr")
switch(drawing_state->text.align)
{
switch(drawing_state->wordart.align)
{
case 0: CP_XML_ATTR(L"algn", L"l"); break;
case 1: CP_XML_ATTR(L"algn", L"ctr"); break;
case 2: CP_XML_ATTR(L"algn", L"r"); break;
}
case 1: CP_XML_ATTR(L"algn", L"l"); break;
case 2: CP_XML_ATTR(L"algn", L"ctr"); break;
case 3: CP_XML_ATTR(L"algn", L"r"); break;
case 4: CP_XML_ATTR(L"algn", L"just"); break;
case 5: CP_XML_ATTR(L"algn", L"dist"); break;
}
}
if (drawing_state->wordart.is)
{
CP_XML_NODE(L"a:r")
{
CP_XML_NODE(L"a:rPr")
{
if (drawing_state->wordart.size > 0)
CP_XML_ATTR(L"sz", (int)(drawing_state->wordart.size * 100));
if (drawing_state->wordart.size < 1) drawing_state->wordart.size = 36;
CP_XML_ATTR(L"sz", (int)(drawing_state->wordart.size * 100));
if (drawing_state->wordart.bold) CP_XML_ATTR(L"b", 1);
if (drawing_state->wordart.italic) CP_XML_ATTR(L"i", 1);
if (drawing_state->wordart.underline) CP_XML_ATTR(L"u", 1);
if (drawing_state->wordart.strike) CP_XML_ATTR(L"strike", L"sngStrike");
CP_XML_ATTR(L"kern", 10);
CP_XML_ATTR(L"spc", 0);
if (drawing_state->wordart.spacing > 1)
CP_XML_ATTR(L"spc", (int) ((drawing_state->wordart.spacing - 1 ) * 3600.));
else if (drawing_state->wordart.spacing < 1)
CP_XML_ATTR(L"spc", (int) ((drawing_state->wordart.spacing - 1 ) * 1800.));
else
CP_XML_ATTR(L"spc", 0);
serialize_line(CP_XML_STREAM(), drawing_state->line);
serialize_fill(CP_XML_STREAM(), drawing_state->fill);
......@@ -992,7 +1020,7 @@ void xlsx_drawing_context::serialize_text(std::wostream & stream, _drawing_state
}
else
{
CP_XML_STREAM() << drawing_state->text_content;
CP_XML_STREAM() << drawing_state->text.content;
}
}
}
......@@ -1001,6 +1029,8 @@ void xlsx_drawing_context::serialize_text(std::wostream & stream, _drawing_state
void xlsx_drawing_context::serialize_line(std::wostream & stream, _drawing_state::_line & line)
{
if (line.fill.type == fillNone) return;
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"a:ln")
......@@ -1295,6 +1325,7 @@ void xlsx_drawing_context::set_line_type (int val)
case 0: current_drawing_states->back()->line.fill.type = fillSolid; break;
case 1: current_drawing_states->back()->line.fill.type = fillPattern; break;
case 2: current_drawing_states->back()->line.fill.type = fillTexture; break;
case 5: current_drawing_states->back()->line.fill.type = fillNone; break;
}
}
void xlsx_drawing_context::set_line_style (int val)
......@@ -1360,11 +1391,23 @@ void xlsx_drawing_context::set_wordart_size (int val)
current_drawing_states->back()->wordart.size = val;
}
void xlsx_drawing_context::set_wordart_align (int val)
void xlsx_drawing_context::set_text_align (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->text.align = val;
}
void xlsx_drawing_context::set_text_vert_align (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->text.vert_align = val;
}
void xlsx_drawing_context::set_text_vertical (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->wordart.align = val;
current_drawing_states->back()->text.vertical = val;
}
void xlsx_drawing_context::set_wordart_bold (bool val)
{
......@@ -1384,23 +1427,36 @@ void xlsx_drawing_context::set_wordart_underline (bool val)
current_drawing_states->back()->wordart.underline = val;
}
void xlsx_drawing_context::set_wordart_strike(bool val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->wordart.strike = val;
}
void xlsx_drawing_context::set_wordart_vertical (bool val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->wordart.vertical = val;
}
void xlsx_drawing_context::set_wordart_spacing (double val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->wordart.spacing = val;
}
void xlsx_drawing_context::set_text (const std::wstring & text)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->text_content = text;
current_drawing_states->back()->text.content = text;
}
void xlsx_drawing_context::set_text_wrap (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->text_wrap = val;
current_drawing_states->back()->text.wrap = val;
}
void xlsx_drawing_context::set_path_rect(_rect & rect)
{
......
......@@ -92,10 +92,8 @@ typedef _CP_PTR(_drawing_state) _drawing_state_ptr;
class _drawing_state
{
public:
_drawing_state() : isInternal(false),
shape_id(msosptRectangle),
flipH(false), flipV(false),
text_wrap(2), //none
_drawing_state() : shape_id(msosptRectangle),
flipH(false), flipV(false),
bTextBox(false)
{
id = -1;
......@@ -125,29 +123,36 @@ public:
std::wstring path;
_rect path_rect;
std::wstring text_content; //c
int text_wrap;
struct _text
{
_text() : align(0)/*noset*/, wrap(2)/*none*/, vert_align(0)/*noset*/, vertical(0)/*horiz*/ {}
std::wstring content; //c
int wrap;
int align;
int vert_align;
int vertical;
}text;
struct _wordart
{
_wordart() : bEnabled(false), size(0), align(1), bold(false), italic(false), underline(false), vertical(false) {}
bool bEnabled;
_wordart() : is(false), size(0), bold(false), italic(false), underline(false), vertical(false), strike(false), spacing(1.) {}
bool is;
std::wstring text;
std::wstring font;
int size;
int align;
bool bold;
bool italic;
bool underline;
bool strike;
bool vertical;
double spacing;
}wordart;
bool isInternal;
bool bTextBox;
struct _shadow
{
_shadow() {is = false;}
_shadow() {is = false; color.SetRGB(0x7f, 0x7f, 0x7f);}
bool is;
_color color;
int opacity;
......@@ -157,6 +162,7 @@ public:
{
_fill()
{
color.SetRGB(0xff, 0xff, 0xff);
angle = opacity = opacity2 = focus = 0; type = fillSolid;
memset(texture_crop, 0, 4 * sizeof(int));
texture_crop_enabled = false;
......@@ -180,6 +186,7 @@ public:
struct _line
{
_line() { fill.color.SetRGB(0, 0, 0);}
std::wstring style;
int width;
_line_typeDash typeDash;
......@@ -207,7 +214,7 @@ public:
bool empty();
void start_group();
bool start_drawing(int type);
bool start_drawing (int type);
void start_image();
void start_shape(int type);
void start_chart();
......@@ -217,56 +224,60 @@ public:
void set_FlipH ();
void set_FlipV ();
void set_shape_id (int id);
void set_name (const std::wstring & str);
void set_description(const std::wstring & str);
//--------------------------------------------------------------------------------------
void set_name (const std::wstring & str);
void set_description (const std::wstring & str);
void set_crop_top (double val);
void set_crop_bottom(double val);
void set_crop_left (double val);
void set_crop_right (double val);
void set_rotation (double val);
void set_fill_color (int nColor, const std::wstring & sColor, bool background = false);
void set_fill_color (int index, int type, bool background = false);
void set_fill_opacity (double val, bool background = false);
void set_fill_type (int val);
void set_fill_angle (double val);
void set_fill_texture_mode(int val);
void set_fill_texture (const std::wstring & str);
void add_fill_colors (double position, const std::wstring & color);
void add_fill_colors (double position, int index, int type);
void set_fill_focus (int val);
void set_line_color (int nColor, const std::wstring & color);
void set_line_color (int index, int type);
void set_line_type (int val);
void set_line_style (int val);
void set_line_width (int val);
void set_line_dash (int val);
void set_chart_sheet_anchor(double width, double height);
void set_anchor (const std::wstring & str);
bool is_anchor ();
void set_properties (const std::wstring & str);
void set_hyperlink (const std::wstring & link, const std::wstring & display, bool is_external);
void set_path_rect (_rect & rect);
void set_path (const std::wstring & path);
void set_text (const std::wstring & text);
void set_text_wrap (int val);
void set_crop_top (double val);
void set_crop_bottom (double val);
void set_crop_left (double val);
void set_crop_right (double val);
void set_rotation (double val);
void set_fill_color (int nColor, const std::wstring & sColor, bool background = false);
void set_fill_color (int index, int type, bool background = false);
void set_fill_opacity (double val, bool background = false);
void set_fill_type (int val);
void set_fill_angle (double val);
void set_fill_texture_mode (int val);
void set_fill_texture (const std::wstring & str);
void add_fill_colors (double position, const std::wstring & color);
void add_fill_colors (double position, int index, int type);
void set_fill_focus (int val);
void set_line_color (int nColor, const std::wstring & color);
void set_line_color (int index, int type);
void set_line_type (int val);
void set_line_style (int val);
void set_line_width (int val);
void set_line_dash (int val);
void set_chart_sheet_anchor (double width, double height);
void set_anchor (const std::wstring & str);
bool is_anchor ();
void set_properties (const std::wstring & str);
void set_hyperlink (const std::wstring & link, const std::wstring & display, bool is_external);
void set_path_rect (_rect & rect);
void set_path (const std::wstring & path);
void set_text (const std::wstring & text);
void set_text_wrap (int val);
void set_text_align (int val);
void set_text_vert_align (int val);
void set_text_vertical (int val);
void set_wordart_text (const std::wstring & text);
void set_wordart_font (const std::wstring & text);
void set_wordart_size (int val);
void set_wordart_align (int val);
void set_wordart_bold (bool val);
void set_wordart_italic (bool val);
void set_wordart_underline (bool val);
void set_wordart_strike (bool val);
void set_wordart_vertical (bool val);
void set_wordart_spacing (double val);
//------------------------------------------------------------------------------
void serialize_shape (_drawing_state_ptr & drawing_state);
......@@ -277,7 +288,7 @@ public:
void serialize_fill (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_fill (std::wostream & stream);
void serialize (std::wostream & stream);
//-----------------------------------------------------------------------------------
void end_drawing();
void end_group();
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