canvas/source/cairo/cairo_canvashelper_text.cxx |    2 +-
 canvas/source/cairo/cairo_textlayout.cxx        |   10 ++++++++++
 canvas/source/cairo/cairo_textlayout.hxx        |    7 ++++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 8a5648d8e59b4b007dbbf3824777c19a21efc61e
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Dec 14 21:42:26 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Sun Dec 18 16:58:14 2022 +0000

    loplugin:unocast (cairocanvas::TextLayout)
    
    (See the upcoming commit introducing that loplugin:unocast on why such
    dynamic_casts from UNO types are dangerous.)
    
    Change-Id: I900d37ee0053e3fbfc8c21b02087a6eaa92cf942
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144352
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/canvas/source/cairo/cairo_canvashelper_text.cxx 
b/canvas/source/cairo/cairo_canvashelper_text.cxx
index b982e069589a..982c16c24377 100644
--- a/canvas/source/cairo/cairo_canvashelper_text.cxx
+++ b/canvas/source/cairo/cairo_canvashelper_text.cxx
@@ -263,7 +263,7 @@ namespace cairocanvas
         ENSURE_ARG_OR_THROW( xLayoutedText.is(),
                          "CanvasHelper::drawTextLayout(): layout is NULL");
 
-        TextLayout* pTextLayout = dynamic_cast< TextLayout* >( 
xLayoutedText.get() );
+        TextLayout* pTextLayout = comphelper::getFromUnoTunnel< TextLayout >( 
xLayoutedText );
 
         if( pTextLayout )
         {
diff --git a/canvas/source/cairo/cairo_textlayout.cxx 
b/canvas/source/cairo/cairo_textlayout.cxx
index 1a6f0143a60a..4324aad832bb 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -28,6 +28,7 @@
 #include <basegfx/numeric/ftools.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <comphelper/diagnose_ex.hxx>
+#include <comphelper/servicehelper.hxx>
 #include <utility>
 #include <vcl/kernarray.hxx>
 #include <vcl/metric.hxx>
@@ -344,6 +345,15 @@ namespace cairocanvas
     {
         return { "com.sun.star.rendering.TextLayout" };
     }
+
+    sal_Int64 TextLayout::getSomething(css::uno::Sequence<sal_Int8> const & 
aIdentifier) {
+        return comphelper::getSomethingImpl(aIdentifier, this);
+    }
+
+    css::uno::Sequence<sal_Int8> const & TextLayout::getUnoTunnelId() {
+        static comphelper::UnoIdInit const id;
+        return id.getSeq();
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/cairo/cairo_textlayout.hxx 
b/canvas/source/cairo/cairo_textlayout.hxx
index bec692e75707..c2a85ceab72a 100644
--- a/canvas/source/cairo/cairo_textlayout.hxx
+++ b/canvas/source/cairo/cairo_textlayout.hxx
@@ -23,6 +23,7 @@
 #include <cppuhelper/basemutex.hxx>
 
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <com/sun/star/rendering/RenderState.hpp>
 #include <com/sun/star/rendering/ViewState.hpp>
 #include <com/sun/star/rendering/XTextLayout.hpp>
@@ -37,7 +38,8 @@
 namespace cairocanvas
 {
     typedef ::cppu::WeakComponentImplHelper< css::rendering::XTextLayout,
-                                             css::lang::XServiceInfo > 
TextLayout_Base;
+                                             css::lang::XServiceInfo,
+                                             css::lang::XUnoTunnel > 
TextLayout_Base;
 
     class TextLayout : public ::cppu::BaseMutex,
                        public TextLayout_Base
@@ -80,6 +82,9 @@ namespace cairocanvas
         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName 
) override;
         virtual css::uno::Sequence< OUString > SAL_CALL 
getSupportedServiceNames() override;
 
+        sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & 
aIdentifier) override;
+        static css::uno::Sequence<sal_Int8> const & getUnoTunnelId();
+
         void draw( OutputDevice&                                   rOutDev,
                    const Point&                                    rOutpos,
                    const css::rendering::ViewState&   viewState,

Reply via email to