diff --git a/OdfFile/Writer/Converter/DocxConverter.cpp b/OdfFile/Writer/Converter/DocxConverter.cpp index f13ef47754..64ea5739de 100644 --- a/OdfFile/Writer/Converter/DocxConverter.cpp +++ b/OdfFile/Writer/Converter/DocxConverter.cpp @@ -1047,18 +1047,34 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87 OOX::Logic::CBr* pBr= dynamic_cast(oox_run->m_arrItems[i]); if (pBr) { - if( !odt_context->pendingBreakType ) // for bug when we have text and after conversion we have early break column (check bug 73365) + int type = pBr->m_oType.m_eValue != 0 ? pBr->m_oType.GetValue() : 2; + + // check bug 55175 + bool beforeAnyText = true; // check, maybe text was there already before break? + for (size_t j = 0; j < i; ++j) { - odt_context->pendingBreakType = true; - odt_context->m_pendingBreakType = pBr->m_oType.GetValue(); + if (oox_run->m_arrItems[j]->getType() == OOX::et_w_t) + { + beforeAnyText = false; + break; + } } - // int type = pBr->m_oType.GetValue(); - - // bool need_restart_para = odt_context->text_context()->set_type_break(type, pBr->m_oClear.GetValue()); + if (beforeAnyText) // if there was no text, insert break + { + bool need_restart_para = odt_context->text_context()->set_type_break(type, pBr->m_oClear.GetValue()); - // if (need_restart_para) - // odt_context->add_paragraph_break(type); + if (need_restart_para) + odt_context->add_paragraph_break(type); + } + else + { + if( !odt_context->pendingBreakType ) // for bug when we have text and after conversion we have early break column (check bug 73365) + { + odt_context->pendingBreakType = true; + odt_context->m_pendingBreakType = type; + } + } } }break; case OOX::et_w_t: diff --git a/OdfFile/Writer/Format/odf_text_context.cpp b/OdfFile/Writer/Format/odf_text_context.cpp index e83fdaed02..319056bd18 100644 --- a/OdfFile/Writer/Format/odf_text_context.cpp +++ b/OdfFile/Writer/Format/odf_text_context.cpp @@ -772,7 +772,7 @@ bool odf_text_context::set_type_break(int type, int clear)//todooo clear ??? { need_break_ = boost::none; } - else if (type == 0)//brtypeColumn + else if (type == 0)//brtypeColumn { need_break_ = fo_break(fo_break::Column); need_restart = true; @@ -780,7 +780,7 @@ bool odf_text_context::set_type_break(int type, int clear)//todooo clear ??? else if (type == 1)//brtypePage { office_element_ptr elm; - create_element(L"text", L"soft-page-break", elm, odf_context_); + create_element(L"text", L"soft-page-break", elm, odf_context_); start_element(elm); end_element(); @@ -794,8 +794,9 @@ bool odf_text_context::set_type_break(int type, int clear)//todooo clear ??? create_element(L"text", L"line-break", elm, odf_context_); if (current_level_.size() > 0) - current_level_.back().elm->add_child_element(elm); + current_level_.back().elm->add_child_element(elm); } + return need_restart; } diff --git a/OdfFile/Writer/Format/odf_text_context.h b/OdfFile/Writer/Format/odf_text_context.h index e771fa189b..ed57558f87 100644 --- a/OdfFile/Writer/Format/odf_text_context.h +++ b/OdfFile/Writer/Format/odf_text_context.h @@ -164,6 +164,7 @@ public: int prevNumID = -1; }list_state_; bool single_paragraph_; + odf_conversion_context *odf_context_; private: bool keep_next_paragraph_; @@ -173,7 +174,6 @@ private: text_format_properties *text_properties_; //хранилка-опознавалка что свойства приписаны другому, не текстовому, объекту odf_style_context_ptr styles_context_; - odf_conversion_context *odf_context_; std::wstring parent_span_style_; std::wstring parent_paragraph_style_;