fix/bug73365

fix bug when after conversion text move to next column. Also detect and fix a new bug, when we have explicit break column but break is happening early
This commit is contained in:
Timofey Derevyankin
2025-08-21 14:28:47 +03:00
parent 98af93c631
commit b1c8969ede
4 changed files with 50 additions and 47 deletions

View File

@ -616,39 +616,6 @@ namespace odf_writer
if ((content_) && (content_->styles_.rdbuf()->in_avail() != 0))
{
std::wstring str_styles = content_->styles_.str();
if( str_styles.find(L"text:dont-balance-text-columns=\"true\"") == std::string::npos )
{
std::size_t style_pos = str_styles.find(L"style:section-properties");
if( style_pos != std::string::npos )
{
std::size_t end_pos = str_styles.find(L">", style_pos);
if( end_pos != std::string::npos )
{
std::wregex break_regex(L"fo:break-before\\s*=\\s*\"column\"");
bool have_fo_break_before_column = std::regex_search( str_styles, break_regex );
if( !have_fo_break_before_column )
{
str_styles.insert(end_pos,L" text:dont-balance-text-columns=\"true\" style:editable=\"false\"");
}
else
{
std::wregex pattern(L"fo:break-before\\s*=\\s*\"column\"");
str_styles.insert(end_pos,L" text:dont-balance-text-columns=\"false\" style:editable=\"false\"");
str_styles = std::regex_replace( str_styles, pattern , L"");
}
content_->styles_.str(L"");
content_->styles_.clear();
content_->styles_ << str_styles;
}
}
}
content_->styles_.flush();
CP_XML_STREAM() << content_->styles_.rdbuf();
content_->styles_.clear();

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 ();