diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-12-08 15:57:27 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-12-14 09:54:30 +0000 |
commit | b0e9c4c5f063cefa9557810e3349bdb9c7493091 (patch) | |
tree | d328a074e9a4c959b5d68d342b393a9523a73d98 /linguistic/source | |
parent | 8ee6cfc9655ce9de4617cea1a0d9cb9d7a4fbfac (diff) |
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 <sbergman@redhat.com>
Diffstat (limited to 'linguistic/source')
-rw-r--r-- | linguistic/source/gciterator.cxx | 11 | ||||
-rw-r--r-- | linguistic/source/gciterator.hxx | 7 | ||||
-rw-r--r-- | linguistic/source/lngsvcmgr.cxx | 3 |
3 files changed, 19 insertions, 2 deletions
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 <i18nlangtag/languagetag.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/servicehelper.hxx> #include <tools/debug.hxx> #include <comphelper/diagnose_ex.hxx> @@ -1167,6 +1168,16 @@ uno::Sequence< OUString > GrammarCheckingIterator::GetServiceList( } +sal_Int64 GrammarCheckingIterator::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence<sal_Int8> 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<css::uno::Any> 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 <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/linguistic2/XProofreadingIterator.hpp> #include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp> #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> @@ -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<sal_Int8> const & aIdentifier) override; + static css::uno::Sequence<sal_Int8> 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 <comphelper/interfacecontainer2.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/servicehelper.hxx> #include <i18nlangtag/lang.h> #include <i18nlangtag/languagetag.hxx> #include <cppuhelper/factory.hxx> @@ -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 ); |