loplugin:unocast (vclcanvas::TextLayout)

(See the upcoming commit introducing that loplugin:unocast on why such
dynamic_casts from UNO types are dangerous.)

Change-Id: I4ee48fe50c6c579952478e6d3f6c2aac168d095c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144769
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2022-12-14 21:07:28 +01:00
parent 80099fdd51
commit 03efbf72f4
3 changed files with 18 additions and 2 deletions

View File

@ -34,6 +34,7 @@
#include <com/sun/star/rendering/PathJoinType.hpp>
#include <com/sun/star/rendering/TextDirection.hpp>
#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <rtl/math.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <tools/poly.hxx>
@ -612,7 +613,7 @@ namespace vclcanvas
ENSURE_ARG_OR_THROW( xLayoutedText.is(),
"layout is NULL");
TextLayout* pTextLayout = dynamic_cast< TextLayout* >( xLayoutedText.get() );
TextLayout* pTextLayout = comphelper::getFromUnoTunnel< TextLayout >( xLayoutedText );
if( pTextLayout )
{

View File

@ -29,6 +29,7 @@
#include <com/sun/star/rendering/TextDirection.hpp>
#include <com/sun/star/rendering/ViewState.hpp>
#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <utility>
#include <vcl/kernarray.hxx>
@ -420,6 +421,15 @@ namespace vclcanvas
{
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: */

View File

@ -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/StringContext.hpp>
#include <com/sun/star/rendering/XTextLayout.hpp>
@ -34,7 +35,8 @@
namespace vclcanvas
{
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
@ -78,6 +80,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();
void draw( OutputDevice& rOutDev,
const Point& rOutpos,
const css::rendering::ViewState& viewState,