Rebased ref, commits from common ancestor: commit 49434467a49c00e2928f6d3669bdfc5f45811af3 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Nov 12 10:01:20 2020 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Fri Aug 19 16:08:03 2022 +0200
basegfx: added Length class as the base unit for length Change-Id: I1d4790b60dd784e8b2e2e438274f3ebd6db4b60c diff --git a/basegfx/CppunitTest_basegfx.mk b/basegfx/CppunitTest_basegfx.mk index 88f4966262f2..98d3a5d41926 100644 --- a/basegfx/CppunitTest_basegfx.mk +++ b/basegfx/CppunitTest_basegfx.mk @@ -45,6 +45,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,basegfx,\ basegfx/test/clipstate \ basegfx/test/genericclipper \ basegfx/test/VectorTest \ + basegfx/test/LengthUnitTest \ )) # vim: set noet sw=4 ts=4: diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx new file mode 100644 index 000000000000..40c21aa7bc90 --- /dev/null +++ b/basegfx/test/LengthUnitTest.cxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <basegfx/units/Length.hxx> +#include <basegfx/range/Range2D.hxx> + +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> + +struct LengthTraits +{ + static constexpr gfx::Length minVal() { return gfx::Length::min(); }; + static constexpr gfx::Length maxVal() { return gfx::Length::max(); }; + static constexpr gfx::Length neutral() { return gfx::Length(); }; + + typedef gfx::Length DifferenceType; +}; + +class LengthTest : public CppUnit::TestFixture +{ +public: + void test() + { + gfx::Length cm = 1_cm + 5_cm - 2_cm; + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, cm.as_cm(), 1e-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04, cm.as_m(), 1e-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(40.0, cm.as_mm(), 1e-4); + CPPUNIT_ASSERT_EQUAL(sal_Int64(1440000), cm.raw()); + + gfx::Length cm2 = 5_cm * 2; + CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), cm2.raw()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, cm2.as_cm(), 1e-4); + + // 1 km - 50 m = 950 m = 95000 cm + gfx::Length cm3 = 100000_cm - 5000_cm; + CPPUNIT_ASSERT_EQUAL(sal_Int64(34200000000), cm3.raw()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(95000.0, cm3.as_cm(), 1e-4); + + gfx::Length cm4(1_cm); + cm4 /= 2; + CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm4.raw()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm4.as_cm(), 1e-4); + + // (635 * 20) + 3 * (635 * 15) = 41275EMU + gfx::Length pt = 1_pt + 3_px; + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.25, pt.as_pt(), 1e-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, pt.as_twip(), 1e-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0451, pt.as_in(), 1e-4); + CPPUNIT_ASSERT_EQUAL(sal_Int64(41275), pt.raw()); + + gfx::Length inch = 1_in; // 1440 * 635 + CPPUNIT_ASSERT_DOUBLES_EQUAL(1440.0, inch.as_twip(), 1e-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(96.0, inch.as_px(), 1e-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, inch.as_in(), 1e-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(914400.0, inch.as_emu(), 1e-4); + CPPUNIT_ASSERT_EQUAL(sal_Int64(914400), inch.raw()); + + // Conversion + sal_Int64 asNumber(17_pt); + asNumber += sal_Int64(1_pt); + gfx::Length asLength = gfx::Length::emu(asNumber); + CPPUNIT_ASSERT_EQUAL(sal_Int64(18 * 635 * 20), asLength.raw()); + + gfx::Length maximum = gfx::Length::emu(SAL_MAX_INT64); + CPPUNIT_ASSERT_DOUBLES_EQUAL(256204778801.5, maximum.as_m(), 1e-1); + // 256204778 km + CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MAX_INT64), maximum.raw()); + + gfx::Length minimum = gfx::Length::emu(SAL_MIN_INT64); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-256204778801.5, minimum.as_m(), 1e-1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(double(SAL_MIN_INT64), minimum.as_emu(), 1e-1); + CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MIN_INT64), minimum.raw()); + + // 27 emu + 33 emu + 360 emu = 420 + gfx::Length emus = 27_emu + 33_emu + 1_hmm; + CPPUNIT_ASSERT_EQUAL(sal_Int64(420), emus.raw()); + + // Creation from number + int number = 10; + auto asCm = gfx::Length::cm(number); + CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asCm.as_cm(), 1e-4); + CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), asCm.raw()); + + auto asMm = gfx::Length::mm(number); + CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asMm.as_mm(), 1e-4); + CPPUNIT_ASSERT_EQUAL(sal_Int64(360000), asMm.raw()); + + auto asInch = gfx::Length::in(number); + CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asInch.as_in(), 1e-4); + CPPUNIT_ASSERT_EQUAL(sal_Int64(9144000), asInch.raw()); + + typedef basegfx::Range2D<gfx::Length, LengthTraits> Range2DL; + typedef basegfx::Tuple2D<gfx::Length> Tuple2DL; + + Range2DL aRange(1_cm, 2_cm, 2_cm, 30_mm); + CPPUNIT_ASSERT_EQUAL(1_cm, aRange.getMinX()); + CPPUNIT_ASSERT_EQUAL(2_cm, aRange.getMaxX()); + CPPUNIT_ASSERT_EQUAL(2_cm, aRange.getMinY()); + CPPUNIT_ASSERT_EQUAL(3_cm, aRange.getMaxY()); + + CPPUNIT_ASSERT_EQUAL(1_cm, aRange.getWidth()); + CPPUNIT_ASSERT_EQUAL(10_mm, aRange.getHeight()); + + Tuple2DL aTuple(0.5_pt, 1_pt); + CPPUNIT_ASSERT_EQUAL(6350_emu, aTuple.getX()); + CPPUNIT_ASSERT_EQUAL(12700_emu, aTuple.getY()); + } + + CPPUNIT_TEST_SUITE(LengthTest); + CPPUNIT_TEST(test); + CPPUNIT_TEST_SUITE_END(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(LengthTest); diff --git a/include/basegfx/units/Length.hxx b/include/basegfx/units/Length.hxx new file mode 100644 index 000000000000..bf1adbf00178 --- /dev/null +++ b/include/basegfx/units/Length.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <basegfx/units/LengthUnitBase.hxx> + +namespace gfx +{ +typedef LengthUnitBase<sal_Int64> Length; + +} // end namespace gfx + +constexpr gfx::Length operator"" _emu(unsigned long long value) { return gfx::Length::emu(value); } +constexpr gfx::Length operator"" _in(unsigned long long value) { return gfx::Length::in(value); } +constexpr gfx::Length operator"" _cm(unsigned long long value) { return gfx::Length::cm(value); } +constexpr gfx::Length operator"" _mm(unsigned long long value) { return gfx::Length::mm(value); } +constexpr gfx::Length operator"" _hmm(unsigned long long value) { return gfx::Length::hmm(value); } +constexpr gfx::Length operator"" _twip(unsigned long long value) +{ + return gfx::Length::twip(value); +} +constexpr gfx::Length operator"" _pt(unsigned long long value) { return gfx::Length::pt(value); } +constexpr gfx::Length operator"" _px(unsigned long long value) { return gfx::Length::px(value); } + +constexpr gfx::Length operator"" _in(long double value) +{ + return gfx::Length::emu(std::round(gfx::constFactor_in_to_EMU * value)); +} +constexpr gfx::Length operator"" _cm(long double value) +{ + return gfx::Length::emu(std::round(gfx::constFactor_cm_to_EMU * value)); +} + +constexpr gfx::Length operator"" _mm(long double value) +{ + return gfx::Length::emu(std::round(gfx::constFactor_mm_to_EMU * value)); +} + +constexpr gfx::Length operator"" _hmm(long double value) +{ + return gfx::Length::emu(std::round(gfx::constFactor_hmm_to_EMU * value)); +} + +constexpr gfx::Length operator"" _twip(long double value) +{ + return gfx::Length::emu(std::round(gfx::constFactor_twip_to_EMU * value)); +} + +constexpr gfx::Length operator"" _pt(long double value) +{ + return gfx::Length::emu(std::round(gfx::constFactor_pt_to_EMU * value)); +} + +constexpr gfx::Length operator"" _px(long double value) +{ + return gfx::Length::emu(std::round(gfx::constFactor_px_to_EMU * value)); +} + +/** Write to char stream */ +template <typename charT, typename traits> +inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, + const gfx::Length& rLength) +{ + return stream << rLength.raw() << " (twip=" << rLength.as_twip() << ", hmm=" << rLength.as_hmm() + << ")"; +} diff --git a/include/basegfx/units/LengthUnitBase.hxx b/include/basegfx/units/LengthUnitBase.hxx new file mode 100644 index 000000000000..81a4f8216d5e --- /dev/null +++ b/include/basegfx/units/LengthUnitBase.hxx @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <sal/types.h> + +#include <ostream> +#include <cmath> + +namespace gfx +{ +namespace +{ +constexpr sal_Int64 constFactor_hmm_to_EMU = 360ll; +constexpr sal_Int64 constFactor_mm_to_EMU = constFactor_hmm_to_EMU * 100ll; +constexpr sal_Int64 constFactor_cm_to_EMU = constFactor_hmm_to_EMU * 1000ll; +constexpr sal_Int64 constFactor_m_to_EMU = constFactor_hmm_to_EMU * 100000ll; + +constexpr sal_Int64 constFactor_twip_to_EMU = 635ll; +constexpr sal_Int64 constFactor_in_to_EMU = constFactor_twip_to_EMU * 1440ll; +constexpr sal_Int64 constFactor_pt_to_EMU = constFactor_twip_to_EMU * 20ll; +constexpr sal_Int64 constFactor_px_to_EMU = constFactor_twip_to_EMU * 15ll; + +} // end anonymous namespace + +template <typename T> class LengthUnitBase +{ +private: + // value in EMU units + T m_nValue; + + constexpr explicit LengthUnitBase(T nValue) + : m_nValue(nValue) + { + } + +public: + static constexpr LengthUnitBase min() { return LengthUnitBase(SAL_MIN_INT64); } + + static constexpr LengthUnitBase max() { return LengthUnitBase(SAL_MAX_INT64); } + + static constexpr LengthUnitBase cm(T nValue) + { + return LengthUnitBase(gfx::constFactor_cm_to_EMU * nValue); + } + + static constexpr LengthUnitBase mm(T nValue) + { + return LengthUnitBase(gfx::constFactor_mm_to_EMU * nValue); + } + + static constexpr LengthUnitBase hmm(T nValue) + { + return LengthUnitBase(gfx::constFactor_hmm_to_EMU * nValue); + } + + static constexpr LengthUnitBase in(T nValue) + { + return LengthUnitBase(gfx::constFactor_in_to_EMU * nValue); + } + + static constexpr LengthUnitBase twip(T nValue) + { + return LengthUnitBase(gfx::constFactor_twip_to_EMU * nValue); + } + + static constexpr LengthUnitBase pt(T nValue) + { + return LengthUnitBase(gfx::constFactor_pt_to_EMU * nValue); + } + + static constexpr LengthUnitBase px(T nValue) + { + return LengthUnitBase(gfx::constFactor_px_to_EMU * nValue); + } + + static constexpr LengthUnitBase emu(T nValue) { return LengthUnitBase(nValue); } + + constexpr explicit LengthUnitBase() + : m_nValue(0) + { + } + + constexpr explicit operator T() const { return m_nValue; } + + constexpr LengthUnitBase& operator+=(LengthUnitBase const& rhs) + { + m_nValue += rhs.m_nValue; + return *this; + } + + constexpr LengthUnitBase& operator-=(LengthUnitBase const& rhs) + { + m_nValue -= rhs.m_nValue; + return *this; + } + + constexpr LengthUnitBase& operator*=(T const& rhs) + { + m_nValue *= rhs; + return *this; + } + + constexpr LengthUnitBase& operator/=(T const& rhs) + { + m_nValue /= rhs; + return *this; + } + + constexpr LengthUnitBase& operator-() + { + m_nValue = -m_nValue; + return *this; + } + + constexpr bool operator<(LengthUnitBase const& other) const + { + return m_nValue < other.m_nValue; + } + constexpr bool operator<=(LengthUnitBase const& other) const + { + return m_nValue <= other.m_nValue; + } + constexpr bool operator>(LengthUnitBase const& other) const + { + return m_nValue > other.m_nValue; + } + constexpr bool operator>=(LengthUnitBase const& other) const + { + return m_nValue >= other.m_nValue; + } + constexpr bool operator==(LengthUnitBase const& other) const + { + return m_nValue == other.m_nValue; + } + constexpr bool operator!=(LengthUnitBase const& other) const + { + return m_nValue != other.m_nValue; + } + + constexpr T raw() const { return m_nValue; } + + double as_hmm() const { return m_nValue / double(constFactor_hmm_to_EMU); } + double as_mm() const { return m_nValue / double(constFactor_mm_to_EMU); } + double as_cm() const { return m_nValue / double(constFactor_cm_to_EMU); } + double as_m() const { return m_nValue / double(constFactor_m_to_EMU); } + double as_twip() const { return m_nValue / double(constFactor_twip_to_EMU); } + double as_in() const { return m_nValue / double(constFactor_in_to_EMU); } + double as_pt() const { return m_nValue / double(constFactor_pt_to_EMU); } + double as_px() const { return m_nValue / double(constFactor_px_to_EMU); } + double as_emu() const { return double(m_nValue); } +}; + +template <typename T> +inline LengthUnitBase<T> operator+(LengthUnitBase<T> lhs, const LengthUnitBase<T>& rhs) +{ + return lhs += rhs; +} + +template <typename T> +inline LengthUnitBase<T> operator-(LengthUnitBase<T> lhs, const LengthUnitBase<T>& rhs) +{ + return lhs -= rhs; +} + +template <typename T> inline LengthUnitBase<T> operator*(LengthUnitBase<T> lhs, const long rhs) +{ + return lhs *= rhs; +} + +template <typename T> inline LengthUnitBase<T> operator/(LengthUnitBase<T> lhs, const long rhs) +{ + return lhs /= rhs; +} + +} // end namespace gfx commit 648ae8bb47d3627455b71da5b4f6f3e443aca314 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Jul 25 15:38:24 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Fri Aug 19 16:08:03 2022 +0200 svgio: use "frozen" for mapping between token strings and enums Change-Id: I2061606146cfcb34169dccf69b6f720727839d04 diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk index c5a35405323f..c4aa4f80e97b 100644 --- a/svgio/Library_svgio.mk +++ b/svgio/Library_svgio.mk @@ -25,7 +25,10 @@ $(eval $(call gb_Library_set_include,svgio,\ -I$(SRCDIR)/svgio/inc \ )) -$(eval $(call gb_Library_use_external,svgio,boost_headers)) +$(eval $(call gb_Library_use_externals,svgio,\ + boost_headers \ + frozen \ +)) $(eval $(call gb_Library_set_precompiled_header,svgio,svgio/inc/pch/precompiled_svgio)) diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx index 0b03e2c3f0cd..955043a9738f 100644 --- a/svgio/source/svgreader/svgtoken.cxx +++ b/svgio/source/svgreader/svgtoken.cxx @@ -18,327 +18,384 @@ */ #include <svgtoken.hxx> -#include <unordered_map> +#include <frozen/unordered_map.h> + namespace svgio::svgreader { - const char aSVGStrWidth[] = "width"; - const char aSVGStrHeight[] = "height"; - const char aSVGStrViewBox[] = "viewBox"; - const char aSVGStrTransform[] = "transform"; - const char aSVGStrStyle[] = "style"; - const char aSVGStrDisplay[] = "display"; // #i121656# - const char aSVGStrD[] = "d"; - const char aSVGStrX[] = "x"; - const char aSVGStrY[] = "y"; - const char aSVGStrXmlns[] = "xmlns"; - const char aSVGStrVersion[] = "version"; - const char aSVGStrId[] = "id"; - const char aSVGStrRx[] = "rx"; - const char aSVGStrRy[] = "ry"; - const char aSVGStrPoints[] = "points"; - const char aSVGStrDx[] = "dx"; - const char aSVGStrDy[] = "dy"; - const char aSVGStrRotate[] = "rotate"; - const char aSVGStrTextLength[] = "textLength"; - const char aSVGStrLengthAdjust[] = "lengthAdjust"; - const char aSVGStrFont[] = "font"; - const char aSVGStrFontFamily[] = "font-family"; - const char aSVGStrFontSize[] = "font-size"; - const char aSVGStrFontSizeAdjust[] = "font-size-adjust"; - const char aSVGStrFontStretch[] = "font-stretch"; - const char aSVGStrFontStyle[] = "font-style"; - const char aSVGStrFontVariant[] = "font-variant"; - const char aSVGStrFontWeight[] = "font-weight"; - const char aSVGStrDirection[] = "direction"; - const char aSVGStrLetterSpacing[] = "letter-spacing"; - const char aSVGStrTextDecoration[] = "text-decoration"; - const char aSVGStrUnicodeBidi[] = "unicode-bidi"; - const char aSVGStrWordSpacing[] = "word-spacing"; - const char aSVGStrTspan[] = "tspan"; - const char aSVGStrTref[] = "tref"; - const char aSVGStrTextPath[] = "textPath"; - const char aSVGStrStartOffset[] = "startOffset"; - const char aSVGStrMethod[] = "method"; - const char aSVGStrSpacing[] = "spacing"; - const char aSVGStrTextAlign[] = "text-align"; - const char aSVGStrPathLength[] = "pathLength"; - const char aSVGStrType[] = "type"; - const char aSVGStrClass[] = "class"; - const char aSVGStrTextAnchor[] = "text-anchor"; - const char aSVGStrXmlSpace[] = "xml:space"; - const char aSVGStrColor[] = "color"; - const char aSVGStrClipPathNode[] = "clipPath"; - const char aSVGStrClipPathProperty[] = "clip-path"; - const char aSVGStrMask[] = "mask"; - const char aSVGStrClipPathUnits[] = "clipPathUnits"; - const char aSVGStrMaskUnits[] = "maskUnits"; - const char aSVGStrMaskContentUnits[] = "maskContentUnits"; - const char aSVGStrClipRule[] = "clip-rule"; - const char aSVGStrMarker[] = "marker"; - const char aSVGStrMarkerStart[] = "marker-start"; - const char aSVGStrMarkerMid[] = "marker-mid"; - const char aSVGStrMarkerEnd[] = "marker-end"; - const char aSVGStrRefX[] = "refX"; - const char aSVGStrRefY[] = "refY"; - const char aSVGStrMarkerUnits[] = "markerUnits"; - const char aSVGStrMarkerWidth[] = "markerWidth"; - const char aSVGStrMarkerHeight[] = "markerHeight"; - const char aSVGStrOrient[] = "orient"; - const char aSVGStrPattern[] = "pattern"; - const char aSVGStrPatternUnits[] = "patternUnits"; - const char aSVGStrPatternContentUnits[] = "patternContentUnits"; - const char aSVGStrPatternTransform[] = "patternTransform"; - const char aSVGStrOpacity[] = "opacity"; - const char aSVGStrVisibility[] = "visibility"; - constexpr OUStringLiteral aSVGStrTitle = u"title"; - constexpr OUStringLiteral aSVGStrDesc = u"desc"; + constexpr const std::u16string_view constToken_Width = u"width"; + constexpr const std::u16string_view constToken_Height = u"height"; + constexpr const std::u16string_view constToken_ViewBox = u"viewBox"; + constexpr const std::u16string_view constTokenLowercase_ViewBox = u"viewbox"; + constexpr const std::u16string_view constToken_Transform = u"transform"; + constexpr const std::u16string_view constToken_Style = u"style"; + constexpr const std::u16string_view constToken_Display = u"display"; // #i121656# + constexpr const std::u16string_view constToken_D = u"d"; + constexpr const std::u16string_view constToken_X = u"x"; + constexpr const std::u16string_view constToken_Y = u"y"; + constexpr const std::u16string_view constToken_Xmlns = u"xmlns"; + constexpr const std::u16string_view constToken_Version = u"version"; + constexpr const std::u16string_view constToken_Id = u"id"; + constexpr const std::u16string_view constToken_Rx = u"rx"; + constexpr const std::u16string_view constToken_Ry = u"ry"; + constexpr const std::u16string_view constToken_Points = u"points"; + constexpr const std::u16string_view constToken_Dx = u"dx"; + constexpr const std::u16string_view constToken_Dy = u"dy"; + constexpr const std::u16string_view constToken_Rotate = u"rotate"; + constexpr const std::u16string_view constToken_TextLength = u"textLength"; + constexpr const std::u16string_view constTokenLowercase_TextLength = u"textlength"; + constexpr const std::u16string_view constToken_LengthAdjust = u"lengthAdjust"; + constexpr const std::u16string_view constTokenLowercase_LengthAdjust = u"lengthadjust"; + constexpr const std::u16string_view constToken_Font = u"font"; + constexpr const std::u16string_view constToken_FontFamily = u"font-family"; + constexpr const std::u16string_view constToken_FontSize = u"font-size"; + constexpr const std::u16string_view constToken_FontSizeAdjust = u"font-size-adjust"; + constexpr const std::u16string_view constToken_FontStretch = u"font-stretch"; + constexpr const std::u16string_view constToken_FontStyle = u"font-style"; + constexpr const std::u16string_view constToken_FontVariant = u"font-variant"; + constexpr const std::u16string_view constToken_FontWeight = u"font-weight"; + constexpr const std::u16string_view constToken_Direction = u"direction"; + constexpr const std::u16string_view constToken_LetterSpacing = u"letter-spacing"; + constexpr const std::u16string_view constToken_TextDecoration = u"text-decoration"; + constexpr const std::u16string_view constToken_UnicodeBidi = u"unicode-bidi"; + constexpr const std::u16string_view constToken_WordSpacing = u"word-spacing"; + constexpr const std::u16string_view constToken_Tspan = u"tspan"; + constexpr const std::u16string_view constToken_Tref = u"tref"; + constexpr const std::u16string_view constToken_TextPath = u"textPath"; + constexpr const std::u16string_view constTokenLowercase_TextPath = u"textpath"; + constexpr const std::u16string_view constToken_StartOffset = u"startOffset"; + constexpr const std::u16string_view constTokenLowercase_StartOffset = u"startoffset"; + constexpr const std::u16string_view constToken_Method = u"method"; + constexpr const std::u16string_view constToken_Spacing = u"spacing"; + constexpr const std::u16string_view constToken_TextAlign = u"text-align"; + constexpr const std::u16string_view constToken_PathLength = u"pathLength"; + constexpr const std::u16string_view constTokenLowercase_PathLength = u"pathlength"; + constexpr const std::u16string_view constToken_Type = u"type"; + constexpr const std::u16string_view constToken_Class = u"class"; + constexpr const std::u16string_view constToken_TextAnchor = u"text-anchor"; + constexpr const std::u16string_view constToken_XmlSpace = u"xml:space"; + constexpr const std::u16string_view constToken_Color = u"color"; + constexpr const std::u16string_view constToken_ClipPathNode = u"clipPath"; + constexpr const std::u16string_view constTokenLowercase_ClipPathNode = u"clippath"; + constexpr const std::u16string_view constToken_ClipPathProperty = u"clip-path"; + constexpr const std::u16string_view constToken_Mask = u"mask"; + constexpr const std::u16string_view constToken_ClipPathUnits = u"clipPathUnits"; + constexpr const std::u16string_view constTokenLowercase_ClipPathUnits = u"clippathunits"; + constexpr const std::u16string_view constToken_MaskUnits = u"maskUnits"; + constexpr const std::u16string_view constTokenLowercase_MaskUnits = u"maskunits"; + constexpr const std::u16string_view constToken_MaskContentUnits = u"maskContentUnits"; + constexpr const std::u16string_view constTokenLowercase_MaskContentUnits = u"maskcontentunits"; + constexpr const std::u16string_view constToken_ClipRule = u"clip-rule"; + constexpr const std::u16string_view constToken_Marker = u"marker"; + constexpr const std::u16string_view constToken_MarkerStart = u"marker-start"; + constexpr const std::u16string_view constToken_MarkerMid = u"marker-mid"; + constexpr const std::u16string_view constToken_MarkerEnd = u"marker-end"; + constexpr const std::u16string_view constToken_RefX = u"refX"; + constexpr const std::u16string_view constToken_RefY = u"refY"; + constexpr const std::u16string_view constToken_MarkerUnits = u"markerUnits"; + constexpr const std::u16string_view constTokenLowercase_MarkerUnits = u"markerunits"; + constexpr const std::u16string_view constToken_MarkerWidth = u"markerWidth"; + constexpr const std::u16string_view constTokenLowercase_MarkerWidth = u"markerwidth"; + constexpr const std::u16string_view constToken_MarkerHeight = u"markerHeight"; + constexpr const std::u16string_view constTokenLowercase_MarkerHeight = u"markerheight"; + constexpr const std::u16string_view constToken_Orient = u"orient"; + constexpr const std::u16string_view constToken_Pattern = u"pattern"; + constexpr const std::u16string_view constToken_PatternUnits = u"patternUnits"; + constexpr const std::u16string_view constTokenLowercase_PatternUnits = u"patternunits"; + constexpr const std::u16string_view constToken_PatternContentUnits = u"patternContentUnits"; + constexpr const std::u16string_view constTokenLowercase_PatternContentUnits = u"patterncontentunits"; + constexpr const std::u16string_view constToken_PatternTransform = u"patternTransform"; + constexpr const std::u16string_view constTokenLowercase_PatternTransform = u"patterntransform"; + constexpr const std::u16string_view constToken_Opacity = u"opacity"; + constexpr const std::u16string_view constToken_Visibility = u"visibility"; + constexpr const std::u16string_view constToken_Title = u"title"; + constexpr const std::u16string_view constToken_Desc = u"desc"; - const char aSVGStrPreserveAspectRatio[] = "preserveAspectRatio"; - const char aSVGStrDefer[] = "defer"; - const char aSVGStrNone[] = "none"; - const char aSVGStrXMinYMin[] = "xMinYMin"; - const char aSVGStrXMidYMin[] = "xMidYMin"; - const char aSVGStrXMaxYMin[] = "xMaxYMin"; - const char aSVGStrXMinYMid[] = "xMinYMid"; - const char aSVGStrXMidYMid[] = "xMidYMid"; - const char aSVGStrXMaxYMid[] = "xMaxYMid"; - const char aSVGStrXMinYMax[] = "xMinYMax"; - const char aSVGStrXMidYMax[] = "xMidYMax"; - const char aSVGStrXMaxYMax[] = "xMaxYMax"; - const char aSVGStrMeet[] = "meet"; - const char aSVGStrSlice[] = "slice"; + constexpr const std::u16string_view constToken_PreserveAspectRatio = u"preserveAspectRatio"; + constexpr const std::u16string_view constTokenLowercase_PreserveAspectRatio = u"preserveaspectratio"; + constexpr const std::u16string_view constToken_Defer = u"defer"; + constexpr const std::u16string_view constToken_None = u"none"; + constexpr const std::u16string_view constToken_XMinYMin = u"xMinYMin"; + constexpr const std::u16string_view constTokenLowercase_XMinYMin = u"xminymin"; + constexpr const std::u16string_view constToken_XMidYMin = u"xMidYMin"; + constexpr const std::u16string_view constTokenLowercase_XMidYMin = u"xmidymin"; + constexpr const std::u16string_view constToken_XMaxYMin = u"xMaxYMin"; + constexpr const std::u16string_view constTokenLowercase_XMaxYMin = u"xmaxymin"; + constexpr const std::u16string_view constToken_XMinYMid = u"xMinYMid"; + constexpr const std::u16string_view constTokenLowercase_XMinYMid = u"xminymid"; + constexpr const std::u16string_view constToken_XMidYMid = u"xMidYMid"; + constexpr const std::u16string_view constTokenLowercase_XMidYMid = u"xmidymid"; + constexpr const std::u16string_view constToken_XMaxYMid = u"xMaxYMid"; + constexpr const std::u16string_view constTokenLowercase_XMaxYMid = u"xmaxymid"; + constexpr const std::u16string_view constToken_XMinYMax = u"xMinYMax"; + constexpr const std::u16string_view constTokenLowercase_XMinYMax = u"xminymax"; + constexpr const std::u16string_view constToken_XMidYMax = u"xMidYMax"; + constexpr const std::u16string_view constTokenLowercase_XMidYMax = u"xmidymax"; + constexpr const std::u16string_view constToken_XMaxYMax = u"xMaxYMax"; + constexpr const std::u16string_view constTokenLowercase_XMaxYMax = u"xmaxymax"; + constexpr const std::u16string_view constToken_Meet = u"meet"; + constexpr const std::u16string_view constToken_Slice = u"slice"; - const char aSVGStrDefs[] = "defs"; - const char aSVGStrG[] = "g"; - const char aSVGStrSvg[] = "svg"; - const char aSVGStrSymbol[] = "symbol"; - const char aSVGStrUse[] = "use"; - const char aSVGStrA[] = "a"; + constexpr const std::u16string_view constToken_Defs = u"defs"; + constexpr const std::u16string_view constToken_G = u"g"; + constexpr const std::u16string_view constToken_Svg = u"svg"; + constexpr const std::u16string_view constToken_Symbol = u"symbol"; + constexpr const std::u16string_view constToken_Use = u"use"; + constexpr const std::u16string_view constToken_A = u"a"; - const char aSVGStrCircle[] = "circle"; - const char aSVGStrEllipse[] = "ellipse"; - const char aSVGStrLine[] = "line"; - const char aSVGStrPath[] = "path"; - const char aSVGStrPolygon[] = "polygon"; - const char aSVGStrPolyline[] = "polyline"; - const char aSVGStrRect[] = "rect"; - const char aSVGStrImage[] = "image"; + constexpr const std::u16string_view constToken_Circle = u"circle"; + constexpr const std::u16string_view constToken_Ellipse = u"ellipse"; + constexpr const std::u16string_view constToken_Line = u"line"; + constexpr const std::u16string_view constToken_Path = u"path"; + constexpr const std::u16string_view constToken_Polygon = u"polygon"; + constexpr const std::u16string_view constToken_Polyline = u"polyline"; + constexpr const std::u16string_view constToken_Rect = u"rect"; + constexpr const std::u16string_view constToken_Image = u"image"; - const char aSVGStrLinearGradient[] = "linearGradient"; - const char aSVGStrRadialGradient[] = "radialGradient"; - const char aSVGStrStop[] = "stop"; - const char aSVGStrOffset[] = "offset"; - const char aSVGStrX1[] = "x1"; - const char aSVGStrY1[] = "y1"; - const char aSVGStrX2[] = "x2"; - const char aSVGStrY2[] = "y2"; - const char aSVGStrCx[] = "cx"; - const char aSVGStrCy[] = "cy"; - const char aSVGStrFx[] = "fx"; - const char aSVGStrFy[] = "fy"; - const char aSVGStrR[] = "r"; - const char aSVGStrGradientUnits[] = "gradientUnits"; - const char aSVGStrGradientTransform[] = "gradientTransform"; - const char aSVGStrSpreadMethod[] = "spreadMethod"; - const char aSVGStrHref[] = "href"; - const char aSVGStrXlinkHref[] = "xlink:href"; - const char aSVGStrStopColor[] = "stop-color"; - const char aSVGStrStopOpacity[] = "stop-opacity"; + constexpr const std::u16string_view constToken_LinearGradient = u"linearGradient"; + constexpr const std::u16string_view constTokenLowercase_LinearGradient = u"lineargradient"; + constexpr const std::u16string_view constToken_RadialGradient = u"radialGradient"; + constexpr const std::u16string_view constTokenLowercase_RadialGradient = u"radialgradient"; + constexpr const std::u16string_view constToken_Stop = u"stop"; + constexpr const std::u16string_view constToken_Offset = u"offset"; + constexpr const std::u16string_view constToken_X1 = u"x1"; + constexpr const std::u16string_view constToken_Y1 = u"y1"; + constexpr const std::u16string_view constToken_X2 = u"x2"; + constexpr const std::u16string_view constToken_Y2 = u"y2"; + constexpr const std::u16string_view constToken_Cx = u"cx"; + constexpr const std::u16string_view constToken_Cy = u"cy"; + constexpr const std::u16string_view constToken_Fx = u"fx"; + constexpr const std::u16string_view constToken_Fy = u"fy"; + constexpr const std::u16string_view constToken_R = u"r"; + constexpr const std::u16string_view constToken_GradientUnits = u"gradientUnits"; + constexpr const std::u16string_view constTokenLowercase_GradientUnits = u"gradientunits"; + constexpr const std::u16string_view constToken_GradientTransform = u"gradientTransform"; + constexpr const std::u16string_view constTokenLowercase_GradientTransform = u"gradienttransform"; + constexpr const std::u16string_view constToken_SpreadMethod = u"spreadMethod"; + constexpr const std::u16string_view constTokenLowercase_SpreadMethod = u"spreadmethod"; + constexpr const std::u16string_view constToken_Href = u"href"; + constexpr const std::u16string_view constToken_XlinkHref = u"xlink:href"; + constexpr const std::u16string_view constToken_StopColor = u"stop-color"; + constexpr const std::u16string_view constToken_StopOpacity = u"stop-opacity"; - const char aSVGStrFill[] = "fill"; - const char aSVGStrFillOpacity[] = "fill-opacity"; - const char aSVGStrFillRule[] = "fill-rule"; + constexpr const std::u16string_view constToken_Fill = u"fill"; + constexpr const std::u16string_view constToken_FillOpacity = u"fill-opacity"; + constexpr const std::u16string_view constToken_FillRule = u"fill-rule"; - const char aSVGStrStroke[] = "stroke"; - const char aSVGStrStrokeDasharray[] = "stroke-dasharray"; - const char aSVGStrStrokeDashoffset[] = "stroke-dashoffset"; - const char aSVGStrStrokeLinecap[] = "stroke-linecap"; - const char aSVGStrStrokeLinejoin[] = "stroke-linejoin"; - const char aSVGStrStrokeMiterlimit[] = "stroke-miterlimit"; - const char aSVGStrStrokeOpacity[] = "stroke-opacity"; - const char aSVGStrStrokeWidth[] = "stroke-width"; + constexpr const std::u16string_view constToken_Stroke = u"stroke"; + constexpr const std::u16string_view constToken_StrokeDasharray = u"stroke-dasharray"; + constexpr const std::u16string_view constToken_StrokeDashoffset = u"stroke-dashoffset"; + constexpr const std::u16string_view constToken_StrokeLinecap = u"stroke-linecap"; + constexpr const std::u16string_view constToken_StrokeLinejoin = u"stroke-linejoin"; + constexpr const std::u16string_view constToken_StrokeMiterlimit = u"stroke-miterlimit"; + constexpr const std::u16string_view constToken_StrokeOpacity = u"stroke-opacity"; + constexpr const std::u16string_view constToken_StrokeWidth = u"stroke-width"; - const char aSVGStrText[] = "text"; - const char aSVGStrBaselineShift[] = "baseline-shift"; + constexpr const std::u16string_view constToken_Text = u"text"; + constexpr const std::u16string_view constToken_BaselineShift = u"baseline-shift"; - const char aSVGStrFlowRoot[] = "flowRoot"; + constexpr const std::u16string_view constToken_FlowRoot = u"flowRoot"; + constexpr const std::u16string_view constTokenLowercase_FlowRoot = u"flowroot"; - SVGToken StrToSVGToken(const OUString& rStr, bool bCaseIndependent) + static constexpr frozen::unordered_map<std::u16string_view, SVGToken, 133> aSVGTokenMapperList { - typedef std::unordered_map< OUString, SVGToken > SVGTokenMapper; - typedef std::pair< OUString, SVGToken > SVGTokenValueType; - static SVGTokenMapper aSVGTokenMapperList { - { aSVGStrWidth, SVGToken::Width }, - { aSVGStrHeight, SVGToken::Height }, - { aSVGStrViewBox, SVGToken::ViewBox }, - { aSVGStrTransform, SVGToken::Transform }, - { aSVGStrStyle, SVGToken::Style }, - { aSVGStrDisplay, SVGToken::Display }, // #i121656# - { aSVGStrD, SVGToken::D }, - { aSVGStrX, SVGToken::X }, - { aSVGStrY, SVGToken::Y }, - { aSVGStrXmlns, SVGToken::Xmlns }, - { aSVGStrVersion, SVGToken::Version }, - { aSVGStrId, SVGToken::Id }, - { aSVGStrRx, SVGToken::Rx }, - { aSVGStrRy, SVGToken::Ry }, - { aSVGStrPoints, SVGToken::Points }, - { aSVGStrDx, SVGToken::Dx }, - { aSVGStrDy, SVGToken::Dy }, - { aSVGStrRotate, SVGToken::Rotate }, - { aSVGStrTextLength, SVGToken::TextLength }, - { aSVGStrLengthAdjust, SVGToken::LengthAdjust }, - { aSVGStrFont, SVGToken::Font }, - { aSVGStrFontFamily, SVGToken::FontFamily }, - { aSVGStrFontSize, SVGToken::FontSize }, - { aSVGStrFontSizeAdjust, SVGToken::FontSizeAdjust }, - { aSVGStrFontStretch, SVGToken::FontStretch }, - { aSVGStrFontStyle, SVGToken::FontStyle }, - { aSVGStrFontVariant, SVGToken::FontVariant }, - { aSVGStrFontWeight, SVGToken::FontWeight }, - { aSVGStrDirection, SVGToken::Direction }, - { aSVGStrLetterSpacing, SVGToken::LetterSpacing }, - { aSVGStrTextDecoration, SVGToken::TextDecoration }, - { aSVGStrUnicodeBidi, SVGToken::UnicodeBidi }, - { aSVGStrWordSpacing, SVGToken::WordSpacing }, - { aSVGStrTspan, SVGToken::Tspan }, - { aSVGStrTref, SVGToken::Tref }, - { aSVGStrTextPath, SVGToken::TextPath }, - { aSVGStrStartOffset, SVGToken::StartOffset }, - { aSVGStrMethod, SVGToken::Method }, - { aSVGStrSpacing, SVGToken::Spacing }, - { aSVGStrTextAlign, SVGToken::TextAlign }, - { aSVGStrPathLength, SVGToken::PathLength }, - { aSVGStrType, SVGToken::Type }, - { aSVGStrClass, SVGToken::Class }, - { aSVGStrTextAnchor, SVGToken::TextAnchor }, - { aSVGStrXmlSpace, SVGToken::XmlSpace }, - { aSVGStrColor, SVGToken::Color }, - { aSVGStrClipPathNode, SVGToken::ClipPathNode }, - { aSVGStrClipPathProperty, SVGToken::ClipPathProperty }, - { aSVGStrMask, SVGToken::Mask }, - { aSVGStrClipPathUnits, SVGToken::ClipPathUnits }, - { aSVGStrMaskUnits, SVGToken::MaskUnits }, - { aSVGStrMaskContentUnits, SVGToken::MaskContentUnits }, - { aSVGStrClipRule, SVGToken::ClipRule }, - { aSVGStrMarker, SVGToken::Marker }, - { aSVGStrMarkerStart, SVGToken::MarkerStart }, - { aSVGStrMarkerMid, SVGToken::MarkerMid }, - { aSVGStrMarkerEnd, SVGToken::MarkerEnd }, - { aSVGStrRefX, SVGToken::RefX }, - { aSVGStrRefY, SVGToken::RefY }, - { aSVGStrMarkerUnits, SVGToken::MarkerUnits }, - { aSVGStrMarkerWidth, SVGToken::MarkerWidth }, - { aSVGStrMarkerHeight, SVGToken::MarkerHeight }, - { aSVGStrOrient, SVGToken::Orient }, - { aSVGStrPattern, SVGToken::Pattern }, - { aSVGStrPatternUnits, SVGToken::PatternUnits }, - { aSVGStrPatternContentUnits, SVGToken::PatternContentUnits }, - { aSVGStrPatternTransform, SVGToken::PatternTransform }, - { aSVGStrOpacity, SVGToken::Opacity }, - { aSVGStrVisibility, SVGToken::Visibility }, - { aSVGStrTitle, SVGToken::Title }, - { aSVGStrDesc, SVGToken::Desc }, + { constToken_Width, SVGToken::Width }, + { constToken_Height, SVGToken::Height }, + { constToken_ViewBox, SVGToken::ViewBox }, + { constToken_Transform, SVGToken::Transform }, + { constToken_Style, SVGToken::Style }, + { constToken_Display, SVGToken::Display }, // #i121656# + { constToken_D, SVGToken::D }, + { constToken_X, SVGToken::X }, + { constToken_Y, SVGToken::Y }, + { constToken_Xmlns, SVGToken::Xmlns }, + { constToken_Version, SVGToken::Version }, + { constToken_Id, SVGToken::Id }, + { constToken_Rx, SVGToken::Rx }, + { constToken_Ry, SVGToken::Ry }, + { constToken_Points, SVGToken::Points }, + { constToken_Dx, SVGToken::Dx }, + { constToken_Dy, SVGToken::Dy }, + { constToken_Rotate, SVGToken::Rotate }, + { constToken_TextLength, SVGToken::TextLength }, + { constToken_LengthAdjust, SVGToken::LengthAdjust }, + { constToken_Font, SVGToken::Font }, + { constToken_FontFamily, SVGToken::FontFamily }, + { constToken_FontSize, SVGToken::FontSize }, + { constToken_FontSizeAdjust, SVGToken::FontSizeAdjust }, + { constToken_FontStretch, SVGToken::FontStretch }, + { constToken_FontStyle, SVGToken::FontStyle }, + { constToken_FontVariant, SVGToken::FontVariant }, + { constToken_FontWeight, SVGToken::FontWeight }, + { constToken_Direction, SVGToken::Direction }, + { constToken_LetterSpacing, SVGToken::LetterSpacing }, + { constToken_TextDecoration, SVGToken::TextDecoration }, + { constToken_UnicodeBidi, SVGToken::UnicodeBidi }, + { constToken_WordSpacing, SVGToken::WordSpacing }, + { constToken_Tspan, SVGToken::Tspan }, + { constToken_Tref, SVGToken::Tref }, + { constToken_TextPath, SVGToken::TextPath }, + { constToken_StartOffset, SVGToken::StartOffset }, + { constToken_Method, SVGToken::Method }, + { constToken_Spacing, SVGToken::Spacing }, + { constToken_TextAlign, SVGToken::TextAlign }, + { constToken_PathLength, SVGToken::PathLength }, + { constToken_Type, SVGToken::Type }, + { constToken_Class, SVGToken::Class }, + { constToken_TextAnchor, SVGToken::TextAnchor }, + { constToken_XmlSpace, SVGToken::XmlSpace }, + { constToken_Color, SVGToken::Color }, + { constToken_ClipPathNode, SVGToken::ClipPathNode }, + { constToken_ClipPathProperty, SVGToken::ClipPathProperty }, + { constToken_Mask, SVGToken::Mask }, + { constToken_ClipPathUnits, SVGToken::ClipPathUnits }, + { constToken_MaskUnits, SVGToken::MaskUnits }, + { constToken_MaskContentUnits, SVGToken::MaskContentUnits }, + { constToken_ClipRule, SVGToken::ClipRule }, + { constToken_Marker, SVGToken::Marker }, + { constToken_MarkerStart, SVGToken::MarkerStart }, + { constToken_MarkerMid, SVGToken::MarkerMid }, + { constToken_MarkerEnd, SVGToken::MarkerEnd }, + { constToken_RefX, SVGToken::RefX }, + { constToken_RefY, SVGToken::RefY }, + { constToken_MarkerUnits, SVGToken::MarkerUnits }, + { constToken_MarkerWidth, SVGToken::MarkerWidth }, + { constToken_MarkerHeight, SVGToken::MarkerHeight }, + { constToken_Orient, SVGToken::Orient }, + { constToken_Pattern, SVGToken::Pattern }, + { constToken_PatternUnits, SVGToken::PatternUnits }, + { constToken_PatternContentUnits, SVGToken::PatternContentUnits }, + { constToken_PatternTransform, SVGToken::PatternTransform }, + { constToken_Opacity, SVGToken::Opacity }, + { constToken_Visibility, SVGToken::Visibility }, + { constToken_Title, SVGToken::Title }, + { constToken_Desc, SVGToken::Desc }, - { aSVGStrPreserveAspectRatio, SVGToken::PreserveAspectRatio }, - { aSVGStrDefer, SVGToken::Defer }, - { aSVGStrNone, SVGToken::None }, - { aSVGStrXMinYMin, SVGToken::XMinYMin }, - { aSVGStrXMidYMin, SVGToken::XMidYMin }, - { aSVGStrXMaxYMin, SVGToken::XMaxYMin }, - { aSVGStrXMinYMid, SVGToken::XMinYMid }, - { aSVGStrXMidYMid, SVGToken::XMidYMid }, - { aSVGStrXMaxYMid, SVGToken::XMaxYMid }, - { aSVGStrXMinYMax, SVGToken::XMinYMax }, - { aSVGStrXMidYMax, SVGToken::XMidYMax }, - { aSVGStrXMaxYMax, SVGToken::XMaxYMax }, - { aSVGStrMeet, SVGToken::Meet }, - { aSVGStrSlice, SVGToken::Slice }, + { constToken_PreserveAspectRatio, SVGToken::PreserveAspectRatio }, + { constToken_Defer, SVGToken::Defer }, + { constToken_None, SVGToken::None }, + { constToken_XMinYMin, SVGToken::XMinYMin }, + { constToken_XMidYMin, SVGToken::XMidYMin }, + { constToken_XMaxYMin, SVGToken::XMaxYMin }, + { constToken_XMinYMid, SVGToken::XMinYMid }, + { constToken_XMidYMid, SVGToken::XMidYMid }, + { constToken_XMaxYMid, SVGToken::XMaxYMid }, + { constToken_XMinYMax, SVGToken::XMinYMax }, + { constToken_XMidYMax, SVGToken::XMidYMax }, + { constToken_XMaxYMax, SVGToken::XMaxYMax }, + { constToken_Meet, SVGToken::Meet }, + { constToken_Slice, SVGToken::Slice }, - { aSVGStrDefs, SVGToken::Defs }, - { aSVGStrG, SVGToken::G }, - { aSVGStrSvg, SVGToken::Svg }, - { aSVGStrSymbol, SVGToken::Symbol }, - { aSVGStrUse, SVGToken::Use }, - { aSVGStrA, SVGToken::A }, + { constToken_Defs, SVGToken::Defs }, + { constToken_G, SVGToken::G }, + { constToken_Svg, SVGToken::Svg }, + { constToken_Symbol, SVGToken::Symbol }, + { constToken_Use, SVGToken::Use }, + { constToken_A, SVGToken::A }, - { aSVGStrCircle, SVGToken::Circle }, - { aSVGStrEllipse, SVGToken::Ellipse }, - { aSVGStrLine, SVGToken::Line }, - { aSVGStrPath, SVGToken::Path }, - { aSVGStrPolygon, SVGToken::Polygon }, - { aSVGStrPolyline, SVGToken::Polyline }, - { aSVGStrRect, SVGToken::Rect }, - { aSVGStrImage, SVGToken::Image }, + { constToken_Circle, SVGToken::Circle }, + { constToken_Ellipse, SVGToken::Ellipse }, + { constToken_Line, SVGToken::Line }, + { constToken_Path, SVGToken::Path }, + { constToken_Polygon, SVGToken::Polygon }, + { constToken_Polyline, SVGToken::Polyline }, + { constToken_Rect, SVGToken::Rect }, + { constToken_Image, SVGToken::Image }, - { aSVGStrLinearGradient, SVGToken::LinearGradient }, - { aSVGStrRadialGradient, SVGToken::RadialGradient }, - { aSVGStrStop, SVGToken::Stop }, - { aSVGStrOffset, SVGToken::Offset }, - { aSVGStrX1, SVGToken::X1 }, - { aSVGStrY1, SVGToken::Y1 }, - { aSVGStrX2, SVGToken::X2 }, - { aSVGStrY2, SVGToken::Y2 }, - { aSVGStrCx, SVGToken::Cx }, - { aSVGStrCy, SVGToken::Cy }, - { aSVGStrFx, SVGToken::Fx }, - { aSVGStrFy, SVGToken::Fy }, - { aSVGStrR, SVGToken::R }, - { aSVGStrGradientUnits, SVGToken::GradientUnits }, - { aSVGStrGradientTransform, SVGToken::GradientTransform }, - { aSVGStrSpreadMethod, SVGToken::SpreadMethod }, - { aSVGStrHref, SVGToken::Href }, - { aSVGStrXlinkHref, SVGToken::XlinkHref }, - { aSVGStrStopColor, SVGToken::StopColor }, - { aSVGStrStopOpacity, SVGToken::StopOpacity }, + { constToken_LinearGradient, SVGToken::LinearGradient }, + { constToken_RadialGradient, SVGToken::RadialGradient }, + { constToken_Stop, SVGToken::Stop }, + { constToken_Offset, SVGToken::Offset }, + { constToken_X1, SVGToken::X1 }, + { constToken_Y1, SVGToken::Y1 }, + { constToken_X2, SVGToken::X2 }, + { constToken_Y2, SVGToken::Y2 }, + { constToken_Cx, SVGToken::Cx }, + { constToken_Cy, SVGToken::Cy }, + { constToken_Fx, SVGToken::Fx }, + { constToken_Fy, SVGToken::Fy }, + { constToken_R, SVGToken::R }, + { constToken_GradientUnits, SVGToken::GradientUnits }, + { constToken_GradientTransform, SVGToken::GradientTransform }, + { constToken_SpreadMethod, SVGToken::SpreadMethod }, + { constToken_Href, SVGToken::Href }, + { constToken_XlinkHref, SVGToken::XlinkHref }, + { constToken_StopColor, SVGToken::StopColor }, + { constToken_StopOpacity, SVGToken::StopOpacity }, - { aSVGStrFill, SVGToken::Fill }, - { aSVGStrFillOpacity, SVGToken::FillOpacity }, - { aSVGStrFillRule, SVGToken::FillRule }, + { constToken_Fill, SVGToken::Fill }, + { constToken_FillOpacity, SVGToken::FillOpacity }, + { constToken_FillRule, SVGToken::FillRule }, - { aSVGStrStroke, SVGToken::Stroke }, - { aSVGStrStrokeDasharray, SVGToken::StrokeDasharray }, - { aSVGStrStrokeDashoffset, SVGToken::StrokeDashoffset }, - { aSVGStrStrokeLinecap, SVGToken::StrokeLinecap }, - { aSVGStrStrokeLinejoin, SVGToken::StrokeLinejoin }, - { aSVGStrStrokeMiterlimit, SVGToken::StrokeMiterlimit }, - { aSVGStrStrokeOpacity, SVGToken::StrokeOpacity }, - { aSVGStrStrokeWidth, SVGToken::StrokeWidth }, + { constToken_Stroke, SVGToken::Stroke }, + { constToken_StrokeDasharray, SVGToken::StrokeDasharray }, + { constToken_StrokeDashoffset, SVGToken::StrokeDashoffset }, + { constToken_StrokeLinecap, SVGToken::StrokeLinecap }, + { constToken_StrokeLinejoin, SVGToken::StrokeLinejoin }, + { constToken_StrokeMiterlimit, SVGToken::StrokeMiterlimit }, + { constToken_StrokeOpacity, SVGToken::StrokeOpacity }, + { constToken_StrokeWidth, SVGToken::StrokeWidth }, - { aSVGStrText, SVGToken::Text }, - { aSVGStrBaselineShift, SVGToken::BaselineShift }, - { aSVGStrFlowRoot, SVGToken::FlowRoot } - }; + { constToken_Text, SVGToken::Text }, + { constToken_BaselineShift, SVGToken::BaselineShift }, + { constToken_FlowRoot, SVGToken::FlowRoot } + }; - const SVGTokenMapper::const_iterator aResult(aSVGTokenMapperList.find(rStr.startsWith("svg:") ? rStr.copy(4) : rStr)); + static constexpr frozen::unordered_map<std::u16string_view, SVGToken, 32> aLowerCaseList + { + { constTokenLowercase_ViewBox, SVGToken::ViewBox }, + { constTokenLowercase_TextLength, SVGToken::TextLength }, + { constTokenLowercase_LengthAdjust, SVGToken::LengthAdjust }, + { constTokenLowercase_TextPath, SVGToken::TextPath }, + { constTokenLowercase_StartOffset, SVGToken::StartOffset }, + { constTokenLowercase_PathLength, SVGToken::PathLength }, + { constTokenLowercase_ClipPathNode, SVGToken::ClipPathNode }, + { constTokenLowercase_ClipPathUnits, SVGToken::ClipPathUnits }, + { constTokenLowercase_MaskUnits, SVGToken::MaskUnits }, + { constTokenLowercase_MaskContentUnits, SVGToken::MaskContentUnits }, + { constTokenLowercase_MarkerUnits, SVGToken::MarkerUnits }, + { constTokenLowercase_MarkerWidth, SVGToken::MarkerWidth }, + { constTokenLowercase_MarkerHeight, SVGToken::MarkerHeight }, + { constTokenLowercase_PatternUnits, SVGToken::PatternUnits }, + { constTokenLowercase_PatternContentUnits, SVGToken::PatternContentUnits }, + { constTokenLowercase_PatternTransform, SVGToken::PatternTransform }, + { constTokenLowercase_PreserveAspectRatio, SVGToken::PreserveAspectRatio }, + { constTokenLowercase_XMinYMin, SVGToken::XMinYMin }, + { constTokenLowercase_XMidYMin, SVGToken::XMidYMin }, + { constTokenLowercase_XMaxYMin, SVGToken::XMaxYMin }, + { constTokenLowercase_XMinYMid, SVGToken::XMinYMid }, + { constTokenLowercase_XMidYMid, SVGToken::XMidYMid }, + { constTokenLowercase_XMaxYMid, SVGToken::XMaxYMid }, + { constTokenLowercase_XMinYMax, SVGToken::XMinYMax }, + { constTokenLowercase_XMidYMax, SVGToken::XMidYMax }, + { constTokenLowercase_XMaxYMax, SVGToken::XMaxYMax }, + { constTokenLowercase_LinearGradient, SVGToken::LinearGradient }, + { constTokenLowercase_RadialGradient, SVGToken::RadialGradient }, + { constTokenLowercase_GradientUnits, SVGToken::GradientUnits }, + { constTokenLowercase_GradientTransform, SVGToken::GradientTransform }, + { constTokenLowercase_SpreadMethod, SVGToken::SpreadMethod }, + { constTokenLowercase_FlowRoot, SVGToken::FlowRoot } + }; - if(aResult == aSVGTokenMapperList.end()) - { - if(bCaseIndependent) - { - static SVGTokenMapper aCaseLindependentSVGTokenMapperList; + SVGToken StrToSVGToken(const OUString& rStr, bool bCaseIndependent) + { + OUString aSearchString = rStr.startsWith("svg:") ? rStr.copy(4) : rStr; - if(aCaseLindependentSVGTokenMapperList.empty()) - { - for(const auto& rCurrent : aSVGTokenMapperList) - { - aCaseLindependentSVGTokenMapperList.insert( - SVGTokenValueType( - rCurrent.first.toAsciiLowerCase(), - rCurrent.second)); - } - } + auto const aResult = aSVGTokenMapperList.find(aSearchString); - const SVGTokenMapper::const_iterator aResult2(aCaseLindependentSVGTokenMapperList.find(rStr.toAsciiLowerCase())); + if (aResult == aSVGTokenMapperList.end()) + { + if (bCaseIndependent) + { + auto const aResultLowerCase(aLowerCaseList.find(rStr.toAsciiLowerCase())); - if(aResult2 == aCaseLindependentSVGTokenMapperList.end()) + if (aResultLowerCase == aLowerCaseList.end()) { return SVGToken::Unknown; } else { - return aResult2->second; + return aResultLowerCase->second; } } @@ -352,12 +409,12 @@ namespace svgio::svgreader OUString getStrTitle() { - return aSVGStrTitle; + return OUString(constToken_Title); } OUString getStrDesc() { - return aSVGStrDesc; + return OUString(constToken_Desc); } } // end of namespace svgio commit 4b3eca5992da6dbcbf30a739cb574cdc84753678 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Jul 16 12:17:20 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Fri Aug 19 16:08:03 2022 +0200 Add frozen library support - for compile-time dict, set support Change-Id: I8fa02569ba02048cc3ef02b349aafba1c0cbebb4 diff --git a/Makefile.fetch b/Makefile.fetch index 8f9b4ba1c6af..4d64ea84dd4b 100644 --- a/Makefile.fetch +++ b/Makefile.fetch @@ -126,6 +126,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S $(call fetch_Optional,FONTCONFIG,FONTCONFIG_TARBALL) \ $(call fetch_Optional,FREEHAND,FREEHAND_TARBALL) \ $(call fetch_Optional,FREETYPE,FREETYPE_TARBALL) \ + FROZEN_TARBALL \ $(call fetch_Optional,EPOXY,EPOXY_TARBALL) \ $(call fetch_Optional,GLM,GLM_TARBALL) \ $(call fetch_Optional,GPGMEPP,GPGME_TARBALL) \ diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index 938fc6bf761f..ea88627a109d 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -4310,5 +4310,13 @@ endef endif # SYSTEM_CUCKOO +define gb_LinkTarget__use_frozen +$(call gb_LinkTarget_use_unpacked,$(1),frozen) +$(call gb_LinkTarget_set_include,$(1),\ + -I$(call gb_UnpackedTarball_get_dir,frozen/include/)\ + $$(INCLUDE) \ +) +endef + # vim: set noet sw=4 ts=4: diff --git a/download.lst b/download.lst index f0a7603fc97e..ed28515150b2 100644 --- a/download.lst +++ b/download.lst @@ -94,6 +94,8 @@ export FREEHAND_SHA256SUM := 0e422d1564a6dbf22a9af598535425271e583514c0f7ba7d909 export FREEHAND_TARBALL := libfreehand-0.1.2.tar.xz export FREETYPE_SHA256SUM := 3333ae7cfda88429c97a7ae63b7d01ab398076c3b67182e960e5684050f2c5c8 export FREETYPE_TARBALL := freetype-2.11.1.tar.xz +export FROZEN_SHA256SUM := f7c7075750e8fceeac081e9ef01944f221b36d9725beac8681cbd2838d26be45 +export FROZEN_TARBALL := frozen-1.1.1.tar.gz export GLM_SHA256SUM := 6bba5f032bed47c73ad9397f2313b9acbfb56253d0d0576b5873d3dcb25e99ad export GLM_TARBALL := glm-0.9.9.8.zip export GPGME_SHA256SUM := 6c8cc4aedb10d5d4c905894ba1d850544619ee765606ac43df7405865de29ed0 diff --git a/external/Module_external.mk b/external/Module_external.mk index ed8f4904798a..9662e770261c 100644 --- a/external/Module_external.mk +++ b/external/Module_external.mk @@ -41,6 +41,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\ $(call gb_Helper_optional,FONTCONFIG,fontconfig) \ $(call gb_Helper_optional,FREEHAND,libfreehand) \ $(call gb_Helper_optional,FREETYPE,freetype) \ + frozen \ $(call gb_Helper_optional,GLM,glm) \ $(call gb_Helper_optional,GPGMEPP,gpgmepp) \ $(call gb_Helper_optional,GRAPHITE,graphite) \ diff --git a/external/frozen/Module_frozen.mk b/external/frozen/Module_frozen.mk new file mode 100644 index 000000000000..10fa0997e0ed --- /dev/null +++ b/external/frozen/Module_frozen.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Module_Module,frozen)) + +$(eval $(call gb_Module_add_targets,frozen,\ + UnpackedTarball_frozen \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/external/frozen/UnpackedTarball_frozen.mk b/external/frozen/UnpackedTarball_frozen.mk new file mode 100644 index 000000000000..01ad0f803f51 --- /dev/null +++ b/external/frozen/UnpackedTarball_frozen.mk @@ -0,0 +1,14 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_UnpackedTarball_UnpackedTarball,frozen)) + +$(eval $(call gb_UnpackedTarball_set_tarball,frozen,$(FROZEN_TARBALL))) + +# vim: set noet sw=4 ts=4: