Commit ce6c064a authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader ..

parent 1766dc9c
......@@ -65,6 +65,7 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
in_automatic_style_ (false),
in_paragraph_ (false),
in_header_ (false),
in_drawing_content_ (false),
table_context_ (*this),
output_document_ (NULL),
section_properties_in_table_(NULL),
......
......@@ -510,9 +510,12 @@ public:
void start_paragraph (bool is_header = false);
void finish_paragraph ();
bool is_paragraph_header() { return in_header_; }
bool get_paragraph_state() { return in_paragraph_; }
void set_paragraph_state(bool Val) {in_paragraph_= Val; }
bool is_paragraph_header() { return in_header_; }
bool get_paragraph_state() { return in_paragraph_; }
void set_paragraph_state(bool val) {in_paragraph_ = val; }
bool get_drawing_state_content() { return in_drawing_content_; }
void set_drawing_state_content(bool val) {in_drawing_content_ = val; }
std::wstring add_hyperlink (const std::wstring & href, bool drawing);
hyperlinks::_ref last_hyperlink ();
......@@ -699,6 +702,7 @@ private:
comments_context comments_context_;
bool first_element_list_item_;
bool in_drawing_content_;
bool in_paragraph_;
bool in_header_;
......
......@@ -394,11 +394,8 @@ void docx_serialize_child(std::wostream & strm, _docx_drawing & val)
}
}
void docx_serialize(std::wostream & strm, _docx_drawing & val)
void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
{
if (val.inGroup)
return docx_serialize_child(strm, val);
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:drawing")
......@@ -500,6 +497,70 @@ void docx_serialize(std::wostream & strm, _docx_drawing & val)
}
}
void docx_serialize_vml(std::wostream & strm, _docx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:pict")
{
CP_XML_NODE(L"v:rect")
{
std::wstring strStyle = L"position:absolute;\
visibility:visible;\
mso-wrap-style:square;\
mso-position-horizontal:absolute;\
mso-position-horizontal-relative:text;\
mso-position-vertical:absolute;\
mso-position-vertical-relative:text;";
strStyle += L"margin-left:" + boost::lexical_cast<std::wstring>(val.x / 12700.) + L"pt;";
strStyle += L"margin-top:" + boost::lexical_cast<std::wstring>(val.y / 12700.) + L"pt;";
strStyle += L"width:" + boost::lexical_cast<std::wstring>(val.cx / 12700.) + L"pt;";
strStyle += L"height:" + boost::lexical_cast<std::wstring>(val.cy / 12700.) + L"pt;";
strStyle += L"z-index:" + boost::lexical_cast<std::wstring>(0xF000800 - val.id);
CP_XML_ATTR(L"id", L"Rect" + boost::lexical_cast<std::wstring>(val.id));
CP_XML_ATTR(L"o:spid", L"_x0000_s" + boost::lexical_cast<std::wstring>(1024 + val.id));
CP_XML_ATTR(L"style", strStyle);
CP_XML_ATTR(L"fillcolor", L"#4f81bd [3204]");
CP_XML_ATTR(L"strokecolor", L"#243f60 [1604]");
CP_XML_ATTR(L"strokeweight", L"1pt");
}
}
}
}
void docx_serialize_alt_content(std::wostream & strm, _docx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"mc:AlternateContent")
{
CP_XML_NODE(L"mc:Choice")
{
CP_XML_ATTR(L"Requires", L"wps");
docx_serialize_wps(CP_XML_STREAM(), val);
}
CP_XML_NODE(L"mc:Fallback")
{
docx_serialize_vml(CP_XML_STREAM(), val);
}
}
}
}
void docx_serialize(std::wostream & strm, _docx_drawing & val, bool insideOtherDrawing)
{
if (val.inGroup)
return docx_serialize_child(strm, val);
//if (insideOtherDrawing)
docx_serialize_wps(strm, val);
//else
// docx_serialize_alt_content(strm, val);
}
}
}
......@@ -76,7 +76,7 @@ struct _docx_drawing : _oox_drawing
std::wstring content_group_;
friend void docx_serialize(std::wostream & _Wostream, _docx_drawing & val);
friend void docx_serialize(std::wostream & _Wostream, _docx_drawing & val, bool insideOtherDrawing);
};
}
}
......@@ -1027,7 +1027,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
else
Context.add_new_run(_T(""));
docx_serialize(strm, drawing);
docx_serialize(strm, drawing, Context.get_drawing_state_content());
if (new_run) Context.finish_run();
......@@ -1136,7 +1136,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(strm, drawing);
docx_serialize(strm, drawing, Context.get_drawing_state_content());
if (!Context.get_drawing_context().in_group())
Context.finish_run();
......@@ -1164,19 +1164,22 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
bool pState = Context.get_paragraph_state();
Context.set_paragraph_state(false);
bool drState = Context.get_drawing_state_content();
bool graphic_parent=false;
Context.set_drawing_state_content(true);
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
ElementType type = elm->get_type();
elm->docx_convert(Context);
}
Context.get_drawing_context().get_text_stream_frame() = temp_stream.str();
Context.set_stream_man(prev);
Context.set_run_state(runState);
Context.set_paragraph_state(pState);
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
Context.set_drawing_state_content (drState);
/////...../////
......@@ -1246,7 +1249,7 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(strm, drawing);
docx_serialize(strm, drawing, Context.get_drawing_state_content());
if (!Context.get_drawing_context().in_group())
Context.finish_run();
......@@ -1260,6 +1263,16 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
Context.add_delayed_element(this);
return;
}
//if (Context.get_drawing_state_content())
//{
// BOOST_FOREACH(const office_element_ptr & elm, content_)
// {
// ElementType type = elm->get_type();
// elm->docx_convert(Context);
// }
// return;
//}
oox::_docx_drawing drawing = oox::_docx_drawing();
......@@ -1339,7 +1352,7 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(strm, drawing);
docx_serialize(strm, drawing, Context.get_drawing_state_content());
if (!Context.get_drawing_context().in_group())
Context.finish_run();
......@@ -1432,7 +1445,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(Context.output_stream(), drawing);
docx_serialize(Context.output_stream(), drawing, Context.get_drawing_state_content());
if (!Context.get_drawing_context().in_group())
Context.finish_run();
......@@ -1470,7 +1483,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(Context.output_stream(), drawing);
docx_serialize(Context.output_stream(), drawing, Context.get_drawing_state_content());
if (!Context.get_drawing_context().in_group())
Context.finish_run();
......
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