diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-12-14 21:11:53 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-12-23 14:21:11 +0000 |
commit | 40db42be1d8fd0f9c6c8c5ba3767ddb9ee2034c2 (patch) | |
tree | 9b8b0a6c5bd90e06acea1cd29aa7ae035721d945 | |
parent | 2d1e7995eae29e2826449eb5179f5fae181794a5 (diff) |
loplugin:unocast (vclcanvas::CanvasFont)
(See the upcoming commit introducing that loplugin:unocast on why such
dynamic_casts from UNO types are dangerous.)
Change-Id: Id92c7e4367aae8e22d77772986d85288cdb73f2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144770
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | canvas/source/vcl/canvasfont.cxx | 10 | ||||
-rw-r--r-- | canvas/source/vcl/canvasfont.hxx | 7 | ||||
-rw-r--r-- | canvas/source/vcl/canvashelper.cxx | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/canvas/source/vcl/canvasfont.cxx b/canvas/source/vcl/canvasfont.cxx index e7fab0492549..0f342de0785a 100644 --- a/canvas/source/vcl/canvasfont.cxx +++ b/canvas/source/vcl/canvasfont.cxx @@ -22,6 +22,7 @@ #include <basegfx/numeric/ftools.hxx> #include <canvas/canvastools.hxx> #include <com/sun/star/rendering/PanoseProportion.hpp> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <i18nlangtag/languagetag.hxx> #include <rtl/math.hxx> @@ -168,6 +169,15 @@ namespace vclcanvas return { "com.sun.star.rendering.CanvasFont" }; } + sal_Int64 CanvasFont::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); + } + + css::uno::Sequence<sal_Int8> const & CanvasFont::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); + } + vcl::Font const & CanvasFont::getVCLFont() const { return *maFont; diff --git a/canvas/source/vcl/canvasfont.hxx b/canvas/source/vcl/canvasfont.hxx index fdfa870f5ed3..a4fd9fb0bc3e 100644 --- a/canvas/source/vcl/canvasfont.hxx +++ b/canvas/source/vcl/canvasfont.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/geometry/Matrix2D.hpp> #include <com/sun/star/rendering/FontRequest.hpp> #include <com/sun/star/rendering/XCanvasFont.hpp> @@ -40,7 +41,8 @@ namespace vclcanvas { typedef ::cppu::WeakComponentImplHelper< css::rendering::XCanvasFont, - css::lang::XServiceInfo > CanvasFont_Base; + css::lang::XServiceInfo, + css::lang::XUnoTunnel > CanvasFont_Base; class CanvasFont : public ::cppu::BaseMutex, public CanvasFont_Base @@ -73,6 +75,9 @@ namespace vclcanvas 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(); + vcl::Font const & getVCLFont() const; private: diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index cbbd18a376d9..60ab39d470a2 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -1111,7 +1111,7 @@ namespace vclcanvas setupOutDevState( viewState, renderState, TEXT_COLOR ); - CanvasFont* pFont = dynamic_cast< CanvasFont* >( xFont.get() ); + CanvasFont* pFont = comphelper::getFromUnoTunnel< CanvasFont >( xFont ); ENSURE_ARG_OR_THROW( pFont, "Font not compatible with this canvas" ); |