From 1709ef0c08220fc69ca5d1c4a26e667072df39a7 Mon Sep 17 00:00:00 2001 From: Kamil Kerimov Date: Wed, 6 Dec 2023 15:51:33 +0500 Subject: [PATCH 1/2] For bug #50186 --- OdfFile/Writer/Format/odf_drawing_context.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/OdfFile/Writer/Format/odf_drawing_context.cpp b/OdfFile/Writer/Format/odf_drawing_context.cpp index 66dd77734e..4219ddffd9 100644 --- a/OdfFile/Writer/Format/odf_drawing_context.cpp +++ b/OdfFile/Writer/Format/odf_drawing_context.cpp @@ -1691,10 +1691,25 @@ int GetFormulaType2(const WCHAR& c1, const WCHAR& c2) return 0; } +static std::wstring replace_textarea(std::wstring textarea_coord) +{ + XmlUtils::replace_all(textarea_coord, L"t", L"top"); + XmlUtils::replace_all(textarea_coord, L"l", L"left"); + XmlUtils::replace_all(textarea_coord, L"r", L"right"); + XmlUtils::replace_all(textarea_coord, L"b", L"bottom"); + + return textarea_coord; +} + void odf_drawing_context::set_textarea (std::wstring l, std::wstring t, std::wstring r, std::wstring b) { if (!impl_->current_drawing_state_.oox_shape_) return; + l = replace_textarea(l); + t = replace_textarea(t); + r = replace_textarea(r); + b = replace_textarea(b); + impl_->current_drawing_state_.oox_shape_->text_areas = l + L" " + t + L" " + r + L" " + b; XmlUtils::replace_all(impl_->current_drawing_state_.oox_shape_->text_areas, L"gd", L"?f"); @@ -1824,8 +1839,8 @@ void odf_drawing_context::add_formula (std::wstring name, std::wstring fmla) } XmlUtils::replace_all(odf_fmla, L"gd", L"?f"); - XmlUtils::replace_all(odf_fmla, L"h", L"logheight"); - XmlUtils::replace_all(odf_fmla, L"w", L"logwidth"); + XmlUtils::replace_all(odf_fmla, L"h", L"(bottom-top)"); + XmlUtils::replace_all(odf_fmla, L"w", L"(right-left)"); XmlUtils::replace_all(odf_fmla, L"adj", L"$"); //XmlUtils::replace_all(name, L"gd", L"f"); From bfa6a6d826a0dde0f34ab5b87d9e84edf48a5f04 Mon Sep 17 00:00:00 2001 From: Kamil Kerimov Date: Thu, 7 Dec 2023 20:12:46 +0500 Subject: [PATCH 2/2] Fix bug #50186 --- .../Format/Shapes/oox_shapePrimitives.h | 31 ++++++------ .../Format/Shapes/oox_shapeSnipRoundRects.h | 50 ++++++++----------- OdfFile/Writer/Format/draw_shapes.cpp | 3 ++ OdfFile/Writer/Format/draw_shapes.h | 3 ++ OdfFile/Writer/Format/odf_drawing_context.cpp | 9 +++- OdfFile/Writer/Format/oox_shape_defines.h | 5 ++ 6 files changed, 57 insertions(+), 44 deletions(-) diff --git a/OdfFile/Writer/Format/Shapes/oox_shapePrimitives.h b/OdfFile/Writer/Format/Shapes/oox_shapePrimitives.h index 0921330a14..939f4e3956 100644 --- a/OdfFile/Writer/Format/Shapes/oox_shapePrimitives.h +++ b/OdfFile/Writer/Format/Shapes/oox_shapePrimitives.h @@ -1347,28 +1347,29 @@ class oox_shape_Triangle : public oox_shape public: oox_shape_Triangle() { - odf_type_name =L"ooxml-triangle"; + odf_type_name =L"isosceles-triangle"; - enhanced_path = L"M 0 ?f6 L ?f2 0 ?f7 ?f6 Z N"; - text_areas = L"?f1 ?f5 ?f4 ?f6"; - view_box = L"0 0 0 0"; - modifiers = L"50000"; + enhanced_path = L"M ?f0 0 L 21600 21600 0 21600 Z N"; + text_areas = L"?f1 10800 ?f2 18000 ?f3 7200 ?f4 21600"; + view_box = L"0 0 21600 21600"; + modifiers = L"10800"; + glue_points = L"?f0 0 ?f1 10800 0 21600 10800 21600 21600 21600 ?f7 10800"; - add(L"f0", L"if(0-$0 ,0,if(100000-$0 ,$0 ,100000))"); - add(L"f1", L"logwidth*?f0 /200000"); - add(L"f2", L"logwidth*?f0 /100000"); - add(L"f3", L"logwidth/2"); - add(L"f4", L"?f1 +?f3 -0"); - add(L"f5", L"logheight/2"); - add(L"f6", L"logheight"); - add(L"f7", L"logwidth"); + add(L"f0", L"$0 "); + add(L"f1", L"$0 /2"); + add(L"f2", L"?f1 +10800"); + add(L"f3", L"$0 *2/3"); + add(L"f4", L"?f3 +7200"); + add(L"f5", L"21600-?f0 "); + add(L"f6", L"?f5 /2"); + add(L"f7", L"21600-?f6 "); ///////////////////////////////////////////////////////// _handle h; - h.position = L"?f2 0"; + h.position = L"$0 top"; h.x_minimum = L"0"; - h.x_maximum = L"100000"; + h.x_maximum = L"21600"; handles.push_back(h); } }; diff --git a/OdfFile/Writer/Format/Shapes/oox_shapeSnipRoundRects.h b/OdfFile/Writer/Format/Shapes/oox_shapeSnipRoundRects.h index 1aa7048e1a..e58a3fb163 100644 --- a/OdfFile/Writer/Format/Shapes/oox_shapeSnipRoundRects.h +++ b/OdfFile/Writer/Format/Shapes/oox_shapeSnipRoundRects.h @@ -724,39 +724,33 @@ class oox_shape_roundRect : public oox_shape public: oox_shape_roundRect() { - odf_type_name =L"ooxml-roundRect"; + odf_type_name =L"round-rectangle"; - enhanced_path = L"M 0 ?f2 G ?f2 ?f2 ?f12 ?f13 L ?f3 0 G ?f2 ?f2 ?f14 ?f15 L ?f11 ?f4 G ?f2 ?f2 ?f16 ?f17 L ?f2 ?f10 G ?f2 ?f2 ?f18 ?f19 Z N"; - text_areas = L"?f5 ?f5 ?f6 ?f7"; - view_box = L"0 0 0 0"; - modifiers = L"16667"; + enhanced_path = L"M ?f7 0 X 0 ?f8 L 0 ?f9 Y ?f7 21600 L ?f10 21600 X 21600 ?f9 L 21600 ?f8 Y ?f10 0 Z N"; + text_areas = L"?f3 ?f4 ?f5 ?f6"; + view_box = L"0 0 21600 21600"; + modifiers = L"3600"; + path_stretchpoint_x = L"10800"; + path_stretchpoint_y = L"10800"; - add(L"f0", L"if(0-$0 ,0,if(50000-$0 ,$0 ,50000))"); - add(L"f1", L"min(logwidth,logheight)"); - add(L"f2", L"?f1 *?f0 /100000"); - add(L"f3", L"logwidth+0-?f2 "); - add(L"f4", L"logheight+0-?f2 "); - add(L"f5", L"?f2 *29289/100000"); - add(L"f6", L"logwidth+0-?f5 "); - add(L"f7", L"logheight+0-?f5 "); - add(L"f8", L"logwidth/2"); - add(L"f9", L"logheight/2"); - add(L"f10", L"logheight"); - add(L"f11", L"logwidth"); - add(L"f12", L"(10800000)/60000.0"); - add(L"f13", L"(5400000)/60000.0"); - add(L"f14", L"(16200000)/60000.0"); - add(L"f15", L"(5400000)/60000.0"); - add(L"f16", L"(0)/60000.0"); - add(L"f17", L"(5400000)/60000.0"); - add(L"f18", L"(5400000)/60000.0"); - add(L"f19", L"(5400000)/60000.0"); + add(L"f0", L"45"); + add(L"f1", L"$0 *sin(?f0 *(pi/180))"); + add(L"f2", L"?f1 *3163/7636 "); + add(L"f3", L"left+?f2 "); + add(L"f4", L"top+?f2 "); + add(L"f5", L"right-?f2 "); + add(L"f6", L"bottom-?f2 "); + add(L"f7", L"left+$0 "); + add(L"f8", L"top+$0 "); + add(L"f9", L"bottom-$0 "); + add(L"f10", L"right-$0 "); //----------------------------------------------------------------- _handle h1; - h1.position = L"?f2 0"; - h1.x_maximum= L"50000"; - h1.x_minimum= L"0"; + h1.position = L"$0 top"; + h1.x_minimum = L"0"; + h1.x_maximum = L"10800"; + h1.handle_swiched = true; handles.push_back(h1); } }; diff --git a/OdfFile/Writer/Format/draw_shapes.cpp b/OdfFile/Writer/Format/draw_shapes.cpp index 3497666ec3..7149a8fed2 100644 --- a/OdfFile/Writer/Format/draw_shapes.cpp +++ b/OdfFile/Writer/Format/draw_shapes.cpp @@ -435,6 +435,9 @@ void draw_enhanced_geometry_attlist::serialize(CP_ATTR_NODE) CP_XML_ATTR_OPT(L"draw:text-path-mode", draw_text_path_mode_); CP_XML_ATTR_OPT(L"draw:text-path-scale", draw_text_path_scale_); CP_XML_ATTR_OPT(L"draw:text-path-same-letter-heights", draw_text_path_same_letter_heights_); + + CP_XML_ATTR_OPT(L"draw:path-stretchpoint-x", draw_path_stretchpoint_x_); + CP_XML_ATTR_OPT(L"draw:path-stretchpoint-y", draw_path_stretchpoint_y_); } //------------------------------------------------------------------------------------------- // draw:enhanced_geometry diff --git a/OdfFile/Writer/Format/draw_shapes.h b/OdfFile/Writer/Format/draw_shapes.h index 4e0bc5bc36..ba79801a85 100644 --- a/OdfFile/Writer/Format/draw_shapes.h +++ b/OdfFile/Writer/Format/draw_shapes.h @@ -323,6 +323,9 @@ public: _CP_OPT(std::wstring) draw_text_path_scale_; _CP_OPT(int) draw_text_rotate_angle_; + + _CP_OPT(std::wstring) draw_path_stretchpoint_x_; + _CP_OPT(std::wstring) draw_path_stretchpoint_y_; void serialize(CP_ATTR_NODE); }; diff --git a/OdfFile/Writer/Format/odf_drawing_context.cpp b/OdfFile/Writer/Format/odf_drawing_context.cpp index 4219ddffd9..6b5e961a3f 100644 --- a/OdfFile/Writer/Format/odf_drawing_context.cpp +++ b/OdfFile/Writer/Format/odf_drawing_context.cpp @@ -1179,7 +1179,14 @@ void odf_drawing_context::end_shape() enhanced->attlist_.draw_glue_points_ = shape_define->glue_points; enhanced->attlist_.draw_sub_view_size_ = shape_define->sub_view_size; - if (impl_->current_drawing_state_.oox_shape_ && !impl_->current_drawing_state_.oox_shape_->modifiers.empty()) + enhanced->attlist_.draw_path_stretchpoint_x_ = shape_define->path_stretchpoint_x; + enhanced->attlist_.draw_path_stretchpoint_y_ = shape_define->path_stretchpoint_y; + + if (!shape_define->modifiers.empty()) + { + enhanced->attlist_.draw_modifiers_ = shape_define->modifiers; + } + else if (impl_->current_drawing_state_.oox_shape_ && !impl_->current_drawing_state_.oox_shape_->modifiers.empty()) { enhanced->attlist_.draw_modifiers_ = impl_->current_drawing_state_.oox_shape_->modifiers; } diff --git a/OdfFile/Writer/Format/oox_shape_defines.h b/OdfFile/Writer/Format/oox_shape_defines.h index 1cbbf7417f..01b987f855 100644 --- a/OdfFile/Writer/Format/oox_shape_defines.h +++ b/OdfFile/Writer/Format/oox_shape_defines.h @@ -66,6 +66,8 @@ namespace cpdoccore _CP_OPT(std::wstring) x_maximum; _CP_OPT(std::wstring) r_minimum; _CP_OPT(std::wstring) r_maximum; + + _CP_OPT(bool) handle_swiched; }; void add(std::wstring name,std::wstring frmla); @@ -81,6 +83,9 @@ namespace cpdoccore _CP_OPT(std::wstring) sub_view_size; _CP_OPT(std::wstring) glue_points; + std::wstring path_stretchpoint_x; + std::wstring path_stretchpoint_y; + std::wstring odf_type_name; }; };