From c961f00fd116e2c66ab6f9653b2f0c0dbf301fc6 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Tue, 26 Mar 2024 20:06:43 +0300 Subject: [PATCH] fix bug #67043 --- OdfFile/Reader/Format/paragraph_elements.cpp | 27 ++++++++++--------- .../Writer/Format/odt_conversion_context.cpp | 9 +++++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/OdfFile/Reader/Format/paragraph_elements.cpp b/OdfFile/Reader/Format/paragraph_elements.cpp index 57e4549b0d..4b90ab12db 100644 --- a/OdfFile/Reader/Format/paragraph_elements.cpp +++ b/OdfFile/Reader/Format/paragraph_elements.cpp @@ -740,16 +740,16 @@ void a::add_space(const std::wstring & Text) } void a::docx_convert(oox::docx_conversion_context & Context) { - bool pushed_style = false; - - bool addNewRun = false; - Context.finish_run(); - - std::wostream & _Wostream = Context.output_stream(); - std::wstring ref = xlink_attlist_.href_.get_value_or(L""); + if (ref.empty()) return; + + bool pushed_style = false; + bool addNewRun = false; + + Context.finish_run(); - if (Context.is_table_content()) + std::wostream& _Wostream = Context.output_stream(); + if (Context.is_table_content() || office_target_frame_name_ || ref[0] == L'#') { size_t pos_outline = ref.find(L"|outline"); if (std::wstring::npos != pos_outline)//без # @@ -766,11 +766,14 @@ void a::docx_convert(oox::docx_conversion_context & Context) { ref = XmlUtils::EncodeXmlString(ref.substr(1)); } - _Wostream << L""; - int type = Context.get_table_content_context().get_type_current_content_template_index(); - //type == 3 (LinkStart) - Context.get_table_content_context().next_level_index(); + + if (Context.is_table_content()) + { + int type = Context.get_table_content_context().get_type_current_content_template_index(); + //type == 3 (LinkStart) + Context.get_table_content_context().next_level_index(); + } } else { diff --git a/OdfFile/Writer/Format/odt_conversion_context.cpp b/OdfFile/Writer/Format/odt_conversion_context.cpp index 89c8a3a133..28d20c9bf8 100644 --- a/OdfFile/Writer/Format/odt_conversion_context.cpp +++ b/OdfFile/Writer/Format/odt_conversion_context.cpp @@ -590,6 +590,15 @@ void odt_conversion_context::start_hyperlink(const std::wstring& link, const std text_a* hyperlink = dynamic_cast(hyperlink_elm.get()); if (hyperlink) { + if (location == L"_top") + hyperlink->office_target_frame_name_ = odf_types::target_frame_name::Top; + else if (location == L"_blank") + hyperlink->office_target_frame_name_ = odf_types::target_frame_name::Blank; + else if (location == L"_self") + hyperlink->office_target_frame_name_ = odf_types::target_frame_name::Self; + else if (location == L"_parent") + hyperlink->office_target_frame_name_ = odf_types::target_frame_name::Parent; + hyperlink->common_xlink_attlist_.href_ = link + (location.empty() ? L"" : (L"#" + location)); hyperlink->common_xlink_attlist_.type_ = xlink_type::Simple;