drawinglayer: ITextLayouter and use it as a VisitingParameter

Change-Id: I04aa42716c2bde4a2652d10892b6b2392a20fb3b
diff --git a/basegfx/Library_basegfx.mk b/basegfx/Library_basegfx.mk
index 8359969..957f1b4 100644
--- a/basegfx/Library_basegfx.mk
+++ b/basegfx/Library_basegfx.mk
@@ -80,6 +80,7 @@
     basegfx/source/vector/b2dvector \
     basegfx/source/vector/b2ivector \
     basegfx/source/vector/b3dvector \
+    basegfx/source/text/UnoTextLayouter \
 ))
 
 
diff --git a/basegfx/source/text/UnoTextLayouter.cxx b/basegfx/source/text/UnoTextLayouter.cxx
new file mode 100644
index 0000000..e3f4826
--- /dev/null
+++ b/basegfx/source/text/UnoTextLayouter.cxx
@@ -0,0 +1,33 @@
+/* -*- 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/text/UnoTextLayouter.hxx>
+#include <cppuhelper/queryinterface.hxx>
+
+using namespace css;
+
+namespace gfx
+{
+// css::lang::XUnoTunnel
+UNO3_GETIMPLEMENTATION_IMPL(UnoTextLayouter);
+
+std::shared_ptr<gfx::ITextLayouter>
+getTextLayouterFromUno(uno::Reference<graphic::XTextLayouter> const& xTextLayouter)
+{
+    gfx::UnoTextLayouter* pUnoTextLayouter
+        = comphelper::getUnoTunnelImplementation<gfx::UnoTextLayouter>(xTextLayouter);
+    if (pUnoTextLayouter)
+        return pUnoTextLayouter->getTextLayouter();
+
+    return std::shared_ptr<gfx::ITextLayouter>();
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/drawinglayer/source/attribute/fontattribute.cxx b/drawinglayer/source/attribute/fontattribute.cxx
index e423b83..b14397f 100644
--- a/drawinglayer/source/attribute/fontattribute.cxx
+++ b/drawinglayer/source/attribute/fontattribute.cxx
@@ -112,15 +112,31 @@
 {
 }
 
-FontAttribute::FontAttribute(const FontAttribute&) = default;
+FontAttribute::FontAttribute(const FontAttribute& rOther)
+    : mpFontAttribute(rOther.mpFontAttribute)
+{
+}
 
-FontAttribute::FontAttribute(FontAttribute&&) = default;
+FontAttribute::FontAttribute(FontAttribute&& rOther) noexcept
+    : mpFontAttribute(std::move(rOther.mpFontAttribute))
+{
+}
 
-FontAttribute::~FontAttribute() = default;
+FontAttribute::~FontAttribute() {}
 
-FontAttribute& FontAttribute::operator=(const FontAttribute&) = default;
+FontAttribute& FontAttribute::operator=(const FontAttribute& rOther)
+{
+    mpFontAttribute = rOther.mpFontAttribute;
 
-FontAttribute& FontAttribute::operator=(FontAttribute&&) = default;
+    return *this;
+}
+
+FontAttribute& FontAttribute::operator=(FontAttribute&& rOther) noexcept
+{
+    mpFontAttribute = std::move(rOther.mpFontAttribute);
+
+    return *this;
+}
 
 bool FontAttribute::operator==(const FontAttribute& rCandidate) const
 {
diff --git a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
index f0e677c..78e2ea0 100644
--- a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
+++ b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/geometry/RealRectangle2D.hpp>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/processor2d/textlayoutdevice.hxx>
 
 #include <drawinglayer/converters.hxx>
 #include <comphelper/sequenceashashmap.hxx>
@@ -118,7 +119,8 @@
                     }
 
                     const geometry::ViewInformation2D aViewInformation2D(aViewInformationSequence);
-                    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D);
+                    auto pTextLayouter = std::make_shared<drawinglayer::processor2d::TextLayouterDevice>();
+                    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, pTextLayouter);
                     const sal_uInt32 nDiscreteWidth(basegfx::fround(o3tl::convert(fWidth, eRangeUnit, o3tl::Length::in) * DPI_X));
                     const sal_uInt32 nDiscreteHeight(basegfx::fround(o3tl::convert(fHeight, eRangeUnit, o3tl::Length::in) * DPI_Y));
 
diff --git a/drawinglayer/source/primitive2d/baseprimitive2d.cxx b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
index 085ccc1..7ec0958 100644
--- a/drawinglayer/source/primitive2d/baseprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
@@ -23,7 +23,10 @@
 #include <drawinglayer/primitive2d/Tools.hxx>
 #include <drawinglayer/geometry/viewinformation2d.hxx>
 #include <basegfx/utils/canvastools.hxx>
+#include <basegfx/text/UnoTextLayouter.hxx>
 #include <comphelper/sequence.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <com/sun/star/graphic/XTextLayouter.hpp>
 
 using namespace css;
 
@@ -85,12 +88,39 @@
 {
 }
 
+namespace
+{
+std::shared_ptr<gfx::ITextLayouter>
+getTextLayouter(const uno::Sequence<beans::PropertyValue>& rProperties)
+{
+    std::shared_ptr<gfx::ITextLayouter> pTextLayouter;
+
+    if (!rProperties.hasElements())
+        return pTextLayouter;
+
+    for (const beans::PropertyValue& rProperty : rProperties)
+    {
+        if (rProperty.Name == "TextLayouter")
+        {
+            uno::Reference<graphic::XTextLayouter> xTextLayouter;
+            rProperty.Value >>= xTextLayouter;
+            if (xTextLayouter.is())
+                pTextLayouter = gfx::getTextLayouterFromUno(xTextLayouter);
+            return pTextLayouter;
+        }
+    }
+    return pTextLayouter;
+}
+
+} // end anonymous namespace
+
 css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D>> SAL_CALL
 BasePrimitive2D::getDecomposition(const uno::Sequence<beans::PropertyValue>& rViewParameters)
 {
     Primitive2DContainer aContainer;
     geometry::ViewInformation2D aViewInformation2D(rViewParameters);
-    VisitingParameters aParameters(aViewInformation2D);
+    std::shared_ptr<gfx::ITextLayouter> pTextLayouter = getTextLayouter(rViewParameters);
+    VisitingParameters aParameters(aViewInformation2D, pTextLayouter);
     get2DDecomposition(aContainer, aParameters);
     return comphelper::containerToSequence(aContainer);
 }
@@ -99,7 +129,8 @@
 BasePrimitive2D::getRange(const uno::Sequence<beans::PropertyValue>& rViewParameters)
 {
     geometry::ViewInformation2D aViewInformation2D(rViewParameters);
-    VisitingParameters aParameters(aViewInformation2D);
+    std::shared_ptr<gfx::ITextLayouter> pTextLayouter = getTextLayouter(rViewParameters);
+    VisitingParameters aParameters(aViewInformation2D, pTextLayouter);
     return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aParameters));
 }
 
diff --git a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
index 0cfa014..09ae46a 100644
--- a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
@@ -107,7 +107,7 @@
                 const primitive2d::Primitive2DContainer xEmbedSeq { xEmbedRef };
 
                 const geometry::ViewInformation2D aViewInformation2D;
-                primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D);
+                primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, rParameters.getTextLayouter());
 
                 const BitmapEx aBitmapEx(
                     convertToBitmapEx(
diff --git a/drawinglayer/source/primitive2d/textprimitive2d.cxx b/drawinglayer/source/primitive2d/textprimitive2d.cxx
index fdf8148..e3b25a1 100644
--- a/drawinglayer/source/primitive2d/textprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/textprimitive2d.cxx
@@ -111,9 +111,10 @@
     const basegfx::B2DVector aFontScale(getCorrectedScaleAndFontScale(aScale));
 
     // prepare textlayoutdevice
-    drawinglayer::processor2d::TextLayouterDevice aTextLayouter;
-    aTextLayouter.setFontAttribute(getFontAttribute(), aFontScale.getX(), aFontScale.getY(),
-                                   getLocale());
+    std::unique_ptr<gfx::ITextLayouter> pTextLayouter
+        = std::make_unique<drawinglayer::processor2d::TextLayouterDevice>();
+    pTextLayouter->setFontAttribute(getFontAttribute(), aFontScale.getX(), aFontScale.getY(),
+                                    getLocale());
 
     // When getting outlines from stretched text (aScale.getX() != 1.0) it
     // is necessary to inverse-scale the DXArray (if used) to not get the
@@ -129,14 +130,14 @@
         }
 
         // get the text outlines
-        aTextLayouter.getTextOutlines(rTarget, getText(), getTextPosition(), getTextLength(),
-                                      aScaledDXArray);
+        pTextLayouter->getTextOutlines(rTarget, getText(), getTextPosition(), getTextLength(),
+                                       aScaledDXArray);
     }
     else
     {
         // get the text outlines
-        aTextLayouter.getTextOutlines(rTarget, getText(), getTextPosition(), getTextLength(),
-                                      getDXArray());
+        pTextLayouter->getTextOutlines(rTarget, getText(), getTextPosition(), getTextLength(),
+                                       getDXArray());
     }
 
     // create primitives for the outlines
diff --git a/drawinglayer/source/processor2d/contourextractor2d.cxx b/drawinglayer/source/processor2d/contourextractor2d.cxx
index 5b9adf4..919c09c 100644
--- a/drawinglayer/source/processor2d/contourextractor2d.cxx
+++ b/drawinglayer/source/processor2d/contourextractor2d.cxx
@@ -131,7 +131,7 @@
                         getViewInformation2D().getVisualizedPage(),
                         getViewInformation2D().getViewTime(),
                         getViewInformation2D().getExtendedInformationSequence());
-                    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D);
+                    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, maVisitingParameters.getTextLayouter());
                     updateVisitingParameters(aVisitingParameters);
 
                     // process content
diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx
index a410374..ffc6c46 100644
--- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx
@@ -240,7 +240,7 @@
                         getViewInformation2D().getVisualizedPage(),
                         getViewInformation2D().getViewTime(),
                         getViewInformation2D().getExtendedInformationSequence());
-                    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D);
+                    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, maVisitingParameters.getTextLayouter());
                     updateVisitingParameters(aVisitingParameters);
 
                     // process child content recursively
diff --git a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx
index cd4593b..8a173b2 100644
--- a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx
+++ b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx
@@ -94,7 +94,7 @@
                         getViewInformation2D().getViewTime(),
                         getViewInformation2D().getExtendedInformationSequence());
 
-                    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D);
+                    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, maVisitingParameters.getTextLayouter());
                     updateVisitingParameters(aVisitingParameters);
 
                     // process content
diff --git a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx
index 5eb6c9f..bc60998 100644
--- a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx
+++ b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx
@@ -185,7 +185,7 @@
                         getViewInformation2D().getViewTime(),
                         getViewInformation2D().getExtendedInformationSequence());
 
-                    primitive2d::VisitingParameters aParameters(aViewInformation2D);
+                    primitive2d::VisitingParameters aParameters(aViewInformation2D, maVisitingParameters.getTextLayouter());
                     updateVisitingParameters(aParameters);
 
                     // process content
diff --git a/drawinglayer/source/processor2d/textlayoutdevice.cxx b/drawinglayer/source/processor2d/textlayoutdevice.cxx
index 759a575..1af699d 100644
--- a/drawinglayer/source/processor2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/processor2d/textlayoutdevice.cxx
@@ -164,6 +164,14 @@
 
 void TextLayouterDevice::setFont(const vcl::Font& rFont) { mrDevice.SetFont(rFont); }
 
+void TextLayouterDevice::setFontAttribute(const gfx::IFontAttribute& rFontAttribute,
+                                          double fFontScaleX, double fFontScaleY,
+                                          const css::lang::Locale& rLocale)
+{
+    auto rFontA = dynamic_cast<attribute::FontAttribute const&>(rFontAttribute);
+    setFontAttribute(rFontA, fFontScaleX, fFontScaleY, rLocale);
+}
+
 void TextLayouterDevice::setFontAttribute(const attribute::FontAttribute& rFontAttribute,
                                           double fFontScaleX, double fFontScaleY,
                                           const css::lang::Locale& rLocale)
@@ -342,8 +350,8 @@
 
 // helper methods for vcl font handling
 
-vcl::Font getVclFontFromFontAttribute(const attribute::FontAttribute& rFontAttribute,
-                                      double fFontScaleX, double fFontScaleY, double fFontRotation,
+vcl::Font getVclFontFromFontAttribute(const gfx::IFontAttribute& rFontAttribute, double fFontScaleX,
+                                      double fFontScaleY, double fFontRotation,
                                       const css::lang::Locale& rLocale)
 {
     // detect FontScaling
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index 042bb4e..25a72a4 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -2311,7 +2311,8 @@
                 getViewInformation2D().getVisualizedPage(), getViewInformation2D().getViewTime(),
                 getViewInformation2D().getExtendedInformationSequence());
 
-            primitive2d::VisitingParameters aVisitingParameters(aViewInfo);
+            primitive2d::VisitingParameters aVisitingParameters(
+                aViewInfo, maVisitingParameters.getTextLayouter());
 
             VclPixelProcessor2D aBufferProcessor(aVisitingParameters, *aBufferDevice);
 
@@ -2451,7 +2452,8 @@
     auto pBufferDevice(CreateBufferDevice(aViewRange, aViewInfo, aRectLogic, aSizePixel));
     if (pBufferDevice)
     {
-        primitive2d::VisitingParameters aVisitingParameters(aViewInfo);
+        primitive2d::VisitingParameters aVisitingParameters(aViewInfo,
+                                                            maVisitingParameters.getTextLayouter());
         VclPixelProcessor2D aBufferProcessor(aVisitingParameters, *pBufferDevice,
                                              maBColorModifierStack);
 
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index 5489e56..a2a3398 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -907,7 +907,8 @@
         getViewInformation2D().getViewTransformation(), getViewInformation2D().getViewport(),
         getViewInformation2D().getVisualizedPage(), getViewInformation2D().getViewTime(),
         getViewInformation2D().getExtendedInformationSequence());
-    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D);
+    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D,
+                                                        maVisitingParameters.getTextLayouter());
     updateVisitingParameters(aVisitingParameters);
 
     // process content
@@ -931,7 +932,8 @@
         getViewInformation2D().getViewTransformation(), getViewInformation2D().getViewport(),
         rPagePreviewCandidate.getXDrawPage(), getViewInformation2D().getViewTime(),
         getViewInformation2D().getExtendedInformationSequence());
-    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D);
+    primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D,
+                                                        maVisitingParameters.getTextLayouter());
     updateVisitingParameters(aVisitingParameters);
 
     // process decomposed content
diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx
index e347e10..8c18973 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -36,6 +36,7 @@
 #include <drawinglayer/geometry/viewinformation2d.hxx>
 #include <drawinglayer/attribute/lineattribute.hxx>
 #include <drawinglayer/attribute/fontattribute.hxx>
+#include <drawinglayer/processor2d/textlayoutdevice.hxx>
 
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
@@ -209,7 +210,8 @@
     ::tools::XmlWriter& rWriter)
 {
     drawinglayer::geometry::ViewInformation2D aInfo;
-    drawinglayer::primitive2d::VisitingParameters aVisitingParameters(aInfo);
+    auto pTextLayouter = std::make_shared<drawinglayer::processor2d::TextLayouterDevice>();
+    drawinglayer::primitive2d::VisitingParameters aVisitingParameters(aInfo, pTextLayouter);
 
     for (size_t i = 0; i < rPrimitive2DSequence.size(); i++)
     {
diff --git a/include/basegfx/text/ITextLayouter.hxx b/include/basegfx/text/ITextLayouter.hxx
new file mode 100644
index 0000000..26ce469
--- /dev/null
+++ b/include/basegfx/text/ITextLayouter.hxx
@@ -0,0 +1,57 @@
+/* -*- 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/config.h>
+#include <basegfx/basegfxdllapi.h>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
+namespace com::sun::star::lang
+{
+struct Locale;
+}
+
+namespace gfx
+{
+class BASEGFX_DLLPUBLIC IFontAttribute
+{
+public:
+    virtual ~IFontAttribute() {}
+
+    virtual const OUString& getFamilyName() const = 0;
+    virtual const OUString& getStyleName() const = 0;
+    virtual sal_uInt16 getWeight() const = 0;
+    virtual bool getSymbol() const = 0;
+    virtual bool getVertical() const = 0;
+    virtual bool getItalic() const = 0;
+    virtual bool getOutline() const = 0;
+    virtual bool getRTL() const = 0;
+    virtual bool getBiDiStrong() const = 0;
+    virtual bool getMonospaced() const = 0;
+};
+
+class BASEGFX_DLLPUBLIC ITextLayouter
+{
+public:
+    virtual ~ITextLayouter() {}
+
+    virtual void setFontAttribute(IFontAttribute const& rFontAttribute, double fFontScaleX,
+                                  double fFontScaleY, const css::lang::Locale& rLocale)
+        = 0;
+
+    virtual void getTextOutlines(basegfx::B2DPolyPolygonVector& rB2DPolyPolyVector,
+                                 const OUString& rText, sal_uInt32 nIndex, sal_uInt32 nLength,
+                                 const std::vector<double>& rDXArray) const = 0;
+};
+
+} // end namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/basegfx/text/UnoTextLayouter.hxx b/include/basegfx/text/UnoTextLayouter.hxx
new file mode 100644
index 0000000..f8b0f25
--- /dev/null
+++ b/include/basegfx/text/UnoTextLayouter.hxx
@@ -0,0 +1,52 @@
+/* -*- 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 <cppuhelper/implbase.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/servicehelper.hxx>
+
+#include <com/sun/star/graphic/XTextLayouter.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+
+#include <basegfx/text/ITextLayouter.hxx>
+#include <basegfx/basegfxdllapi.h>
+
+namespace gfx
+{
+BASEGFX_DLLPUBLIC std::shared_ptr<gfx::ITextLayouter>
+getTextLayouterFromUno(css::uno::Reference<css::graphic::XTextLayouter> const& xTextLayouter);
+
+class UnoTextLayouter final
+    : public cppu::WeakImplHelper<css::graphic::XTextLayouter, css::lang::XUnoTunnel>
+{
+private:
+    std::shared_ptr<gfx::ITextLayouter> mpTextLayouter;
+
+public:
+    UnoTextLayouter() {}
+
+    UnoTextLayouter(std::shared_ptr<gfx::ITextLayouter> const& rTextLayouter)
+        : mpTextLayouter(rTextLayouter)
+    {
+    }
+
+    std::shared_ptr<gfx::ITextLayouter> const& getTextLayouter() const { return mpTextLayouter; }
+
+    void setTextLayouter(std::shared_ptr<gfx::ITextLayouter> const& rTextLayouter)
+    {
+        mpTextLayouter = rTextLayouter;
+    }
+
+    UNO3_GETIMPLEMENTATION_DECL(UnoTextLayouter)
+};
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/attribute/fontattribute.hxx b/include/drawinglayer/attribute/fontattribute.hxx
index 1a725017..ed0be64 100644
--- a/include/drawinglayer/attribute/fontattribute.hxx
+++ b/include/drawinglayer/attribute/fontattribute.hxx
@@ -23,6 +23,8 @@
 #include <o3tl/cow_wrapper.hxx>
 #include <rtl/ustring.hxx>
 
+#include <basegfx/text/ITextLayouter.hxx>
+
 namespace drawinglayer::attribute
 {
 class ImpFontAttribute;
@@ -35,7 +37,7 @@
     This attribute class is able to hold all parameters needed/used
     to completely define the parametrisation of a text portion.
  */
-class DRAWINGLAYER_DLLPUBLIC FontAttribute
+class DRAWINGLAYER_DLLPUBLIC FontAttribute : public gfx::IFontAttribute
 {
 public:
     typedef o3tl::cow_wrapper<ImpFontAttribute> ImplType;
@@ -50,26 +52,26 @@
                   bool bMonospaced = false, bool bOutline = false, bool bRTL = false,
                   bool bBiDiStrong = false);
     FontAttribute();
-    FontAttribute(const FontAttribute&);
-    FontAttribute(FontAttribute&&);
-    FontAttribute& operator=(const FontAttribute&);
-    FontAttribute& operator=(FontAttribute&&);
-    ~FontAttribute();
+    FontAttribute(const FontAttribute& rOther);
+    FontAttribute(FontAttribute&& rOther) noexcept;
+    FontAttribute& operator=(const FontAttribute& rOther);
+    FontAttribute& operator=(FontAttribute&& rOther) noexcept;
+    virtual ~FontAttribute();
 
     // compare operator
     bool operator==(const FontAttribute& rCandidate) const;
 
     /// data read access
-    const OUString& getFamilyName() const;
-    const OUString& getStyleName() const;
-    sal_uInt16 getWeight() const;
-    bool getSymbol() const;
-    bool getVertical() const;
-    bool getItalic() const;
-    bool getOutline() const;
-    bool getRTL() const;
-    bool getBiDiStrong() const;
-    bool getMonospaced() const;
+    const OUString& getFamilyName() const override;
+    const OUString& getStyleName() const override;
+    sal_uInt16 getWeight() const override;
+    bool getSymbol() const override;
+    bool getVertical() const override;
+    bool getItalic() const override;
+    bool getOutline() const override;
+    bool getRTL() const override;
+    bool getBiDiStrong() const override;
+    bool getMonospaced() const override;
 };
 } // end of namespace drawinglayer::attribute
 
diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
index 486bf03..69ff76a 100644
--- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
@@ -30,6 +30,7 @@
 #include <cppuhelper/basemutex.hxx>
 #include <basegfx/range/b2drange.hxx>
 #include <com/sun/star/graphic/XPrimitive2D.hpp>
+#include <basegfx/text/ITextLayouter.hxx>
 #include <drawinglayer/geometry/viewinformation2d.hxx>
 
 
@@ -39,10 +40,13 @@
 {
 private:
     geometry::ViewInformation2D maViewInformation;
+    std::shared_ptr<gfx::ITextLayouter> mpTextLayouter;
 
 public:
-    explicit VisitingParameters(const geometry::ViewInformation2D& rViewInformation)
+    explicit VisitingParameters(geometry::ViewInformation2D const& rViewInformation,
+                                std::shared_ptr<gfx::ITextLayouter> const& pTextLayouter)
         : maViewInformation(rViewInformation)
+        , mpTextLayouter(pTextLayouter)
     {
     }
 
@@ -54,6 +58,8 @@
     }
 
     const geometry::ViewInformation2D& getViewInformation() const { return maViewInformation; }
+
+    const std::shared_ptr<gfx::ITextLayouter>& getTextLayouter() const { return mpTextLayouter; }
 };
 
 typedef cppu::WeakComponentImplHelper<css::graphic::XPrimitive2D, css::util::XAccounting>
diff --git a/include/drawinglayer/processor2d/baseprocessor2d.hxx b/include/drawinglayer/processor2d/baseprocessor2d.hxx
index 802434f..c723c5c 100644
--- a/include/drawinglayer/processor2d/baseprocessor2d.hxx
+++ b/include/drawinglayer/processor2d/baseprocessor2d.hxx
@@ -24,7 +24,7 @@
 
 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
 #include <drawinglayer/geometry/viewinformation2d.hxx>
-
+#include <basegfx/text/ITextLayouter.hxx>
 
 namespace drawinglayer::processor2d
     {
diff --git a/include/drawinglayer/processor2d/textlayoutdevice.hxx b/include/drawinglayer/processor2d/textlayoutdevice.hxx
index ddcdf06..edcefec 100644
--- a/include/drawinglayer/processor2d/textlayoutdevice.hxx
+++ b/include/drawinglayer/processor2d/textlayoutdevice.hxx
@@ -25,6 +25,7 @@
 #include <vector>
 #include <basegfx/polygon/b2dpolypolygon.hxx>
 #include <vcl/svapp.hxx>
+#include <basegfx/text/ITextLayouter.hxx>
 
 // predefines
 class VirtualDevice;
@@ -58,7 +59,7 @@
     When in the future FontHandling may move to an own library independent
     from VCL, primitives will be prepared.
  */
-class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice
+class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice : public gfx::ITextLayouter
 {
     /// internally used VirtualDevice
     SolarMutexGuard maSolarGuard;
@@ -71,6 +72,10 @@
 
     /// tooling methods
     void setFont(const vcl::Font& rFont);
+
+    void setFontAttribute(const gfx::IFontAttribute& rFontAttribute, double fFontScaleX,
+                          double fFontScaleY, const css::lang::Locale& rLocale) override;
+
     void setFontAttribute(const attribute::FontAttribute& rFontAttribute, double fFontScaleX,
                           double fFontScaleY, const css::lang::Locale& rLocale);
 
@@ -84,7 +89,7 @@
     double getTextWidth(const OUString& rText, sal_uInt32 nIndex, sal_uInt32 nLength) const;
 
     void getTextOutlines(basegfx::B2DPolyPolygonVector&, const OUString& rText, sal_uInt32 nIndex,
-                         sal_uInt32 nLength, const ::std::vector<double>& rDXArray) const;
+                         sal_uInt32 nLength, const ::std::vector<double>& rDXArray) const override;
 
     basegfx::B2DRange getTextBoundRect(const OUString& rText, sal_uInt32 nIndex,
                                        sal_uInt32 nLength) const;
@@ -111,7 +116,7 @@
             fFontScaleY == fFontScaleX
          */
 vcl::Font DRAWINGLAYER_DLLPUBLIC getVclFontFromFontAttribute(
-    const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY,
+    const gfx::IFontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY,
     double fFontRotation, const css::lang::Locale& rLocale);
 
 /** Generate FontAttribute DataSet derived from the given VCL-Font.
diff --git a/offapi/com/sun/star/graphic/XTextLayouter.idl b/offapi/com/sun/star/graphic/XTextLayouter.idl
new file mode 100644
index 0000000..c518558
--- /dev/null
+++ b/offapi/com/sun/star/graphic/XTextLayouter.idl
@@ -0,0 +1,30 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef com_sun_star_graphic_XTextLayouter_idl
+#define com_sun_star_graphic_XTextLayouter_idl
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module com { module sun { module star { module graphic
+{
+
+/** Text layouter interface
+*/
+
+interface XTextLayouter : ::com::sun::star::uno::XInterface
+{
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */