Merge remote-tracking branch 'origin/fix/bug73365' into fix/fix-bugs

This commit is contained in:
ElenaSubbotina
2025-08-21 16:50:07 +03:00
4 changed files with 51 additions and 15 deletions

View File

@ -309,7 +309,7 @@ void DocxConverter::convert_document()
{
current_section_properties = &sections[sect];
for (size_t i = sections[sect].start_para; i < sections[sect].end_para; ++i)
for (size_t i = sections[sect].start_para; i < sections[sect].end_para; ++i)
{
convert(doc->m_arrItems[i]);
}
@ -875,6 +875,7 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
}
if(oox_paragraph->m_oParagraphProperty)
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties);
}
if (odt_context->in_drop_cap())
@ -947,7 +948,7 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
}
//---------------------------------------------------------------------------------------------------------------------
for (size_t i = 0; i < oox_paragraph->m_arrItems.size(); ++i)
for (size_t i = 0; i < oox_paragraph->m_arrItems.size(); ++i)
{
//те элементы которые тока для Paragraph - здесь - остальные в общей куче
switch(oox_paragraph->m_arrItems[i]->getType())
@ -1046,12 +1047,18 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
OOX::Logic::CBr* pBr= dynamic_cast<OOX::Logic::CBr*>(oox_run->m_arrItems[i]);
if (pBr)
{
int type = pBr->m_oType.GetValue();
bool need_restart_para = odt_context->text_context()->set_type_break(type, pBr->m_oClear.GetValue());
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 = pBr->m_oType.GetValue();
}
if (need_restart_para)
odt_context->add_paragraph_break(type);
// int type = pBr->m_oType.GetValue();
// 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);
}
}break;
case OOX::et_w_t:
@ -2241,8 +2248,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty* oox_section_pr, bool b
{
odt_context->add_section(continuous);
}
if (bSection && oox_section_pr->m_oCols.IsInit())
if ( oox_section_pr->m_oCols.IsInit() )
{
int num_columns = oox_section_pr->m_oCols->m_oNum.IsInit() ? oox_section_pr->m_oCols->m_oNum->GetValue() : 1;
@ -2254,10 +2260,21 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty* oox_section_pr, bool b
bool separator = oox_section_pr->m_oCols->m_oSep.IsInit() && oox_section_pr->m_oCols->m_oSep->ToBool();
odt_context->add_section_columns(num_columns,
oox_section_pr->m_oCols->m_arrColumns.size() > 0 ? -1 : default_space_pt , separator );
bool flag;
if( oox_section_pr->m_oCols->m_oEqualWidth.IsInit() )
{
flag = true;
}
else
{
flag = false;
}
if (num_columns > 1) //
odt_context->add_section_columns(num_columns,
oox_section_pr->m_oCols->m_arrColumns.size() > 0 ? -1 : default_space_pt ,
separator, flag );
if (num_columns > 1)
{
std::vector<std::pair<double,double>> width_space;

View File

@ -326,6 +326,13 @@ void odt_conversion_context::end_drawing_context()
}
void odt_conversion_context::start_paragraph(bool styled)
{
if (pendingBreakType) // for bug when we have text and after conversion we have early break column (check bug 73365)
{
add_paragraph_break(m_pendingBreakType);
m_pendingBreakType = -1;
pendingBreakType = false;
}
if (false == current_fields.empty() && current_fields.back().status == 1 && false == current_fields.back().in_span)
{
current_fields.back().status = 2;
@ -1106,7 +1113,7 @@ void odt_conversion_context::add_section(bool continuous)
sections_.push_back(state);
}
void odt_conversion_context::add_section_columns(int count, double space_pt, bool separator)
void odt_conversion_context::add_section_columns(int count, double space_pt, bool separator, bool flag)
{
if (sections_.empty() || count < 1) return;
@ -1114,6 +1121,15 @@ void odt_conversion_context::add_section_columns(int count, double space_pt, boo
if (!style_)return;
style_section_properties* section_properties = style_->content_.add_get_style_section_properties();
if( flag ) // for bug when we have implicit break column (check bug 73365)
{
section_properties->text_dont_balance_text_columns_ = flag;
}
else if( !flag )
{
section_properties->text_dont_balance_text_columns_ = flag;
}
create_element(L"style", L"columns", section_properties->style_columns_,this);

View File

@ -142,7 +142,7 @@ public:
void end_run ();
void add_section (bool continuous);
void add_section_columns (int count, double space_pt, bool separator );
void add_section_columns (int count, double space_pt, bool separator, bool flag );
void add_section_column (std::vector<std::pair<double,double>> width_space);
int get_current_section_columns ();
void flush_section ();
@ -202,6 +202,9 @@ public:
bool empty() {return current_root_elements_.empty();}
int m_pendingBreakType = -1;
bool pendingBreakType = false;
private:
void start_table_header_rows();
void end_table_header_rows ();

View File

@ -39,7 +39,7 @@ int main(int argc, char** argv)
std::wstring wsep = FILE_SEPARATOR_STR;
std::wstring filename_in = curr_dir + wsep + L"123.docx";
std::wstring filename_out = curr_dir + wsep + L"123.pdf";
std::wstring filename_out = curr_dir + wsep + L"123.odt";
std::wstring fonts_dir = curr_dir + wsep + L"fonts";
std::wstring xml = curr_dir + wsep + L"params.xml";