diff --git a/ASCOfficeOdfFile/src/odf/datatypes/length.cpp b/ASCOfficeOdfFile/src/odf/datatypes/length.cpp index ef043891ed..b54d33f16c 100644 --- a/ASCOfficeOdfFile/src/odf/datatypes/length.cpp +++ b/ASCOfficeOdfFile/src/odf/datatypes/length.cpp @@ -46,6 +46,22 @@ std::wostream & operator << (std::wostream & _Wostream, const length & _Length) _Wostream << _Length.get_value() << _Length.get_unit(); return _Wostream; } +length operator + (length & _Length1, length & _Length2) +{ + return length(_Length1.get_value() + _Length2.get_value(),_Length1.get_unit()); //проверка на одинаковость типа .. или приведение к одному +} +length operator - (length & _Length1, length & _Length2) +{ + return length(_Length1.get_value() - _Length2.get_value(),_Length1.get_unit()); //проверка на одинаковость типа .. или приведение к одному +} +length operator / (length & _Length1, double val) +{ + return length(_Length1.get_value() / val ,_Length1.get_unit()); +} +length operator * (length & _Length1, double val) +{ + return length(_Length1.get_value() * val ,_Length1.get_unit()); +} length length::parse(const std::wstring & Str) { diff --git a/ASCOfficeOdfFile/src/odf/datatypes/length.h b/ASCOfficeOdfFile/src/odf/datatypes/length.h index d477aedd7b..9acd6cfa0f 100644 --- a/ASCOfficeOdfFile/src/odf/datatypes/length.h +++ b/ASCOfficeOdfFile/src/odf/datatypes/length.h @@ -47,6 +47,11 @@ private: std::wostream & operator << (std::wostream & _Wostream, const length::unit _Unit); std::wostream & operator << (std::wostream & _Wostream, const length & _Length); +length operator + (length & _Length1, length & _Length2); +length operator - (length & _Length1, length & _Length2); +length operator / (length & _Length1, double val); +length operator * (length & _Length1, double val); + typedef length coordinate; } diff --git a/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp b/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp index fa0b525f54..c93edda88a 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp @@ -398,6 +398,7 @@ void draw_enhanced_geometry_attlist::serialize(CP_ATTR_NODE) { CP_XML_ATTR_OPT(L"draw:type", draw_type_); CP_XML_ATTR_OPT(L"draw:modifiers", draw_modifiers_); + CP_XML_ATTR_OPT(L"draw:enhanced-path", draw_enhanced_path_); } // draw:enhanced_geometry const wchar_t * draw_enhanced_geometry::ns = L"draw"; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h b/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h index d2ad2ef9d7..2b41832e54 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h @@ -299,6 +299,7 @@ class draw_enhanced_geometry_attlist public: _CP_OPT(std::wstring) draw_type_; _CP_OPT(std::wstring) draw_modifiers_; + _CP_OPT(std::wstring) draw_enhanced_path_; void serialize(CP_ATTR_NODE); }; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp index ef5996031a..a39b5cf5f0 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp @@ -53,6 +53,12 @@ struct odf_drawing_state flipH = false; flipV = false; tile = false; + + path_ = L""; + view_box_ = L""; + path_last_command_ = L""; + + fill_ = true; //потом по нормальному .. с типами } std::vector elements_; @@ -68,6 +74,12 @@ struct odf_drawing_state bool flipV; bool tile; _CP_OPT(double) rotateAngle; + + std::wstring path_; + std::wstring view_box_; + std::wstring path_last_command_; + + bool fill_; }; class odf_drawing_context::Impl @@ -169,7 +181,18 @@ void odf_drawing_context::end_drawing()// std::wstring strTransform; if (impl_->current_drawing_state_.rotateAngle) { - strTransform = strTransform + std::wstring(L"rotate(") + boost::lexical_cast(impl_->current_drawing_state_.rotateAngle.get()) + std::wstring(L")"); + strTransform = std::wstring(L"rotate(") + boost::lexical_cast(impl_->current_drawing_state_.rotateAngle.get()) + std::wstring(L")"); + //так как вращения все в мс относительно центра фигуры, а не от начала координат - убираем смещение + if (impl_->current_drawing_state_.svg_x_ && impl_->current_drawing_state_.svg_y_) + { + strTransform += std::wstring(L" translate(") + boost::lexical_cast(impl_->current_drawing_state_.svg_x_.get() + + (impl_->current_drawing_state_.svg_width_.get()/2))+ std::wstring(L",") + + boost::lexical_cast(impl_->current_drawing_state_.svg_y_.get() + + (impl_->current_drawing_state_.svg_height_.get()/2))+ std::wstring(L")") ; + } + + impl_->current_drawing_state_.svg_x_ = boost::none; + impl_->current_drawing_state_.svg_y_ = boost::none; } if (strTransform.length()>0) frame->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_transform_attlist_.draw_transform_ = strTransform; @@ -188,19 +211,39 @@ void odf_drawing_context::end_drawing()// shape->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_z_index_attlist_.draw_z_index_ = impl_->current_drawing_state_.z_order_; std::wstring strTransform; - if (impl_->current_drawing_state_.rotateAngle!=0) + if (impl_->current_drawing_state_.rotateAngle) { - strTransform = strTransform + std::wstring(L"rotate(") + boost::lexical_cast(impl_->current_drawing_state_.rotateAngle.get()) + std::wstring(L")"); + strTransform = std::wstring(L"rotate(") + boost::lexical_cast(impl_->current_drawing_state_.rotateAngle.get()) + std::wstring(L")"); + //так как вращения все в мс относительно центра фигуры, а не от начала координат - убираем смещение + if (impl_->current_drawing_state_.svg_x_ && impl_->current_drawing_state_.svg_y_) + { + strTransform += std::wstring(L" translate(") + boost::lexical_cast(impl_->current_drawing_state_.svg_x_.get() + + (impl_->current_drawing_state_.svg_width_.get()/2))+ std::wstring(L",") + + boost::lexical_cast(impl_->current_drawing_state_.svg_y_.get() + + (impl_->current_drawing_state_.svg_height_.get()/2))+ std::wstring(L")") ; + } + + impl_->current_drawing_state_.svg_x_ = boost::none; + impl_->current_drawing_state_.svg_y_ = boost::none; } if (strTransform.length()>0) - frame->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_transform_attlist_.draw_transform_ = strTransform; + shape->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_transform_attlist_.draw_transform_ = strTransform; shape->common_draw_attlists_.position_.svg_x_ = impl_->current_drawing_state_.svg_x_; shape->common_draw_attlists_.position_.svg_y_ = impl_->current_drawing_state_.svg_y_; shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = impl_->current_drawing_state_.svg_height_; shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = impl_->current_drawing_state_.svg_width_; + + draw_path* path = dynamic_cast(impl_->current_drawing_state_.elements_[0].elm.get()); + if (path) + { + if (impl_->current_drawing_state_.path_.length()>1) + path->draw_path_attlist_.svg_d_ = impl_->current_drawing_state_.path_; + if (impl_->current_drawing_state_.view_box_.length()>1) + path->draw_path_attlist_.svg_viewbox_ = impl_->current_drawing_state_.view_box_; + } } - +/////////////////////////////////////////////////// style* style_ = dynamic_cast(impl_->current_drawing_state_.elements_[0].style_elm.get()); if (style_) { @@ -212,6 +255,8 @@ void odf_drawing_context::end_drawing()// if (impl_->current_drawing_state_.flipV) gr_properties->content().style_mirror_ = std::wstring(L"vertical"); + if (impl_->current_drawing_state_.fill_ == false) + gr_properties->content().common_draw_fill_attlist_.draw_fill_ = draw_fill::none; //fo:clip //draw:image-opacity } @@ -225,11 +270,30 @@ void odf_drawing_context::set_name(std::wstring name) { impl_->current_drawing_state_.name_ = name; } +void odf_drawing_context::set_no_fill() +{ + impl_->current_drawing_state_.fill_ = false; +} void odf_drawing_context::set_z_order(int id) { impl_->current_drawing_state_.z_order_ = id; } +void odf_drawing_context::add_path_element(std::wstring command, std::wstring & strE) +{ + if (command != impl_->current_drawing_state_.path_last_command_) + { + impl_->current_drawing_state_.path_ += command + L" "; + impl_->current_drawing_state_.path_last_command_ = command; + } + + impl_->current_drawing_state_.path_ += strE + L" "; +} + +void odf_drawing_context::set_viewBox(double W, double H) +{ + impl_->current_drawing_state_.view_box_ = std::wstring(L"0 0 ") + boost::lexical_cast((int)W) + L" " + boost::lexical_cast((int)H); +} void odf_drawing_context::set_flip_H(bool bVal) { impl_->current_drawing_state_.flipH= true; @@ -300,23 +364,44 @@ void odf_drawing_context::start_shape(int type, std::wstring & sub_type) impl_->current_drawing_state_.elements_.push_back(state); ////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (sub_type.length()>0 && shape_elm) + if (type == 7 && shape_elm) //custom shape { office_element_ptr enhanced_elm; create_element(L"draw", L"enhanced-geometry", enhanced_elm, impl_->odf_context_); + + start_element(enhanced_elm); + draw_enhanced_geometry* enhanced = dynamic_cast(enhanced_elm.get()); if (enhanced) { - enhanced->draw_enhanced_geometry_attlist_.draw_type_ = sub_type; + if (sub_type.length()>1) + { + enhanced->draw_enhanced_geometry_attlist_.draw_type_ = sub_type; + } + if (impl_->current_drawing_state_.path_.length()>1) + { + enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ =impl_->current_drawing_state_.path_; + } + if (impl_->current_drawing_state_.view_box_.length()>1) + { + enhanced->svg_viewbox_ = impl_->current_drawing_state_.view_box_; + } } - start_element(enhanced_elm); -///.... - end_element(); } } void odf_drawing_context::end_shape() { + //вторичные, вычисляемые свойства шейпов + draw_line* line = dynamic_cast(impl_->current_level_.back().get()); + if (line) + { + line->draw_line_attlist_.svg_x1_ = impl_->current_drawing_state_.svg_x_; + line->draw_line_attlist_.svg_y1_ = impl_->current_drawing_state_.svg_y_; + line->draw_line_attlist_.svg_x2_ = impl_->current_drawing_state_.svg_x_.get() + impl_->current_drawing_state_.svg_width_.get(); + line->draw_line_attlist_.svg_y2_ = impl_->current_drawing_state_.svg_y_.get() + impl_->current_drawing_state_.svg_height_.get(); + } + end_element(); } void odf_drawing_context::start_element(office_element_ptr & elm) @@ -353,7 +438,7 @@ bool odf_drawing_context::is_exist_content() void odf_drawing_context::finalize(office_element_ptr & root_elm) { - for (int i=0; i< impl_->drawing_list_.size()>0; i++) + for (int i=0; i< impl_->drawing_list_.size(); i++) { if (impl_->drawing_list_[i].elements_.size() > 0) { @@ -366,6 +451,9 @@ office_element_ptr odf_drawing_context::create_shape(int type) office_element_ptr element; switch(type) { + case 0: + create_element(L"draw", L"frame", element, impl_->odf_context_); + break; case 1: create_element(L"draw", L"caption", element, impl_->odf_context_); break; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h index 054436d919..d93e9e2d30 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h @@ -48,6 +48,12 @@ public: bool is_exist_content(); + //void start_path(int W, int H); + //void end_path(); + + void add_path_element(std::wstring command, std::wstring & elm); + void set_viewBox(double W, double H); + void finalize(office_element_ptr & root_elm); /////////////////////////////////////////////////// @@ -61,6 +67,8 @@ public: void set_rotate(int iVal); + void set_no_fill(); + private: office_element_ptr create_shape(int type); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp index b816d9093b..94b679fb85 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp @@ -13,6 +13,10 @@ namespace Oox2Odf { + static double pt2emu(double Val) + { + return (Val * 360000 * 2.54) / 72; + } Converter::Converter(const std::wstring & path) { std::wstring type = L"spreadsheet"; @@ -28,7 +32,7 @@ namespace Oox2Odf void Converter::convert() { if (!impl_)return; - impl_->convert(); + impl_->convertDocument(); } void Converter::write(const std::wstring & path) const { @@ -36,6 +40,61 @@ namespace Oox2Odf } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// +void OoxConverter::convert(OOX::WritingElement *oox_unknown) +{ + if (oox_unknown == NULL)return; + + switch(oox_unknown->getType()) + { + case OOX::et_a_prstGeom: + { + OOX::Drawing::CPresetGeometry2D* pPresetGeom = static_cast(oox_unknown); + convert(pPresetGeom); + }break; + case OOX::et_a_custGeom: + { + OOX::Drawing::CCustomGeometry2D* pCustomGeom = static_cast(oox_unknown); + convert(pCustomGeom); + }break; + case OOX::et_a_lnTo: + { + OOX::Drawing::CPath2DLineTo* pLineTo = static_cast(oox_unknown); + convert(pLineTo); + }break; + case OOX::et_a_moveTo: + { + OOX::Drawing::CPath2DMoveTo* pMoveTo = static_cast(oox_unknown); + convert(pMoveTo); + }break; + case OOX::et_a_arcTo: + { + OOX::Drawing::CPath2DArcTo* pArcTo = static_cast(oox_unknown); + convert(pArcTo); + }break; + case OOX::et_a_quadBezTo: + { + OOX::Drawing::CPath2DQuadBezierTo* pQuadBezierTo = static_cast(oox_unknown); + convert(pQuadBezierTo); + }break; + case OOX::et_a_cubicBezTo: + { + OOX::Drawing::CPath2DCubicBezierTo* pCubicBezierT = static_cast(oox_unknown); + convert(pCubicBezierT); + }break; + case OOX::et_a_close: + { + OOX::Drawing::CPath2DClose* pClose= static_cast(oox_unknown); + convert(pClose); + }break; + default: + { + std::wstringstream ss; + ss << L"[warning] : no convert element(" << oox_unknown->getType() << L")\n"; + _CP_LOG(error) << ss.str(); + } + } +} + void OoxConverter::convert_SpPr(OOX::Drawing::CShapeProperties * oox_spPr) { if (!oox_spPr) return; @@ -64,6 +123,8 @@ void OoxConverter::convert_SpPr(OOX::Drawing::CShapeProperties * oox_spPr) if(oox_spPr->m_oSolidFill.IsInit())convert(oox_spPr->m_oSolidFill.GetPointer());break; case OOX::Drawing::filltypeGroup: case OOX::Drawing::filltypeNo: + odf_context()->drawing_context().set_no_fill(); + break; case OOX::Drawing::filltypeUnknown: default: break; } @@ -104,26 +165,35 @@ void OoxConverter::convert_CNvPr(OOX::Drawing::CNonVisualDrawingProps * oox_cnvP //nullable m_sDescr; //nullable> m_oHidden; //nullable m_sTitle; - } -void OoxConverter::convert(OOX::Drawing::CCustomGeometry2D *oox_cust_geom) +void OoxConverter::convert/*_CustGeom*/(OOX::Drawing::CCustomGeometry2D *oox_cust_geom) { if (!oox_cust_geom)return; - //odf_context()->drawing_context().set_shape_type(); - - - + for (long i=0; i< oox_cust_geom->m_oPthLst.m_arrPath.GetSize();i++) + { + convert(&oox_cust_geom->m_oPthLst.m_arrPath[i]); + } } -void OoxConverter::convert(OOX::Drawing::CPresetGeometry2D *oox_prst_geom) +void OoxConverter::convert/*_PrstGeom*/(OOX::Drawing::CPresetGeometry2D *oox_prst_geom) { if (!oox_prst_geom)return; - //odf_context()->drawing_context().set_shape_type(); + // +} +void OoxConverter::convert(OOX::Drawing::CPath2D *oox_geom_path) +{ + if (!oox_geom_path) return; + odf_context()->drawing_context().set_viewBox(oox_geom_path->m_oW.GetValue(), oox_geom_path->m_oH.GetValue()); + + for (long i =0 ; i< oox_geom_path->m_arrItems.GetSize(); i++) + { + convert(oox_geom_path->m_arrItems[i]); + } } ////////////////////////////////////////////////////////////////////////////////////////// void OoxConverter::convert(OOX::Drawing::CBlipFillProperties *oox_bitmap_fill) @@ -143,5 +213,67 @@ void OoxConverter::convert(OOX::Drawing::CSolidColorFillProperties *oox_solid_fi { if (!oox_solid_fill)return; } +void OoxConverter::convert(OOX::Drawing::CPath2DLineTo *oox_geom_path) +{ + if (!oox_geom_path) return; + std::wstring path_elm = boost::lexical_cast ( (int)pt2emu(oox_geom_path->m_oPt.m_oX.GetValue())) + + std::wstring(L" ")+ boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oPt.m_oY.GetValue())); + + odf_context()->drawing_context().add_path_element(std::wstring(L"L"), path_elm); +} +void OoxConverter::convert(OOX::Drawing::CPath2DMoveTo *oox_geom_path) +{ + if (!oox_geom_path) return; + + std::wstring path_elm = boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oPt.m_oX.GetValue())) + + std::wstring(L" ")+ boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oPt.m_oY.GetValue())); + + odf_context()->drawing_context().add_path_element(std::wstring(L"M"), path_elm); +} +void OoxConverter::convert(OOX::Drawing::CPath2DArcTo *oox_geom_path) +{ + if (!oox_geom_path) return; + + //std::wstring path_elm = boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oPt.m_oX.GetValue())) + + // std::wstring(L" ")+ boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oPt.m_oY.GetValue())); + // + //odf_context()->drawing_context().add_path_element(std::wstring(L"A"), path_elm); +} +void OoxConverter::convert(OOX::Drawing::CPath2DQuadBezierTo *oox_geom_path) +{ + if (!oox_geom_path) return; + + std::wstring path_elm = boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oCtrl.m_oX.GetValue())) + + std::wstring(L" ") + boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oCtrl.m_oY.GetValue())) + + std::wstring(L" ") + boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oEnd.m_oX.GetValue())) + + std::wstring(L" ") + boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oEnd.m_oY.GetValue())) ; + + odf_context()->drawing_context().add_path_element(std::wstring(L"S"), path_elm); + +} +void OoxConverter::convert(OOX::Drawing::CPath2DCubicBezierTo *oox_geom_path) +{ + if (!oox_geom_path) return; + + std::wstring path_elm = boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oCtrl1.m_oX.GetValue())) + + std::wstring(L" ") + boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oCtrl1.m_oY.GetValue())) + + std::wstring(L" ") + boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oCtrl2.m_oX.GetValue())) + + std::wstring(L" ") + boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oCtrl2.m_oY.GetValue())) + + std::wstring(L" ") + boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oEnd.m_oX.GetValue())) + + std::wstring(L" ") + boost::lexical_cast ((int)pt2emu(oox_geom_path->m_oEnd.m_oY.GetValue())) ; + + odf_context()->drawing_context().add_path_element(std::wstring(L"C"), path_elm); + + +} +void OoxConverter::convert(OOX::Drawing::CPath2DClose *oox_geom_path) +{ + if (!oox_geom_path) return; + + std::wstring path_elm ; + + odf_context()->drawing_context().add_path_element(std::wstring(L"N"), path_elm); + +} } // namespace Docx2Odt \ No newline at end of file diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h index ace40af6d7..e8a1e068d0 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h @@ -16,6 +16,8 @@ namespace cpdoccore } namespace OOX { + class WritingElement; + namespace Drawing { class CNonVisualDrawingProps; @@ -26,6 +28,14 @@ namespace OOX class CGradientFillProperties; class CPatternFillProperties; class CSolidColorFillProperties; + class CPath2D; + class CPath2DLineTo; + class CPath2DMoveTo; + class CPath2DArcTo; + class CPath2DQuadBezierTo; + class CPath2DCubicBezierTo; + class CPath2DClose; + } } @@ -34,23 +44,33 @@ namespace Oox2Odf class OoxConverter { public: - virtual void convert() = 0; + virtual void convertDocument() = 0; virtual void write(const std::wstring & path) = 0; OoxConverter(){} virtual cpdoccore::odf::odf_conversion_context* odf_context() = 0; + + void convert(OOX::WritingElement *oox_unknown); - void convert_CNvPr(OOX::Drawing::CNonVisualDrawingProps* oox_cnvPr); - void convert_SpPr(OOX::Drawing::CShapeProperties* oox_spPr); + void convert_CNvPr(OOX::Drawing::CNonVisualDrawingProps * oox_cnvPr); + void convert_SpPr(OOX::Drawing::CShapeProperties * oox_spPr); - void convert(OOX::Drawing::CCustomGeometry2D *oox_cust_geom); - void convert(OOX::Drawing::CPresetGeometry2D *oox_prst_geom); + void convert/*_CustGeom*/(OOX::Drawing::CCustomGeometry2D *oox_cust_geom); + void convert/*_PrstGeom*/(OOX::Drawing::CPresetGeometry2D *oox_prst_geom); - void convert(OOX::Drawing::CBlipFillProperties *oox_bitmap_fill); - void convert(OOX::Drawing::CGradientFillProperties *oox_grad_fill); - void convert(OOX::Drawing::CPatternFillProperties *oox_pattern_fill); - void convert(OOX::Drawing::CSolidColorFillProperties *oox_solid_fill); + void convert(OOX::Drawing::CBlipFillProperties *oox_bitmap_fill); + void convert(OOX::Drawing::CGradientFillProperties *oox_grad_fill); + void convert(OOX::Drawing::CPatternFillProperties *oox_pattern_fill); + void convert(OOX::Drawing::CSolidColorFillProperties *oox_solid_fill); + void convert(OOX::Drawing::CPath2D *oox_geom_path); + void convert(OOX::Drawing::CPath2DLineTo *oox_geom_path); + void convert(OOX::Drawing::CPath2DMoveTo *oox_geom_path); + void convert(OOX::Drawing::CPath2DArcTo *oox_geom_path); + void convert(OOX::Drawing::CPath2DQuadBezierTo *oox_geom_path); + void convert(OOX::Drawing::CPath2DCubicBezierTo *oox_geom_path); + void convert(OOX::Drawing::CPath2DClose *oox_geom_path); + }; class Converter diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp index 58cb07b77a..24aacc12f0 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp @@ -33,7 +33,7 @@ odf::odf_conversion_context* DocxConverter::odf_context() { return NULL;//odt_context; } -void DocxConverter::convert() +void DocxConverter::convertDocument() { if (!docx_document)return; diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h index 1e47c72237..f009014ab9 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h @@ -27,7 +27,7 @@ namespace Oox2Odf public: DocxConverter(const std::wstring & path); - virtual void convert(); + virtual void convertDocument(); virtual void write(const std::wstring & path); virtual odf::odf_conversion_context* odf_context(); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index b070f40cce..fc422b6335 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -42,7 +42,7 @@ odf::odf_conversion_context* XlsxConverter::odf_context() return ods_context; } -void XlsxConverter::convert() +void XlsxConverter::convertDocument() { if (!xlsx_document)return; if (!output_document)return; @@ -987,6 +987,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor) { convert(oox_anchor->m_oShape.GetPointer()); } + else if (oox_anchor->m_oConnShape.IsInit()) + { + convert(oox_anchor->m_oConnShape.GetPointer()); + } else if (oox_anchor->m_oGraphicFrame.IsInit())//chart { ods_context->drawing_context().start_frame(); @@ -1029,7 +1033,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CShape* oox_shape) int type = -1; if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypeCustom) { - type = 6; + type = 7;//6??? } else if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypePreset) { @@ -1037,34 +1041,83 @@ void XlsxConverter::convert(OOX::Spreadsheet::CShape* oox_shape) { OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer(); int oox_shape = (int)(geometry->m_oPrst.GetValue()); - sub_type = Shape_Types_Mapping[oox_shape].first; type = Shape_Types_Mapping[oox_shape].second; + sub_type = Shape_Types_Mapping[oox_shape].first; } } else return; - ods_context->drawing_context().start_shape(type,sub_type ); + convert_SpPr(oox_shape->m_oSpPr.GetPointer());//все, окромя типа геометрии + + if (oox_shape->m_oNvSpPr.IsInit()) { - convert_SpPr(oox_shape->m_oSpPr.GetPointer());//все, окромя типа геометрии - - if (oox_shape->m_oNvSpPr.IsInit()) + if (oox_shape->m_oNvSpPr->m_oCNvPr.IsInit()) { - if (oox_shape->m_oNvSpPr->m_oCNvPr.IsInit()) - { - convert_CNvPr(oox_shape->m_oNvSpPr->m_oCNvPr.GetPointer()); - } - - if (oox_shape->m_oNvSpPr->m_oCNvSpPr.IsInit()) - { - } + convert_CNvPr(oox_shape->m_oNvSpPr->m_oCNvPr.GetPointer()); } - - if (oox_shape->m_oShapeStyle.IsInit()) + if (oox_shape->m_oNvSpPr->m_oCNvSpPr.IsInit()) { } } + + + if (oox_shape->m_oShapeStyle.IsInit()) + { + } + + ods_context->drawing_context().start_shape(type,sub_type ); + { + } + ods_context->drawing_context().end_shape(); +} + + +void XlsxConverter::convert(OOX::Spreadsheet::CConnShape* oox_shape) +{ + if (!oox_shape)return; + if (!oox_shape->m_oSpPr.IsInit()) return; + + std::wstring sub_type; + int type = -1; + if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypeCustom) + { + type = 7;//6??? + } + else if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypePreset) + { + if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit()) + { + OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer(); + int oox_shape = (int)(geometry->m_oPrst.GetValue()); + type = Shape_Types_Mapping[oox_shape].second; + sub_type = Shape_Types_Mapping[oox_shape].first; + } + } + else + return; + + convert_SpPr(oox_shape->m_oSpPr.GetPointer());//все, окромя типа геометрии + + if (oox_shape->m_oNvConnSpPr.IsInit()) + { + if (oox_shape->m_oNvConnSpPr->m_oCNvPr.IsInit()) + { + convert_CNvPr(oox_shape->m_oNvConnSpPr->m_oCNvPr.GetPointer()); + } + + if (oox_shape->m_oNvConnSpPr->m_oCNvConnSpPr.IsInit()) + { + } + } + + if (oox_shape->m_oShapeStyle.IsInit()) + { + } + ods_context->drawing_context().start_shape(type,sub_type ); + { + } ods_context->drawing_context().end_shape(); } diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h index 5bd02aa1fe..7972be2b48 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h @@ -54,7 +54,7 @@ namespace Oox2Odf public: XlsxConverter(const std::wstring & path); - virtual void convert(); + virtual void convertDocument(); virtual void write(const std::wstring & path); virtual odf::odf_conversion_context* odf_context(); @@ -110,6 +110,7 @@ namespace Oox2Odf void convert(OOX::Spreadsheet::CPic* oox_picture); void convert(OOX::Spreadsheet::CShape* oox_shape); + void convert(OOX::Spreadsheet::CConnShape* oox_conn_shape); }; } \ No newline at end of file diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/shape_types_mapping.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/shape_types_mapping.h index abd5689e95..3841fe6de3 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/shape_types_mapping.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/shape_types_mapping.h @@ -43,7 +43,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy { L"mso-spt41" , 7}, // shapetypeCallout1, { L"mso-spt42" , 7}, // shapetypeCallout2, { L"mso-spt43" , 7}, // shapetypeCallout3, - { L"lightning" , 7}, // shapetypeCan, + { L"can" , 7}, // shapetypeCan, { L"" , 7}, // shapetypeChartPlus, { L"" , 7}, // shapetypeChartStar, { L"" , 7}, // shapetypeChartX, @@ -127,7 +127,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy { L"" , 7}, // shapetypeLeftRightRibbon, { L"mso-spt182" , 7}, // shapetypeLeftRightUpArrow, { L"mso-spt89" , 7}, // shapetypeLeftUpArrow, - { L"can" , 7}, // shapetypeLightningBolt, + { L"lightning" , 7}, // shapetypeLightningBolt, { L"" , 5}, // shapetypeLine, { L"" , 7}, // shapetypeLineInv, { L"" , 7}, // shapetypeMathDivide, @@ -135,7 +135,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy { L"" , 7}, // shapetypeMathMinus, { L"" , 7}, // shapetypeMathMultiply, { L"" , 7}, // shapetypeMathNotEqual, - { L"" , 7}, // shapetypeMathPlus, + { L"cross" , 7}, // shapetypeMathPlus, { L"moon" , 7}, // shapetypeMoon, { L"" , 7}, // shapetypeNonIsoscelesTrapezoid, { L"forbidden" , 7}, // shapetypeNoSmoking, @@ -147,7 +147,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy { L"" , 7}, // shapetypePieWedge, { L"" , 7}, // shapetypePlaque, { L"" , 7}, // shapetypePlaqueTabs, - { L"" , 7}, // shapetypePlus, + { L"cross" , 7}, // shapetypePlus, { L"quad-arrow" , 7}, // shapetypeQuadArrow, { L"quad-arrow-callout" , 7}, // shapetypeQuadArrowCallout, { L"rectangle" , 2}, // shapetypeRect, @@ -161,7 +161,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy { L"" , 7}, // shapetypeRound2DiagRect, { L"" , 7}, // shapetypeRound2SameRect, { L"round-rectangle" , 7}, // shapetypeRoundRect, - { L"" , 7}, // shapetypeRtTriangle, + { L"right-triangle" , 7}, // shapetypeRtTriangle, { L"smiley" , 7}, // shapetypeSmileyFace, { L"" , 7}, // shapetypeSnip1Rect, { L"" , 7}, // shapetypeSnip2DiagRect, diff --git a/ASCOfficeOdfFileW/version.h b/ASCOfficeOdfFileW/version.h index 4425ff6e9f..200c98aa7b 100644 --- a/ASCOfficeOdfFileW/version.h +++ b/ASCOfficeOdfFileW/version.h @@ -2,6 +2,6 @@ //1 //2 //0 -//13 -#define INTVER 1,2,0,13 -#define STRVER "1,2,0,13\0" +//15 +#define INTVER 1,2,0,15 +#define STRVER "1,2,0,15\0" diff --git a/Common/DocxFormat/Source/Common/SimpleTypes_Drawing.h b/Common/DocxFormat/Source/Common/SimpleTypes_Drawing.h index 084c203020..e96276aa90 100644 --- a/Common/DocxFormat/Source/Common/SimpleTypes_Drawing.h +++ b/Common/DocxFormat/Source/Common/SimpleTypes_Drawing.h @@ -154,7 +154,11 @@ namespace SimpleTypes { return m_sGuide; } - + + double GetValue() const + { + return m_dValue; + } private: void Parse2(CString &sValue) diff --git a/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingCoreInfo.cpp b/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingCoreInfo.cpp index a6f1739b76..b387560454 100644 --- a/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingCoreInfo.cpp +++ b/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingCoreInfo.cpp @@ -83,6 +83,8 @@ namespace OOX } void CNonVisualDrawingProps::fromXML(XmlUtils::CXmlLiteReader& oReader) { + ReadAttributes( oReader ); + m_eType = et_Unknown; CWCharWrapper sName = oReader.GetName(); diff --git a/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h b/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h index 78451857ad..8d5050f71b 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h +++ b/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h @@ -101,7 +101,9 @@ namespace OOX m_oPicture = oReader; else if (_T("xdr:sp") == sName) m_oShape = oReader; - else if (_T("xdr:grpSp") == sName || _T("xdr:cxnSp") == sName || _T("mc:AlternateContent") == sName) + else if (_T("xdr:cxnSp") == sName) + m_oConnShape = oReader; + else if (_T("xdr:grpSp") == sName || _T("mc:AlternateContent") == sName) m_oXml = oReader.GetOuterXml(); } } @@ -141,6 +143,7 @@ namespace OOX nullable m_oGraphicFrame; nullable m_oPicture; nullable m_oShape; + nullable m_oConnShape; nullable m_oXml; }; } //Spreadsheet diff --git a/Common/DocxFormat/Source/XlsxFormat/Drawing/Shape.h b/Common/DocxFormat/Source/XlsxFormat/Drawing/Shape.h index af6deed892..8850a26e0b 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Drawing/Shape.h +++ b/Common/DocxFormat/Source/XlsxFormat/Drawing/Shape.h @@ -188,6 +188,188 @@ namespace OOX nullable m_oShapeStyle; //txBody (Shape Text Body) }; + + //-------------------------------------------------------------------------------- + // 20.5.2.4 cNvCxnSpPr (Non-Visual Connector Shape Drawing Properties) + //-------------------------------------------------------------------------------- + class CConnectionNonVisualConnShapeProps : public WritingElement + { + public: + WritingElementSpreadsheet_AdditionConstructors(CConnectionNonVisualConnShapeProps) + CConnectionNonVisualConnShapeProps() + { + } + virtual ~CConnectionNonVisualConnShapeProps() + { + } + + public: + virtual CString toXML() const + { + return _T(""); + } + virtual void toXML(XmlUtils::CStringWriter& writer) const + { + } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + CWCharWrapper sName = oReader.GetName(); + + sName = oReader.GetName(); + if ( _T("a:picLocks") == sName ) + m_oPicLocks = oReader; + else if ( _T("a:extLst") == sName ) + m_oExtLst = oReader; + } + } + + virtual EElementType getType () const + { + return et_ConnectionNonVisualConnShapeProps; + } + + private: + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("preferRelativeResize"), m_oPreferRelativeResize ) + WritingElement_ReadAttributes_End( oReader ) + } + public: + EElementType m_eType; + // Attributes + SimpleTypes::COnOff m_oPreferRelativeResize; + + // Childs + nullable m_oExtLst; + nullable m_oPicLocks; + }; + + //-------------------------------------------------------------------------------- + // 20.5.2.19 nvCxnSpPr (Non-Visual Properties for a Connection Shape) + //-------------------------------------------------------------------------------- + class CConnShapeNonVisual : public WritingElement + { + public: + WritingElementSpreadsheet_AdditionConstructors(CConnShapeNonVisual) + CConnShapeNonVisual() + { + } + virtual ~CConnShapeNonVisual() + { + } + + public: + virtual CString toXML() const + { + return _T(""); + } + virtual void toXML(XmlUtils::CStringWriter& writer) const + { + } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + CWCharWrapper sName = oReader.GetName(); + + if ( _T("xdr:cNvCxnSpPr") == sName ) + m_oCNvConnSpPr = oReader; + else if ( _T("xdr:cNvPr") == sName ) + m_oCNvPr = oReader; + } + } + + virtual EElementType getType () const + { + return et_ConnShapeNonVisual; + } + + private: + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_End( oReader ) + } + public: + EElementType m_eType; + // Childs + nullable m_oCNvConnSpPr; + nullable m_oCNvPr; + }; + + + //-------------------------------------------------------------------------------- + //20.5.2.13 cxnSp (Connection Shape) + //-------------------------------------------------------------------------------- + class CConnShape : public WritingElement + { + public: + WritingElementSpreadsheet_AdditionConstructors(CConnShape) + CConnShape() + { + } + virtual ~CConnShape() + { + } + + public: + virtual CString toXML() const + { + return _T(""); + } + virtual void toXML(XmlUtils::CStringWriter& writer) const + { + } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + CWCharWrapper sName = oReader.GetName(); + + if ( _T("xdr:nvCxnSpPr") == sName ) + m_oNvConnSpPr = oReader; + if ( _T("xdr:spPr") == sName ) + m_oSpPr = oReader; + if ( _T("xdr:style") == sName ) + m_oShapeStyle = oReader; } + } + + virtual EElementType getType () const + { + return et_ConnShape; + } + + private: + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + } + public: + nullable m_oNvConnSpPr; + nullable m_oSpPr; + nullable m_oShapeStyle; + //txBody (Shape Text Body) + }; } //Spreadsheet } // namespace OOX diff --git a/Common/DocxFormat/Source/XlsxFormat/WritingElement.h b/Common/DocxFormat/Source/XlsxFormat/WritingElement.h index e391b99e75..530f53e485 100644 --- a/Common/DocxFormat/Source/XlsxFormat/WritingElement.h +++ b/Common/DocxFormat/Source/XlsxFormat/WritingElement.h @@ -309,7 +309,10 @@ et_alternatecontentfallback, et_ShapeProperties, et_ShapeNonVisual, et_ShapeStyle, - et_Shape + et_Shape, + et_ConnShape, + et_ConnShapeNonVisual, + et_ConnectionNonVisualConnShapeProps };