diff --git a/DesktopEditor/graphics/pro/js/drawingfile.json b/DesktopEditor/graphics/pro/js/drawingfile.json index 571be3aee7..1cffe21331 100644 --- a/DesktopEditor/graphics/pro/js/drawingfile.json +++ b/DesktopEditor/graphics/pro/js/drawingfile.json @@ -73,8 +73,7 @@ "freetype-2.10.4/include", "freetype-2.10.4/include/freetype", "../../../../OfficeUtils/src/zlib-1.2.11", "../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip", "../../../../OfficeUtils/src", "../../../../Common/3dParty/icu/icu/source/common", - "../../../../Common/3dParty/libxml/libxml2/include", - "../../../xml/build/qt", + "../../../xml/libxml2/include", "../../../xml/build/qt", "../../../../PdfFile/lib/goo", "../../../../PdfFile/lib/fofi", "../../../../PdfFile/lib/splash", "../../../../PdfFile/lib", "../../../raster/Jp2/openjpeg", "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2", "../../../../Common/3dParty/openssl/openssl/include", diff --git a/OOXML/Base/Unit.cpp b/OOXML/Base/Unit.cpp index 41829156fb..e3fc66221e 100644 --- a/OOXML/Base/Unit.cpp +++ b/OOXML/Base/Unit.cpp @@ -859,29 +859,31 @@ namespace XmlUtils case L'\0': default: { - if (!IsUnicodeSymbol(static_cast( data[pos]))) - { -#ifdef _WIN32 - wchar_t symbol1 = data[pos]; +#if defined(_WIN32) || defined(_WIN64) + wchar_t symbol1 = data[pos]; #else - uint16_t symbol1 = static_cast(data[pos]); + uint16_t symbol1 = static_cast(data[pos]); #endif + if (!IsUnicodeSymbol(static_cast( symbol1))) + { + if(0xD800 <= symbol1 && symbol1 <= 0xDFFF && pos + 1 < data.size()) { -#ifdef _WIN32 + +#if defined(_WIN32) || defined(_WIN64) wchar_t symbol2 = data[pos+1]; #else uint16_t symbol2 = static_cast(data[pos+1]); #endif + if (symbol1 < 0xDC00 && symbol2 >= 0xDC00 && symbol2 <= 0xDFFF) { -#ifdef _WIN32 - buffer.append(&data[pos], 2); -#else + uint32_t codepoint = 0x10000 + ((symbol1 - 0xD800) << 10) + (symbol2 - 0xDC00); - buffer += static_cast(codepoint); -#endif + wchar_t hexBuf[20]; + swprintf(hexBuf, 20, L"&#x%X;", codepoint); + buffer.append(hexBuf); pos++; } else diff --git a/OdfFile/Reader/Format/draw_shapes.cpp b/OdfFile/Reader/Format/draw_shapes.cpp index b1bde73148..62ed96af72 100644 --- a/OdfFile/Reader/Format/draw_shapes.cpp +++ b/OdfFile/Reader/Format/draw_shapes.cpp @@ -252,6 +252,27 @@ void draw_path::add_attributes( const xml::attributes_wc_ptr & Attributes ) sub_type_ = 6; } + +std::vector transform_svg_view_box(std::wstring& svg_view_box) +{ + std::wstring::iterator it_start = svg_view_box.begin(), it_end = svg_view_box.end(); + std::vector vec_svg_view_box; + std::wstring element{}; + for(;it_start != it_end; it_start++) + { + if(std::iswspace(*it_start) && !element.empty()) + { + vec_svg_view_box.push_back(std::stod(element)); + element.clear(); + } + else if(std::isdigit(*it_start) || *it_start == L'\u002D') + element.push_back(*it_start); + } + if(!element.empty()) + vec_svg_view_box.push_back(std::stod(element)); + + return vec_svg_view_box; +} void draw_path::reset_svg_path() { if (!draw_path_attlist_.svg_d_) @@ -262,7 +283,16 @@ void draw_path::reset_svg_path() { std::vector<::svg_path::_polyline> o_Polyline_pt; std::vector<::svg_path::_polyline> o_Polyline_cm; - + std::vector svg_view_box = transform_svg_view_box(draw_path_attlist_.svg_viewbox_.get()); + + double scale_y{0.0}, scale_x{0.0}; + if(svg_view_box.size() == 4) + { + scale_y = draw_path_attlist_.svg_height_->get_value()/(svg_view_box[3]/1000.); + scale_x = draw_path_attlist_.svg_width_->get_value()/(svg_view_box[2]/1000.); + } + + bool bClosed = false, bStroked = true; bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_path_attlist_.svg_d_.get(), false, bClosed, bStroked); @@ -276,11 +306,17 @@ void draw_path::reset_svg_path() { if (poly.points[i].x) { - poly.points[i].x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu); + if(svg_view_box.size() == 4 && scale_x != 0.0) + poly.points[i].x = length((poly.points[i].x.get() - svg_view_box[0])/1000. * scale_x,length::cm).get_value_unit(length::emu); + else + poly.points[i].x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu); } if (poly.points[i].y) { - poly.points[i].y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu); + if(svg_view_box.size() == 4 && scale_y != 0.0) + poly.points[i].y = length((poly.points[i].y.get() - svg_view_box[1])/1000. * scale_y,length::cm).get_value_unit(length::emu); + else + poly.points[i].y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu); } } o_Polyline_pt.push_back(poly); diff --git a/OdfFile/Reader/Format/draw_shapes.h b/OdfFile/Reader/Format/draw_shapes.h index 91814338d0..22fd8c52a0 100644 --- a/OdfFile/Reader/Format/draw_shapes.h +++ b/OdfFile/Reader/Format/draw_shapes.h @@ -228,6 +228,8 @@ public: virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); _CP_OPT(std::wstring) svg_d_; _CP_OPT(std::wstring) svg_viewbox_; + _CP_OPT(odf_types::length) svg_height_; + _CP_OPT(odf_types::length) svg_width_; }; ///////////////////////////////////////////////////////////////////////// diff --git a/OdfFile/Reader/Format/draw_shapes_pptx.cpp b/OdfFile/Reader/Format/draw_shapes_pptx.cpp index da2cf95006..1228087b0e 100644 --- a/OdfFile/Reader/Format/draw_shapes_pptx.cpp +++ b/OdfFile/Reader/Format/draw_shapes_pptx.cpp @@ -233,6 +233,9 @@ void draw_line::pptx_convert(oox::pptx_conversion_context & Context) void draw_path::pptx_convert(oox::pptx_conversion_context & Context) { + draw_path_attlist_.svg_height_ = Context.get_text_context().get_svg_height(); + draw_path_attlist_.svg_width_ = Context.get_text_context().get_svg_width(); + reset_svg_path(); /////////////////////////////////////////////////////////////////////// Context.get_slide_context().start_shape(sub_type_);