From 06edc93c7be90fae57dc63a60cb4723b355eae3d Mon Sep 17 00:00:00 2001 From: Kamil Kerimov Date: Wed, 24 Jul 2024 18:16:50 +0300 Subject: [PATCH] Fix bug #69238 --- OdfFile/Writer/Converter/ConvertDrawing.cpp | 24 ++++++++-- .../Writer/Format/Shapes/oox_shapeArrows.h | 48 +++++++++++-------- OdfFile/Writer/Format/odf_drawing_context.cpp | 7 +++ OdfFile/Writer/Format/odf_drawing_context.h | 2 + 4 files changed, 59 insertions(+), 22 deletions(-) diff --git a/OdfFile/Writer/Converter/ConvertDrawing.cpp b/OdfFile/Writer/Converter/ConvertDrawing.cpp index 69b6c8857a..61d4f1ce85 100644 --- a/OdfFile/Writer/Converter/ConvertDrawing.cpp +++ b/OdfFile/Writer/Converter/ConvertDrawing.cpp @@ -2828,14 +2828,32 @@ void OoxConverter::convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeSt odf_context()->end_text_context(); } + +static std::wstring convert_arc_angle(const std::wstring& angle, odf_writer::odf_drawing_context* dc) +{ + std::wstring result = L"0"; + + int angleInt = XmlUtils::GetInteger(angle); + + if (angleInt == 0 && angle != L"0") + { + result = std::wstring(L"gd") + std::to_wstring(dc->get_formulas_count()); + dc->add_formula(result, L"*/ 1 " + angle + L" 60000"); + } + else + result = std::to_wstring(angleInt / 60000); + + return result; +} + void OoxConverter::convert(PPTX::Logic::ArcTo *oox_geom_path) { if (!oox_geom_path) return; - int stAng = XmlUtils::GetInteger(oox_geom_path->stAng); - int swAng = XmlUtils::GetInteger(oox_geom_path->swAng); + const std::wstring stAng = convert_arc_angle(oox_geom_path->stAng, odf_context()->drawing_context()); + const std::wstring swAng = convert_arc_angle(oox_geom_path->swAng, odf_context()->drawing_context()); - std::wstring path_elm = oox_geom_path->wR + L" " + oox_geom_path->hR + L" " + std::to_wstring(stAng/60000) + L" " + std::to_wstring(swAng /60000); + std::wstring path_elm = oox_geom_path->wR + L" " + oox_geom_path->hR + L" " + stAng + L" " + swAng; odf_context()->drawing_context()->add_path_element(std::wstring(L"G"), path_elm); } diff --git a/OdfFile/Writer/Format/Shapes/oox_shapeArrows.h b/OdfFile/Writer/Format/Shapes/oox_shapeArrows.h index bc10c970e4..3c8948957c 100644 --- a/OdfFile/Writer/Format/Shapes/oox_shapeArrows.h +++ b/OdfFile/Writer/Format/Shapes/oox_shapeArrows.h @@ -53,29 +53,39 @@ public: { odf_type_name = L"ooxml-leftArrow"; - enhanced_path = L"M 21600 ?f0 L ?f1 ?f0 ?f1 0 0 10800 ?f1 21600 ?f1 ?f2 21600 ?f2 Z N"; - text_areas = L"?f7 ?f0 21600 ?f2"; - modifiers = L"9078 5400"; - view_box = L"0 0 21600 21600"; + enhanced_path = L"M 0 ?f7 L ?f5 0 ?f5 ?f8 ?f13 ?f8 ?f13 ?f9 ?f5 ?f9 ?f5 ?f14 Z N"; + text_areas = L"?f12 ?f8 ?f13 ?f9"; + modifiers = L"50000 50000"; + view_box = L"0 0 0 0"; - add(L"f0", L"$1 "); - add(L"f1", L"$0 "); - add(L"f2", L"21600-$1 "); - add(L"f3", L"21600-?f1 "); - add(L"f4", L"?f3 *?f0 /10800"); - add(L"f5", L"?f1 +?f4 "); - add(L"f6", L"?f1 *?f0 /10800"); - add(L"f7", L"?f1 -?f6 "); + add(L"f0", L"min(logwidth,logheight)"); + add(L"f1", L"100000*logwidth/?f0 "); + add(L"f2", L"if(0-$0 ,0,if(100000-$0 ,$0 ,100000))"); + add(L"f3", L"if(0-$1 ,0,if(?f1 -$1 ,$1 ,?f1 ))"); + add(L"f4", L"?f0 *?f3 /100000"); + add(L"f5", L"0+?f4 -0"); + add(L"f6", L"logheight*?f2 /200000"); + add(L"f7", L"logheight/2"); + add(L"f8", L"?f7 +0-?f6 "); + add(L"f9", L"?f7 +?f6 -0"); + add(L"f10", L"logheight/2"); + add(L"f11", L"?f8 *?f4 /?f10 "); + add(L"f12", L"?f5 +0-?f11 "); + add(L"f13", L"logwidth"); + add(L"f14", L"logheight"); ///////////////////////////////////////////////////////// - _handle h; + _handle h1, h2; - h.position = L"$0 $1"; - h.x_minimum = L"0"; - h.x_maximum = L"21600"; - h.y_minimum = L"0"; - h.y_maximum = L"10800"; + h1.position = L"?f13 ?f8"; + h1.y_minimum = L"0"; + h1.y_maximum = L"100000"; + + h2.position = L"?f5 0"; + h2.x_minimum = L"0"; + h2.x_maximum = L"?f1"; - handles.push_back(h); + handles.push_back(h1); + handles.push_back(h2); } }; class oox_shape_RightArrow : public oox_shape diff --git a/OdfFile/Writer/Format/odf_drawing_context.cpp b/OdfFile/Writer/Format/odf_drawing_context.cpp index 7bd677c38a..8679507fc1 100644 --- a/OdfFile/Writer/Format/odf_drawing_context.cpp +++ b/OdfFile/Writer/Format/odf_drawing_context.cpp @@ -1643,6 +1643,13 @@ void odf_drawing_context::set_z_order(int id) impl_->current_drawing_state_.z_order_ = id + 1; } +int odf_drawing_context::get_formulas_count() +{ + if (!impl_->current_drawing_state_.oox_shape_) + return 0; + + return impl_->current_drawing_state_.oox_shape_->equations.size(); +} void odf_drawing_context::set_path(std::wstring path_string) { impl_->current_drawing_state_.path_ = path_string; diff --git a/OdfFile/Writer/Format/odf_drawing_context.h b/OdfFile/Writer/Format/odf_drawing_context.h index 28949e0cf8..d97e4f2942 100644 --- a/OdfFile/Writer/Format/odf_drawing_context.h +++ b/OdfFile/Writer/Format/odf_drawing_context.h @@ -201,6 +201,8 @@ public: bool is_exist_content(); bool is_current_empty(); ////////////////////////////////////////////////////////////////////////////////////// + int get_formulas_count(); + void set_path (std::wstring path_string); void add_path_element (std::wstring command, std::wstring elm); void add_modifier (std::wstring modifier);