XUnoTunnel->dynamic_cast in RootItemContainer

Change-Id: I79a44f69dd7233a7e885698d29b929d9831025c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145630
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2023-01-16 08:48:06 +02:00
parent b8cda1fe1c
commit 5ed9bb8bdc
4 changed files with 7 additions and 25 deletions

View file

@ -25,7 +25,6 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <rtl/ustring.hxx>
#include <cppuhelper/basemutex.hxx>
@ -40,8 +39,7 @@ class ConstItemContainer;
typedef ::cppu::WeakImplHelper<
css::container::XIndexContainer,
css::lang::XSingleComponentFactory,
css::lang::XUnoTunnel > RootItemContainer_BASE;
css::lang::XSingleComponentFactory > RootItemContainer_BASE;
class RootItemContainer final : private cppu::BaseMutex,
public ::cppu::OBroadcastHelper ,
@ -65,10 +63,6 @@ class RootItemContainer final : private cppu::BaseMutex,
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
// XUnoTunnel
static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId() noexcept;
sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier ) override;
// XIndexContainer
virtual void SAL_CALL insertByIndex( sal_Int32 Index, const css::uno::Any& Element ) override;

View file

@ -138,18 +138,6 @@ Reference< XIndexAccess > RootItemContainer::deepCopyContainer( const Reference<
return xReturn;
}
// XUnoTunnel
sal_Int64 RootItemContainer::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier )
{
return comphelper::getSomethingImpl(rIdentifier, this);
}
const Sequence< sal_Int8 >& RootItemContainer::getUnoTunnelId() noexcept
{
static const comphelper::UnoIdInit theRootItemContainerUnoTunnelId;
return theRootItemContainerUnoTunnelId.getSeq();
}
// XElementAccess
sal_Bool SAL_CALL RootItemContainer::hasElements()
{

View file

@ -429,7 +429,7 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement
{
MenuConfiguration aMenuCfg( m_xContext );
Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream ));
auto pRootItemContainer = comphelper::getFromUnoTunnel<RootItemContainer>( xContainer );
auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xContainer.get() );
if ( pRootItemContainer )
aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
else
@ -448,7 +448,7 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement
{
Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
ToolBoxConfiguration::LoadToolBox( m_xContext, xInputStream, xIndexContainer );
auto pRootItemContainer = comphelper::getFromUnoTunnel<RootItemContainer>( xIndexContainer );
auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}
@ -465,7 +465,7 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement
{
Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
StatusBarConfiguration::LoadStatusBar( m_xContext, xInputStream, xIndexContainer );
auto pRootItemContainer = comphelper::getFromUnoTunnel<RootItemContainer>( xIndexContainer );
auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}

View file

@ -350,7 +350,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
{
MenuConfiguration aMenuCfg( m_xContext );
Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream ));
auto pRootItemContainer = comphelper::getFromUnoTunnel<RootItemContainer>( xContainer );
auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xContainer.get() );
if ( pRootItemContainer )
aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
else
@ -369,7 +369,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
{
Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
ToolBoxConfiguration::LoadToolBox( m_xContext, xInputStream, xIndexContainer );
auto pRootItemContainer = comphelper::getFromUnoTunnel<RootItemContainer>( xIndexContainer );
auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}
@ -386,7 +386,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
{
Reference< XIndexContainer > xIndexContainer( new RootItemContainer() );
StatusBarConfiguration::LoadStatusBar( m_xContext, xInputStream, xIndexContainer );
auto pRootItemContainer = comphelper::getFromUnoTunnel<RootItemContainer>( xIndexContainer );
auto pRootItemContainer = dynamic_cast<RootItemContainer*>( xIndexContainer.get() );
aUIElementData.xSettings = new ConstItemContainer( pRootItemContainer, true );
return;
}