framework/inc/uielement/addonstoolbarwrapper.hxx | 8 +++++++- framework/source/layoutmanager/toolbarlayoutmanager.cxx | 3 ++- framework/source/uielement/addonstoolbarwrapper.cxx | 12 +++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-)
New commits: commit 840154daf934d8df52ead1cb7acd798c4d30f007 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Dec 13 11:08:06 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Dec 14 11:59:44 2022 +0000 loplugin:unocast (framework::AddonsToolBarWrapper) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I8014f683b939da9d638545c77dbddb3e478a385e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144143 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/framework/inc/uielement/addonstoolbarwrapper.hxx b/framework/inc/uielement/addonstoolbarwrapper.hxx index 68cfc0ff31d0..1d189662feee 100644 --- a/framework/inc/uielement/addonstoolbarwrapper.hxx +++ b/framework/inc/uielement/addonstoolbarwrapper.hxx @@ -22,12 +22,15 @@ #include <helper/uielementwrapperbase.hxx> #include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/implbase.hxx> namespace framework { -class AddonsToolBarWrapper final : public UIElementWrapperBase +class AddonsToolBarWrapper final : + public cppu::ImplInheritanceHelper<UIElementWrapperBase, css::lang::XUnoTunnel> { public: AddonsToolBarWrapper( const css::uno::Reference< css::uno::XComponentContext >& xContext ); @@ -45,6 +48,9 @@ class AddonsToolBarWrapper final : public UIElementWrapperBase // cf. ToolbarLayoutManager void populateImages(); + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override; + static css::uno::Sequence<sal_Int8> const & getUnoTunnelId(); + private: css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::lang::XComponent > m_xToolBarManager; diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index cf444b5ab31d..9ec6bdbfe52b 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/ui/XUIFunctionListener.hpp> #include <comphelper/propertyvalue.hxx> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/queryinterface.hxx> #include <o3tl/string_view.hxx> #include <unotools/cmdoptions.hxx> @@ -668,7 +669,7 @@ bool ToolbarLayoutManager::showToolbar( std::u16string_view rResourceURL ) // Addons appear to need to be populated at start, but we don't // want to populate them with (scaled) images until later. AddonsToolBarWrapper *pAddOns; - pAddOns = dynamic_cast<AddonsToolBarWrapper *>( aUIElement.m_xUIElement.get()); + pAddOns = comphelper::getFromUnoTunnel<AddonsToolBarWrapper>( aUIElement.m_xUIElement); if (pAddOns) pAddOns->populateImages(); diff --git a/framework/source/uielement/addonstoolbarwrapper.cxx b/framework/source/uielement/addonstoolbarwrapper.cxx index 6547d1c6bcde..6a8984ab654c 100644 --- a/framework/source/uielement/addonstoolbarwrapper.cxx +++ b/framework/source/uielement/addonstoolbarwrapper.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/ui/UIElementType.hpp> +#include <comphelper/servicehelper.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/svapp.hxx> @@ -40,7 +41,7 @@ namespace framework { AddonsToolBarWrapper::AddonsToolBarWrapper( const Reference< XComponentContext >& xContext ) : - UIElementWrapperBase( UIElementType::TOOLBAR ), + ImplInheritanceHelper( UIElementType::TOOLBAR ), m_xContext( xContext ), m_bCreatedImages( false ) { @@ -166,6 +167,15 @@ void AddonsToolBarWrapper::populateImages() } } +sal_Int64 AddonsToolBarWrapper::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence<sal_Int8> const & AddonsToolBarWrapper::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + } // namespace framework /* vim:set shiftwidth=4 softtabstop=4 expandtab: */