From 5c3bb713c96b7dff126f4f55fa5d951fdbbad3f9 Mon Sep 17 00:00:00 2001 From: "Elen.Subbotina" Date: Thu, 5 Jun 2014 09:11:40 +0000 Subject: [PATCH] (1.2.0.58): ASCOfficeOdfFileW 24591 git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56498 954022d7-b5bf-4e40-9824-e11837661b57 --- .../source/OdfFormat/odf_drawing_context.cpp | 163 ++++++++++++++++-- .../source/OdfFormat/odf_drawing_context.h | 14 +- .../OdfFormat/ods_conversion_context.cpp | 8 +- .../source/OdfFormat/ods_conversion_context.h | 5 +- .../source/OdfFormat/ods_table_state.cpp | 2 +- .../source/Oox2OdfConverter/Converter.cpp | 49 ++++-- .../source/Oox2OdfConverter/Converter.h | 2 + .../source/Oox2OdfConverter/XlsxConverter.cpp | 133 ++++++++++++-- .../source/Oox2OdfConverter/XlsxConverter.h | 2 + ASCOfficeOdfFileW/version.h | 6 +- .../DocxFormat/Drawing/DrawingCoreInfo.h | 146 ++++++++++++++++ .../DocxFormat/Drawing/DrawingTransform.h | 2 +- .../Source/DocxFormat/WritingElement.h | 4 +- .../Source/XlsxFormat/Drawing/Shape.h | 70 +------- .../Source/XlsxFormat/WritingElement.h | 1 - 15 files changed, 486 insertions(+), 121 deletions(-) diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp index 0ff3ac05a5..add337d975 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp @@ -102,7 +102,6 @@ public: current_graphic_properties = NULL; current_paragraph_properties = NULL; } - std::vector drawing_list_;//все элементы .. для удобства разделение по "топам" odf_drawing_state current_drawing_state_; _drawing_part current_drawing_part_; @@ -118,10 +117,18 @@ public: style_graphic_properties *current_graphic_properties; style_paragraph_properties *current_paragraph_properties; + _CP_OPT(length) global_svg_x_; //from anchor cell + _CP_OPT(length) global_svg_y_; + _CP_OPT(length) global_svg_height_; + _CP_OPT(length) global_svg_width_; + + std::vector group_list_; //группы + std::vector drawing_list_; //все элементы(кроме групп) .. для удобства разделение по "топам" + }; //////////////////////////////////////////////////////////////////////////// - +//////////////////////////////////////////////////////////////////////////// odf_drawing_context::odf_drawing_context(odf_conversion_context *odf_context) : impl_(new odf_drawing_context::Impl(odf_context)) { @@ -138,16 +145,128 @@ void odf_drawing_context::set_styles_context(odf_style_context* styles_context) impl_->styles_context_ = styles_context; } +void odf_drawing_context::start_group(std::wstring name, int id) +{ + office_element_ptr & group_elm = impl_->create_draw_element(5000); + + draw_g* group = dynamic_cast(group_elm.get()); + + int level = impl_->current_level_.size(); + + odf_element_state group_state = {group_elm, L"", office_element_ptr(),level}; + impl_->group_list_.push_back(group_state); + + if (impl_->current_level_.size()>0) + impl_->current_level_.back()->add_child_element(group_elm); + + impl_->current_level_.push_back(group_elm); + + if (group== NULL)return; + + group->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_name_attlist_.draw_name_ = name; + if (id >=0) + group->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_z_index_attlist_.draw_z_index_ = id; + +} +void odf_drawing_context::end_group() +{ + impl_->current_level_.pop_back(); +} + +void odf_drawing_context::set_group_size( double width_pt, double height_pt) +{ + if (impl_->group_list_.size()<1)return; + //draw_g* group = dynamic_cast(impl_->group_list_.back().elm.get()); + //if (!group) return; + + //group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm); + //group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm); +} + +void odf_drawing_context::set_group_position(double x_pt, double y_pt) +{ + if (impl_->group_list_.size()<1)return; + //draw_g* group = dynamic_cast(impl_->group_list_.back().elm.get()); + //if (!group) return; + // + //group->common_draw_attlists_.position_.svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm); + //group->common_draw_attlists_.position_.svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm); +} + +void odf_drawing_context::set_group_flip_H(bool bVal) +{ + if (impl_->group_list_.size()<1)return; + //draw_g* group = dynamic_cast(impl_->group_list_.back().elm.get()); + //if (!group) return; + +} +void odf_drawing_context::set_group_flip_V(bool bVal) +{ + if (impl_->group_list_.size()<1)return; +} + +void odf_drawing_context::set_group_rotate(int iVal) +{ + if (impl_->group_list_.size()<1)return; + //draw_g* group = dynamic_cast(impl_->group_list_.back().elm.get()); + //if (!group) return; + + //double dRotate = iVal/60000.; + //dRotate = (360 - dRotate)/180. * 3.14159265358979323846; + // + //std::wstring strTransform; + //if (abs(dRotate)>0.001) + //{ + // strTransform = std::wstring(L"rotate(") + boost::lexical_cast(dRotate) + std::wstring(L")"); + // //так как вращения все в мс относительно центра фигуры, а не от начала координат - убираем смещение + // if (group->common_draw_attlists_.position_.svg_x_ && group->common_draw_attlists_.position_.svg_y_) + // { + // strTransform += std::wstring(L" translate(") + boost::lexical_cast(group->common_draw_attlists_.position_.svg_x_.get() + + // (group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_.get()/2))+ std::wstring(L",") + + // boost::lexical_cast(group->common_draw_attlists_.position_.svg_y_.get() + + // (group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_.get()/2))+ std::wstring(L")") ; + // } + + // group->common_draw_attlists_.position_.svg_x_ = boost::none; + // group->common_draw_attlists_.position_.svg_y_ = boost::none; + //} + //if (strTransform.length()>0) + // group->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_transform_attlist_.draw_transform_ = strTransform; +} + +void odf_drawing_context::clear() +{ + impl_->global_svg_x_ = boost::none; + impl_->global_svg_y_ = boost::none; + impl_->global_svg_height_ = boost::none; + impl_->global_svg_width_ = boost::none; +} + void odf_drawing_context::start_drawing() { impl_->current_drawing_state_.clear(); - //text_context_.clear(); + + if (impl_->current_level_.size() < 1) + { + impl_->current_drawing_state_.svg_x_ = impl_->global_svg_x_; + impl_->current_drawing_state_.svg_y_ = impl_->global_svg_y_; + + impl_->current_drawing_state_.svg_width_ = impl_->global_svg_width_; + impl_->current_drawing_state_.svg_height_ = impl_->global_svg_height_; + } } void odf_drawing_context::end_drawing() { if (impl_->current_drawing_state_.elements_.size() < 1) return; + if (!impl_->current_drawing_state_.svg_x_) impl_->current_drawing_state_.svg_x_ = impl_->global_svg_x_; + if (!impl_->current_drawing_state_.svg_y_) impl_->current_drawing_state_.svg_y_ = impl_->global_svg_y_; + + if (!impl_->current_drawing_state_.svg_width_) impl_->current_drawing_state_.svg_width_ = impl_->global_svg_width_; + if (!impl_->current_drawing_state_.svg_height_) impl_->current_drawing_state_.svg_height_ = impl_->global_svg_height_; + draw_base* draw = dynamic_cast(impl_->current_drawing_state_.elements_[0].elm.get()); + if (draw) { if (impl_->current_drawing_state_.name_.length() > 0) @@ -188,6 +307,9 @@ void odf_drawing_context::end_drawing() impl_->current_paragraph_properties = NULL; } + +//////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////// office_element_ptr odf_drawing_context::Impl::create_draw_element(int type) { office_element_ptr element; @@ -223,6 +345,9 @@ office_element_ptr odf_drawing_context::Impl::create_draw_element(int type) case 9: create_element(L"draw", L"connector", element, odf_context_); break; + case 5000: + create_element(L"draw", L"g", element, odf_context_); + break; } return element; @@ -559,20 +684,21 @@ void odf_drawing_context::set_rotate(int iVal) double dRotate = iVal/60000.; impl_->current_drawing_state_.rotateAngle = (360 - dRotate)/180. * 3.14159265358979323846; } -void odf_drawing_context::set_rect(double x_pt, double y_pt, double width_pt, double height_pt) +void odf_drawing_context::set_drawings_rect(double x_pt, double y_pt, double width_pt, double height_pt) { //хороший тон сохранить все размеры в см (хотя можно и в другой системе) - impl_->current_drawing_state_.svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm); - impl_->current_drawing_state_.svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm); + impl_->global_svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm); + impl_->global_svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm); - impl_->current_drawing_state_.svg_height_ = length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm); - impl_->current_drawing_state_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm); + impl_->global_svg_height_ = length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm); + impl_->global_svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm); } void odf_drawing_context::set_position(double x_pt, double y_pt) { - //хороший тон сохранить все размеры в см (хотя можно и в другой системе) - impl_->current_drawing_state_.svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm); - //impl_->current_drawing_state_.svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm); + if (!impl_->current_drawing_state_.svg_x_) + impl_->current_drawing_state_.svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm); + if (!impl_->current_drawing_state_.svg_y_) + impl_->current_drawing_state_.svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm); } void odf_drawing_context::get_size( double & width_pt, double & height_pt) { @@ -583,8 +709,10 @@ void odf_drawing_context::get_size( double & width_pt, double & height_pt) } void odf_drawing_context::set_size( double width_pt, double height_pt) { - impl_->current_drawing_state_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm); - impl_->current_drawing_state_.svg_height_= length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm); + //if (!impl_->current_drawing_state_.svg_width_) + impl_->current_drawing_state_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm); + //if (!impl_->current_drawing_state_.svg_height_) + impl_->current_drawing_state_.svg_height_= length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm); } void odf_drawing_context::set_line_width(double pt) { @@ -811,9 +939,16 @@ bool odf_drawing_context::is_exist_content() void odf_drawing_context::finalize(office_element_ptr & root_elm)//для привязки { + for (int i=0; i< impl_->group_list_.size(); i++) + { + if (impl_->group_list_[i].level ==0 ) + { + root_elm->add_child_element(impl_->group_list_[i].elm); + } + } for (int i=0; i< impl_->drawing_list_.size(); i++) { - if (impl_->drawing_list_[i].elements_.size() > 0) + if (impl_->drawing_list_[i].elements_.size() > 0 && impl_->drawing_list_[i].elements_[0].level == 0 ) { root_elm->add_child_element(impl_->drawing_list_[i].elements_[0].elm); } diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h index 80cb786ea0..f5b66ea1f0 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h @@ -26,14 +26,27 @@ public: odf_drawing_context(odf_conversion_context *odf_context); ~odf_drawing_context(); + void set_drawings_rect(double x_pt, double y_pt, double width_pt, double height_pt); + void clear(); void set_styles_context(odf_style_context* styles_context);//для embedded +/////////////////////////////////////////////////////////////////////////////////////////////////////////// office_element_ptr & get_current_style_element() ; office_element_ptr & get_current_element(); void start_drawing(); void end_drawing(); + void start_group(std::wstring name, int id); + void set_group_size( double width_pt, double height_pt); + void set_group_position(double x_pt, double y_pt); + + void set_group_flip_H(bool bVal); + void set_group_flip_V(bool bVal); + + void set_group_rotate(int iVal); + void end_group(); + void start_shape(int type); void end_shape(); @@ -60,7 +73,6 @@ public: /////////////////////////////////////////////////////////////////////////////////////// - void set_rect(double x_pt, double y_pt, double width_pt, double height_pt); void set_size( double width_pt, double height_pt); void set_position(double x_pt, double y_pt); void get_size( double & width_pt, double & height_pt); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp index 378baac0da..675d2ebc9d 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp @@ -438,7 +438,13 @@ void ods_conversion_context::end_cell_text() current_text_context_->end_paragraph(); } } - +void ods_conversion_context::start_drawings() +{ +} +void ods_conversion_context::end_drawings() +{ + current_table().drawing_context()->clear(); +} void ods_conversion_context::start_image(std::wstring & image_file_name) { std::wstring odf_ref_name ; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.h b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.h index 201a5de235..5a1de82798 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.h @@ -66,11 +66,10 @@ public: virtual odf_drawing_context * drawing_context() {return current_table().drawing_context();} virtual odf_text_context * text_context() {return current_text_context_;} - void start_drawing() {drawing_context()->start_drawing();} - void end_drawing() {drawing_context()->end_drawing();} + void start_drawings(); + void end_drawings(); void start_image(std::wstring & image_file_name); - void end_image(){drawing_context()->end_image();} double convert_symbol_width(double val); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp index 61652e152c..41b11833f8 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp @@ -209,7 +209,7 @@ void ods_table_state::set_column_default_cell_style(std::wstring & style_name) column->table_table_column_attlist_.table_default_cell_style_name_ = style_ref(style_name); } -void ods_table_state::set_column_width(double width)//cm, pt ??? +void ods_table_state::set_column_width(double width)//pt { odf::style* style = dynamic_cast(columns_.back().style_elm.get()); if (!style)return; diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp index 1678484732..e376e53b9b 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp @@ -113,7 +113,36 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown) } } } +void OoxConverter::convert(OOX::Drawing::CGroupShapeProperties * oox_group_spPr) +{ + if (!oox_group_spPr) return; + + if (oox_group_spPr->m_oXfrm.IsInit()) //CTransform2D + { + if (oox_group_spPr->m_oXfrm->m_oChOff.IsInit() && oox_group_spPr->m_oXfrm->m_oOff.IsInit()) + { + double x =oox_group_spPr->m_oXfrm->m_oOff->m_oX.GetValue()/ oox_group_spPr->m_oXfrm->m_oChOff->m_oX.GetValue(); + double y =oox_group_spPr->m_oXfrm->m_oOff->m_oY.GetValue()/ oox_group_spPr->m_oXfrm->m_oChOff->m_oY.GetValue(); + //odf_context()->drawing_context()->set_group_position_delata(x, y); + } + if (oox_group_spPr->m_oXfrm->m_oExt.IsInit() && oox_group_spPr->m_oXfrm->m_oChExt.IsInit()) + { + double x =oox_group_spPr->m_oXfrm->m_oExt->m_oCx.GetValue()/ oox_group_spPr->m_oXfrm->m_oChExt->m_oCx.GetValue(); + double y =oox_group_spPr->m_oXfrm->m_oExt->m_oCy.GetValue()/ oox_group_spPr->m_oXfrm->m_oChExt->m_oCy.GetValue(); + + //odf_context()->drawing_context()->set_group_size_koeff(x, y); + } + //??? + //if (oox_group_spPr->m_oXfrm->m_oFlipH.GetValue() == SimpleTypes::onoffTrue) + // odf_context()->drawing_context()->set_group_flip_H(true); + //if (oox_group_spPr->m_oXfrm->m_oFlipV.GetValue() == SimpleTypes::onoffTrue) + // odf_context()->drawing_context()->set_group_flip_V(true); + if (oox_group_spPr->m_oXfrm->m_oRot.GetValue() > 0) + odf_context()->drawing_context()->set_group_rotate(oox_group_spPr->m_oXfrm->m_oRot.GetValue()); + } + +} void OoxConverter::convert(OOX::Drawing::CShapeProperties * oox_spPr) { if (!oox_spPr) return; @@ -156,16 +185,16 @@ void OoxConverter::convert(OOX::Drawing::CShapeProperties * oox_spPr) if (oox_spPr->m_oXfrm.IsInit()) //CTransform2D { - //if (oox_spPr->m_oXfrm->m_oOff.IsInit()) - //{ - // odf_context()->drawing_context()->set_position(oox_spPr->m_oXfrm->m_oOff->m_oX.GetValue(), - // oox_spPr->m_oXfrm->m_oOff->m_oY.GetValue()); - //} - //if (oox_spPr->m_oXfrm->m_oExt.IsInit()) - //{ - // odf_context()->drawing_context()->set_size( oox_spPr->m_oXfrm->m_oExt->m_oCx.ToPoints(), - // oox_spPr->m_oXfrm->m_oExt->m_oCy.ToPoints()); - //} + if (oox_spPr->m_oXfrm->m_oOff.IsInit()) + { + odf_context()->drawing_context()->set_position(oox_spPr->m_oXfrm->m_oOff->m_oX.GetValue(), + oox_spPr->m_oXfrm->m_oOff->m_oY.GetValue()); + } + if (oox_spPr->m_oXfrm->m_oExt.IsInit()) + { + odf_context()->drawing_context()->set_size( oox_spPr->m_oXfrm->m_oExt->m_oCx.ToPoints(), + oox_spPr->m_oXfrm->m_oExt->m_oCy.ToPoints()); + } if (oox_spPr->m_oXfrm->m_oFlipH.GetValue() == SimpleTypes::onoffTrue) odf_context()->drawing_context()->set_flip_H(true); if (oox_spPr->m_oXfrm->m_oFlipV.GetValue() == SimpleTypes::onoffTrue) diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h index 5295e529c6..4b2be604cd 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h @@ -30,6 +30,7 @@ namespace OOX { class CNonVisualDrawingProps; class CShapeProperties; + class CGroupShapeProperties; class CCustomGeometry2D; class CPresetGeometry2D; class CBlipFillProperties; @@ -228,6 +229,7 @@ public: void convert(OOX::Drawing::CNonVisualDrawingProps *oox_cnvPr); void convert(OOX::Drawing::CShapeProperties *oox_spPr); + void convert(OOX::Drawing::CGroupShapeProperties *oox_groupSpPr); void convert(OOX::Drawing::CTextBodyProperties *oox_bodyPr); void convert(OOX::Drawing::CCustomGeometry2D *oox_cust_geom); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index 1b98f2d479..fb94cf3699 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -445,7 +445,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::WritingElement *oox_unknown) { OOX::Spreadsheet::CFormulaCF *pF = static_cast(oox_unknown); convert(pF); - }break; default: + }break; + default: { std::wstringstream ss; ss << L"[warning] : no convert element(" << oox_unknown->getType() << L")\n"; @@ -536,20 +537,33 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_run_pr) SimpleTypes::Spreadsheet::EFontScheme type = oox_run_pr->m_oScheme->m_oFontScheme->GetValue(); if (type == SimpleTypes::Spreadsheet::fontschemeMajor) { - text_properties->content().style_text_position_ = odf::text_position(+33.); } if (type == SimpleTypes::Spreadsheet::fontschemeMinor) { - text_properties->content().style_text_position_ = odf::text_position(-33.); + if (oox_run_pr->m_oVertAlign.IsInit() && oox_run_pr->m_oVertAlign->m_oVerticalAlign.IsInit()) + { + switch(oox_run_pr->m_oVertAlign->m_oVerticalAlign->GetValue()) + { + case SimpleTypes::verticalalignrunSuperscript: + //text_properties->content().style_text_position_ = odf::text_position(odf::text_position::Super); break; + text_properties->content().style_text_position_ = odf::text_position(+33.); break; + case SimpleTypes::verticalalignrunSubscript: + //text_properties->content().style_text_position_ = odf::text_position(odf::text_position::Sub); break; + text_properties->content().style_text_position_ = odf::text_position(-33.); break;//по умолчанию 58% - хуже выглядит + } + } + else + text_properties->content().style_text_position_ = odf::text_position(-33.); } } - //nullable m_oCharset; + if (oox_run_pr->m_oStrike.IsInit()) + text_properties->content().style_text_line_through_type_ = odf::line_type(odf::line_type::Single); + + //nullable m_oCharset; //nullable > m_oCondense; //nullable > m_oExtend; //nullable > m_oOutline; //nullable > m_oShadow; - //nullable > m_oStrike; - } void XlsxConverter::convert(OOX::Spreadsheet::CText *oox_text) @@ -695,9 +709,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p if (oox_sheet_format_pr->m_oDefaultColWidth.IsInit()) { width = oox_sheet_format_pr->m_oDefaultColWidth->GetValue(); + width = ods_context->convert_symbol_width(width); } - ods_context->current_table().defaut_column_width_ = 6*width;//pt - column_properties->style_table_column_properties_attlist_.style_column_width_ = odf::length(width/4.35,odf::length::cm); + ods_context->current_table().defaut_column_width_ = width;//pt + column_properties->style_table_column_properties_attlist_.style_column_width_ = odf::length(odf::length(width,odf::length::pt).get_value_unit(odf::length::cm),odf::length::cm); } } ods_context->styles_context()->add_default(ods_context->styles_context()->last_state()); @@ -716,7 +731,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p double height = oox_sheet_format_pr->m_oDefaultRowHeight->GetValue(); ods_context->current_table().defaut_row_height_ = height;//pt - row_properties->style_table_row_properties_attlist_.style_row_height_ = odf::length(height/32.,odf::length::cm); + row_properties->style_table_row_properties_attlist_.style_row_height_ = odf::length(odf::length(height,odf::length::pt).get_value_unit(odf::length::cm),odf::length::cm); } row_properties->style_table_row_properties_attlist_.style_use_optimal_row_height_ = true; //???? не знаю cтоит ли row_properties->style_table_row_properties_attlist_.common_break_attlist_.fo_break_before_ = odf::fo_break(odf::fo_break::Auto); @@ -829,13 +844,27 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf::style_text_prop SimpleTypes::Spreadsheet::EFontScheme type = font->m_oScheme->m_oFontScheme->GetValue(); if (type == SimpleTypes::Spreadsheet::fontschemeMajor) { - text_properties->content().style_text_position_ = odf::text_position(+33.); } if (type == SimpleTypes::Spreadsheet::fontschemeMinor) { - text_properties->content().style_text_position_ = odf::text_position(-33.); + if (font->m_oVertAlign.IsInit() && font->m_oVertAlign->m_oVerticalAlign.IsInit()) + { + switch(font->m_oVertAlign->m_oVerticalAlign->GetValue()) + { + case SimpleTypes::verticalalignrunSuperscript: + //text_properties->content().style_text_position_ = odf::text_position(odf::text_position::Super); break; + text_properties->content().style_text_position_ = odf::text_position(+33.); break; + case SimpleTypes::verticalalignrunSubscript: + //text_properties->content().style_text_position_ = odf::text_position(odf::text_position::Sub); break; + text_properties->content().style_text_position_ = odf::text_position(-33.); break;//по умолчанию 58% - хуже выглядит + } + } + else + text_properties->content().style_text_position_ = odf::text_position(-33.); } } + if (font->m_oStrike.IsInit()) + text_properties->content().style_text_line_through_type_ = odf::line_type(odf::line_type::Single); ods_context->calculate_font_metrix(font_name,font_size,font_italic,font_bold); } @@ -1268,7 +1297,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor) ods_context->current_table().convert_position(from, x1, y1); ods_context->current_table().convert_position(to, x2, y2); - ods_context->drawing_context()->set_rect(x1, y1, x2-x1, y2-y1); + ods_context->drawing_context()->set_drawings_rect(x1, y1, x2-x1, y2-y1); } ////////////// @@ -1296,9 +1325,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor) { convert(oox_anchor->m_oGraphicFrame.GetPointer()); } - else if (oox_anchor->m_oGraphicFrame.IsInit())//chart + else if (oox_anchor->m_oGroupShape.IsInit())//chart { - convert(oox_anchor->m_oGraphicFrame.GetPointer()); + convert(oox_anchor->m_oGroupShape.GetPointer()); } } @@ -1309,9 +1338,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDrawing *oox_drawing) for (long dr = 0 ; dr < oox_drawing->m_arrItems.GetSize(); dr++) { - ods_context->start_drawing(); + ods_context->start_drawings(); convert(oox_drawing->m_arrItems[dr]); - ods_context->end_drawing(); + ods_context->end_drawings(); } xlsx_current_drawing = NULL; @@ -1328,11 +1357,68 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFromTo* oox_from_to, oox_table_po if (oox_from_to->m_oColOff.IsInit()) pos->col_off = oox_from_to->m_oColOff->GetValue();//pt } +void XlsxConverter::convert(OOX::Spreadsheet::CGroupShape* oox_group_shape) +{ + if (!oox_group_shape)return; + if (oox_group_shape->m_arrItems.GetSize() < 1) return; + + std::wstring name; + int id = -1; + if (oox_group_shape->m_oNvGroupSpPr.IsInit()) + { + if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr.IsInit()) + { + if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName.IsInit()) + name = string2std_string(*oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName); + if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId.IsInit()) + id = oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId->GetValue(); + } + } + ods_context->drawing_context()->start_group(name,id); + + OoxConverter::convert(oox_group_shape->m_oGroupSpPr.GetPointer()); + + for (long i=0; i < oox_group_shape->m_arrItems.GetSize(); i++) + { + switch(oox_group_shape->m_arrItems[i]->getType()) + { + case OOX::Spreadsheet::et_Shape: + { + OOX::Spreadsheet::CShape* item = static_cast(oox_group_shape->m_arrItems[i]); + convert(item); + }break; + case OOX::Spreadsheet::et_ConnShape: + { + OOX::Spreadsheet::CConnShape* item = static_cast(oox_group_shape->m_arrItems[i]); + convert(item); + }break; + case OOX::Spreadsheet::et_GroupShape: + { + OOX::Spreadsheet::CGroupShape* item = static_cast(oox_group_shape->m_arrItems[i]); + convert(item); + }break; + case OOX::Spreadsheet::et_Pic: + { + OOX::Spreadsheet::CPic* item = static_cast(oox_group_shape->m_arrItems[i]); + convert(item); + }break; + case OOX::Spreadsheet::et_xdr_GraphicFrame: + { + OOX::Spreadsheet::CGraphicFrame* item = static_cast(oox_group_shape->m_arrItems[i]); + convert(item); + }break; + } + } + ods_context->drawing_context()->end_group(); +} + void XlsxConverter::convert(OOX::Spreadsheet::CShape* oox_shape) { if (!oox_shape)return; if (!oox_shape->m_oSpPr.IsInit()) return; + ods_context->drawing_context()->start_drawing(); + int type = -1; if (oox_shape->m_oSpPr->m_oCustGeom.IsInit()) { @@ -1383,12 +1469,16 @@ void XlsxConverter::convert(OOX::Spreadsheet::CShape* oox_shape) } if (type == 2000)ods_context->drawing_context()->end_text_box(); else ods_context->drawing_context()->end_shape(); + + ods_context->drawing_context()->end_drawing(); + } void XlsxConverter::convert(OOX::Spreadsheet::CGraphicFrame* oox_graphic_frame) { if (!oox_graphic_frame)return; //////////////////////////////////////////////////////////////////////////////// + ods_context->drawing_context()->start_drawing(); ods_context->drawing_context()->start_object(ods_context->get_next_name_object()); { @@ -1430,7 +1520,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CGraphicFrame* oox_graphic_frame) //могут быть и другие типы объектов } } - ods_context->drawing_context()->end_object(); + ods_context->drawing_context()->end_object(); + ods_context->drawing_context()->end_drawing(); } @@ -1439,6 +1530,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConnShape* oox_shape) if (!oox_shape)return; if (!oox_shape->m_oSpPr.IsInit()) return; + ods_context->drawing_context()->start_drawing(); + int type = -1; if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypeCustom) { @@ -1477,6 +1570,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConnShape* oox_shape) } ods_context->drawing_context()->end_shape(); + ods_context->drawing_context()->end_drawing(); } @@ -1485,6 +1579,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CPic* oox_picture) if (!oox_picture)return; if (!oox_picture->m_oBlipFill.IsInit()) return; // невeрная структура оох + ods_context->drawing_context()->start_drawing(); + CString pathImage; double Width=0, Height = 0; @@ -1550,7 +1646,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CPic* oox_picture) { } } - ods_context->end_image(); + ods_context->drawing_context()->end_image(); + ods_context->drawing_context()->end_drawing(); } void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt) diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h index 2ed87a1adc..567665675c 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h @@ -42,6 +42,7 @@ namespace OOX class CPic; class CShape; class CConnShape; + class CGroupShape; class CCommentItem; class CGraphicFrame; class CDefinedName; @@ -159,6 +160,7 @@ namespace Oox2Odf void convert(OOX::Spreadsheet::CShape *oox_shape); void convert(OOX::Spreadsheet::CConnShape *oox_conn_shape); void convert(OOX::Spreadsheet::CGraphicFrame *oox_graphic_frame); + void convert(OOX::Spreadsheet::CGroupShape *oox_group_shape); void convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt); void convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_cond_rule); diff --git a/ASCOfficeOdfFileW/version.h b/ASCOfficeOdfFileW/version.h index d6bd96ac98..5fe8148bd0 100644 --- a/ASCOfficeOdfFileW/version.h +++ b/ASCOfficeOdfFileW/version.h @@ -2,6 +2,6 @@ //1 //2 //0 -//56 -#define INTVER 1,2,0,56 -#define STRVER "1,2,0,56\0" +//59 +#define INTVER 1,2,0,59 +#define STRVER "1,2,0,59\0" diff --git a/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingCoreInfo.h b/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingCoreInfo.h index 7e9d423f68..894dd5f469 100644 --- a/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingCoreInfo.h +++ b/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingCoreInfo.h @@ -1047,6 +1047,152 @@ namespace OOX }; + + //-------------------------------------------------------------------------------- + // 20.5.2.18 grpSpPr (Group Shape Properties) + //-------------------------------------------------------------------------------- + class CGroupShapeProperties : public WritingElement + { + public: + WritingElement_AdditionConstructors(CGroupShapeProperties) + CGroupShapeProperties() + { + m_eType = et_Unknown; + m_eFillType = filltypeUnknown; + m_eEffectType = effecttypeUnknown; + } + virtual ~CGroupShapeProperties() + { + } + + public: + virtual CString toXML() const + { + return _T(""); + } + virtual void toXML(XmlUtils::CStringWriter& writer) const + { + } + virtual void fromXML(XmlUtils::CXmlNode& oNode) + { + m_eType = et_Unknown; + m_eFillType = filltypeUnknown; + m_eEffectType = effecttypeUnknown; + + // TO DO: Реализовать CShapeProperties::fromXML(XmlUtils::CXmlNode& oNode) + } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_eType = et_Unknown; + m_eFillType = filltypeUnknown; + m_eEffectType = effecttypeUnknown; + + CWCharWrapper sName = oReader.GetName(); + if ( _T("a:grpSpPr") == sName ) + m_eType = et_a_groupSpPr; + else if ( _T("xdr:grpSpPr") == sName ) + m_eType = et_xdr_groupSpPr; + else + return; + + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while ( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + sName = oReader.GetName(); + if ( _T("a:blipFill") == sName ) + { + m_oBlipFill = oReader; + m_eFillType = filltypeBlip; + } + else if ( _T("a:effectDag") == sName ) + { + m_oEffectDag = oReader; + m_eEffectType = effecttypeDag; + } + else if ( _T("a:effectLst") == sName ) + { + m_oEffectList = oReader; + m_eEffectType = effecttypeLst; + } + else if ( _T("a:extLst") == sName ) + m_oExtLst = oReader; + else if ( _T("a:gradFill") == sName ) + { + m_oGradFill = oReader; + m_eFillType = filltypeGradient; + } + else if ( _T("a:grpFill") == sName ) + { + m_oGrpFill = oReader; + m_eFillType = filltypeGroup; + } + else if ( _T("a:noFill") == sName ) + { + m_oNoFill = oReader; + m_eFillType = filltypeNo; + } + else if ( _T("a:pattFill") == sName ) + { + m_oPattFill = oReader; + m_eFillType = filltypePattern; + } + else if ( _T("a:scene3d") == sName ) + m_oScene3D = oReader; + else if ( _T("a:solidFill") == sName ) + { + m_oSolidFill = oReader; + m_eFillType = filltypeSolid; + } + else if ( _T("a:xfrm") == sName ) + m_oXfrm = oReader; + } + } + + virtual EElementType getType () const + { + return m_eType; + } + + EFillType GetFillType() const + { + return m_eFillType; + } + + EEffectType GetEffectType() const + { + return m_eEffectType; + } + private: + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_End( oReader ) + } + public: + EElementType m_eType; // Тип ноды + + // Childs + EFillType m_eFillType; // Тип заливки + nullable m_oBlipFill; + nullable m_oGradFill; + nullable m_oGrpFill; + nullable m_oNoFill; + nullable m_oPattFill; + nullable m_oSolidFill; + + EEffectType m_eEffectType; // Тип контейнера эффектов + nullable m_oEffectDag; + nullable m_oEffectList; + + nullable m_oExtLst; + nullable m_oScene3D; + nullable m_oXfrm; + }; //----------------------------------------------------------------------- // CShapeStyle 20.1.2.2.37 //----------------------------------------------------------------------- diff --git a/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingTransform.h b/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingTransform.h index d3034b6de8..bbe05bc524 100644 --- a/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingTransform.h +++ b/Common/DocxFormat/Source/DocxFormat/Drawing/DrawingTransform.h @@ -133,7 +133,7 @@ namespace OOX nullable m_oChExt; nullable m_oChOff; nullable m_oExt; - nullable m_oOff; + nullable m_oOff; }; //-------------------------------------------------------------------------------- diff --git a/Common/DocxFormat/Source/DocxFormat/WritingElement.h b/Common/DocxFormat/Source/DocxFormat/WritingElement.h index 806b0e1f36..260e9e3039 100644 --- a/Common/DocxFormat/Source/DocxFormat/WritingElement.h +++ b/Common/DocxFormat/Source/DocxFormat/WritingElement.h @@ -277,7 +277,8 @@ namespace OOX et_a_txDef, // et_a_up, // et_a_xfrm, // - + et_a_groupSpPr, // + et_a_p, // et_a_pPr, // et_a_r, // @@ -466,6 +467,7 @@ namespace OOX et_xdr_cNvPr, // et_xdr_spPr, // + et_xdr_groupSpPr, // et_c_chart, // et_c_spPr, diff --git a/Common/DocxFormat/Source/XlsxFormat/Drawing/Shape.h b/Common/DocxFormat/Source/XlsxFormat/Drawing/Shape.h index ca7f6787de..d26d50f43c 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Drawing/Shape.h +++ b/Common/DocxFormat/Source/XlsxFormat/Drawing/Shape.h @@ -372,70 +372,6 @@ namespace OOX nullable m_oPicLocks; }; - //-------------------------------------------------------------------------------- - // 20.5.2.18 grpSpPr (Group Shape Properties) - //-------------------------------------------------------------------------------- - class CGroupShapeProperties : public WritingElement - { - public: - WritingElementSpreadsheet_AdditionConstructors(CGroupShapeProperties) - CGroupShapeProperties() - { - } - virtual ~CGroupShapeProperties() - { - } - - 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_GroupShapeProperties; - } - - private: - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_End( oReader ) - } - public: - // Childs -//blipFill (Picture Fill) §20.1.8.14 -//effectDag (Effect Container) §20.1.8.25 -//effectLst (Effect Container) §20.1.8.26 -//extLst (Extension List) §20.1.2.2.15 -//gradFill (Gradient Fill) §20.1.8.33 -//grpFill (Group Fill) §20.1.8.35 -//noFill (No Fill) §20.1.8.44 -//pattFill (Pattern Fill) §20.1.8.47 - }; - //-------------------------------------------------------------------------------- // 20.5.2.19 nvCxnSpPr (Non-Visual Properties for a Connection Shape) //-------------------------------------------------------------------------------- @@ -645,8 +581,8 @@ namespace OOX if ( _T("xdr:nvGrpSpPr") == sName ) m_oNvGroupSpPr = oReader; - //else if ( _T("xdr:grpSpPr") == sName ) - // m_oGroupSpPr = oReader; + else if ( _T("xdr:grpSpPr") == sName ) + m_oGroupSpPr = oReader; else if ( _T("xdr:sp") == sName ) m_arrItems.Add( new OOX::Spreadsheet::CShape( oReader )); @@ -671,7 +607,7 @@ namespace OOX { } public: - //nullable m_oGroupSpPr; + nullable m_oGroupSpPr; nullable m_oNvGroupSpPr; }; } //Spreadsheet diff --git a/Common/DocxFormat/Source/XlsxFormat/WritingElement.h b/Common/DocxFormat/Source/XlsxFormat/WritingElement.h index 90ff42d1a4..8dcf38a5eb 100644 --- a/Common/DocxFormat/Source/XlsxFormat/WritingElement.h +++ b/Common/DocxFormat/Source/XlsxFormat/WritingElement.h @@ -312,7 +312,6 @@ namespace Spreadsheet et_ShapeTextBody, et_ConnShapeNonVisual, et_GroupShapeNonVisual, - et_GroupShapeProperties, et_NonVisualGroupShapeDrawingProps, et_ConnectionNonVisualConnShapeProps, et_GraphicFrameNonVisual,