Compare commits

...

1 Commits

Author SHA1 Message Date
bd1dc5a7b6 . 2018-09-17 17:28:46 +03:00
5 changed files with 109 additions and 53 deletions

View File

@ -407,6 +407,7 @@ void draw_enhanced_geometry_attlist::serialize(CP_ATTR_NODE)
CP_XML_ATTR_OPT(L"draw:type", draw_type_);
CP_XML_ATTR_OPT(L"drawooo:sub-view-size", draw_sub_view_size_);
CP_XML_ATTR_OPT(L"draw:text-areas", draw_text_areas_);
CP_XML_ATTR_OPT(L"draw:text-rotate-angle", draw_text_rotate_angle_);
CP_XML_ATTR_OPT(L"draw:modifiers", draw_modifiers_);
CP_XML_ATTR_OPT(L"drawooo:enhanced-path", draw_enhanced_path_);
//CP_XML_ATTR_OPT(L"draw:enhanced-path", draw_enhanced_path_);
@ -430,7 +431,7 @@ void draw_enhanced_geometry::serialize(std::wostream & _Wostream)
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"svg:viewBox", svg_viewbox_);
draw_enhanced_geometry_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
for (size_t i = 0; i < draw_equation_.size(); i++)
{

View File

@ -331,6 +331,8 @@ public:
_CP_OPT(odf_types::Bool) draw_text_path_same_letter_heights_;
_CP_OPT(std::wstring) draw_text_path_mode_;
_CP_OPT(std::wstring) draw_text_path_scale_;
_CP_OPT(int) draw_text_rotate_angle_;
void serialize(CP_ATTR_NODE);
};
@ -350,7 +352,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
draw_enhanced_geometry_attlist draw_enhanced_geometry_attlist_;
draw_enhanced_geometry_attlist attlist_;
_CP_OPT(std::wstring) svg_viewbox_;

View File

@ -186,6 +186,7 @@ struct odf_drawing_state
presentation_placeholder_ = boost::none;
rotateAngle_ = boost::none;
text_rotateAngle_ = boost::none;
path_ = L"";
view_box_ = L"";
@ -218,6 +219,7 @@ struct odf_drawing_state
_CP_OPT(double) rotateAngle_;
_CP_OPT(unsigned int) fill_color_;
_CP_OPT(int) text_rotateAngle_;
_CP_OPT(presentation_class) presentation_class_;
_CP_OPT(std::wstring) presentation_placeholder_;
@ -232,6 +234,7 @@ struct odf_drawing_state
int oox_shape_preset_;
bool in_group_;
bool text_box_tableframe_;
};
class odf_drawing_context::Impl
@ -536,7 +539,7 @@ void odf_drawing_context::end_drawing()
if (impl_->current_drawing_state_.rotateAngle_)
rotate += *impl_->current_drawing_state_.rotateAngle_;
if (fabs(rotate)>0.001)impl_->current_drawing_state_.rotateAngle_ = rotate;
if (fabs(rotate) > 0.001)impl_->current_drawing_state_.rotateAngle_ = rotate;
}
double x = impl_->current_drawing_state_.svg_x_ ? impl_->current_drawing_state_.svg_x_->get_value() : 0;
double y = impl_->current_drawing_state_.svg_y_ ? impl_->current_drawing_state_.svg_y_->get_value() : 0;
@ -615,8 +618,8 @@ void odf_drawing_context::end_drawing()
draw_enhanced_geometry* enhan = dynamic_cast<draw_enhanced_geometry*>(custom->draw_enhanced_geometry_.get());
if(enhan)
{
if (impl_->current_drawing_state_.flipV_) enhan->draw_enhanced_geometry_attlist_.draw_mirror_vertical_ = true;
if (impl_->current_drawing_state_.flipH_) enhan->draw_enhanced_geometry_attlist_.draw_mirror_horizontal_ = true;
if (impl_->current_drawing_state_.flipV_) enhan->attlist_.draw_mirror_vertical_ = true;
if (impl_->current_drawing_state_.flipH_) enhan->attlist_.draw_mirror_horizontal_ = true;
}
}else
{
@ -986,15 +989,17 @@ void odf_drawing_context::end_shape()
{
if (text_shape)
{
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_same_letter_heights_ = false;
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_scale_ = L"path" ;
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_mode_ = L"shape" ;
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_ = true;
enhanced->attlist_.draw_text_path_same_letter_heights_ = false;
enhanced->attlist_.draw_text_path_scale_ = L"path" ;
enhanced->attlist_.draw_text_path_mode_ = L"shape" ;
enhanced->attlist_.draw_text_path_ = true;
enhanced->attlist_.draw_text_rotate_angle_ = impl_->current_drawing_state_.text_rotateAngle_;
}
if (!impl_->current_drawing_state_.path_.empty())
{
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ =impl_->current_drawing_state_.path_;
enhanced->attlist_.draw_enhanced_path_ =impl_->current_drawing_state_.path_;
}
if (!impl_->current_drawing_state_.view_box_.empty())
{
@ -1002,7 +1007,7 @@ void odf_drawing_context::end_shape()
}
if (!sub_type.empty())
{
enhanced->draw_enhanced_geometry_attlist_.draw_type_ = sub_type;
enhanced->attlist_.draw_type_ = sub_type;
}
else
{
@ -1018,23 +1023,23 @@ void odf_drawing_context::end_shape()
else
enhanced->svg_viewbox_ = shape_define->view_box;
enhanced->draw_enhanced_geometry_attlist_.draw_type_ = shape_define->odf_type_name;
enhanced->draw_enhanced_geometry_attlist_.draw_text_areas_ = shape_define->text_areas;
enhanced->attlist_.draw_type_ = shape_define->odf_type_name;
enhanced->attlist_.draw_text_areas_ = shape_define->text_areas;
enhanced->draw_enhanced_geometry_attlist_.draw_glue_points_ = shape_define->glue_points;
enhanced->draw_enhanced_geometry_attlist_.draw_sub_view_size_ = shape_define->sub_view_size;
enhanced->attlist_.draw_glue_points_ = shape_define->glue_points;
enhanced->attlist_.draw_sub_view_size_ = shape_define->sub_view_size;
if (impl_->current_drawing_state_.oox_shape_ && !impl_->current_drawing_state_.oox_shape_->modifiers.empty())
{
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.oox_shape_->modifiers;
enhanced->attlist_.draw_modifiers_ = impl_->current_drawing_state_.oox_shape_->modifiers;
}
else // обязательно нужны дефолтовые
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = shape_define->modifiers;
enhanced->attlist_.draw_modifiers_ = shape_define->modifiers;
if (!shape_define->enhanced_path.empty())
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = shape_define->enhanced_path;
enhanced->attlist_.draw_enhanced_path_ = shape_define->enhanced_path;
else
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = impl_->current_drawing_state_.path_;
enhanced->attlist_.draw_enhanced_path_ = impl_->current_drawing_state_.path_;
for (size_t i = 0; i < shape_define->equations.size(); i++)
{
@ -1074,6 +1079,18 @@ void odf_drawing_context::end_shape()
}
end_element();
}
if (impl_->current_drawing_state_.flipV_)
{
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"vertical");
}
if (impl_->current_drawing_state_.flipH_)
{
if (impl_->current_graphic_properties->style_mirror_)
impl_->current_graphic_properties->style_mirror_ = *impl_->current_graphic_properties->style_mirror_ + std::wstring(L" horizontal");
else
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"horizontal");
}
end_element();
}
@ -1599,26 +1616,10 @@ void odf_drawing_context::set_viewBox (double W, double H)
void odf_drawing_context::set_flip_H(bool bVal)
{
impl_->current_drawing_state_.flipH_ = bVal;
if (impl_->current_graphic_properties == NULL) return;
if (bVal == false)return;
//for image
if (impl_->current_graphic_properties->style_mirror_)
impl_->current_graphic_properties->style_mirror_ = *impl_->current_graphic_properties->style_mirror_ + std::wstring(L" horizontal");
else
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"horizontal");
}
void odf_drawing_context::set_flip_V(bool bVal)
{
impl_->current_drawing_state_.flipV_ = bVal;
if (impl_->current_graphic_properties == NULL) return;
if (bVal == false)return;
//for image
if (impl_->current_graphic_properties->style_mirror_)
impl_->current_graphic_properties->style_mirror_ = *impl_->current_graphic_properties->style_mirror_ + std::wstring(L" vertical");
else
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"vertical");
}
void odf_drawing_context::set_rotate(double dVal)
@ -2278,6 +2279,33 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
if (mode == 1) return;//незачем
if (impl_->current_drawing_state_.elements_.empty())return;
if (impl_->current_drawing_state_.oox_shape_preset_ > 2000 && impl_->current_drawing_state_.oox_shape_preset_ < 3000)
{
switch(mode)
{
case 5://textverticaltypeWordArtVert:
case 6://textverticaltypeWordArtVertRtl:
case 3://SimpleTypes::textverticaltypeVert:
case 2://SimpleTypes::textverticaltypeMongolianVert:
case 0://SimpleTypes::textverticaltypeEaVert:
impl_->current_drawing_state_.rotateAngle_ = 90. / 180. * 3.14159265358979323846;
break;
case 4://SimpleTypes::textverticaltypeVert270:
impl_->current_drawing_state_.rotateAngle_ = 270. / 180. * 3.14159265358979323846;
break;
case 1://SimpleTypes::textverticaltypeHorz:
default:
break;
}
if (impl_->current_drawing_state_.flipH_ && impl_->current_drawing_state_.rotateAngle_ )
{
impl_->current_drawing_state_.rotateAngle_ = - *impl_->current_drawing_state_.rotateAngle_;
impl_->current_drawing_state_.flipH_ = false;
}
return;
}
if (!impl_->current_paragraph_properties)
{
style* style_ = dynamic_cast<style*>(impl_->current_drawing_state_.elements_[0].style_elm.get());
@ -2647,7 +2675,13 @@ void odf_drawing_context::end_image()
end_shape();
return;
}
if (impl_->current_drawing_state_.flipH_)
{
if (impl_->current_graphic_properties->style_mirror_)
impl_->current_graphic_properties->style_mirror_ = *impl_->current_graphic_properties->style_mirror_ + std::wstring(L" horizontal");
else
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"horizontal");
}
end_element();
end_frame();
}
@ -2860,10 +2894,20 @@ void odf_drawing_context::start_gradient_style()
if (gradient->draw_start_color_) gradient->draw_start_intensity_ = 100.;
gradient->draw_border_ = 0;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_gradient_name_ = gradient->draw_name_;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_ = draw_fill(draw_fill::gradient);
switch(impl_->current_drawing_part_)
{
case Area:
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_gradient_name_ = gradient->draw_name_;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_ = draw_fill(draw_fill::gradient);
break;
case Line:
if (!impl_->current_graphic_properties->draw_stroke_)
impl_->current_graphic_properties->draw_stroke_ = line_style(line_style::Solid);//default
if (!impl_->current_graphic_properties->svg_stroke_width_)
impl_->current_graphic_properties->svg_stroke_width_ = length(length(1, length::pt).get_value_unit(length::cm), length::cm);//default
break;
}
}
void odf_drawing_context::set_gradient_type(gradient_style::type style)
{
@ -2882,6 +2926,11 @@ void odf_drawing_context::set_gradient_start(std::wstring hexColor, _CP_OPT(doub
gradient->draw_start_color_ = hexColor;
gradient->draw_start_intensity_ = 100.;
if (impl_->current_drawing_part_ == Line)
{
impl_->current_graphic_properties->svg_stroke_color_ = hexColor;
}
}
void odf_drawing_context::set_gradient_end (std::wstring hexColor, _CP_OPT(double) & intensiv)
{

View File

@ -1067,8 +1067,13 @@ void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB)
std::wstring hexColorStart, hexColorEnd;
_CP_OPT(double) opacityStart, opacityEnd;
convert(&oox_grad_fill->GsLst[0].color,hexColorEnd, opacityEnd, nARGB);
convert(&oox_grad_fill->GsLst[oox_grad_fill->GsLst.size()-1].color,hexColorStart, opacityStart, nARGB);
convert(&oox_grad_fill->GsLst[0].color, hexColorEnd, opacityEnd, nARGB);
convert(&oox_grad_fill->GsLst[oox_grad_fill->GsLst.size() - 1].color, hexColorStart, opacityStart, nARGB);
if (hexColorEnd == hexColorStart && opacityEnd == opacityStart && oox_grad_fill->GsLst.size() > 2)
{
convert(&oox_grad_fill->GsLst[oox_grad_fill->GsLst.size() / 2].color, hexColorStart, opacityStart, nARGB);
}
odf_context()->drawing_context()->set_gradient_start(hexColorStart, opacityStart);
odf_context()->drawing_context()->set_gradient_end (hexColorEnd, opacityEnd);
@ -1253,6 +1258,16 @@ void OoxConverter::convert(PPTX::Logic::BodyPr *oox_bodyPr)
{
if (!oox_bodyPr) return;
if ((oox_bodyPr->fromWordArt.IsInit() && (*oox_bodyPr->fromWordArt)) && oox_bodyPr->prstTxWarp.IsInit())
{
for (size_t i = 0; i < oox_bodyPr->prstTxWarp->avLst.size(); i++)
{
if (oox_bodyPr->prstTxWarp->avLst[i].fmla.IsInit())
{
odf_context()->drawing_context()->add_modifier(oox_bodyPr->prstTxWarp->avLst[i].fmla.get());
}
}
}
if (oox_bodyPr->vert.IsInit())
{
odf_context()->drawing_context()->set_textarea_writing_mode (oox_bodyPr->vert->GetBYTECode());
@ -1300,17 +1315,6 @@ void OoxConverter::convert(PPTX::Logic::BodyPr *oox_bodyPr)
{
}
}
if ((oox_bodyPr->fromWordArt.IsInit() && (*oox_bodyPr->fromWordArt)) && oox_bodyPr->prstTxWarp.IsInit())
{
for (size_t i = 0; i < oox_bodyPr->prstTxWarp->avLst.size(); i++)
{
if (oox_bodyPr->prstTxWarp->avLst[i].fmla.IsInit())
{
odf_context()->drawing_context()->add_modifier(oox_bodyPr->prstTxWarp->avLst[i].fmla.get());
}
}
}
}
void OoxConverter::convert(PPTX::Logic::NvSpPr *oox_nvSpPr)
{

View File

@ -2245,7 +2245,7 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
}
bool set_color = false;
if (oox_run_pr->m_oTextFill.getType() == OOX::et_a_gradFill || oox_run_pr->m_oTextOutline.IsInit())
if (oox_run_pr->m_oTextFill.is_init() || oox_run_pr->m_oTextOutline.is_init())
{
odf_writer::odf_drawing_context *drawing_context = odf_context()->drawing_context();
if (drawing_context)