Rebased ref, commits from common ancestor:
commit 3905a86e8f0db4bdb85ec5b5c41c4ad766b18cbb
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: Sun Aug 21 08:32:08 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..421e98934c90
--- /dev/null
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -0,0 +1,135 @@
+/* -*- 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 <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class LengthTest : public CppUnit::TestFixture
+{
+public:
+    void testBasic()
+    {
+        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());
+
+        auto aa = gfx::Length::hmm<sal_Int64>(10.1);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(3600), aa.raw());
+
+        auto bb = gfx::Length::hmm<double>(10.1);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(3636), bb.raw());
+    }
+
+    void testInRange()
+    {
+        gfx::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());
+    }
+
+    void testInTuple()
+    {
+        gfx::Tuple2DL aTuple(0.5_pt, 1_pt);
+        CPPUNIT_ASSERT_EQUAL(6350_emu, aTuple.getX());
+        CPPUNIT_ASSERT_EQUAL(12700_emu, aTuple.getY());
+    }
+
+    void testConversionToRectanle()
+    {
+        tools::Rectangle aRectangle(10, 20, 110, 120);
+        gfx::Range2DL aRange = gfx::length::fromRectangleHmm(aRectangle);
+        CPPUNIT_ASSERT_EQUAL(10_hmm, aRange.getMinX());
+        CPPUNIT_ASSERT_EQUAL(20_hmm, aRange.getMinY());
+        CPPUNIT_ASSERT_EQUAL(110_hmm, aRange.getMaxX());
+        CPPUNIT_ASSERT_EQUAL(120_hmm, aRange.getMaxY());
+
+        tools::Rectangle aRectangleConverted = 
gfx::length::toRectangleHmm(aRange);
+        CPPUNIT_ASSERT_EQUAL(aRectangle, aRectangleConverted);
+    }
+
+    CPPUNIT_TEST_SUITE(LengthTest);
+    CPPUNIT_TEST(testBasic);
+    CPPUNIT_TEST(testInRange);
+    CPPUNIT_TEST(testInTuple);
+    CPPUNIT_TEST(testConversionToRectanle);
+    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..64fd22260f83
--- /dev/null
+++ b/include/basegfx/units/Length.hxx
@@ -0,0 +1,110 @@
+/* -*- 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>
+#include <basegfx/range/Range2D.hxx>
+
+#include <tools/gen.hxx>
+
+namespace gfx
+{
+typedef LengthUnitBase<sal_Int64> Length;
+
+struct LengthTraits
+{
+    static constexpr Length minVal() { return Length::min(); };
+    static constexpr Length maxVal() { return Length::max(); };
+    static constexpr Length neutral() { return Length(); };
+
+    typedef Length DifferenceType;
+};
+
+typedef basegfx::Range2D<gfx::Length, gfx::LengthTraits> Range2DL;
+typedef basegfx::Tuple2D<gfx::Length> Tuple2DL;
+
+namespace length
+{
+static inline Range2DL fromRectangleHmm(tools::Rectangle const& rRectangle)
+{
+    auto left = Length::hmm(rRectangle.Left());
+    auto top = Length::hmm(rRectangle.Top());
+    auto right = Length::hmm(rRectangle.Right());
+    auto bottom = Length::hmm(rRectangle.Bottom());
+    return Range2DL(left, top, right, bottom);
+}
+
+static inline tools::Rectangle toRectangleHmm(Range2DL const& rRange2D)
+{
+    auto left = rRange2D.getMinX().as_hmm();
+    auto top = rRange2D.getMinY().as_hmm();
+    auto right = rRange2D.getMaxX().as_hmm();
+    auto bottom = rRange2D.getMaxY().as_hmm();
+    return tools::Rectangle(left, top, right, bottom);
+}
+
+} // end namespace 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..c1d8a8e8e431
--- /dev/null
+++ b/include/basegfx/units/LengthUnitBase.hxx
@@ -0,0 +1,186 @@
+/* -*- 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 TYPE> class LengthUnitBase
+{
+private:
+    // value in EMU units
+    TYPE m_nValue;
+
+    constexpr explicit LengthUnitBase(TYPE nValue)
+        : m_nValue(nValue)
+    {
+    }
+
+public:
+    static constexpr LengthUnitBase min() { return 
LengthUnitBase(SAL_MIN_INT64); }
+
+    static constexpr LengthUnitBase max() { return 
LengthUnitBase(SAL_MAX_INT64); }
+
+    template <typename INPUT_TYPE> static constexpr LengthUnitBase 
cm(INPUT_TYPE nValue)
+    {
+        return LengthUnitBase(TYPE(gfx::constFactor_cm_to_EMU * nValue));
+    }
+
+    template <typename INPUT_TYPE> static constexpr LengthUnitBase 
mm(INPUT_TYPE nValue)
+    {
+        return LengthUnitBase(TYPE(gfx::constFactor_mm_to_EMU * nValue));
+    }
+
+    template <typename INPUT_TYPE> static constexpr LengthUnitBase 
hmm(INPUT_TYPE nValue)
+    {
+        return LengthUnitBase(TYPE(gfx::constFactor_hmm_to_EMU * nValue));
+    }
+
+    template <typename INPUT_TYPE> static constexpr LengthUnitBase 
in(INPUT_TYPE nValue)
+    {
+        return LengthUnitBase(TYPE(gfx::constFactor_in_to_EMU * nValue));
+    }
+
+    template <typename INPUT_TYPE> static constexpr LengthUnitBase 
twip(INPUT_TYPE nValue)
+    {
+        return LengthUnitBase(TYPE(gfx::constFactor_twip_to_EMU * nValue));
+    }
+
+    template <typename INPUT_TYPE> static constexpr LengthUnitBase 
pt(INPUT_TYPE nValue)
+    {
+        return LengthUnitBase(TYPE(gfx::constFactor_pt_to_EMU * nValue));
+    }
+
+    template <typename INPUT_TYPE> static constexpr LengthUnitBase 
px(INPUT_TYPE nValue)
+    {
+        return LengthUnitBase(TYPE(gfx::constFactor_px_to_EMU * nValue));
+    }
+
+    template <typename INPUT_TYPE> static constexpr LengthUnitBase 
emu(INPUT_TYPE nValue)
+    {
+        return LengthUnitBase(TYPE(nValue));
+    }
+
+    constexpr explicit LengthUnitBase()
+        : m_nValue(0)
+    {
+    }
+
+    constexpr explicit operator TYPE() 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*=(TYPE const& rhs)
+    {
+        m_nValue *= rhs;
+        return *this;
+    }
+
+    constexpr LengthUnitBase& operator/=(TYPE 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 TYPE 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 ebe336f7ad214a7363d35be6110101cc2e0d6cb3
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: Sun Aug 21 08:32:08 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..6e7578518497 100644
--- a/svgio/source/svgreader/svgtoken.cxx
+++ b/svgio/source/svgreader/svgtoken.cxx
@@ -18,327 +18,383 @@
  */
 
 #include <svgtoken.hxx>
-#include <unordered_map>
+#include <frozen/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::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::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 +408,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 5a29ce759d55649e3d0be6036790fb5ce4e3d7a2
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: Sun Aug 21 08:32:08 2022 +0200

    Add frozen library support - for compile-time dict, set support
    
    Change-Id: I8fa02569ba02048cc3ef02b349aafba1c0cbebb4

diff --git a/Makefile.fetch b/Makefile.fetch
index cb76c9f08883..4d6e1d3ec5be 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -125,6 +125,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 30463ee56beb..4e6a9ccbfe89 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -4279,4 +4279,14 @@ endif # ENABLE_ZXING
 
 endif # SYSTEM_ZXING
 
+
+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 012163625b95..40dc0899f3ab 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 73d6530ac10f..cd9c5924d71d 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:
commit 653427c9a0efa932c86e4732035711b7763ef6fb
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon May 10 15:45:13 2021 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sun Aug 21 08:32:07 2022 +0200

    vcl: add more methods to the PDFium
    
    Change-Id: I74ef0f713125c7069620d1abc9534a636c1707d9

diff --git a/include/vcl/filter/PDFiumLibrary.hxx 
b/include/vcl/filter/PDFiumLibrary.hxx
index 3a4d0d83faf6..4eba70bf2b5f 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -113,6 +113,13 @@ public:
     virtual PDFSegmentType getType() const = 0;
 };
 
+struct PDFImageMetadata
+{
+    sal_uInt32 mnWidth;
+    sal_uInt32 mnHeight;
+    sal_uInt32 mnBitsPerPixel;
+};
+
 class VCL_DLLPUBLIC PDFiumPageObject
 {
 public:
@@ -129,15 +136,20 @@ public:
     virtual double getFontSize() = 0;
     virtual OUString getFontName() = 0;
     virtual PDFTextRenderMode getTextRenderMode() = 0;
+    virtual bool hasTransparency() = 0;
     virtual Color getFillColor() = 0;
     virtual Color getStrokeColor() = 0;
     virtual double getStrokeWidth() = 0;
     // Path
     virtual int getPathSegmentCount() = 0;
     virtual std::unique_ptr<PDFiumPathSegment> getPathSegment(int index) = 0;
+    virtual bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) = 0;
+    // Image
     virtual Size getImageSize(PDFiumPage& rPage) = 0;
+    virtual PDFImageMetadata getImageMetadata(PDFiumPage& rPage) = 0;
+
     virtual std::unique_ptr<PDFiumBitmap> getImageBitmap() = 0;
-    virtual bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) = 0;
+    virtual bool getDecodedImageData(std::vector<sal_uInt8>& rData) = 0;
 };
 
 class VCL_DLLPUBLIC PDFiumSearchHandle
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index b02358d43a9c..249f24b08306 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -255,15 +255,19 @@ public:
     double getFontSize() override;
     OUString getFontName() override;
     PDFTextRenderMode getTextRenderMode() override;
+    bool hasTransparency() override;
     Color getFillColor() override;
     Color getStrokeColor() override;
     double getStrokeWidth() override;
     // Path
     int getPathSegmentCount() override;
     std::unique_ptr<PDFiumPathSegment> getPathSegment(int index) override;
+    bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) override;
+    // Image
     Size getImageSize(PDFiumPage& rPage) override;
+    PDFImageMetadata getImageMetadata(PDFiumPage& rPage) override;
     std::unique_ptr<PDFiumBitmap> getImageBitmap() override;
-    bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) override;
+    bool getDecodedImageData(std::vector<sal_uInt8>& rData) override;
 };
 
 class PDFiumSearchHandleImpl final : public PDFiumSearchHandle
@@ -849,6 +853,8 @@ Color PDFiumPageObjectImpl::getFillColor()
     return aColor;
 }
 
+bool PDFiumPageObjectImpl::hasTransparency() { return 
FPDFPageObj_HasTransparency(mpPageObject); }
+
 Color PDFiumPageObjectImpl::getStrokeColor()
 {
     Color aColor = COL_TRANSPARENT;
@@ -888,6 +894,28 @@ Size PDFiumPageObjectImpl::getImageSize(PDFiumPage& rPage)
     return Size(aMeta.width, aMeta.height);
 }
 
+PDFImageMetadata PDFiumPageObjectImpl::getImageMetadata(PDFiumPage& rPage)
+{
+    FPDF_IMAGEOBJ_METADATA aMeta;
+    auto& rPageImpl = static_cast<PDFiumPageImpl&>(rPage);
+    FPDFImageObj_GetImageMetadata(mpPageObject, rPageImpl.getPointer(), 
&aMeta);
+    return { aMeta.width, aMeta.height, aMeta.bits_per_pixel };
+}
+
+bool PDFiumPageObjectImpl::getDecodedImageData(std::vector<sal_uInt8>& rData)
+{
+    unsigned long nLength = FPDFImageObj_GetImageDataDecoded(mpPageObject, 
nullptr, 0);
+    if (nLength > 0)
+    {
+        rData.resize(nLength);
+        unsigned long nReadLength
+            = FPDFImageObj_GetImageDataDecoded(mpPageObject, rData.data(), 
nLength);
+        if (nReadLength == nLength)
+            return true;
+    }
+    return false;
+}
+
 std::unique_ptr<PDFiumBitmap> PDFiumPageObjectImpl::getImageBitmap()
 {
     std::unique_ptr<PDFiumBitmap> pPDFiumBitmap;
commit 961b2cd13a720fe37cb542e73a5a3f378d10c726
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon May 3 16:42:22 2021 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sun Aug 21 08:32:01 2022 +0200

    Add PDF importer to read a PDF into drawinglayer primitives
    
    Change-Id: I8d2e28a39515dfef8a1b4c6b06df095dd3a4eaec

diff --git a/Repository.mk b/Repository.mk
index e9680db6d54c..c25e728eaade 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -439,6 +439,7 @@ $(eval $(call 
gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
        passwordcontainer \
        pcr \
        pdffilter \
+       pdfimporter \
        $(call gb_Helper_optional,SCRIPTING,protocolhandler) \
        sax \
        sb \
diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx 
b/drawinglayer/source/tools/primitive2dxmldump.cxx
index 63562973d6ca..5aa2c9771f84 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -513,6 +513,13 @@ void Primitive2dXmlDump::dump(
     aWriter.endDocument();
 
     pStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+    std::size_t nSize = pStream->remainingSize();
+    std::unique_ptr<sal_uInt8[]> pBuffer(new sal_uInt8[nSize + 1]);
+    pStream->ReadBytes(pBuffer.get(), nSize);
+    pBuffer[nSize] = 0;
+
+    printf ("%s\n", pBuffer.get());
 }
 
 namespace
diff --git a/filter/CppunitTest_filter_pdfimporter_test.mk 
b/filter/CppunitTest_filter_pdfimporter_test.mk
new file mode 100644
index 000000000000..3b17dcdcb43f
--- /dev/null
+++ b/filter/CppunitTest_filter_pdfimporter_test.mk
@@ -0,0 +1,48 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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_CppunitTest_CppunitTest,filter_pdfimporter_test))
+
+$(eval $(call gb_CppunitTest_use_externals,filter_pdfimporter_test,\
+       boost_headers \
+       libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,filter_pdfimporter_test, \
+    filter/qa/cppunit/PdfImporterTest \
+))
+
+$(eval $(call gb_CppunitTest_use_library_objects,filter_pdfimporter_test,\
+    pdfimporter \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,filter_pdfimporter_test, \
+    basegfx \
+    drawinglayer \
+    comphelper \
+    cppu \
+    cppuhelper \
+    sal \
+    test \
+    unotest \
+    utl \
+    tl \
+    vcl \
+    tk \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,filter_pdfimporter_test))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,filter_pdfimporter_test))
+$(eval $(call gb_CppunitTest_use_ure,filter_pdfimporter_test))
+$(eval $(call gb_CppunitTest_use_vcl,filter_pdfimporter_test))
+$(eval $(call gb_CppunitTest_use_rdb,filter_pdfimporter_test,services))
+
+
+# vim: set noet sw=4 ts=4:
diff --git a/filter/Library_pdfimporter.mk b/filter/Library_pdfimporter.mk
new file mode 100644
index 000000000000..01f6786d6e11
--- /dev/null
+++ b/filter/Library_pdfimporter.mk
@@ -0,0 +1,38 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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_Library_Library,pdfimporter))
+
+$(eval $(call gb_Library_set_include,pdfimporter,\
+       -I$(SRCDIR)/filter/inc \
+       $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_external,pdfimporter,boost_headers))
+
+$(eval $(call gb_Library_add_exception_objects,pdfimporter,\
+       filter/source/pdfimporter/PDFImporter \
+))
+
+$(eval $(call gb_Library_use_libraries,pdfimporter,\
+       drawinglayercore \
+       drawinglayer \
+       basegfx \
+       vcl \
+       tl \
+       sal \
+       cppu \
+       tk \
+       svxcore \
+       salhelper \
+))
+
+$(eval $(call gb_Library_use_sdk_api,pdfimporter))
+
+# vim: set noet sw=4 ts=4:
diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk
index c28c72705cec..e8ef1649c876 100644
--- a/filter/Module_filter.mk
+++ b/filter/Module_filter.mk
@@ -26,6 +26,7 @@ $(eval $(call gb_Module_add_targets,filter,\
        Library_msfilter \
        Library_odfflatxml \
        Library_pdffilter \
+       Library_pdfimporter \
        Library_storagefd \
        Library_svgfilter \
        Library_graphicfilter \
@@ -49,6 +50,7 @@ $(eval $(call gb_Module_add_check_targets,filter,\
     CppunitTest_filter_xslt \
     CppunitTest_filter_priority \
     CppunitTest_filter_msfilter \
+    CppunitTest_filter_pdfimporter_test \
     CppunitTest_filter_textfilterdetect \
     CppunitTest_filter_pdf \
 ))
diff --git a/filter/qa/cppunit/PdfImporterTest.cxx 
b/filter/qa/cppunit/PdfImporterTest.cxx
new file mode 100644
index 000000000000..ee57b9bdbc67
--- /dev/null
+++ b/filter/qa/cppunit/PdfImporterTest.cxx
@@ -0,0 +1,173 @@
+/* -*- 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 <sal/config.h>
+#include <sal/types.h>
+#include <test/bootstrapfixture.hxx>
+#include <test/xmltesttools.hxx>
+
+#include <filter/pdfimporter/PDFImporter.hxx>
+#include <vcl/BinaryDataContainer.hxx>
+#include <tools/stream.hxx>
+#include <drawinglayer/converters.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <drawinglayer/tools/primitive2dxmldump.hxx>
+
+#include <tools/stream.hxx>
+#include <vcl/pngwrite.hxx>
+
+class PDFImporterTest : public test::BootstrapFixture, public XmlTestTools
+{
+    OUString getFullUrl(std::u16string_view sFileName)
+    {
+        return m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/") + 
sFileName;
+    }
+
+    void testPath();
+    void testImage();
+    void testText();
+
+    CPPUNIT_TEST_SUITE(PDFImporterTest);
+    //CPPUNIT_TEST(testPath);
+    //CPPUNIT_TEST(testImage);
+    CPPUNIT_TEST(testText);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void PDFImporterTest::testPath()
+{
+    SvFileStream aFileStream(getFullUrl(u"/PdfTest-Rect.pdf"), 
StreamMode::READ);
+    const sal_uInt64 nStreamLength = aFileStream.TellEnd();
+    auto rData = std::make_unique<std::vector<sal_uInt8>>(nStreamLength);
+    aFileStream.ReadBytes(rData->data(), rData->size());
+    BinaryDataContainer aDataContainer(std::move(rData));
+    PDFImporter aImporter(aDataContainer);
+
+    drawinglayer::primitive2d::Primitive2DContainer aContainer;
+    aImporter.importPage(0, aContainer);
+
+    drawinglayer::geometry::ViewInformation2D rViewInformation2D;
+
+    auto aRange = aContainer.getB2DRange(rViewInformation2D);
+
+    BitmapEx aBitmapEx
+        = drawinglayer::convertToBitmapEx(aContainer, rViewInformation2D, 
2000, 2000, 10000 * 1000);
+
+    SvFileStream aNew("~/xxxxxxx.png", StreamMode::WRITE | StreamMode::TRUNC);
+    vcl::PNGWriter aPNGWriter(aBitmapEx);
+    aPNGWriter.Write(aNew);
+
+    drawinglayer::Primitive2dXmlDump aDumper;
+    aDumper.dump(aContainer, OUString());
+    xmlDocUniquePtr pDocument = aDumper.dumpAndParse(aContainer);
+    CPPUNIT_ASSERT(pDocument);
+
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/transform/unifiedtransparence",
+                "transparence", "0.498039215686275");
+
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinX());
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinY());
+    CPPUNIT_ASSERT_EQUAL(612.5, aRange.getMaxX());
+    CPPUNIT_ASSERT_EQUAL(792.5, aRange.getMaxY());
+
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Height());
+
+    CPPUNIT_ASSERT(false);
+}
+
+void PDFImporterTest::testImage()
+{
+    SvFileStream aFileStream(getFullUrl(u"/PdfTest-Image.pdf"), 
StreamMode::READ);
+    const sal_uInt64 nStreamLength = aFileStream.TellEnd();
+    auto rData = std::make_unique<std::vector<sal_uInt8>>(nStreamLength);
+    aFileStream.ReadBytes(rData->data(), rData->size());
+    BinaryDataContainer aDataContainer(std::move(rData));
+    PDFImporter aImporter(aDataContainer);
+
+    drawinglayer::primitive2d::Primitive2DContainer aContainer;
+    aImporter.importPage(0, aContainer);
+
+    drawinglayer::geometry::ViewInformation2D rViewInformation2D;
+
+    auto aRange = aContainer.getB2DRange(rViewInformation2D);
+
+    BitmapEx aBitmapEx
+        = drawinglayer::convertToBitmapEx(aContainer, rViewInformation2D, 
2000, 2000, 10000 * 1000);
+
+    SvFileStream aNew("~/xxxxxxx.png", StreamMode::WRITE | StreamMode::TRUNC);
+    vcl::PNGWriter aPNGWriter(aBitmapEx);
+    aPNGWriter.Write(aNew);
+
+    drawinglayer::Primitive2dXmlDump aDumper;
+    aDumper.dump(aContainer, OUString());
+    xmlDocUniquePtr pDocument = aDumper.dumpAndParse(aContainer);
+    CPPUNIT_ASSERT(pDocument);
+
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/transform/unifiedtransparence",
+                "transparence", "0.498039215686275");
+
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinX());
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinY());
+    CPPUNIT_ASSERT_EQUAL(612.5, aRange.getMaxX());
+    CPPUNIT_ASSERT_EQUAL(792.5, aRange.getMaxY());
+
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Height());
+
+    CPPUNIT_ASSERT(false);
+}
+
+void PDFImporterTest::testText()
+{
+    SvFileStream aFileStream(getFullUrl(u"/PdfTest-Text.pdf"), 
StreamMode::READ);
+    const sal_uInt64 nStreamLength = aFileStream.TellEnd();
+    auto rData = std::make_unique<std::vector<sal_uInt8>>(nStreamLength);
+    aFileStream.ReadBytes(rData->data(), rData->size());
+    BinaryDataContainer aDataContainer(std::move(rData));
+    PDFImporter aImporter(aDataContainer);
+
+    drawinglayer::primitive2d::Primitive2DContainer aContainer;
+    aImporter.importPage(0, aContainer);
+
+    drawinglayer::geometry::ViewInformation2D rViewInformation2D;
+
+    auto aRange = aContainer.getB2DRange(rViewInformation2D);
+
+    BitmapEx aBitmapEx
+        = drawinglayer::convertToBitmapEx(aContainer, rViewInformation2D, 
2000, 2000, 10000 * 1000);
+
+    SvFileStream aNew("~/xxxxxxx.png", StreamMode::WRITE | StreamMode::TRUNC);
+    vcl::PNGWriter aPNGWriter(aBitmapEx);
+    aPNGWriter.Write(aNew);
+
+    drawinglayer::Primitive2dXmlDump aDumper;
+    aDumper.dump(aContainer, OUString());
+    xmlDocUniquePtr pDocument = aDumper.dumpAndParse(aContainer);
+    CPPUNIT_ASSERT(pDocument);
+
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/transform/unifiedtransparence",
+                "transparence", "0.498039215686275");
+
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinX());
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinY());
+    CPPUNIT_ASSERT_EQUAL(612.5, aRange.getMaxX());
+    CPPUNIT_ASSERT_EQUAL(792.5, aRange.getMaxY());
+
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Height());
+
+    CPPUNIT_ASSERT(false);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(PDFImporterTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/qa/cppunit/data/PdfTest-Image.pdf 
b/filter/qa/cppunit/data/PdfTest-Image.pdf
new file mode 100644
index 000000000000..394ee272f3d4
Binary files /dev/null and b/filter/qa/cppunit/data/PdfTest-Image.pdf differ
diff --git a/filter/qa/cppunit/data/PdfTest-Rect.pdf 
b/filter/qa/cppunit/data/PdfTest-Rect.pdf
new file mode 100644
index 000000000000..7115df65176f
--- /dev/null
+++ b/filter/qa/cppunit/data/PdfTest-Rect.pdf
@@ -0,0 +1,134 @@
+%PDF-1.6
+%äüöß
+2 0 obj
+<</Length 3 0 R/Filter/FlateDecode>>
+stream
+x����JA��y��{�&ٙ�Y(=�UQ�z�   ڪl.H_����"����!��%��x�7$�@R03��el;��=<-�
���#��O��
X#7��Ly�3��y9����j���6H��զ
+1���%K�̤0��hL:R,�SsSH�8S����BJ�duL�bg��|�Օs �4�����h����m�}E�� 
�ƅ��*�H���l��'���8a���M9��4S���Q���X8wY
+endstream
+endobj
+
+3 0 obj
+241
+endobj
+
+8 0 obj
+<<
+>>
+endobj
+
+9 0 obj
+<</Font 8 0 R
+/ProcSet[/PDF/Text]
+>>
+endobj
+
+1 0 obj
+<</Type/Page/Parent 7 0 R/Resources 9 0 R/MediaBox[0 0 612 792]/StructParents 0
+/Group<</S/Transparency/CS/DeviceRGB/I true>>/Contents 2 0 R>>
+endobj
+
+10 0 obj
+<</Count 1/First 11 0 R/Last 11 0 R
+>>
+endobj
+
+11 0 obj
+<</Count 0/Title<FEFF005000610067006500200031>
+/Dest[1 0 R/XYZ 0 792 0]/Parent 10 0 R>>
+endobj
+
+4 0 obj
+<</Type/StructElem
+/S/Figure
+/P 12 0 R
+/Pg 1 0 R
+/K[0 ]
+>>
+endobj
+
+5 0 obj
+<</Type/StructElem
+/S/Figure
+/P 12 0 R
+/Pg 1 0 R
+/K[1 ]
+>>
+endobj
+
+6 0 obj
+<</Type/StructElem
+/S/Figure
+/P 12 0 R
+/Pg 1 0 R
+/K[2 ]
+>>
+endobj
+
+12 0 obj
+<</Type/StructTreeRoot
+/ParentTree 13 0 R
+/K[4 0 R 5 0 R 6 0 R ]
+>>
+endobj
+
+13 0 obj
+<</Nums[
+0 [ 4 0 R 5 0 R 6 0 R ]
+]>>
+endobj
+
+7 0 obj
+<</Type/Pages
+/Resources 9 0 R
+/MediaBox[ 0 0 612 792 ]
+/Kids[ 1 0 R ]
+/Count 1>>
+endobj
+
+14 0 obj
+<</Type/Catalog/Pages 7 0 R
+/OpenAction[1 0 R /XYZ null null 0]
+/ViewerPreferences<</DisplayDocTitle true
+>>
+/Outlines 10 0 R
+/StructTreeRoot 12 0 R
+/MarkInfo<</Marked true>>
+>>
+endobj
+
+15 0 obj
+<</Title<FEFF004D007900540065006D0070006C006100740065>
+/Creator<FEFF0044007200610077>
+/Producer<FEFF004C0069006200720065004F0066006600690063006500200037002E0030>
+/CreationDate(D:20210505091047+09'00')>>
+endobj
+
+xref
+0 16
+0000000000 65535 f 
+0000000426 00000 n 
+0000000019 00000 n 
+0000000331 00000 n 
+0000000746 00000 n 
+0000000821 00000 n 
+0000000896 00000 n 
+0000001110 00000 n 
+0000000351 00000 n 
+0000000373 00000 n 
+0000000585 00000 n 
+0000000641 00000 n 
+0000000971 00000 n 
+0000001056 00000 n 
+0000001208 00000 n 
+0000001403 00000 n 
+trailer
+<</Size 16/Root 14 0 R
+/Info 15 0 R
+/ID [ <3F7788F2D0928B3B95B0CDBBD9EAC1B8>
+<3F7788F2D0928B3B95B0CDBBD9EAC1B8> ]
+/DocChecksum /F2715E25D79DC609834CA579FA23A5BA
+>>
+startxref
+1623
+%%EOF
diff --git a/filter/qa/cppunit/data/PdfTest-Text.pdf 
b/filter/qa/cppunit/data/PdfTest-Text.pdf
new file mode 100644
index 000000000000..c449bf559228
Binary files /dev/null and b/filter/qa/cppunit/data/PdfTest-Text.pdf differ
diff --git a/filter/source/pdfimporter/PDFImporter.cxx 
b/filter/source/pdfimporter/PDFImporter.cxx
new file mode 100644
index 000000000000..30734819f47d
--- /dev/null
+++ b/filter/source/pdfimporter/PDFImporter.cxx
@@ -0,0 +1,384 @@
+/* -*- 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 <filter/pdfimporter/PDFImporter.hxx>
+
+#include <sal/log.hxx>
+#include <tools/UnitConversion.hxx>
+#include <tools/color.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/BitmapTools.hxx>
+
+#include <cmath>
+
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+#include <drawinglayer/attribute/lineattribute.hxx>
+#include <drawinglayer/attribute/strokeattribute.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx>
+#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
+#include <drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx>
+#include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
+#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+
+PDFImporter::PDFImporter(BinaryDataContainer& rDataContainer)
+    : mpPDFium(vcl::pdf::PDFiumLibrary::get())
+{
+    auto* pData = rDataContainer.getData();
+    sal_Int32 nSize = rDataContainer.getSize();
+    OString aEmptyPassword;
+    mpPdfDocument = mpPDFium->openDocument(pData, nSize, aEmptyPassword);
+}
+
+namespace
+{
+void setupPage(drawinglayer::primitive2d::Primitive2DContainer& rContainer,
+               basegfx::B2DSize const& rPageSize)
+{
+    basegfx::B2DRange aPageRange(0.0, 0.0, rPageSize.getX(), rPageSize.getY());
+
+    printf("Page Size %.2fpt %.2fpt\n", rPageSize.getX(), rPageSize.getY());
+
+    const auto aPolygon = basegfx::utils::createPolygonFromRect(aPageRange);
+
+    const drawinglayer::primitive2d::Primitive2DReference xPage(
+        new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPolygon,
+                                                                  
basegfx::BColor(0.0, 0.0, 0.0)));
+    const drawinglayer::primitive2d::Primitive2DReference xHidden(
+        new drawinglayer::primitive2d::HiddenGeometryPrimitive2D(
+            drawinglayer::primitive2d::Primitive2DContainer{ xPage }));
+
+    rContainer.push_back(xHidden);
+}
+
+double sqrt2(double a, double b) { return sqrt(a * a + b * b); }
+
+} // end anonymous namespace
+
+bool PDFImporter::importPage(int nPageIndex,
+                             drawinglayer::primitive2d::Primitive2DContainer& 
rContainer)
+{
+    if (!mpPdfDocument)
+        return false;
+
+    drawinglayer::primitive2d::Primitive2DContainer aContent;
+
+    const int nPageCount = mpPdfDocument->getPageCount();
+    if (!(nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount))
+        return false;
+
+    mpPdfPage = mpPdfDocument->openPage(nPageIndex);
+    if (!mpPdfPage)
+        return false;
+
+    basegfx::B2DSize aPageSize = mpPdfDocument->getPageSize(nPageIndex);
+
+    setupPage(aContent, aPageSize);
+
+    // Load the page text to extract it when we get text elements.
+    auto pTextPage = mpPdfPage->getTextPage();
+
+    const int nPageObjectCount = mpPdfPage->getObjectCount();
+
+    for (int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; 
++nPageObjectIndex)
+    {
+        auto pPageObject = mpPdfPage->getObject(nPageObjectIndex);
+        importPdfObject(pPageObject, pTextPage, nPageObjectIndex, aContent);
+    }
+
+    // point to pixel conversion
+    double dConversionFactor = double(conversionFract(o3tl::Length::pt, 
o3tl::Length::px));
+    const auto aTransform = basegfx::utils::createScaleTranslateB2DHomMatrix(
+        dConversionFactor, -dConversionFactor, 0.0, aPageSize.getY() * 
dConversionFactor);
+
+    const drawinglayer::primitive2d::Primitive2DReference xTransform(
+        new drawinglayer::primitive2d::TransformPrimitive2D(aTransform, 
std::move(aContent)));
+
+    rContainer.push_back(xTransform);
+
+    return true;
+}
+
+void PDFImporter::importPdfObject(std::unique_ptr<vcl::pdf::PDFiumPageObject> 
const& pPageObject,
+                                  std::unique_ptr<vcl::pdf::PDFiumTextPage> 
const& pTextPage,
+                                  int nPageObjectIndex,
+                                  
drawinglayer::primitive2d::Primitive2DContainer& rContent)
+{
+    if (!pPageObject)
+        return;
+
+    const vcl::pdf::PDFPageObjectType ePageObjectType = pPageObject->getType();
+    switch (ePageObjectType)
+    {
+        case vcl::pdf::PDFPageObjectType::Text:
+            printf("pdf::PDFPageObjectType::Text\n");
+            importText(pPageObject, pTextPage, rContent);
+            break;
+        case vcl::pdf::PDFPageObjectType::Path:
+            printf("pdf::PDFPageObjectType::Path\n");
+            importPath(pPageObject, rContent);
+            break;
+        case vcl::pdf::PDFPageObjectType::Image:
+            printf("pdf::PDFPageObjectType::Image\n");
+            importImage(pPageObject, rContent);
+            break;
+        case vcl::pdf::PDFPageObjectType::Shading:
+            printf("pdf::PDFPageObjectType::Shading\n");
+            break;
+        case vcl::pdf::PDFPageObjectType::Form:
+            printf("pdf::PDFPageObjectType::Form\n");
+            break;
+        case vcl::pdf::PDFPageObjectType::Unknown:
+            SAL_WARN("filter", "Unknown PDF page object #" << nPageObjectIndex
+                                                           << " of type: " << 
int(ePageObjectType));
+            break;
+    }
+}
+
+void PDFImporter::importText(std::unique_ptr<vcl::pdf::PDFiumPageObject> 
const& pPageObject,
+                             std::unique_ptr<vcl::pdf::PDFiumTextPage> const& 
pTextPage,
+                             drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer)
+{
+    basegfx::B2DRectangle aTextRect = pPageObject->getBounds();
+    basegfx::B2DHomMatrix aMatrix = pPageObject->getMatrix();
+
+    OUString sText = pPageObject->getText(pTextPage);
+
+    const double dFontSize = pPageObject->getFontSize();
+    double dFontSizeH = std::fabs(sqrt2(aMatrix.a(), aMatrix.c()) * dFontSize);
+    double dFontSizeV = std::fabs(sqrt2(aMatrix.b(), aMatrix.d()) * dFontSize);
+
+    OUString sFontName = pPageObject->getFontName();
+
+    printf("TEXT: %s\n", sText.toUtf8().getStr());
+
+    Color aTextColor(COL_TRANSPARENT);
+    bool bFill = false;
+    bool bUse = true;
+
+    switch (pPageObject->getTextRenderMode())
+    {
+        case vcl::pdf::PDFTextRenderMode::Fill:
+        case vcl::pdf::PDFTextRenderMode::FillClip:
+        case vcl::pdf::PDFTextRenderMode::FillStroke:
+        case vcl::pdf::PDFTextRenderMode::FillStrokeClip:
+            bFill = true;
+            break;
+        case vcl::pdf::PDFTextRenderMode::Stroke:
+        case vcl::pdf::PDFTextRenderMode::StrokeClip:
+        case vcl::pdf::PDFTextRenderMode::Unknown:
+            break;
+        case vcl::pdf::PDFTextRenderMode::Invisible:
+        case vcl::pdf::PDFTextRenderMode::Clip:
+            bUse = false;
+            break;
+    }
+
+    if (bUse)
+    {
+        Color aColor = bFill ? pPageObject->getFillColor() : 
pPageObject->getStrokeColor();
+        if (aColor != COL_TRANSPARENT)
+        {
+            aTextColor = aColor.GetRGBColor();
+        }
+    }
+}
+
+void PDFImporter::importImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> 
const& pPageObject,
+                              drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer)
+{
+    std::unique_ptr<vcl::pdf::PDFiumBitmap> pPdfBitmap = 
pPageObject->getImageBitmap();
+    if (!pPdfBitmap)
+    {
+        SAL_WARN("filter", "Failed to get IMAGE");
+        return;
+    }
+
+    const vcl::pdf::PDFBitmapType eFormat = pPdfBitmap->getFormat();
+    if (eFormat == vcl::pdf::PDFBitmapType::Unknown)
+    {
+        SAL_WARN("filter", "Failed to get IMAGE format");
+        return;
+    }
+
+    vcl::pdf::PDFImageMetadata aMetadata = 
pPageObject->getImageMetadata(*mpPdfPage);
+    printf("METADATA %lu %lu %lu\n", aMetadata.mnWidth, aMetadata.mnHeight,
+           aMetadata.mnBitsPerPixel);
+
+    const sal_uInt8* pBuffer = pPdfBitmap->getBuffer();
+    const int nWidth = pPdfBitmap->getWidth();
+    const int nHeight = pPdfBitmap->getHeight();
+    const int nStride = pPdfBitmap->getStride();
+
+    BitmapEx aBitmap;
+
+    printf("hasTransparency %d\n", pPageObject->hasTransparency());
+
+    switch (eFormat)
+    {
+        case vcl::pdf::PDFBitmapType::BGR:
+            printf("vcl::pdf::PDFBitmapType::BGR\n");
+            aBitmap = vcl::bitmap::CreateFromData(pBuffer, nWidth, nHeight, 
nStride,
+                                                  vcl::PixelFormat::N24_BPP);
+            break;
+        case vcl::pdf::PDFBitmapType::BGRx:
+            printf("vcl::pdf::PDFBitmapType::BGRx\n");
+            aBitmap = vcl::bitmap::CreateFromData(pBuffer, nWidth, nHeight, 
nStride,
+                                                  vcl::PixelFormat::N32_BPP);
+            break;
+        case vcl::pdf::PDFBitmapType::BGRA:
+            printf("vcl::pdf::PDFBitmapType::BGRA\n");
+            aBitmap = vcl::bitmap::CreateFromData(pBuffer, nWidth, nHeight, 
nStride,
+                                                  vcl::PixelFormat::N32_BPP);
+            break;
+        case vcl::pdf::PDFBitmapType::Gray:
+            // TODO
+        default:
+            SAL_WARN("filter", "Got IMAGE width: " << nWidth << ", height: " 
<< nHeight
+                                                   << ", stride: " << nStride
+                                                   << ", format: " << 
int(eFormat));
+            break;
+    }
+
+    basegfx::B2DRectangle aBounds = pPageObject->getBounds();
+
+    rRootContainer.push_back(new drawinglayer::primitive2d::BitmapPrimitive2D(
+        VCLUnoHelper::CreateVCLXBitmap(aBitmap), 
basegfx::utils::createScaleTranslateB2DHomMatrix(
+                                                     aBounds.getRange(), 
aBounds.getMinimum())));
+}
+
+void PDFImporter::importPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> 
const& pPageObject,
+                             drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer)
+{
+    drawinglayer::primitive2d::Primitive2DContainer aContent;
+
+    basegfx::B2DHomMatrix aPathMatrix = pPageObject->getMatrix();
+
+    basegfx::B2DPolyPolygon aPolyPolygon;
+    basegfx::B2DPolygon aPolygon;
+    std::vector<basegfx::B2DPoint> aBezier;
+
+    const int nSegments = pPageObject->getPathSegmentCount();
+    for (int nSegmentIndex = 0; nSegmentIndex < nSegments; ++nSegmentIndex)
+    {
+        auto pPathSegment = pPageObject->getPathSegment(nSegmentIndex);
+        if (!pPathSegment)
+            continue;
+
+        basegfx::B2DPoint aB2DPoint = pPathSegment->getPoint();
+
+        aPolygon.setClosed(pPathSegment->isClosed());
+
+        const vcl::pdf::PDFSegmentType eSegmentType = pPathSegment->getType();
+        switch (eSegmentType)
+        {
+            case vcl::pdf::PDFSegmentType::Lineto:
+            {
+                aPolygon.append(aB2DPoint);
+            }
+            break;
+
+            case vcl::pdf::PDFSegmentType::Bezierto:
+            {
+                aBezier.emplace_back(aB2DPoint.getX(), aB2DPoint.getY());
+                if (aBezier.size() == 3)
+                {
+                    aPolygon.appendBezierSegment(aBezier[0], aBezier[1], 
aBezier[2]);
+                    aBezier.clear();
+                }
+            }
+            break;
+
+            case vcl::pdf::PDFSegmentType::Moveto:
+            {
+                if (aPolygon.count() > 0)
+                {
+                    aPolyPolygon.append(aPolygon);
+                    aPolygon.clear();
+                }
+
+                aPolygon.append(aB2DPoint);
+            }
+            break;
+
+            case vcl::pdf::PDFSegmentType::Unknown:
+            default:
+            {
+                SAL_WARN("filter", "Unknown path segment type in PDF: " << 
int(eSegmentType));
+            }
+            break;
+        }
+    }
+
+    if (aBezier.size() == 3)
+    {
+        aPolygon.appendBezierSegment(aBezier[0], aBezier[1], aBezier[2]);
+        aBezier.clear();
+    }
+
+    if (aPolygon.count() > 0)
+    {
+        aPolyPolygon.append(aPolygon, 1);
+        aPolygon.clear();
+    }
+
+    printf("PolyPoly size %d\n", aPolyPolygon.count());
+    for (auto const& rPoly : aPolyPolygon)
+        printf("Poly size %d\n", rPoly.count());
+
+    double fStrokeWidth = pPageObject->getStrokeWidth();
+    printf("Stroke: %f\n", fStrokeWidth);
+
+    vcl::pdf::PDFFillMode nFillMode = vcl::pdf::PDFFillMode::Alternate;
+    bool bStroke = true;
+
+    if (!pPageObject->getDrawMode(nFillMode, bStroke))
+    {
+        SAL_WARN("filter", "Huh...");
+    }
+
+    Color aFillColor = pPageObject->getFillColor();
+    Color aStokeColor = COL_TRANSPARENT;
+
+    if (bStroke)
+    {
+        aStokeColor = pPageObject->getStrokeColor();
+    }
+
+    if (aStokeColor == COL_TRANSPARENT)
+        aStokeColor = aFillColor;
+
+    if (!bStroke)
+    {
+        const drawinglayer::primitive2d::Primitive2DReference 
xPolyPolygonColorPrimitive(
+            new 
drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(aPolyPolygon,
+                                                                       
aFillColor.getBColor()));
+        aContent.push_back(xPolyPolygonColorPrimitive);
+    }
+
+    drawinglayer::attribute::LineAttribute 
aLineAttribute(aStokeColor.getBColor(), fStrokeWidth);
+    const drawinglayer::primitive2d::Primitive2DReference 
xPolyPolygonStrokePrimitive(
+        new 
drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(aPolyPolygon, 
aLineAttribute));
+    aContent.push_back(xPolyPolygonStrokePrimitive);
+
+    const drawinglayer::primitive2d::Primitive2DReference xTransform(
+        new drawinglayer::primitive2d::TransformPrimitive2D(aPathMatrix, 
std::move(aContent)));
+    rRootContainer.push_back(xTransform);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/filter/pdfimporter/PDFImporter.hxx 
b/include/filter/pdfimporter/PDFImporter.hxx
new file mode 100644
index 000000000000..01cd94d264c9
--- /dev/null
+++ b/include/filter/pdfimporter/PDFImporter.hxx
@@ -0,0 +1,45 @@
+/* -*- 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 <vcl/filter/PDFiumLibrary.hxx>
+#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
+#include <vcl/BinaryDataContainer.hxx>
+
+class PDFImporter
+{
+private:
+    std::shared_ptr<vcl::pdf::PDFium> mpPDFium;
+    std::unique_ptr<vcl::pdf::PDFiumDocument> mpPdfDocument;
+    std::unique_ptr<vcl::pdf::PDFiumPage> mpPdfPage;
+
+    void importPdfObject(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& 
pPageObject,
+                         std::unique_ptr<vcl::pdf::PDFiumTextPage> const& 
pTextPage,
+                         int nPageObjectIndex,
+                         drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer);
+
+    void importText(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& 
pPageObject,
+                    std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
+                    drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer);
+
+    void importPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& 
pPageObject,
+                    drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer);
+
+    void importImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& 
pPageObject,
+                     drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer);
+
+public:
+    PDFImporter(BinaryDataContainer& rDataContainer);
+
+    bool importPage(int nPageIndex, 
drawinglayer::primitive2d::Primitive2DContainer& rContainer);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to