From b0e9c4c5f063cefa9557810e3349bdb9c7493091 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 8 Dec 2022 15:57:27 +0100 Subject: loplugin:unocast (GrammarCheckingIterator) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I4ecaa3cfafbb2e01ede956e4f3f6d58f40bdbb57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144146 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- linguistic/source/gciterator.cxx | 11 +++++++++++ linguistic/source/gciterator.hxx | 7 ++++++- linguistic/source/lngsvcmgr.cxx | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'linguistic/source') diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 581f356f215e..2300b7343268 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -1167,6 +1168,16 @@ uno::Sequence< OUString > GrammarCheckingIterator::GetServiceList( } +sal_Int64 GrammarCheckingIterator::getSomething(css::uno::Sequence const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence const & GrammarCheckingIterator::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + + extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* linguistic_GrammarCheckingIterator_get_implementation( css::uno::XComponentContext* , css::uno::Sequence const&) diff --git a/linguistic/source/gciterator.hxx b/linguistic/source/gciterator.hxx index c4cc076b3c9b..55e2527e6e9b 100644 --- a/linguistic/source/gciterator.hxx +++ b/linguistic/source/gciterator.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -78,7 +79,8 @@ class GrammarCheckingIterator: css::linguistic2::XLinguServiceEventListener, css::linguistic2::XLinguServiceEventBroadcaster, css::lang::XComponent, - css::lang::XServiceInfo + css::lang::XServiceInfo, + css::lang::XUnoTunnel >, public LinguDispatcher { @@ -179,6 +181,9 @@ public: // LinguDispatcher virtual void SetServiceList( const css::lang::Locale &rLocale, const css::uno::Sequence< OUString > &rSvcImplNames ) override; virtual css::uno::Sequence< OUString > GetServiceList( const css::lang::Locale &rLocale ) const override; + + sal_Int64 SAL_CALL getSomething(css::uno::Sequence const & aIdentifier) override; + static css::uno::Sequence const & getUnoTunnelId(); }; diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index f38ee262099c..7ef56cb10fb8 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -890,7 +891,7 @@ void LngSvcMgr::GetGrammarCheckerDsp_Impl( bool bSetSvcList ) if (xGCI.is()) { - mxGrammarDsp = dynamic_cast< GrammarCheckingIterator * >(xGCI.get()); + mxGrammarDsp = comphelper::getFromUnoTunnel< GrammarCheckingIterator >(xGCI); SAL_WARN_IF( mxGrammarDsp == nullptr, "linguistic", "failed to get implementation" ); if (bSetSvcList && mxGrammarDsp.is()) SetCfgServiceLists( *mxGrammarDsp ); -- cgit