Commit 4d5b9503 authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

OdfFormatReader - конвертация смартаартов, организционных диаграмм ...

parent 1fc2e22b
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
current_level_++; current_level_++;
objects_count_++; objects_count_++;
_frame_ fr = {drawFrame,L"",objects_count_,false}; _frame_ fr = {drawFrame, L"", objects_count_, false};
frames_.push_back(fr); frames_.push_back(fr);
} }
...@@ -125,6 +125,14 @@ public: ...@@ -125,6 +125,14 @@ public:
current_object_name_ = L""; current_object_name_ = L"";
current_shape_ = drawShape; current_shape_ = drawShape;
} }
void start_group()
{
current_level_++;
objects_count_++;
current_shape_id_ = objects_count_;
groups_.push_back(current_level_);
}
void add_name_object(const std::wstring & name) void add_name_object(const std::wstring & name)
{ {
current_object_name_ = name; current_object_name_ = name;
...@@ -146,10 +154,8 @@ public: ...@@ -146,10 +154,8 @@ public:
bool & get_use_image_replace() bool & get_use_image_replace()
{ {
bool res = false; bool res = false;
if (frames_.size()>0) if (frames_.size()>0) return frames_.back().use_image_replace;
return frames_.back().use_image_replace; else return res;
else
return res;
} }
std::wstring & get_text_stream_shape() std::wstring & get_text_stream_shape()
...@@ -172,17 +178,20 @@ public: ...@@ -172,17 +178,20 @@ public:
shape_text_content_=L""; shape_text_content_=L"";
current_shape_id_ =0; current_shape_id_ =0;
} }
int get_current_level() const { return current_level_; } void stop_group()
{
current_level_--;
groups_.pop_back();
}
int get_current_frame_id() const int get_current_frame_id() const
{ {
if (frames_.size()>0) if (frames_.size()>0) return frames_.back().id;
return frames_.back().id; else return 0;
else
return 0;
} }
int get_current_shape_id() const { return current_shape_id_; } bool in_group() { return groups_.size() > 0; }
int get_current_level() const { return current_level_; }
int get_current_shape_id() const { return current_shape_id_; }
const std::wstring & get_current_object_name() const { return current_object_name_; } const std::wstring & get_current_object_name() const { return current_object_name_; }
...@@ -194,19 +203,20 @@ public: ...@@ -194,19 +203,20 @@ public:
odf_reader::draw_shape * get_current_shape() const { return current_shape_; } odf_reader::draw_shape * get_current_shape() const { return current_shape_; }
private: private:
std::wstring shape_text_content_; std::wstring shape_text_content_;
std::wstring current_object_name_; std::wstring current_object_name_;
unsigned int objects_count_; unsigned int objects_count_;
int current_level_; int current_level_;
std::vector<_frame_> frames_; std::vector<int> groups_;
std::vector<_frame_> frames_;
odf_reader::draw_shape * current_shape_; odf_reader::draw_shape * current_shape_;
size_t current_shape_id_; size_t current_shape_id_;
std::wstring zero_string_; std::wstring zero_string_;
}; };
......
...@@ -179,101 +179,114 @@ void docx_serialize_text(std::wostream & strm, const std::vector<odf_reader::_pr ...@@ -179,101 +179,114 @@ void docx_serialize_text(std::wostream & strm, const std::vector<odf_reader::_pr
oox_serialize_bodyPr(strm, properties, L"wps"); oox_serialize_bodyPr(strm, properties, L"wps");
} }
void docx_serialize_image(std::wostream & strm, _docx_drawing & val) //--------------------------------------------------------------------
void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
{ {
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"wp:docPr") CP_XML_NODE(L"pic:pic")
{
CP_XML_ATTR(L"name",val.name);
CP_XML_ATTR(L"id", val.id+1);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
}
CP_XML_NODE(L"wp:cNvGraphicFramePr")
{ {
CP_XML_NODE(L"a:graphicFrameLocks") CP_XML_ATTR(L"xmlns:pic",L"http://schemas.openxmlformats.org/drawingml/2006/picture");
{ {
CP_XML_ATTR(L"xmlns:a",L"http://schemas.openxmlformats.org/drawingml/2006/main"); CP_XML_NODE(L"pic:nvPicPr")
CP_XML_ATTR(L"noChangeAspect",1);
}
}
CP_XML_NODE(L"a:graphic")
{
CP_XML_ATTR(L"xmlns:a",L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_NODE(L"a:graphicData")
{
CP_XML_ATTR(L"uri",L"http://schemas.openxmlformats.org/drawingml/2006/picture");
CP_XML_NODE(L"pic:pic")
{ {
CP_XML_ATTR(L"xmlns:pic",L"http://schemas.openxmlformats.org/drawingml/2006/picture"); CP_XML_NODE(L"pic:cNvPr")
{ {
CP_XML_NODE(L"pic:nvPicPr") //CP_XML_ATTR(L"desc text",L"");
{ CP_XML_ATTR(L"id",val.id);
CP_XML_NODE(L"pic:cNvPr") CP_XML_ATTR(L"name",val.name);
{
//CP_XML_ATTR(L"desc text",L"");
CP_XML_ATTR(L"id",val.id);
CP_XML_ATTR(L"name",val.name);
}
CP_XML_NODE(L"pic:cNvPicPr")
{
CP_XML_NODE(L"a:picLocks") CP_XML_ATTR(L"noChangeAspect",1);
}
}
} }
val.fill.bitmap->name_space = L"pic"; CP_XML_NODE(L"pic:cNvPicPr")
oox_serialize_fill(CP_XML_STREAM(), val.fill);
CP_XML_NODE(L"pic:spPr")
{ {
oox_serialize_xfrm(CP_XML_STREAM(), val); CP_XML_NODE(L"a:picLocks") CP_XML_ATTR(L"noChangeAspect",1);
}
}
}
val.fill.bitmap->name_space = L"pic";
oox_serialize_fill(CP_XML_STREAM(), val.fill);
CP_XML_NODE(L"a:prstGeom") CP_XML_NODE(L"pic:spPr")
{ {
CP_XML_ATTR(L"prst",L"rect"); oox_serialize_xfrm(CP_XML_STREAM(), val);
CP_XML_NODE(L"a:avLst");
}
oox_serialize_ln(CP_XML_STREAM(),val.additional); CP_XML_NODE(L"a:prstGeom")
} {
CP_XML_ATTR(L"prst",L"rect");
CP_XML_NODE(L"a:avLst");
} }
oox_serialize_ln(CP_XML_STREAM(),val.additional);
} }
} }
} }
} }
void docx_serialize_shape_child(std::wostream & strm, _docx_drawing & val)
void docx_serialize_chart(std::wostream & strm, _docx_drawing & val) {
{
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"wp:docPr") CP_XML_NODE(L"wps:wsp")
{ {
CP_XML_ATTR(L"name",val.name); CP_XML_NODE(L"wps:cNvSpPr")
CP_XML_ATTR(L"id", val.id+1); {
//oox_serialize_hlink(CP_XML_STREAM(),val.hlink); if (val.sub_type==1 || val.sub_type==0)//frame
} {
CP_XML_ATTR(L"txBox", 1);
}
CP_XML_NODE(L"a:spLocks")
{
CP_XML_ATTR(L"noChangeAspect", 1);
}
}
CP_XML_NODE(L"wp:cNvGraphicFramePr"); CP_XML_NODE(L"wps:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
CP_XML_NODE(L"a:graphic") oox_serialize_shape(CP_XML_STREAM(),val);
{
CP_XML_ATTR(L"xmlns:a",L"http://schemas.openxmlformats.org/drawingml/2006/main"); oox_serialize_ln(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:graphicData") }
docx_serialize_text(CP_XML_STREAM(),val.additional);
}
}
}
void docx_serialize_group_child(std::wostream & strm, _docx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"wpg:wgp")
{
CP_XML_NODE(L"wpg:cNvGrpSpPr")
{ {
CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/drawingml/2006/chart"); CP_XML_NODE(L"a:spLocks")
CP_XML_NODE(L"c:chart")
{ {
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart"); CP_XML_ATTR(L"noChangeAspect", 1);
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.chartId);
} }
} }
}
CP_XML_NODE(L"wpg:grpSpPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
}
CP_XML_STREAM() << val.content_group_;
}
}
}
void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"c:chart")
{
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.chartId);
}
} }
} }
void docx_serialize_shape(std::wostream & strm, _docx_drawing & val) void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
{ {
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
...@@ -297,39 +310,55 @@ void docx_serialize_shape(std::wostream & strm, _docx_drawing & val) ...@@ -297,39 +310,55 @@ void docx_serialize_shape(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"xmlns:a",L"http://schemas.openxmlformats.org/drawingml/2006/main"); CP_XML_ATTR(L"xmlns:a",L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_NODE(L"a:graphicData") CP_XML_NODE(L"a:graphicData")
{ {
CP_XML_ATTR(L"uri",L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); if (val.type == mediaitems::typeShape)
CP_XML_NODE(L"wps:wsp")
{ {
CP_XML_NODE(L"wps:cNvSpPr") CP_XML_ATTR(L"uri",L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
{ docx_serialize_shape_child(CP_XML_STREAM(), val);
if (val.sub_type==1 || val.sub_type==0)//frame }
{ else if (val.type == mediaitems::typeImage)
CP_XML_ATTR(L"txBox", 1); {
} CP_XML_ATTR(L"uri",L"http://schemas.openxmlformats.org/drawingml/2006/picture");
CP_XML_NODE(L"a:spLocks") docx_serialize_image_child(CP_XML_STREAM(), val);
{ }
CP_XML_ATTR(L"noChangeAspect", 1); else if (val.type == mediaitems::typeChart)
} {
} CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
docx_serialize_chart_child(CP_XML_STREAM(), val);
CP_XML_NODE(L"wps:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
oox_serialize_shape(CP_XML_STREAM(),val);
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
docx_serialize_text(CP_XML_STREAM(),val.additional);
} }
else if (val.type == mediaitems::typeGroup)
{
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
docx_serialize_group_child(CP_XML_STREAM(), val);
}
} }
} }
} }
} }
void docx_serialize_child(std::wostream & strm, _docx_drawing & val)
{
if (val.type == mediaitems::typeShape)
{
docx_serialize_shape_child(strm,val);
}
else if (val.type == mediaitems::typeImage)
{
docx_serialize_image_child(strm,val);
}
else if (val.type == mediaitems::typeChart)
{
docx_serialize_chart_child(strm,val);
}
else if (val.type == mediaitems::typeGroup)
{
docx_serialize_group_child(strm,val);
}
}
void docx_serialize(std::wostream & strm, _docx_drawing & val) void docx_serialize(std::wostream & strm, _docx_drawing & val)
{ {
if (val.inGroup)
return docx_serialize_child(strm, val);
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"w:drawing") CP_XML_NODE(L"w:drawing")
...@@ -426,18 +455,7 @@ void docx_serialize(std::wostream & strm, _docx_drawing & val) ...@@ -426,18 +455,7 @@ void docx_serialize(std::wostream & strm, _docx_drawing & val)
serialize_wrap(CP_XML_STREAM(), val); serialize_wrap(CP_XML_STREAM(), val);
} }
if (val.type == mediaitems::typeShape) docx_serialize_common(CP_XML_STREAM(), val);
{
docx_serialize_shape(CP_XML_STREAM(),val);
}
else if (val.type == mediaitems::typeImage)
{
docx_serialize_image(CP_XML_STREAM(),val);
}
else if (val.type == mediaitems::typeChart)
{
docx_serialize_chart(CP_XML_STREAM(),val);
}
} }
} }
} }
......
...@@ -14,8 +14,8 @@ namespace cpdoccore { ...@@ -14,8 +14,8 @@ namespace cpdoccore {
namespace oox { namespace oox {
struct _docx_drawing : _oox_drawing struct _docx_drawing : _oox_drawing
{ {
_docx_drawing():_oox_drawing(),parallel(0),isInline(false),number_wrapped_paragraphs(0),posOffsetV(0),posOffsetH(0) _docx_drawing():_oox_drawing(), parallel(0), isInline(false), inGroup(false), number_wrapped_paragraphs(0), posOffsetV(0), posOffsetH(0)
{ {
} }
unsigned int parallel; unsigned int parallel;
...@@ -28,6 +28,7 @@ struct _docx_drawing : _oox_drawing ...@@ -28,6 +28,7 @@ struct _docx_drawing : _oox_drawing
_CP_OPT(odf_types::style_wrap) styleWrap; _CP_OPT(odf_types::style_wrap) styleWrap;
bool inGroup;
bool isInline; bool isInline;
int number_wrapped_paragraphs; int number_wrapped_paragraphs;
...@@ -43,6 +44,8 @@ struct _docx_drawing : _oox_drawing ...@@ -43,6 +44,8 @@ struct _docx_drawing : _oox_drawing
// std::wstring distL; // std::wstring distL;
// std::wstring distR; // std::wstring distR;
std::wstring content_group_;
friend void docx_serialize(std::wostream & _Wostream, _docx_drawing & val); friend void docx_serialize(std::wostream & _Wostream, _docx_drawing & val);
}; };
} }
......
...@@ -11,7 +11,7 @@ class rels; ...@@ -11,7 +11,7 @@ class rels;
class mediaitems class mediaitems
{ {
public: public:
enum Type { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia}; enum Type { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroup};
mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket) mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{ {
......
...@@ -164,8 +164,6 @@ class draw_g_attlist ...@@ -164,8 +164,6 @@ class draw_g_attlist
public: public:
void add_attributes( const xml::attributes_wc_ptr & Attributes ); void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
}; };
...@@ -188,10 +186,10 @@ private: ...@@ -188,10 +186,10 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name); virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
public: public:
odf_types::union_common_draw_attlists common_draw_attlists_; odf_types::union_common_draw_attlists common_draw_attlists_;
draw_g_attlist draw_g_attlist_; draw_g_attlist draw_g_attlist_;
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
CP_REGISTER_OFFICE_ELEMENT2(draw_g); CP_REGISTER_OFFICE_ELEMENT2(draw_g);
......
...@@ -940,9 +940,9 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context) ...@@ -940,9 +940,9 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
oox::_docx_drawing drawing = oox::_docx_drawing(); oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::mediaitems::typeShape; drawing.type = oox::mediaitems::typeShape;
drawing.id = Context.get_drawing_context().get_current_shape_id(); drawing.id = Context.get_drawing_context().get_current_shape_id();
drawing.name = Context.get_drawing_context().get_current_object_name(); drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
drawing.sub_type = sub_type_; drawing.sub_type = sub_type_;
drawing.additional = additional_;// ... drawing.additional = additional_;// ...
...@@ -970,7 +970,8 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context) ...@@ -970,7 +970,8 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
Context.set_paragraph_state(false); Context.set_paragraph_state(false);
bool new_run = true; bool new_run = true;
if (pState == false && Context.get_drawing_context().get_current_level() == 1)
if ((pState == false && Context.get_drawing_context().get_current_level() == 1) || (Context.get_drawing_context().in_group()))
{ {
new_run = false; new_run = false;
} }
...@@ -1026,10 +1027,12 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context) ...@@ -1026,10 +1027,12 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
///////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////
oox::_docx_drawing drawing = oox::_docx_drawing(); oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::mediaitems::typeImage;
drawing.id = Context.get_drawing_context().get_current_frame_id(); drawing.type = oox::mediaitems::typeImage;
drawing.name = Context.get_drawing_context().get_current_object_name(); drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
oox::hyperlinks::_ref hyperlink = Context.last_hyperlink(); oox::hyperlinks::_ref hyperlink = Context.last_hyperlink();
// - "" - ( ) // - "" - ( )
...@@ -1082,9 +1085,13 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context) ...@@ -1082,9 +1085,13 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
pState = Context.get_paragraph_state(); pState = Context.get_paragraph_state();
Context.set_paragraph_state(false); Context.set_paragraph_state(false);
Context.add_new_run(_T("")); if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(strm,drawing); docx_serialize(strm,drawing);
Context.finish_run();
if (!Context.get_drawing_context().in_group())
Context.finish_run();
Context.set_paragraph_state(pState); Context.set_paragraph_state(pState);
...@@ -1130,10 +1137,10 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context) ...@@ -1130,10 +1137,10 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
return; return;
oox::_docx_drawing drawing = oox::_docx_drawing(); oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::mediaitems::typeShape; drawing.type = oox::mediaitems::typeShape;
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.id = Context.get_drawing_context().get_current_frame_id(); drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.name = Context.get_drawing_context().get_current_object_name(); drawing.inGroup = Context.get_drawing_context().in_group();
drawing.sub_type = 1; //textBox drawing.sub_type = 1; //textBox
...@@ -1188,23 +1195,81 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context) ...@@ -1188,23 +1195,81 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
pState = Context.get_paragraph_state(); pState = Context.get_paragraph_state();
Context.set_paragraph_state(false); Context.set_paragraph_state(false);
Context.add_new_run(_T("")); if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(strm, drawing); docx_serialize(strm, drawing);
Context.finish_run();
if (!Context.get_drawing_context().in_group())
Context.finish_run();
Context.set_paragraph_state(pState); Context.set_paragraph_state(pState);
} }
void draw_g::docx_convert(oox::docx_conversion_context & Context) void draw_g::docx_convert(oox::docx_conversion_context & Context)
{ {
BOOST_FOREACH(const office_element_ptr & elm, content_) if ((!Context.get_paragraph_state() && !Context.get_drawing_context().in_group()) && !Context.delayed_converting_)
{
Context.add_delayed_element(this);
return;
}
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.id = Context.get_drawing_context().get_current_shape_id();
drawing.type = oox::mediaitems::typeGroup;
drawing.inGroup = Context.get_drawing_context().in_group();
Context.get_drawing_context().start_group();
/////////
common_draw_docx_convert(Context, common_draw_attlists_, drawing);
/////////
oox::docx_conversion_context::StreamsManPtr prev = Context.get_stream_man();
std::wstringstream temp_stream(drawing.content_group_);
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
bool runState = Context.get_run_state();
Context.set_run_state(false);
bool pState = Context.get_paragraph_state();
Context.set_paragraph_state(false);
BOOST_FOREACH(const office_element_ptr & elm, content_)
{ {
ElementType type = elm->get_type(); ElementType type = elm->get_type();
elm->docx_convert(Context); elm->docx_convert(Context);
} }
if (drawing.cx < 1 || drawing.cy < 1 && content_.size() > 0)
{// - ...
draw_frame* frame = dynamic_cast<draw_frame*>(content_[0].get());
if (frame)
{
drawing.cx = get_value_emu(frame->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
drawing.cy = get_value_emu(frame->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
}
else
{
draw_shape* shape = dynamic_cast<draw_shape*>(content_[0].get());
if (shape)
{
drawing.cx = get_value_emu(shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
drawing.cy = get_value_emu(shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
}
}
}
drawing.content_group_ = temp_stream.str();
Context.set_stream_man(prev);
Context.set_run_state(runState);
Context.set_paragraph_state(pState);
docx_serialize(Context.output_stream(), drawing);
Context.get_drawing_context().stop_group();
} }
void draw_frame::docx_convert(oox::docx_conversion_context & Context) void draw_frame::docx_convert(oox::docx_conversion_context & Context)
{ {
if (!Context.get_paragraph_state() && !Context.delayed_converting_) if ((!Context.get_paragraph_state() && !Context.get_drawing_context().in_group()) && !Context.delayed_converting_)
{ {
Context.add_delayed_element(this); Context.add_delayed_element(this);
return; return;
...@@ -1271,6 +1336,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) ...@@ -1271,6 +1336,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
drawing.id = Context.get_drawing_context().get_current_frame_id(); drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name(); drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
bool isMediaInternal = true; bool isMediaInternal = true;
drawing.chartId = Context.add_mediaitem(href, drawing.type, isMediaInternal, href); drawing.chartId = Context.add_mediaitem(href, drawing.type, isMediaInternal, href);
...@@ -1283,11 +1349,13 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) ...@@ -1283,11 +1349,13 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
Context.set_run_state(false); Context.set_run_state(false);
Context.set_paragraph_state(false); Context.set_paragraph_state(false);
Context.add_new_run(_T("")); 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.finish_run(); if (!Context.get_drawing_context().in_group())
Context.finish_run();
Context.set_run_state(runState); Context.set_run_state(runState);
Context.set_paragraph_state(pState); Context.set_paragraph_state(pState);
...@@ -1299,6 +1367,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) ...@@ -1299,6 +1367,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
drawing.type = oox::mediaitems::typeShape; drawing.type = oox::mediaitems::typeShape;
drawing.id = Context.get_drawing_context().get_current_frame_id(); drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name(); drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing); common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
...@@ -1310,6 +1379,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) ...@@ -1310,6 +1379,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
if (drawing.fill.type > 0) if (drawing.fill.type > 0)
in_frame = true; in_frame = true;
if (in_frame) if (in_frame)
{ {
drawing.additional.push_back(_property(L"text-content", std::wstring(L"<w:p><m:oMathPara><m:oMathParaPr/>") + drawing.additional.push_back(_property(L"text-content", std::wstring(L"<w:p><m:oMathPara><m:oMathParaPr/>") +
...@@ -1317,11 +1387,13 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) ...@@ -1317,11 +1387,13 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
Context.set_run_state(false); Context.set_run_state(false);
Context.set_paragraph_state(false); Context.set_paragraph_state(false);
Context.add_new_run(_T("")); 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.finish_run(); if (!Context.get_drawing_context().in_group())
Context.finish_run();
Context.set_run_state(runState); Context.set_run_state(runState);
Context.set_paragraph_state(pState); Context.set_paragraph_state(pState);
......
...@@ -84,7 +84,7 @@ void draw_shape::common_docx_convert(oox::docx_conversion_context & Context) ...@@ -84,7 +84,7 @@ void draw_shape::common_docx_convert(oox::docx_conversion_context & Context)
} }
void draw_rect::docx_convert(oox::docx_conversion_context & Context) void draw_rect::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context); common_docx_convert(Context);
//... //...
...@@ -93,7 +93,7 @@ void draw_rect::docx_convert(oox::docx_conversion_context & Context) ...@@ -93,7 +93,7 @@ void draw_rect::docx_convert(oox::docx_conversion_context & Context)
} }
void draw_ellipse::docx_convert(oox::docx_conversion_context & Context) void draw_ellipse::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context); common_docx_convert(Context);
//... //...
...@@ -101,7 +101,7 @@ void draw_ellipse::docx_convert(oox::docx_conversion_context & Context) ...@@ -101,7 +101,7 @@ void draw_ellipse::docx_convert(oox::docx_conversion_context & Context)
} }
void draw_circle::docx_convert(oox::docx_conversion_context & Context) void draw_circle::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context); common_docx_convert(Context);
//... //...
...@@ -109,7 +109,7 @@ void draw_circle::docx_convert(oox::docx_conversion_context & Context) ...@@ -109,7 +109,7 @@ void draw_circle::docx_convert(oox::docx_conversion_context & Context)
} }
void draw_line::docx_convert(oox::docx_conversion_context & Context) void draw_line::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
reset_svg_attributes(); reset_svg_attributes();
...@@ -120,7 +120,7 @@ void draw_line::docx_convert(oox::docx_conversion_context & Context) ...@@ -120,7 +120,7 @@ void draw_line::docx_convert(oox::docx_conversion_context & Context)
void draw_path::docx_convert(oox::docx_conversion_context & Context) void draw_path::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context); common_docx_convert(Context);
//... //...
...@@ -130,7 +130,7 @@ void draw_path::docx_convert(oox::docx_conversion_context & Context) ...@@ -130,7 +130,7 @@ void draw_path::docx_convert(oox::docx_conversion_context & Context)
void draw_connector::docx_convert(oox::docx_conversion_context & Context) void draw_connector::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context); common_docx_convert(Context);
//... //...
...@@ -139,7 +139,7 @@ void draw_connector::docx_convert(oox::docx_conversion_context & Context) ...@@ -139,7 +139,7 @@ void draw_connector::docx_convert(oox::docx_conversion_context & Context)
} }
void draw_polygon::docx_convert(oox::docx_conversion_context & Context) void draw_polygon::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context); common_docx_convert(Context);
//... //...
...@@ -148,7 +148,7 @@ void draw_polygon::docx_convert(oox::docx_conversion_context & Context) ...@@ -148,7 +148,7 @@ void draw_polygon::docx_convert(oox::docx_conversion_context & Context)
} }
void draw_polyline::docx_convert(oox::docx_conversion_context & Context) void draw_polyline::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context); common_docx_convert(Context);
//... //...
...@@ -157,7 +157,7 @@ void draw_polyline::docx_convert(oox::docx_conversion_context & Context) ...@@ -157,7 +157,7 @@ void draw_polyline::docx_convert(oox::docx_conversion_context & Context)
} }
void draw_custom_shape::docx_convert(oox::docx_conversion_context & Context) void draw_custom_shape::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context); common_docx_convert(Context);
//... //...
...@@ -165,7 +165,7 @@ void draw_custom_shape::docx_convert(oox::docx_conversion_context & Context) ...@@ -165,7 +165,7 @@ void draw_custom_shape::docx_convert(oox::docx_conversion_context & Context)
} }
void draw_caption::docx_convert(oox::docx_conversion_context & Context) void draw_caption::docx_convert(oox::docx_conversion_context & Context)
{ {
if (Context.get_drawing_context().get_current_level() >0 )return; //if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context); common_docx_convert(Context);
//... //...
......
 #include <string>
#include "SvmFile.h"
#include <string>
#include "../../../graphics/GraphicsRenderer.h"
#include "../Common/MetaFileTypes.h" #include "../Common/MetaFileTypes.h"
#include "../Common/MetaFileRenderer.h" #include "../Common/MetaFileRenderer.h"
#include "../../../../Common/DocxFormat/Source/Base/Types_32.h"
#include "../../../../OfficeUtils/src/OfficeUtils.h" #include "../../../../OfficeUtils/src/OfficeUtils.h"
#ifdef _DEBUG #ifdef _DEBUG
#include <iostream> #include <iostream>
#endif #endif
#include "SvmFile.h"
#include "SvmEnums.h" #include "SvmEnums.h"
#include "SvmObjects.h" #include "SvmObjects.h"
...@@ -191,7 +191,7 @@ void CSvmFile::PlayMetaFile() ...@@ -191,7 +191,7 @@ void CSvmFile::PlayMetaFile()
m_oStream.Skip(need_skip); m_oStream.Skip(need_skip);
#ifdef _DEBUG #ifdef _DEBUG
if (100 <= actionType && actionType <= META_LAST_ACTION && need_skip > 0 && !m_pOutput) if (/*100 <= actionType &&*/ actionType <= META_LAST_ACTION && /*need_skip > 0 &&*/ !m_pOutput)
{ {
std::wstring name = actionNames[actionType - 99].actionName; std::wstring name = actionNames[actionType - 99].actionName;
...@@ -203,6 +203,15 @@ void CSvmFile::PlayMetaFile() ...@@ -203,6 +203,15 @@ void CSvmFile::PlayMetaFile()
m_pOutput->End(); m_pOutput->End();
} }
void CSvmFile::Read_META_LAYOUTMODE()
{
unsigned int textLayputMode;
m_oStream >> textLayputMode;
UpdateOutputDC();
}
void CSvmFile::Read_META_LINE() void CSvmFile::Read_META_LINE()
{ {
TSvmPoint start, end; TSvmPoint start, end;
...@@ -218,7 +227,7 @@ void CSvmFile::Read_META_LINE() ...@@ -218,7 +227,7 @@ void CSvmFile::Read_META_LINE()
CSvmPen *last_pen = dynamic_cast<CSvmPen *>(m_oPlayer.GetLastObject(SVM_OBJECT_PEN)); CSvmPen *last_pen = dynamic_cast<CSvmPen *>(m_oPlayer.GetLastObject(SVM_OBJECT_PEN));
if (last_pen) if (last_pen)
{ {
last_pen->Width = line_info.width; last_pen->Width = line_info.width / (m_oPlayer.GetDC()->m_dPixelWidth * 2);
switch(line_info.style) switch(line_info.style)
{ {
...@@ -227,8 +236,8 @@ void CSvmFile::Read_META_LINE() ...@@ -227,8 +236,8 @@ void CSvmFile::Read_META_LINE()
} }
} }
} }
MoveTo(start.x, start.y); MoveTo(start.x + m_oCurrnetOffset.x, start.y + m_oCurrnetOffset.y);
LineTo(end.x, end.y); LineTo(end.x + m_oCurrnetOffset.x, end.y + m_oCurrnetOffset.y);
} }
void CSvmFile::Read_META_RECTANGLE() void CSvmFile::Read_META_RECTANGLE()
{ {
...@@ -249,13 +258,16 @@ void CSvmFile::Read_SVM_HEADER() ...@@ -249,13 +258,16 @@ void CSvmFile::Read_SVM_HEADER()
m_pDC->SetMapMode(m_oHeader.mapMode, true); m_pDC->SetMapMode(m_oHeader.mapMode, true);
m_oBoundingBox = m_oHeader.boundRect; if (m_bMainStream)
m_oBoundingBox.nRight *= m_pDC->m_dPixelWidthPrefered * 2; {
m_oBoundingBox.nBottom *= m_pDC->m_dPixelHeightPrefered * 2; m_oBoundingBox = m_oHeader.boundRect;
m_oBoundingBox.nRight *= m_pDC->m_dPixelWidthPrefered * 2;
m_oBoundingBox.nBottom *= m_pDC->m_dPixelHeightPrefered * 2;
m_oBoundingBox.nLeft *= m_pDC->m_dPixelWidthPrefered * 2;
m_oBoundingBox.nTop *= m_pDC->m_dPixelHeightPrefered * 2;
}// *2 ради повышения качества картинки (если в векторе насамом деле растр - сментся на растровые размеры ниже
m_oBoundingBox.nLeft *= m_pDC->m_dPixelWidthPrefered * 2;
m_oBoundingBox.nTop *= m_pDC->m_dPixelHeightPrefered * 2;
// *2 ради повышения качества картинки (если в векторе насамом деле растр - сментся на растровые размеры ниже
m_bFirstPoint = true; m_bFirstPoint = true;
} }
void CSvmFile::Read_META_POLYLINE() void CSvmFile::Read_META_POLYLINE()
...@@ -271,13 +283,16 @@ void CSvmFile::Read_META_POLYLINE() ...@@ -271,13 +283,16 @@ void CSvmFile::Read_META_POLYLINE()
CSvmPen *last_pen = dynamic_cast<CSvmPen *>(m_oPlayer.GetLastObject(SVM_OBJECT_PEN)); CSvmPen *last_pen = dynamic_cast<CSvmPen *>(m_oPlayer.GetLastObject(SVM_OBJECT_PEN));
if (last_pen) if (last_pen)
{ {
last_pen->Width = line_info.width; last_pen->Width = line_info.width / (m_oPlayer.GetDC()->m_dPixelWidth * 2);
switch(line_info.style) switch(line_info.style)
{ {
case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break; case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break;
case LINE_DASH: last_pen->PenStyle = PS_DASH ; break; case LINE_DASH: last_pen->PenStyle = PS_DASH ; break;
} }
if (last_pen->Width < 1)
last_pen->Width = 20;
} }
} }
...@@ -300,11 +315,11 @@ void CSvmFile::Read_META_POLYLINE() ...@@ -300,11 +315,11 @@ void CSvmFile::Read_META_POLYLINE()
if (polygon.points.size() < 1) return; if (polygon.points.size() < 1) return;
MoveTo(polygon.points[0].x, polygon.points[0].y); MoveTo(polygon.points[0].x + m_oCurrnetOffset.x, polygon.points[0].y + m_oCurrnetOffset.y);
for (int i = 1; i < polygon.points.size(); i++) for (int i = 1; i < polygon.points.size(); i++)
{ {
LineTo(polygon.points[i].x, polygon.points[i].y); LineTo(polygon.points[i].x + m_oCurrnetOffset.x, polygon.points[i].y + m_oCurrnetOffset.y);
} }
ClosePath(); ClosePath();
DrawPath(true, false); DrawPath(true, false);
...@@ -318,11 +333,11 @@ void CSvmFile::Read_META_POLYGON() ...@@ -318,11 +333,11 @@ void CSvmFile::Read_META_POLYGON()
if (polygon.points.size() < 1) return; if (polygon.points.size() < 1) return;
MoveTo(polygon.points[0].x, polygon.points[0].y); MoveTo(polygon.points[0].x + m_oCurrnetOffset.x, polygon.points[0].y + m_oCurrnetOffset.y);
for (int i = 1; i < polygon.points.size(); i++) for (int i = 1; i < polygon.points.size(); i++)
{ {
LineTo(polygon.points[i].x, polygon.points[i].y); LineTo(polygon.points[i].x + m_oCurrnetOffset.x, polygon.points[i].y + m_oCurrnetOffset.y);
} }
ClosePath(); ClosePath();
DrawPath(true, true); DrawPath(true, true);
...@@ -384,10 +399,10 @@ void CSvmFile::Read_META_POLYPOLYGON() ...@@ -384,10 +399,10 @@ void CSvmFile::Read_META_POLYPOLYGON()
if (ushPointsCount <= 0) if (ushPointsCount <= 0)
continue; continue;
MoveTo(polygons[ushPolygonIndex].points[0].x, polygons[ushPolygonIndex].points[0].y); MoveTo(polygons[ushPolygonIndex].points[0].x + m_oCurrnetOffset.x, polygons[ushPolygonIndex].points[0].y + m_oCurrnetOffset.y);
for (int i = 1; i < ushPointsCount; i++) for (int i = 1; i < ushPointsCount; i++)
{ {
LineTo(polygons[ushPolygonIndex].points[i].x, polygons[ushPolygonIndex].points[i].y); LineTo(polygons[ushPolygonIndex].points[i].x + m_oCurrnetOffset.x, polygons[ushPolygonIndex].points[i].y + m_oCurrnetOffset.y);
} }
ClosePath(); ClosePath();
} }
...@@ -398,10 +413,10 @@ void CSvmFile::Read_META_POLYPOLYGON() ...@@ -398,10 +413,10 @@ void CSvmFile::Read_META_POLYPOLYGON()
// if (ushPointsCount <= 0) // if (ushPointsCount <= 0)
// continue; // continue;
// MoveTo(complexPolygons[ushPolygonIndex].points[0].x, complexPolygons[ushPolygonIndex].points[0].y); // MoveTo(complexPolygons[ushPolygonIndex].points[0].x + m_oCurrnetOffset.x, complexPolygons[ushPolygonIndex].points[0].y);
// for (int i = 1; i < ushPointsCount; i++) // for (int i = 1; i < ushPointsCount; i++)
// { // {
// LineTo(complexPolygons[ushPolygonIndex].points[i].x, complexPolygons[ushPolygonIndex].points[i].y); // LineTo(complexPolygons[ushPolygonIndex].points[i].x + m_oCurrnetOffset.x, complexPolygons[ushPolygonIndex].points[i].y);
// } // }
// ClosePath(); // ClosePath();
//} //}
...@@ -416,6 +431,8 @@ void CSvmFile::Read_META_SETMAPMODE() ...@@ -416,6 +431,8 @@ void CSvmFile::Read_META_SETMAPMODE()
m_pDC->SetMapMode(mapMode); m_pDC->SetMapMode(mapMode);
m_oCurrnetOffset = mapMode.origin;
UpdateOutputDC(); UpdateOutputDC();
} }
...@@ -450,7 +467,7 @@ void CSvmFile::Read_META_STRETCHTEXT() ...@@ -450,7 +467,7 @@ void CSvmFile::Read_META_STRETCHTEXT()
} }
sText = buf; sText = buf;
} }
DrawText(sText, sText.length(), startPoint.x, startPoint.y); DrawText(sText, sText.length(), startPoint.x + m_oCurrnetOffset.x, startPoint.y + m_oCurrnetOffset.y);
} }
...@@ -482,7 +499,7 @@ void CSvmFile::Read_META_TEXT() ...@@ -482,7 +499,7 @@ void CSvmFile::Read_META_TEXT()
// } // }
// sText = buf; // sText = buf;
//} //}
DrawText(sText, sText.length(), startPoint.x, startPoint.y); DrawText(sText, sText.length(), startPoint.x + m_oCurrnetOffset.x, startPoint.y + m_oCurrnetOffset.y);
} }
void CSvmFile::Read_META_ARRAYTEXT() void CSvmFile::Read_META_ARRAYTEXT()
{ {
...@@ -530,7 +547,7 @@ void CSvmFile::Read_META_ARRAYTEXT() ...@@ -530,7 +547,7 @@ void CSvmFile::Read_META_ARRAYTEXT()
tempBuffer += (wchar_t)nTemp; tempBuffer += (wchar_t)nTemp;
} }
} }
DrawText(sText, sText.length(), startPoint.x, startPoint.y, mpDXAry); DrawText(sText, sText.length(), startPoint.x + m_oCurrnetOffset.x, startPoint.y + m_oCurrnetOffset.y, mpDXAry);
if (mpDXAry) if (mpDXAry)
delete []mpDXAry; delete []mpDXAry;
...@@ -704,10 +721,10 @@ void CSvmFile::Read_META_TRANSPARENT() ...@@ -704,10 +721,10 @@ void CSvmFile::Read_META_TRANSPARENT()
if (ushPointsCount <= 0) if (ushPointsCount <= 0)
continue; continue;
MoveTo(polygons[ushPolygonIndex].points[0].x, polygons[ushPolygonIndex].points[0].y); MoveTo(polygons[ushPolygonIndex].points[0].x + m_oCurrnetOffset.x, polygons[ushPolygonIndex].points[0].y + m_oCurrnetOffset.y);
for (int i = 1; i < ushPointsCount; i++) for (int i = 1; i < ushPointsCount; i++)
{ {
LineTo(polygons[ushPolygonIndex].points[i].x, polygons[ushPolygonIndex].points[i].y); LineTo(polygons[ushPolygonIndex].points[i].x + m_oCurrnetOffset.x, polygons[ushPolygonIndex].points[i].y + m_oCurrnetOffset.y);
} }
m_pOutput->ClosePath(); m_pOutput->ClosePath();
...@@ -719,12 +736,15 @@ void CSvmFile::Read_META_TRANSPARENT() ...@@ -719,12 +736,15 @@ void CSvmFile::Read_META_TRANSPARENT()
void CSvmFile::Read_META_FLOATTRANSPARENT() void CSvmFile::Read_META_FLOATTRANSPARENT()
{ {
return;
// тут возможен также вариант svg // тут возможен также вариант svg
CSvmFile metaFile(m_oStream.GetCurPtr() , m_unRecordSize); CSvmFile subMetaFile(m_oStream.GetCurPtr() , m_unRecordSize);
metaFile.SetOutputDevice(m_pOutput);
metaFile.PlayMetaFile();
int skip_size = metaFile.m_oStream.Tell(); subMetaFile.m_bMainStream = false;
subMetaFile.SetFontManager(GetFontManager());
subMetaFile.PlayMetaFile();
int skip_size = subMetaFile.m_oStream.Tell();
m_oStream.Skip( skip_size); m_oStream.Skip( skip_size);
...@@ -739,19 +759,17 @@ void CSvmFile::Read_META_FLOATTRANSPARENT() ...@@ -739,19 +759,17 @@ void CSvmFile::Read_META_FLOATTRANSPARENT()
if (!pBrush) if (!pBrush)
return SetError(); return SetError();
m_oStream >> pBrush->BrushBounds;
TSvmGradient gradient; TSvmGradient gradient;
m_oStream >> gradient; m_oStream >> gradient;
switch((ESvmGradientStyle)gradient.style) switch((ESvmGradientStyle)gradient.style)
{ {
case GRADIENT_LINEAR: pBrush->BrushStyle = BS_LINEARGRADIENT; break; case GRADIENT_LINEAR: pBrush->BrushStyle = BS_LINEARGRADIENT; break;
case GRADIENT_AXIAL: pBrush->BrushStyle = BS_AXIALGRADIENT; break; case GRADIENT_AXIAL: pBrush->BrushStyle = BS_AXIALGRADIENT; break;
case GRADIENT_RADIAL: pBrush->BrushStyle = BS_RADIALGRADIENT; break; case GRADIENT_RADIAL: pBrush->BrushStyle = BS_RADIALGRADIENT; break;
case GRADIENT_ELLIPTICAL: pBrush->BrushStyle = BS_RADIALGRADIENT; break; case GRADIENT_ELLIPTICAL: pBrush->BrushStyle = BS_RADIALGRADIENT; break;
case GRADIENT_SQUARE: pBrush->BrushStyle = BS_LINEARGRADIENT; break; case GRADIENT_SQUARE: pBrush->BrushStyle = BS_LINEARGRADIENT; break;
case GRADIENT_RECT: pBrush->BrushStyle = BS_RECTGRADIENT; break; case GRADIENT_RECT: pBrush->BrushStyle = BS_RECTGRADIENT; break;
} }
pBrush->Color.Set(gradient.color1.r>>8, gradient.color1.g>>8, gradient.color1.b>>8); pBrush->Color.Set(gradient.color1.r>>8, gradient.color1.g>>8, gradient.color1.b>>8);
...@@ -760,6 +778,65 @@ void CSvmFile::Read_META_FLOATTRANSPARENT() ...@@ -760,6 +778,65 @@ void CSvmFile::Read_META_FLOATTRANSPARENT()
pBrush->BrushStyleEx = 90 + gradient.angle % 3600; //проверить на разных pBrush->BrushStyleEx = 90 + gradient.angle % 3600; //проверить на разных
m_oPlayer.RegisterObject((CSvmObjectBase*)pBrush); m_oPlayer.RegisterObject((CSvmObjectBase*)pBrush);
//---------------------------------------------------------
CSvmBrush* pBrushCopy = new CSvmBrush(*pBrush);
subMetaFile.m_oPlayer.RegisterObject((CSvmObjectBase*)pBrushCopy);
//---------------------------------------------------------
subMetaFile.m_oStream.SeekToStart();
//CGraphicsRenderer oRenderer;
//TRect *rect = subMetaFile.GetBounds();
//
//int nW = rect->nRight - rect->nLeft;
//int nH = rect->nBottom - rect->nTop;
//
//double dWidth = nW;
//double dHeight = nH;
//BYTE* pBgraData = new BYTE[nW * nH * 4];
//if (!pBgraData)
// return;
// _UINT32 alfa = 0xffffff;
////дефолтный тон должен быть прозрачным, а не белым
////memset(pBgraData, 0xff, nWidth * nHeight * 4);
//for (int i = 0; i < nW * nH; i++)
//{
// ((_UINT32*)pBgraData)[i] = alfa;
//}
//CBgraFrame oFrame;
//oFrame.put_Data(pBgraData);
//oFrame.put_Width(nW);
//oFrame.put_Height(nH);
//oFrame.put_Stride(-4 * nW);
//oRenderer.CreateFromBgraFrame(&oFrame);
//oRenderer.SetSwapRGB(false);
//oRenderer.put_Width(dWidth);
//oRenderer.put_Height(dHeight);
//
//CMetaFileRenderer oSvmOut(&subMetaFile, &oRenderer, 0, 0, dWidth, dHeight);
subMetaFile.SetOutputDevice(m_pOutput);//&oSvmOut);
subMetaFile.PlayMetaFile();
double dX = point.x, dY = point.y, dR = point.x + size.cx, dB = point.y + size.cy;
TranslatePoint(point.x, point.y, dX, dY);
TranslatePoint(point.x + size.cx, point.y + size.cy, dR, dB);
//if (m_pOutput)
//{
// LONG width, height;
// BYTE* bytes = oRenderer.GetPixels(width, height);
// m_pOutput->DrawBitmap(dX, dY, dR - dX, dB - dY, bytes, width, height);
// oFrame.SaveFile(NSFile::CFileBinary::CreateTempFileWithUniqueName(L"d:\\test\\_svm", L"svm"), 1);
//}
} }
void CSvmFile::Read_META_GRADIENT() void CSvmFile::Read_META_GRADIENT()
...@@ -843,6 +920,17 @@ void CSvmFile::Read_META_RASTEROP() ...@@ -843,6 +920,17 @@ void CSvmFile::Read_META_RASTEROP()
m_oStream >> tmp; m_oStream >> tmp;
m_oPlayer.SetRasterOp(tmp); m_oPlayer.SetRasterOp(tmp);
//ROP_OVERPAINT, ROP_XOR, ROP_0, ROP_1, ROP_INVERT
//switch(tmp)
//{
//case 0: if ( m_pOutput) m_pOutput->EndClipPath(0); break;
//case 1: if ( m_pOutput) m_pOutput->StartClipPath(RGN_AND); break;
//case 2: if ( m_pOutput) m_pOutput->StartClipPath(RGN_OR); break;
//case 3: if ( m_pOutput) m_pOutput->StartClipPath(RGN_DIFF); break;
//}
} }
...@@ -967,7 +1055,7 @@ void CSvmFile::Read_META_BMPSCALE() ...@@ -967,7 +1055,7 @@ void CSvmFile::Read_META_BMPSCALE()
{ {
if ( m_pOutput) if ( m_pOutput)
{ {
m_pOutput->DrawBitmap( point.x, point.y, size.cx, size.cy, pBgraBuffer, bitmap_info.nWidth, bitmap_info.nHeight); m_pOutput->DrawBitmap( point.x + m_oCurrnetOffset.x, point.y + m_oCurrnetOffset.y, size.cx, size.cy, pBgraBuffer, bitmap_info.nWidth, bitmap_info.nHeight);
} }
delete []pBgraBuffer; delete []pBgraBuffer;
......
...@@ -17,6 +17,7 @@ class CSvmFile : virtual public IMetaFileBase ...@@ -17,6 +17,7 @@ class CSvmFile : virtual public IMetaFileBase
m_currentActionVersion = 0; m_currentActionVersion = 0;
m_currentCharset = 0; m_currentCharset = 0;
m_currentActionType = 0; m_currentActionType = 0;
m_bMainStream = true;
}; };
CSvmFile(BYTE *Data, int DataSize): m_oPlayer(this) CSvmFile(BYTE *Data, int DataSize): m_oPlayer(this)
{ {
...@@ -26,6 +27,7 @@ class CSvmFile : virtual public IMetaFileBase ...@@ -26,6 +27,7 @@ class CSvmFile : virtual public IMetaFileBase
m_currentActionVersion = 0; m_currentActionVersion = 0;
m_currentCharset = 0; m_currentCharset = 0;
m_currentActionType = 0; m_currentActionType = 0;
m_bMainStream = true;
} }
~CSvmFile() ~CSvmFile()
...@@ -151,10 +153,12 @@ class CSvmFile : virtual public IMetaFileBase ...@@ -151,10 +153,12 @@ class CSvmFile : virtual public IMetaFileBase
} }
private: private:
TSvmPoint m_oCurrnetOffset;
BYTE* m_pBufferData; BYTE* m_pBufferData;
CSvmDC* m_pDC; CSvmDC* m_pDC;
CSvmPlayer m_oPlayer; CSvmPlayer m_oPlayer;
SvmHeader m_oHeader; SvmHeader m_oHeader;
bool m_bMainStream;
unsigned short m_currentActionVersion; unsigned short m_currentActionVersion;
unsigned short m_currentCharset; unsigned short m_currentCharset;
...@@ -195,6 +199,7 @@ class CSvmFile : virtual public IMetaFileBase ...@@ -195,6 +199,7 @@ class CSvmFile : virtual public IMetaFileBase
void Read_META_GRADIENTEX(); void Read_META_GRADIENTEX();
void Read_META_TRANSPARENT(); void Read_META_TRANSPARENT();
void Read_META_FLOATTRANSPARENT(); void Read_META_FLOATTRANSPARENT();
void Read_META_LAYOUTMODE();
void Read_META_SECTRECTCLIPREGION(); void Read_META_SECTRECTCLIPREGION();
void Read_META_SECTREGIONCLIPREGION(); void Read_META_SECTREGIONCLIPREGION();
...@@ -215,8 +220,8 @@ class CSvmFile : virtual public IMetaFileBase ...@@ -215,8 +220,8 @@ class CSvmFile : virtual public IMetaFileBase
//TSvmWindow* pWindow = m_pDC->GetWindow(); //TSvmWindow* pWindow = m_pDC->GetWindow();
//TSvmWindow* pViewport = m_pDC->GetViewport(); //TSvmWindow* pViewport = m_pDC->GetViewport();
dX = (double)(nX) * m_pDC->m_dPixelWidth ; //dX = (double)(nX) * m_pDC->m_dPixelWidth ;
dY = (double)(nY) * m_pDC->m_dPixelHeight ; //dY = (double)(nY) * m_pDC->m_dPixelHeight ;
//dX = (double)((double)(nX - pWindow->lX) * m_pDC->m_dPixelWidth) + pViewport->lX; //dX = (double)((double)(nX - pWindow->lX) * m_pDC->m_dPixelWidth) + pViewport->lX;
//dY = (double)((double)(nY - pWindow->lY) * m_pDC->m_dPixelHeight) + pViewport->lY; //dY = (double)((double)(nY - pWindow->lY) * m_pDC->m_dPixelHeight) + pViewport->lY;
......
...@@ -542,9 +542,7 @@ void CSvmDC::SetMapMode(TSvmMapMode & mapMode, bool prefered ) ...@@ -542,9 +542,7 @@ void CSvmDC::SetMapMode(TSvmMapMode & mapMode, bool prefered )
{ {
m_dPixelHeightPrefered = m_dPixelHeight; m_dPixelHeightPrefered = m_dPixelHeight;
m_dPixelWidthPrefered = m_dPixelWidth; m_dPixelWidthPrefered = m_dPixelWidth;
} }
} }
TXForm* CSvmDC::GetTransform() TXForm* CSvmDC::GetTransform()
......
...@@ -41,15 +41,12 @@ private: ...@@ -41,15 +41,12 @@ private:
typedef std::map < unsigned int, CSvmObjectBase* > CSvmObjectMap; typedef std::map < unsigned int, CSvmObjectBase* > CSvmObjectMap;
CSvmDC* m_pDC; CSvmDC* m_pDC;
std::vector<CSvmDC*> m_vDCStack; std::vector<CSvmDC*> m_vDCStack;
CSvmFile* m_pFile; CSvmFile* m_pFile;
CSvmObjectMap m_mObjects; CSvmObjectMap m_mObjects;
int m_nFlags; int m_nFlags;
ESvnRasterOp m_eRasterOp; ESvnRasterOp m_eRasterOp;
typedef std::map <unsigned int, CWmfObjectBase*> CWmfObjectMap;
unsigned short m_ushIndex; unsigned short m_ushIndex;
std::vector<unsigned short> m_vAvailableIndexes; std::vector<unsigned short> m_vAvailableIndexes;
......
...@@ -78,7 +78,7 @@ void main() ...@@ -78,7 +78,7 @@ void main()
oFonts.Initialize(); oFonts.Initialize();
CMetaFile oMetaFile(&oFonts); CMetaFile oMetaFile(&oFonts);
ConvertFolder(oMetaFile, L"D://test//_svm//5//", c_lMetaSvm); ConvertFolder(oMetaFile, L"D://test//_svm//1//", c_lMetaSvm);
//ConvertFolder(oMetaFile, L"D://Test Files//Wmf//Test//", c_lMetaWmf); //ConvertFolder(oMetaFile, L"D://Test Files//Wmf//Test//", c_lMetaWmf);
//ConvertFolder(oMetaFile, L"D://Test Files//Emf//Temp//", c_lMetaEmf); //ConvertFolder(oMetaFile, L"D://Test Files//Emf//Temp//", c_lMetaEmf);
......
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