From a4ebe56f28b75b3b110ea8c44604a48a7cecc647 Mon Sep 17 00:00:00 2001 From: Timofey Derevyankin Date: Sun, 17 Aug 2025 10:18:47 +0300 Subject: [PATCH] Fix/bug73365 fix bug with convert from docx to odt --- OdfFile/Writer/Format/object_package.cpp | 35 ++++++++++++++++++++++++ X2tConverter/test/qmake/main.cpp | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/OdfFile/Writer/Format/object_package.cpp b/OdfFile/Writer/Format/object_package.cpp index 73d60d4f0c..c06bfb59d1 100644 --- a/OdfFile/Writer/Format/object_package.cpp +++ b/OdfFile/Writer/Format/object_package.cpp @@ -43,6 +43,8 @@ #include "../../../OOXML/SystemUtility/SystemUtility.h" #include "../../../Common/3dParty/cryptopp/osrng.h" +#include + namespace cpdoccore { namespace odf_writer @@ -614,6 +616,39 @@ 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(); diff --git a/X2tConverter/test/qmake/main.cpp b/X2tConverter/test/qmake/main.cpp index c1ff84e987..68e2f3a639 100644 --- a/X2tConverter/test/qmake/main.cpp +++ b/X2tConverter/test/qmake/main.cpp @@ -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";