diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-12-14 21:42:26 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-12-18 16:58:14 +0000 |
commit | 8a5648d8e59b4b007dbbf3824777c19a21efc61e (patch) | |
tree | e4dc16dfe26d58918e9cbe8094f3662f7668cfe9 | |
parent | 28c27a0623bc78a0590858f97d03b620985bc84c (diff) |
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 <sbergman@redhat.com>
-rw-r--r-- | canvas/source/cairo/cairo_canvashelper_text.cxx | 2 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_textlayout.cxx | 10 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_textlayout.hxx | 7 |
3 files changed, 17 insertions, 2 deletions
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, |