From 467724410dc470ec259131f97abd836fe9b021a1 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 26 Sep 2017 12:01:53 +0200 Subject: loplugin:flatten in toolkit..vbahelper Change-Id: I6d4be3e1cc29b2b91d5c39b757ff3b903c47112d Reviewed-on: https://gerrit.libreoffice.org/42794 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../source/controls/controlmodelcontainerbase.cxx | 67 +++++++++++----------- 1 file changed, 33 insertions(+), 34 deletions(-) (limited to 'toolkit/source/controls/controlmodelcontainerbase.cxx') diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx index 551dda47a63c..291894605b49 100644 --- a/toolkit/source/controls/controlmodelcontainerbase.cxx +++ b/toolkit/source/controls/controlmodelcontainerbase.cxx @@ -1827,48 +1827,47 @@ ControlModelContainerBase::updateUserFormChildren( const Reference< XNameContain if ( Operation < Insert || Operation > Remove ) throw IllegalArgumentException(); - if ( xAllChildren.is() ) + if ( !xAllChildren.is() ) + throw IllegalArgumentException(); + + if ( Operation == Remove ) { - if ( Operation == Remove ) - { - Reference< XControlModel > xOldModel( xAllChildren->getByName( aName ), UNO_QUERY ); - xAllChildren->removeByName( aName ); + Reference< XControlModel > xOldModel( xAllChildren->getByName( aName ), UNO_QUERY ); + xAllChildren->removeByName( aName ); - Reference< XNameContainer > xChildContainer( xOldModel, UNO_QUERY ); - if ( xChildContainer.is() ) - { - Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY ); - // container control is being removed from this container, reset the - // global list of containees - if ( xProps.is() ) - xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( uno::Reference< XNameContainer >() ) ); - Sequence< OUString > aChildNames = xChildContainer->getElementNames(); - for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index ) - updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, Reference< XControlModel > () ); - } + Reference< XNameContainer > xChildContainer( xOldModel, UNO_QUERY ); + if ( xChildContainer.is() ) + { + Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY ); + // container control is being removed from this container, reset the + // global list of containees + if ( xProps.is() ) + xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( uno::Reference< XNameContainer >() ) ); + Sequence< OUString > aChildNames = xChildContainer->getElementNames(); + for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index ) + updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, Reference< XControlModel > () ); } - else if ( Operation == Insert ) + } + else if ( Operation == Insert ) + { + xAllChildren->insertByName( aName, uno::makeAny( xTarget ) ); + Reference< XNameContainer > xChildContainer( xTarget, UNO_QUERY ); + if ( xChildContainer.is() ) { - xAllChildren->insertByName( aName, uno::makeAny( xTarget ) ); - Reference< XNameContainer > xChildContainer( xTarget, UNO_QUERY ); - if ( xChildContainer.is() ) + // container control is being added from this container, reset the + // global list of containees to point to the correct global list + Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY ); + if ( xProps.is() ) + xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( xAllChildren ) ); + Sequence< OUString > aChildNames = xChildContainer->getElementNames(); + for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index ) { - // container control is being added from this container, reset the - // global list of containees to point to the correct global list - Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY ); - if ( xProps.is() ) - xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( xAllChildren ) ); - Sequence< OUString > aChildNames = xChildContainer->getElementNames(); - for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index ) - { - Reference< XControlModel > xChildTarget( xChildContainer->getByName( aChildNames[ index ] ), UNO_QUERY ); - updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, xChildTarget ); - } + Reference< XControlModel > xChildTarget( xChildContainer->getByName( aChildNames[ index ] ), UNO_QUERY ); + updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, xChildTarget ); } } } - else - throw IllegalArgumentException(); + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit