From 78d1f6f1e4a8042fcee1274f6637a3ebac18a65d Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 16 Mar 2023 20:27:30 +0300 Subject: [PATCH] fix bug #61633 --- OdfFile/DataTypes/common_attlists.cpp | 3 ++ OdfFile/DataTypes/common_attlists.h | 1 + OdfFile/DataTypes/writingmode.cpp | 7 +++- OdfFile/DataTypes/writingmode.h | 1 + .../Reader/Format/style_table_properties.cpp | 39 +++++++++++++++++-- .../Reader/Format/style_table_properties.h | 1 + OdfFile/Writer/Converter/DocxConverter.cpp | 19 +++++---- .../Writer/Format/style_table_properties.cpp | 2 + .../Writer/Format/style_table_properties.h | 1 + 9 files changed, 59 insertions(+), 15 deletions(-) diff --git a/OdfFile/DataTypes/common_attlists.cpp b/OdfFile/DataTypes/common_attlists.cpp index 0c86092d00..04484eb139 100644 --- a/OdfFile/DataTypes/common_attlists.cpp +++ b/OdfFile/DataTypes/common_attlists.cpp @@ -360,14 +360,17 @@ void common_keep_with_next_attlist::serialize(CP_ATTR_NODE) void common_writing_mode_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes ) { CP_APPLY_ATTR(L"style:writing-mode", style_writing_mode_); + CP_APPLY_ATTR(L"loext:writing-mode", loext_writing_mode_); } void common_writing_mode_attlist::apply_from(const common_writing_mode_attlist & Other) { _CP_APPLY_PROP(style_writing_mode_, Other.style_writing_mode_); + _CP_APPLY_PROP(loext_writing_mode_, Other.loext_writing_mode_); } void common_writing_mode_attlist::serialize(CP_ATTR_NODE) { CP_XML_ATTR_OPT(L"style:writing-mode", style_writing_mode_); + CP_XML_ATTR_OPT(L"loext:writing-mode", loext_writing_mode_); } ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/OdfFile/DataTypes/common_attlists.h b/OdfFile/DataTypes/common_attlists.h index 9580376d65..3330f6e8e5 100644 --- a/OdfFile/DataTypes/common_attlists.h +++ b/OdfFile/DataTypes/common_attlists.h @@ -243,6 +243,7 @@ public: void serialize(CP_ATTR_NODE); _CP_OPT(writing_mode) style_writing_mode_; + _CP_OPT(writing_mode) loext_writing_mode_; }; /// common-draw-data-attlist diff --git a/OdfFile/DataTypes/writingmode.cpp b/OdfFile/DataTypes/writingmode.cpp index 57653c1a20..572b42b91e 100644 --- a/OdfFile/DataTypes/writingmode.cpp +++ b/OdfFile/DataTypes/writingmode.cpp @@ -65,6 +65,9 @@ std::wostream & operator << (std::wostream & _Wostream, const writing_mode & _Va case writing_mode::Page: _Wostream << L"page"; break; + case writing_mode::BtLr: + _Wostream << L"bt-lr"; + break; default: break; } @@ -92,7 +95,9 @@ writing_mode writing_mode::parse(const std::wstring & Str) return writing_mode( Tb ); else if (tmp == L"page") return writing_mode( Page ); - else + else if (tmp == L"bt-lr") + return writing_mode( BtLr ); + else { return writing_mode( LrTb ); } diff --git a/OdfFile/DataTypes/writingmode.h b/OdfFile/DataTypes/writingmode.h index 1fa34a69a1..787af31a6b 100644 --- a/OdfFile/DataTypes/writingmode.h +++ b/OdfFile/DataTypes/writingmode.h @@ -53,6 +53,7 @@ public: Rl, Tb, Page, + BtLr }; writing_mode() {} diff --git a/OdfFile/Reader/Format/style_table_properties.cpp b/OdfFile/Reader/Format/style_table_properties.cpp index 5480b4e382..b34ede2c7b 100644 --- a/OdfFile/Reader/Format/style_table_properties.cpp +++ b/OdfFile/Reader/Format/style_table_properties.cpp @@ -295,6 +295,7 @@ void style_table_cell_properties_attlist::add_attributes( const xml::attributes_ common_background_color_attlist_.add_attributes(Attributes); common_border_attlist_.add_attributes(Attributes); common_border_line_width_attlist_.add_attributes(Attributes); + common_writing_mode_attlist_.add_attributes(Attributes); CP_APPLY_ATTR(L"style:diagonal-tl-br" , style_diagonal_tl_br_); CP_APPLY_ATTR(L"style:diagonal-tl-br-widths" , style_diagonal_tl_br_widths_); @@ -624,7 +625,7 @@ void style_table_cell_properties_attlist::docx_convert(oox::docx_conversion_cont const std::wstring w_fill = (common_background_color_attlist_.fo_background_color_->get_type() == background_color::Enabled ? common_background_color_attlist_.fo_background_color_->get_color().get_hex_value() : L"auto"); - strm << L""; + strm << L""; } if (common_padding_attlist_.fo_padding_ || @@ -657,6 +658,35 @@ void style_table_cell_properties_attlist::docx_convert(oox::docx_conversion_cont } strm << L""; } + bool bVertical = (style_direction_ ? style_direction_->get_type() == direction::Ttb : false); + + if (common_writing_mode_attlist_.loext_writing_mode_ || common_writing_mode_attlist_.style_writing_mode_) + { + writing_mode type = common_writing_mode_attlist_.loext_writing_mode_.get_value_or(common_writing_mode_attlist_.style_writing_mode_.get_value_or(writing_mode::LrTb)); + switch (type.get_type()) + { + case writing_mode::TbRl: + { + strm << (bVertical ? L"" : L""); + }break; + case writing_mode::LrTb: + { + strm << (bVertical ? L"" : L""); + + }break; + case writing_mode::BtLr: + { + strm << L""; + }break; + default: + { + if (bVertical) + { + strm << L""; + } + }break; + } + } } void style_table_cell_properties_attlist::pptx_serialize(oox::pptx_conversion_context & Context, std::wostream & strm) @@ -705,9 +735,10 @@ void style_table_cell_properties_attlist::apply_from(const style_table_cell_prop _CP_APPLY_PROP(style_direction_ , Other.style_direction_); _CP_APPLY_PROP(style_glyph_orientation_vertical_ , Other.style_glyph_orientation_vertical_); - common_shadow_attlist_.apply_from (Other.common_shadow_attlist_); - common_background_color_attlist_.apply_from (Other.common_background_color_attlist_); - common_border_attlist_.apply_from (Other.common_border_attlist_); + common_shadow_attlist_.apply_from(Other.common_shadow_attlist_); + common_background_color_attlist_.apply_from(Other.common_background_color_attlist_); + common_border_attlist_.apply_from(Other.common_border_attlist_); + common_writing_mode_attlist_.apply_from(Other.common_writing_mode_attlist_); _CP_APPLY_PROP(style_diagonal_tl_br_ , Other.style_diagonal_tl_br_); _CP_APPLY_PROP(style_diagonal_tl_br_widths_ , Other.style_diagonal_tl_br_widths_); diff --git a/OdfFile/Reader/Format/style_table_properties.h b/OdfFile/Reader/Format/style_table_properties.h index 40eb388571..3b51196f69 100644 --- a/OdfFile/Reader/Format/style_table_properties.h +++ b/OdfFile/Reader/Format/style_table_properties.h @@ -206,6 +206,7 @@ public: odf_types::common_border_line_width_attlist common_border_line_width_attlist_; odf_types::common_padding_attlist common_padding_attlist_; odf_types::common_rotation_angle_attlist common_rotation_angle_attlist_; + odf_types::common_writing_mode_attlist common_writing_mode_attlist_; _CP_OPT(odf_types::vertical_align) style_vertical_align_; _CP_OPT(odf_types::text_align_source) style_text_align_source_; diff --git a/OdfFile/Writer/Converter/DocxConverter.cpp b/OdfFile/Writer/Converter/DocxConverter.cpp index 7eabc6c287..bf5767f453 100644 --- a/OdfFile/Writer/Converter/DocxConverter.cpp +++ b/OdfFile/Writer/Converter/DocxConverter.cpp @@ -4740,7 +4740,8 @@ void DocxConverter::convert(OOX::Logic::CTc *oox_table_cell) } } - odt_context->start_table_cell( oox_table_cell->m_nNumCol, covered, convert(oox_table_cell->m_pTableCellProperties, oox_table_cell->m_nNumCol + 1)); + bool styled = convert(oox_table_cell->m_pTableCellProperties, oox_table_cell->m_nNumCol + 1); + odt_context->start_table_cell( oox_table_cell->m_nNumCol, covered, styled); if (oox_table_cell->m_pTableCellProperties) { @@ -4911,7 +4912,7 @@ void DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr, odf_writer } bool DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr, bool base_styled) { - if (oox_table_pr && oox_table_pr->m_oTblBorders.IsInit()) + if ((oox_table_pr && oox_table_pr->m_oTblBorders.IsInit()) || base_styled) {//напрямую задать cell_prop на саму таблицу низя - тока как default-cell-style-name на columns & row //общие свойства ячеек @@ -5024,25 +5025,23 @@ bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr, { switch(oox_table_cell_pr->m_oTextDirection->m_oVal->GetValue()) { + case SimpleTypes::textdirectionRl: + { + table_cell_properties->content_.common_writing_mode_attlist_.loext_writing_mode_ = odf_types::writing_mode::TbRl; + }break; case SimpleTypes::textdirectionTb : { + table_cell_properties->content_.common_writing_mode_attlist_.loext_writing_mode_ = odf_types::writing_mode::LrTb; table_cell_properties->content_.style_direction_ = odf_types::direction(odf_types::direction::Ltr); }break; case SimpleTypes::textdirectionLr ://повернутость буковок + table_cell_properties->content_.common_writing_mode_attlist_.loext_writing_mode_ = odf_types::writing_mode::BtLr; case SimpleTypes::textdirectionLrV : case SimpleTypes::textdirectionTbV : case SimpleTypes::textdirectionRlV : { table_cell_properties->content_.style_direction_ = odf_types::direction(odf_types::direction::Ttb); - odf_writer::style_text_properties *text_cell_properties = odt_context->styles_context()->last_state()->get_text_properties(); - if (text_cell_properties) - { - text_cell_properties->content_.style_text_rotation_angle_ = 90; - text_cell_properties->content_.style_text_rotation_scale_ = odf_types::text_rotation_scale::LineHeight; - } }break; - case SimpleTypes::textdirectionRl ://rtl - break; } } convert(oox_table_cell_pr->m_oTcBorders.GetPointer() , table_cell_properties); diff --git a/OdfFile/Writer/Format/style_table_properties.cpp b/OdfFile/Writer/Format/style_table_properties.cpp index 74c2d0c625..6278f839d3 100644 --- a/OdfFile/Writer/Format/style_table_properties.cpp +++ b/OdfFile/Writer/Format/style_table_properties.cpp @@ -219,6 +219,7 @@ void style_table_cell_properties_attlist::serialize(std::wostream & _Wostream ,c common_background_color_attlist_.serialize(CP_GET_XML_NODE()); common_border_attlist_.serialize(CP_GET_XML_NODE()); common_border_line_width_attlist_.serialize(CP_GET_XML_NODE()); + common_writing_mode_attlist_.serialize(CP_GET_XML_NODE()); CP_XML_ATTR_OPT(L"style:diagonal-tl-br", style_diagonal_tl_br_); CP_XML_ATTR_OPT(L"style:diagonal-tl-br-widths", style_diagonal_tl_br_widths_); @@ -247,6 +248,7 @@ void style_table_cell_properties_attlist::apply_from(const style_table_cell_prop common_shadow_attlist_.apply_from(Other.common_shadow_attlist_); common_background_color_attlist_.apply_from(Other.common_background_color_attlist_); common_border_attlist_.apply_from(Other.common_border_attlist_); + common_writing_mode_attlist_.apply_from(Other.common_writing_mode_attlist_); _CP_APPLY_PROP(style_diagonal_tl_br_, Other.style_diagonal_tl_br_); _CP_APPLY_PROP(style_diagonal_tl_br_widths_, Other.style_diagonal_tl_br_widths_); diff --git a/OdfFile/Writer/Format/style_table_properties.h b/OdfFile/Writer/Format/style_table_properties.h index fe08bdcd02..45606e4e97 100644 --- a/OdfFile/Writer/Format/style_table_properties.h +++ b/OdfFile/Writer/Format/style_table_properties.h @@ -201,6 +201,7 @@ public: odf_types::common_shadow_attlist common_shadow_attlist_; odf_types::common_background_color_attlist common_background_color_attlist_; odf_types::common_border_attlist common_border_attlist_; + odf_types::common_writing_mode_attlist common_writing_mode_attlist_; _CP_OPT(std::wstring) style_diagonal_tl_br_; _CP_OPT(odf_types::border_widths) style_diagonal_tl_br_widths_;