canvas/source/vcl/canvashelper.cxx | 3 ++- canvas/source/vcl/textlayout.cxx | 10 ++++++++++ canvas/source/vcl/textlayout.hxx | 7 ++++++- framework/source/services/desktop.cxx | 10 ++++++++++ framework/source/services/sessionlistener.cxx | 3 ++- include/framework/desktop.hxx | 7 ++++++- 6 files changed, 36 insertions(+), 4 deletions(-)
New commits: commit 4cfcc9ac37b90ce64c8402a41eb4638adb185b5c Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Dec 13 10:51:31 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Dec 23 22:57:07 2022 +0000 loplugin:unocast (framework::Desktop) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: Ifcf713b0543e78a124f613bcbda496069a280dab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144762 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index 048b677c9daa..d58eaa9334c7 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -50,6 +50,7 @@ #include <comphelper/numberedcollection.hxx> #include <comphelper/sequence.hxx> #include <comphelper/lok.hxx> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <utility> #include <vcl/svapp.hxx> @@ -335,6 +336,15 @@ void Desktop::shutdown() xSfxTerminator->notifyTermination(aEvent); } +sal_Int64 Desktop::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence<sal_Int8> const & Desktop::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + namespace { class QuickstartSuppressor diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx index 188b082fe94c..01c8218b087d 100644 --- a/framework/source/services/sessionlistener.cxx +++ b/framework/source/services/sessionlistener.cxx @@ -23,6 +23,7 @@ #include <framework/desktop.hxx> #include <comphelper/diagnose_ex.hxx> +#include <comphelper/servicehelper.hxx> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/frame/theAutoRecovery.hpp> @@ -342,7 +343,7 @@ void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create( m_xContext ); // honestly: how many implementations of XDesktop will we ever have? // so casting this directly to the implementation - Desktop* pDesktop(dynamic_cast<Desktop*>(xDesktop.get())); + Desktop* pDesktop(comphelper::getFromUnoTunnel<Desktop>(xDesktop)); if(pDesktop) { SAL_INFO("fwk.session", " XDesktop is a framework::Desktop -- good."); diff --git a/include/framework/desktop.hxx b/include/framework/desktop.hxx index 3d525eb54938..deeb9c20233b 100644 --- a/include/framework/desktop.hxx +++ b/include/framework/desktop.hxx @@ -36,6 +36,7 @@ #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/frame/XFrames.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XTasksSupplier.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> @@ -94,7 +95,8 @@ typedef cppu::WeakComponentImplHelper< css::frame::XTasksSupplier , css::frame::XDispatchResultListener , // => XEventListener css::task::XInteractionHandler , - css::frame::XUntitledNumbers > Desktop_BASE; + css::frame::XUntitledNumbers, + css::lang::XUnoTunnel > Desktop_BASE; class FWK_DLLPUBLIC Desktop final : private cppu::BaseMutex, public Desktop_BASE, @@ -287,6 +289,9 @@ class FWK_DLLPUBLIC Desktop final : private cppu::BaseMutex, void shutdown(); + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override; + static css::uno::Sequence<sal_Int8> const & getUnoTunnelId(); + private: // OPropertySetHelper virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue , commit 03efbf72f4ddf7a84aa8aabef348331bd4b75e8a Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Dec 14 21:07:28 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Dec 23 22:56:54 2022 +0000 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 <sberg...@redhat.com> diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 60ab39d470a2..9ad9716dde1d 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -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 ) { diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx index 689720e4570a..6131cce0e380 100644 --- a/canvas/source/vcl/textlayout.cxx +++ b/canvas/source/vcl/textlayout.cxx @@ -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: */ diff --git a/canvas/source/vcl/textlayout.hxx b/canvas/source/vcl/textlayout.hxx index be8603d812f1..53f3f73033ac 100644 --- a/canvas/source/vcl/textlayout.hxx +++ b/canvas/source/vcl/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/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,