diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-18 14:08:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-19 11:01:18 +0200 |
commit | 9df2821e61979dab32390d5c64dd49bee868adbb (patch) | |
tree | 5b827e29e73ac2300c164b0a389a784a358956e6 /chart2/source/controller/accessibility | |
parent | 8b0a69498b025e13d9772689e9e4fa3d6b05e609 (diff) |
loplugin:flatten in chart2
Change-Id: Iadc4da6515a7d82e7a92b33d74d589b61fa2c64f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92480
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/controller/accessibility')
4 files changed, 117 insertions, 115 deletions
diff --git a/chart2/source/controller/accessibility/AccessibleBase.cxx b/chart2/source/controller/accessibility/AccessibleBase.cxx index 91040ee70671..6f9192eba064 100644 --- a/chart2/source/controller/accessibility/AccessibleBase.cxx +++ b/chart2/source/controller/accessibility/AccessibleBase.cxx @@ -253,24 +253,24 @@ bool AccessibleBase::ImplUpdateChildren() void AccessibleBase::AddChild( AccessibleBase * pChild ) { OSL_ENSURE( pChild != nullptr, "Invalid Child" ); - if( pChild ) - { - ClearableMutexGuard aGuard( m_aMutex ); + if( !pChild ) + return; - Reference< XAccessible > xChild( pChild ); - m_aChildList.push_back( xChild ); + ClearableMutexGuard aGuard( m_aMutex ); - m_aChildOIDMap[ pChild->GetId() ] = xChild; + Reference< XAccessible > xChild( pChild ); + m_aChildList.push_back( xChild ); - // inform listeners of new child - if( m_bChildrenInitialized ) - { - Any aEmpty, aNew; - aNew <<= xChild; + m_aChildOIDMap[ pChild->GetId() ] = xChild; - aGuard.clear(); - BroadcastAccEvent( AccessibleEventId::CHILD, aNew, aEmpty ); - } + // inform listeners of new child + if( m_bChildrenInitialized ) + { + Any aEmpty, aNew; + aNew <<= xChild; + + aGuard.clear(); + BroadcastAccEvent( AccessibleEventId::CHILD, aNew, aEmpty ); } } @@ -282,41 +282,41 @@ void AccessibleBase::RemoveChildByOId( const ObjectIdentifier& rOId ) ClearableMutexGuard aGuard( m_aMutex ); ChildOIDMap::iterator aIt( m_aChildOIDMap.find( rOId )); - if( aIt != m_aChildOIDMap.end()) - { - Reference< XAccessible > xChild( aIt->second ); + if( aIt == m_aChildOIDMap.end()) + return; - // remove from map - m_aChildOIDMap.erase( aIt ); + Reference< XAccessible > xChild( aIt->second ); - // search child in vector - ChildListVectorType::iterator aVecIter = - std::find( m_aChildList.begin(), m_aChildList.end(), xChild ); + // remove from map + m_aChildOIDMap.erase( aIt ); - OSL_ENSURE( aVecIter != m_aChildList.end(), - "Inconsistent ChildMap" ); + // search child in vector + ChildListVectorType::iterator aVecIter = + std::find( m_aChildList.begin(), m_aChildList.end(), xChild ); - // remove child from vector - m_aChildList.erase( aVecIter ); - bool bInitialized = m_bChildrenInitialized; + OSL_ENSURE( aVecIter != m_aChildList.end(), + "Inconsistent ChildMap" ); - // call listeners unguarded - aGuard.clear(); + // remove child from vector + m_aChildList.erase( aVecIter ); + bool bInitialized = m_bChildrenInitialized; - // inform listeners of removed child - if( bInitialized ) - { - Any aEmpty, aOld; - aOld <<= xChild; + // call listeners unguarded + aGuard.clear(); - BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); - } + // inform listeners of removed child + if( bInitialized ) + { + Any aEmpty, aOld; + aOld <<= xChild; - // dispose the child - Reference< lang::XComponent > xComp( xChild, UNO_QUERY ); - if( xComp.is()) - xComp->dispose(); + BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); } + + // dispose the child + Reference< lang::XComponent > xComp( xChild, UNO_QUERY ); + if( xComp.is()) + xComp->dispose(); } awt::Point AccessibleBase::GetUpperLeftOnScreen() const diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.cxx b/chart2/source/controller/accessibility/AccessibleChartElement.cxx index 89a5c1cd14bd..cbee2ddbb01a 100644 --- a/chart2/source/controller/accessibility/AccessibleChartElement.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartElement.cxx @@ -95,20 +95,22 @@ void AccessibleChartElement::InitTextEdit() } } - if( m_xTextHelper.is()) - try - { - Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW ); - Sequence< uno::Any > aArgs( 3 ); - aArgs[0] <<= GetInfo().m_aOID.getObjectCID(); - aArgs[1] <<= Reference< XAccessible >( this ); - aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow ); - xInit->initialize( aArgs ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + if( !m_xTextHelper.is()) + return; + + try + { + Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW ); + Sequence< uno::Any > aArgs( 3 ); + aArgs[0] <<= GetInfo().m_aOID.getObjectCID(); + aArgs[1] <<= Reference< XAccessible >( this ); + aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow ); + xInit->initialize( aArgs ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } } // Interfaces diff --git a/chart2/source/controller/accessibility/AccessibleChartShape.cxx b/chart2/source/controller/accessibility/AccessibleChartShape.cxx index cba557c683d7..d9c2f7071338 100644 --- a/chart2/source/controller/accessibility/AccessibleChartShape.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartShape.cxx @@ -38,27 +38,27 @@ AccessibleChartShape::AccessibleChartShape( const AccessibleElementInfo& rAccInfo ) :impl::AccessibleChartShape_Base( rAccInfo, true/*bMayHaveChildren*/, false/*bAlwaysTransparent*/ ) { - if ( rAccInfo.m_aOID.isAdditionalShape() ) - { - Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() ); - Reference< XAccessible > xParent; - if ( rAccInfo.m_pParent ) - { - xParent.set( rAccInfo.m_pParent ); - } - ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent ); - - m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView ); - m_aShapeTreeInfo.SetController( nullptr ); - m_aShapeTreeInfo.SetDevice( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) ); - m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder ); - - ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance(); - m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo ); - if ( m_pAccShape.is() ) - { - m_pAccShape->Init(); - } + if ( !rAccInfo.m_aOID.isAdditionalShape() ) + return; + + Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() ); + Reference< XAccessible > xParent; + if ( rAccInfo.m_pParent ) + { + xParent.set( rAccInfo.m_pParent ); + } + ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent ); + + m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView ); + m_aShapeTreeInfo.SetController( nullptr ); + m_aShapeTreeInfo.SetDevice( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) ); + m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder ); + + ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance(); + m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo ); + if ( m_pAccShape.is() ) + { + m_pAccShape->Init(); } } diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx b/chart2/source/controller/accessibility/AccessibleChartView.cxx index 9ce465b70613..0738f52abc36 100644 --- a/chart2/source/controller/accessibility/AccessibleChartView.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx @@ -289,37 +289,37 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments if( bOldInvalid && bNewInvalid ) bChanged = false; - if( bChanged ) + if( !bChanged ) + return; + { - { - //before notification we prepare for creation of new context - //the old context will be deleted after notification than - MutexGuard aGuard( m_aMutex); - Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); - if( xChartDoc.is()) - m_spObjectHierarchy = - std::make_shared<ObjectHierarchy>( xChartDoc, comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(m_xChartView) ); - else - m_spObjectHierarchy.reset(); - } + //before notification we prepare for creation of new context + //the old context will be deleted after notification than + MutexGuard aGuard( m_aMutex); + Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); + if( xChartDoc.is()) + m_spObjectHierarchy = + std::make_shared<ObjectHierarchy>( xChartDoc, comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(m_xChartView) ); + else + m_spObjectHierarchy.reset(); + } - { - AccessibleElementInfo aAccInfo; - aAccInfo.m_aOID = ObjectIdentifier("ROOT"); - aAccInfo.m_xChartDocument = uno::WeakReference< chart2::XChartDocument >( - uno::Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY )); - aAccInfo.m_xSelectionSupplier = m_xSelectionSupplier; - aAccInfo.m_xView = m_xChartView; - aAccInfo.m_xWindow = m_xWindow; - aAccInfo.m_pParent = nullptr; - aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy; - aAccInfo.m_pSdrView = m_pSdrView; - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( m_xWindow ); - m_pViewForwarder.reset( new AccessibleViewForwarder( this, pWindow ) ); - aAccInfo.m_pViewForwarder = m_pViewForwarder.get(); - // broadcasts an INVALIDATE_ALL_CHILDREN event globally - SetInfo( aAccInfo ); - } + { + AccessibleElementInfo aAccInfo; + aAccInfo.m_aOID = ObjectIdentifier("ROOT"); + aAccInfo.m_xChartDocument = uno::WeakReference< chart2::XChartDocument >( + uno::Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY )); + aAccInfo.m_xSelectionSupplier = m_xSelectionSupplier; + aAccInfo.m_xView = m_xChartView; + aAccInfo.m_xWindow = m_xWindow; + aAccInfo.m_pParent = nullptr; + aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy; + aAccInfo.m_pSdrView = m_pSdrView; + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( m_xWindow ); + m_pViewForwarder.reset( new AccessibleViewForwarder( this, pWindow ) ); + aAccInfo.m_pViewForwarder = m_pViewForwarder.get(); + // broadcasts an INVALIDATE_ALL_CHILDREN event globally + SetInfo( aAccInfo ); } } @@ -333,19 +333,19 @@ void SAL_CALL AccessibleChartView::selectionChanged( const lang::EventObject& /* xSelectionSupplier.set(m_xSelectionSupplier); } - if( xSelectionSupplier.is() ) + if( !xSelectionSupplier.is() ) + return; + + ObjectIdentifier aSelectedOID( xSelectionSupplier->getSelection() ); + if ( m_aCurrentSelectionOID.isValid() ) { - ObjectIdentifier aSelectedOID( xSelectionSupplier->getSelection() ); - if ( m_aCurrentSelectionOID.isValid() ) - { - NotifyEvent( EventType::LOST_SELECTION, m_aCurrentSelectionOID ); - } - if( aSelectedOID.isValid() ) - { - NotifyEvent( EventType::GOT_SELECTION, aSelectedOID ); - } - m_aCurrentSelectionOID = aSelectedOID; + NotifyEvent( EventType::LOST_SELECTION, m_aCurrentSelectionOID ); + } + if( aSelectedOID.isValid() ) + { + NotifyEvent( EventType::GOT_SELECTION, aSelectedOID ); } + m_aCurrentSelectionOID = aSelectedOID; } // XEventListener |