Commit 6b6abbd2 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat - arrow drawing

parent 8ef8ee29
......@@ -1294,6 +1294,30 @@ void XlsConverter::convert_line_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
{
xlsx_context->get_drawing_context().set_line_dash(props[i]->op);
}break;
case NSOfficeDrawing::lineStartArrowhead:
{
xlsx_context->get_drawing_context().set_arrow_start(props[i]->op);
}break;
case NSOfficeDrawing::lineEndArrowhead:
{
xlsx_context->get_drawing_context().set_arrow_end(props[i]->op);
}break;
case NSOfficeDrawing::lineStartArrowWidth:
{
xlsx_context->get_drawing_context().set_arrow_start_width(props[i]->op);
}break;
case NSOfficeDrawing::lineStartArrowLength:
{
xlsx_context->get_drawing_context().set_arrow_start_length(props[i]->op);
}break;
case NSOfficeDrawing::lineEndArrowWidth:
{
xlsx_context->get_drawing_context().set_arrow_end_width(props[i]->op);
}break;
case NSOfficeDrawing::lineEndArrowLength:
{
xlsx_context->get_drawing_context().set_arrow_end_length(props[i]->op);
}break;
case NSOfficeDrawing::lineBoolean:
{
ODRAW::LineStyleBooleanProperties * bools = (ODRAW::LineStyleBooleanProperties *)(props[i].get());
......@@ -1301,6 +1325,11 @@ void XlsConverter::convert_line_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
{
if (bools->fUsefLine && bools->fLine == false)
xlsx_context->get_drawing_context().set_line_type(5); //no line
if (bools->fUsefArrowheadsOK && bools->fArrowheadsOK)
{
xlsx_context->get_drawing_context().set_line_arrow(true);
}
}
}break;
}
......
......@@ -1405,6 +1405,43 @@ void xlsx_drawing_context::serialize_line(std::wostream & stream, _drawing_state
case lineDashDotDot:CP_XML_ATTR(L"val", L"lgDashDotDot"); break;
}
}
if (line.arrow.enabled)
{
serialize_arrow(CP_XML_STREAM(), L"a:headEnd", line.arrow.start, line.arrow.start_width, line.arrow.start_length);
serialize_arrow(CP_XML_STREAM(), L"a:tailEnd", line.arrow.end, line.arrow.end_width, line.arrow.end_length);
}
}
}
}
void xlsx_drawing_context::serialize_arrow(std::wostream & stream, std::wstring name, int type, int width, int length)
{
if (type < 1) return;
CP_XML_WRITER(stream)
{
CP_XML_NODE(name)
{
switch(type)
{
case 1: CP_XML_ATTR(L"type", L"triangle"); break;
case 2: CP_XML_ATTR(L"type", L"stealth"); break;
case 3: CP_XML_ATTR(L"type", L"diamond"); break;
case 4: CP_XML_ATTR(L"type", L"oval"); break;
case 5: CP_XML_ATTR(L"type", L"arrow"); break;
}
switch(width)
{
case 1: CP_XML_ATTR(L"w", L"lg"); break;
case 2: CP_XML_ATTR(L"w", L"med"); break;
case 3: CP_XML_ATTR(L"w", L"sm"); break;
}
switch(length)
{
case 1: CP_XML_ATTR(L"len", L"lg"); break;
case 2: CP_XML_ATTR(L"len", L"med");break;
case 3: CP_XML_ATTR(L"len", L"sm"); break;
}
}
}
}
......@@ -1747,6 +1784,49 @@ void xlsx_drawing_context::set_line_width (int val)
current_drawing_states->back()->line.width = val;
}
void xlsx_drawing_context::set_line_arrow(bool val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->line.arrow.enabled = val;
}
void xlsx_drawing_context::set_arrow_start (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->line.arrow.start = val;
}
void xlsx_drawing_context::set_arrow_end (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->line.arrow.end = val;
}
void xlsx_drawing_context::set_arrow_start_width (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->line.arrow.start_width = val;
}
void xlsx_drawing_context::set_arrow_end_width (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->line.arrow.end_width = val;
}
void xlsx_drawing_context::set_arrow_start_length (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->line.arrow.start_length = val;
}
void xlsx_drawing_context::set_arrow_end_length (int val)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->line.arrow.end_length = val;
}
//----------------------------------------------------------------------
void xlsx_drawing_context::set_fill_old_version (_UINT32 val)
{
......
......@@ -246,14 +246,26 @@ public:
std::vector<std::pair<double, _color>> colorsPosition;
}fill;
struct _arrow
{
_arrow() { enabled = false; start = end = 0; start_length = end_length = end_width = start_width = 2;}
bool enabled;
int start;
int end;
int start_width;
int end_width;
int start_length;
int end_length;
};
struct _line
{
_line() { fill.color.SetRGB(0, 0, 0); width = 0;}
_line() { fill.color.SetRGB(0, 0, 0); width = 0; }
std::wstring style;
int width;
_line_typeDash typeDash;
_fill fill;
_arrow arrow;
}line;
//for group
std::vector<_drawing_state_ptr> drawing_states;
......@@ -311,13 +323,19 @@ public:
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_line_arrow (bool val);
void set_arrow_start (int val);
void set_arrow_end (int val);
void set_arrow_start_width (int val);
void set_arrow_end_width (int val);
void set_arrow_start_length (int val);
void set_arrow_end_length (int val);
void set_fill_old_version (_UINT32 val);
void set_line_old_version (_UINT32 val);
......@@ -331,7 +349,6 @@ public:
void set_properties (const std::wstring & str);
void set_hyperlink (const std::wstring & link, const std::wstring & display, bool is_external);
void set_text (const std::wstring & text);
void set_text_wrap (int val);
void set_text_align (int val);
......@@ -401,6 +418,8 @@ private:
void serialize_text (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_color (std::wostream & stream, const _color &color, double opacity = 0);
void serialize_arrow (std::wostream & stream, std::wstring name, int type, int width, int length);
bool ChangeBlack2ColorImage(std::wstring sRgbColor1, std::wstring sRgbColor2, _drawing_state_ptr & drawing_state);
_color CorrectSysColor(int nColorCode, _drawing_state_ptr & drawing_state);
......
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