diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-07 13:03:58 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-06-08 01:29:32 +0200 |
commit | 5708534b942c1d0ce384f6a8473da6bb569410e7 (patch) | |
tree | 2ec4fe87624541c15bf89c8b839e8f8dba8a89f4 /sdext | |
parent | 1e55a47e89a9d9d6cf9cb3993484022aaf2c097b (diff) |
look for unnecessary calls to Reference::is() after an UNO_QUERY_THROW
Since the previous call would throw if there was nothing to be assigned
to the value.
Idea from tml.
Used the following script to find places:
git grep -A3 -n UNO_QUERY_THROW | grep -B3 -F 'is()'
Change-Id: I36ba7b00bcd014bdf16c0455ab91056f82194969
Reviewed-on: https://gerrit.libreoffice.org/55417
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/source/minimizer/graphiccollector.cxx | 63 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterButton.cxx | 5 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterScrollBar.cxx | 5 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterSlideShowView.cxx | 8 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterSlideSorter.cxx | 3 |
5 files changed, 35 insertions, 49 deletions
diff --git a/sdext/source/minimizer/graphiccollector.cxx b/sdext/source/minimizer/graphiccollector.cxx index 34e7964049d6..2e8c129082f9 100644 --- a/sdext/source/minimizer/graphiccollector.cxx +++ b/sdext/source/minimizer/graphiccollector.cxx @@ -135,54 +135,51 @@ void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxMSF, const if ( rxPropertySet->getPropertyValue( "FillBitmap" ) >>= xFillBitmap ) { Reference< XGraphic > xGraphic( xFillBitmap, UNO_QUERY_THROW ); - if ( xGraphic.is() ) + awt::Size aLogicalSize( rLogicalSize ); + Reference< XPropertySetInfo > axPropSetInfo( rxPropertySet->getPropertySetInfo() ); + if ( axPropSetInfo.is() ) { - awt::Size aLogicalSize( rLogicalSize ); - Reference< XPropertySetInfo > axPropSetInfo( rxPropertySet->getPropertySetInfo() ); - if ( axPropSetInfo.is() ) + if ( axPropSetInfo->hasPropertyByName( "FillBitmapMode" ) ) { - if ( axPropSetInfo->hasPropertyByName( "FillBitmapMode" ) ) + BitmapMode eBitmapMode; + if ( rxPropertySet->getPropertyValue( "FillBitmapMode" ) >>= eBitmapMode ) { - BitmapMode eBitmapMode; - if ( rxPropertySet->getPropertyValue( "FillBitmapMode" ) >>= eBitmapMode ) + if ( ( eBitmapMode == BitmapMode_REPEAT ) || ( eBitmapMode == BitmapMode_NO_REPEAT ) ) { - if ( ( eBitmapMode == BitmapMode_REPEAT ) || ( eBitmapMode == BitmapMode_NO_REPEAT ) ) + bool bLogicalSize = false; + awt::Size aSize( 0, 0 ); + if ( ( rxPropertySet->getPropertyValue( "FillBitmapLogicalSize" ) >>= bLogicalSize ) + && ( rxPropertySet->getPropertyValue( "FillBitmapSizeX" ) >>= aSize.Width ) + && ( rxPropertySet->getPropertyValue( "FillBitmapSizeY" ) >>= aSize.Height ) ) { - bool bLogicalSize = false; - awt::Size aSize( 0, 0 ); - if ( ( rxPropertySet->getPropertyValue( "FillBitmapLogicalSize" ) >>= bLogicalSize ) - && ( rxPropertySet->getPropertyValue( "FillBitmapSizeX" ) >>= aSize.Width ) - && ( rxPropertySet->getPropertyValue( "FillBitmapSizeY" ) >>= aSize.Height ) ) + if ( bLogicalSize ) { - if ( bLogicalSize ) + if ( !aSize.Width || !aSize.Height ) { - if ( !aSize.Width || !aSize.Height ) - { - awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) ); - if ( aSize100thMM.Width && aSize100thMM.Height ) - aLogicalSize = aSize100thMM; - } - else - aLogicalSize = aSize; + awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) ); + if ( aSize100thMM.Width && aSize100thMM.Height ) + aLogicalSize = aSize100thMM; } else - { - aLogicalSize.Width = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Width ) * aSize.Width ) / -100.0 ); - aLogicalSize.Height = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Height ) * aSize.Height ) / -100.0 ); - } + aLogicalSize = aSize; + } + else + { + aLogicalSize.Width = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Width ) * aSize.Width ) / -100.0 ); + aLogicalSize.Height = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Height ) * aSize.Height ) / -100.0 ); } } } } } - GraphicCollector::GraphicUser aUser; - aUser.mxPropertySet = rxPropertySet; - aUser.mxGraphic = xGraphic; - aUser.mbFillBitmap = true; - aUser.maLogicalSize = aLogicalSize; - aUser.mxPagePropertySet = rxPagePropertySet; - ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser ); } + GraphicCollector::GraphicUser aUser; + aUser.mxPropertySet = rxPropertySet; + aUser.mxGraphic = xGraphic; + aUser.mbFillBitmap = true; + aUser.maLogicalSize = aLogicalSize; + aUser.mxPagePropertySet = rxPagePropertySet; + ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser ); } } } diff --git a/sdext/source/presenter/PresenterButton.cxx b/sdext/source/presenter/PresenterButton.cxx index 70f9c493981c..7b7232b04e1a 100644 --- a/sdext/source/presenter/PresenterButton.cxx +++ b/sdext/source/presenter/PresenterButton.cxx @@ -127,10 +127,7 @@ PresenterButton::PresenterButton ( // Make the background transparent. Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY_THROW); - if (xPeer.is()) - { - xPeer->setBackground(0xff000000); - } + xPeer->setBackground(0xff000000); mxWindow->setVisible(true); mxWindow->addWindowListener(this); diff --git a/sdext/source/presenter/PresenterScrollBar.cxx b/sdext/source/presenter/PresenterScrollBar.cxx index 5cc42ef5e64f..da089fb335ce 100644 --- a/sdext/source/presenter/PresenterScrollBar.cxx +++ b/sdext/source/presenter/PresenterScrollBar.cxx @@ -122,10 +122,7 @@ PresenterScrollBar::PresenterScrollBar ( // Make the background transparent. The slide show paints its own background. Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY_THROW); - if (xPeer.is()) - { - xPeer->setBackground(0xff000000); - } + xPeer->setBackground(0xff000000); mxWindow->setVisible(true); mxWindow->addWindowListener(this); diff --git a/sdext/source/presenter/PresenterSlideShowView.cxx b/sdext/source/presenter/PresenterSlideShowView.cxx index 88c60b1625a3..c4368fa3eb9b 100644 --- a/sdext/source/presenter/PresenterSlideShowView.cxx +++ b/sdext/source/presenter/PresenterSlideShowView.cxx @@ -94,8 +94,7 @@ void PresenterSlideShowView::LateInit() { mxSlideShow.set( mxSlideShowController->getSlideShow(), UNO_QUERY_THROW); Reference<lang::XComponent> xSlideShowComponent (mxSlideShow, UNO_QUERY); - if (xSlideShowComponent.is()) - xSlideShowComponent->addEventListener(static_cast<awt::XWindowListener*>(this)); + xSlideShowComponent->addEventListener(static_cast<awt::XWindowListener*>(this)); Reference<lang::XMultiComponentFactory> xFactory ( mxComponentContext->getServiceManager(), UNO_QUERY_THROW); @@ -819,10 +818,7 @@ Reference<awt::XWindow> PresenterSlideShowView::CreateViewWindow ( // Make the background transparent. The slide show paints its own background. Reference<awt::XWindowPeer> xPeer (xViewWindow, UNO_QUERY_THROW); - if (xPeer.is()) - { - xPeer->setBackground(0xff000000); - } + xPeer->setBackground(0xff000000); xViewWindow->setVisible(true); } diff --git a/sdext/source/presenter/PresenterSlideSorter.cxx b/sdext/source/presenter/PresenterSlideSorter.cxx index cc1f98358a3b..210b74087407 100644 --- a/sdext/source/presenter/PresenterSlideSorter.cxx +++ b/sdext/source/presenter/PresenterSlideSorter.cxx @@ -701,8 +701,7 @@ geometry::RealRectangle2D PresenterSlideSorter::PlaceScrollBars ( mpLayout->Update(rUpperBox, GetSlideAspectRatio()); bool bIsScrollBarNeeded (false); Reference<container::XIndexAccess> xSlides (mxSlideShowController, UNO_QUERY_THROW); - if (xSlides.is()) - bIsScrollBarNeeded = mpLayout->IsScrollBarNeeded(xSlides->getCount()); + bIsScrollBarNeeded = mpLayout->IsScrollBarNeeded(xSlides->getCount()); if (mpVerticalScrollBar.get() != nullptr) { if (bIsScrollBarNeeded) |