Kaydet (Commit) 82dca420 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:inlinefields in dbaccess::SubComponentLoader

Change-Id: Idc4ac037d023a7019e62ec3b7d12bc7717c11be8
Reviewed-on: https://gerrit.libreoffice.org/36345Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 51289601
...@@ -42,123 +42,82 @@ namespace dbaccess ...@@ -42,123 +42,82 @@ namespace dbaccess
using ::com::sun::star::frame::XController2; using ::com::sun::star::frame::XController2;
using ::com::sun::star::lang::XComponent; using ::com::sun::star::lang::XComponent;
// SubComponentLoader
struct SubComponentLoader_Data
{
const Reference< XCommandProcessor > xDocDefCommands;
const Reference< XComponent > xNonDocComponent;
Reference< XWindow > xAppComponentWindow;
explicit SubComponentLoader_Data( const Reference< XCommandProcessor >& i_rDocumentDefinition )
:xDocDefCommands( i_rDocumentDefinition )
,xNonDocComponent()
{
}
explicit SubComponentLoader_Data( const Reference< XComponent >& i_rNonDocumentComponent )
:xDocDefCommands()
,xNonDocComponent( i_rNonDocumentComponent )
{
}
};
// helper
namespace
{
void lcl_onWindowShown_nothrow( const SubComponentLoader_Data& i_rData )
{
try
{
if ( i_rData.xDocDefCommands.is() )
{
Command aCommandOpen;
aCommandOpen.Name = "show";
const sal_Int32 nCommandIdentifier = i_rData.xDocDefCommands->createCommandIdentifier();
i_rData.xDocDefCommands->execute( aCommandOpen, nCommandIdentifier, nullptr );
}
else
{
const Reference< XController > xController( i_rData.xNonDocComponent, UNO_QUERY_THROW );
const Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
const Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
xWindow->setVisible( true );
}
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
}
// SubComponentLoader // SubComponentLoader
SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController, SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
const Reference< XCommandProcessor >& i_rSubDocumentDefinition ) const Reference< XCommandProcessor >& i_rSubDocumentDefinition )
:m_pData( new SubComponentLoader_Data( i_rSubDocumentDefinition ) ) :mxDocDefCommands( i_rSubDocumentDefinition )
{ {
// add as window listener to the controller's container window, so we get notified when it is shown // add as window listener to the controller's container window, so we get notified when it is shown
Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW ); Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
m_pData->xAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW ); mxAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
osl_atomic_increment( &m_refCount ); osl_atomic_increment( &m_refCount );
{ {
m_pData->xAppComponentWindow->addWindowListener( this ); mxAppComponentWindow->addWindowListener( this );
} }
osl_atomic_decrement( &m_refCount ); osl_atomic_decrement( &m_refCount );
} }
SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController, SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
const Reference< XComponent >& i_rNonDocumentComponent ) const Reference< XComponent >& i_rNonDocumentComponent )
:m_pData( new SubComponentLoader_Data( i_rNonDocumentComponent ) ) :mxNonDocComponent( i_rNonDocumentComponent )
{ {
// add as window listener to the controller's container window, so we get notified when it is shown // add as window listener to the controller's container window, so we get notified when it is shown
Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW ); Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
m_pData->xAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW ); mxAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
osl_atomic_increment( &m_refCount ); osl_atomic_increment( &m_refCount );
{ {
m_pData->xAppComponentWindow->addWindowListener( this ); mxAppComponentWindow->addWindowListener( this );
} }
osl_atomic_decrement( &m_refCount ); osl_atomic_decrement( &m_refCount );
} }
SubComponentLoader::~SubComponentLoader() SubComponentLoader::~SubComponentLoader()
{ {
delete m_pData;
m_pData = nullptr;
} }
void SAL_CALL SubComponentLoader::windowResized( const WindowEvent& i_rEvent ) void SAL_CALL SubComponentLoader::windowResized( const WindowEvent& )
{ {
// not interested in
(void)i_rEvent;
} }
void SAL_CALL SubComponentLoader::windowMoved( const WindowEvent& i_rEvent ) void SAL_CALL SubComponentLoader::windowMoved( const WindowEvent& )
{ {
// not interested in
(void)i_rEvent;
} }
void SAL_CALL SubComponentLoader::windowShown( const EventObject& i_rEvent ) void SAL_CALL SubComponentLoader::windowShown( const EventObject& )
{ {
(void)i_rEvent; try
{
if ( mxDocDefCommands.is() )
{
Command aCommandOpen;
aCommandOpen.Name = "show";
lcl_onWindowShown_nothrow( *m_pData ); const sal_Int32 nCommandIdentifier = mxDocDefCommands->createCommandIdentifier();
m_pData->xAppComponentWindow->removeWindowListener( this ); mxDocDefCommands->execute( aCommandOpen, nCommandIdentifier, nullptr );
}
else
{
const Reference< XController > xController( mxNonDocComponent, UNO_QUERY_THROW );
const Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
const Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
xWindow->setVisible( true );
}
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
mxAppComponentWindow->removeWindowListener( this );
} }
void SAL_CALL SubComponentLoader::windowHidden( const EventObject& i_rEvent ) void SAL_CALL SubComponentLoader::windowHidden( const EventObject& )
{ {
// not interested in
(void)i_rEvent;
} }
void SAL_CALL SubComponentLoader::disposing( const EventObject& i_rEvent ) void SAL_CALL SubComponentLoader::disposing( const EventObject& )
{ {
// not interested in
(void)i_rEvent;
} }
} // namespace dbaccess } // namespace dbaccess
......
...@@ -35,7 +35,6 @@ namespace dbaccess ...@@ -35,7 +35,6 @@ namespace dbaccess
// SubComponentLoader // SubComponentLoader
typedef ::cppu::WeakImplHelper< css::awt::XWindowListener typedef ::cppu::WeakImplHelper< css::awt::XWindowListener
> SubComponentLoader_Base; > SubComponentLoader_Base;
struct SubComponentLoader_Data;
/** is a helper class which loads/opens a given sub component as soon as the main application /** is a helper class which loads/opens a given sub component as soon as the main application
window becomes visible. window becomes visible.
*/ */
...@@ -65,7 +64,9 @@ namespace dbaccess ...@@ -65,7 +64,9 @@ namespace dbaccess
virtual ~SubComponentLoader() override; virtual ~SubComponentLoader() override;
private: private:
SubComponentLoader_Data* m_pData; const css::uno::Reference< css::ucb::XCommandProcessor > mxDocDefCommands;
const css::uno::Reference< css::lang::XComponent > mxNonDocComponent;
css::uno::Reference< css::awt::XWindow > mxAppComponentWindow;
}; };
} // namespace dbaccess } // namespace dbaccess
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment