diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-02 10:36:43 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2013-05-22 10:44:29 +0000 |
commit | 6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37 (patch) | |
tree | 2746468845d6f1159e3759ee2cf7a620fca15b6e /extensions | |
parent | Fix exception specifications (diff) | |
download | core-6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37.tar.gz core-6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37.zip |
Use the new type-checking Reference constructor to reduce code noise
Also create a Clang compiler plugin to detect such cases.
Change-Id: I61ad1a1d6b1c017eeb51f226d2dde0e9bb7f1752
Reviewed-on: https://gerrit.libreoffice.org/4001
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/abpilot/datasourcehandling.cxx | 10 | ||||
-rw-r--r-- | extensions/source/bibliography/datman.cxx | 4 | ||||
-rw-r--r-- | extensions/source/propctrlr/formcomponenthandler.cxx | 5 | ||||
-rw-r--r-- | extensions/source/propctrlr/formgeometryhandler.cxx | 3 | ||||
-rw-r--r-- | extensions/source/propctrlr/formlinkdialog.cxx | 16 |
5 files changed, 15 insertions, 23 deletions
diff --git a/extensions/source/abpilot/datasourcehandling.cxx b/extensions/source/abpilot/datasourcehandling.cxx index 9c94c01858a3..bc0f78eb63a0 100644 --- a/extensions/source/abpilot/datasourcehandling.cxx +++ b/extensions/source/abpilot/datasourcehandling.cxx @@ -89,17 +89,15 @@ namespace abp //............................................................. // create a new data source - Reference< XSingleServiceFactory > xFactory( xContext, UNO_QUERY ); Reference< XPropertySet > xNewDataSource; - if (xFactory.is()) - xNewDataSource = Reference< XPropertySet >( xFactory->createInstance(), UNO_QUERY ); + if (xContext.is()) + xNewDataSource = Reference< XPropertySet >( xContext->createInstance(), UNO_QUERY ); DBG_ASSERT( xNewDataSource.is(), "lcl_implCreateAndInsert: could not create a new data source!" ); //............................................................. // insert the data source into the context - Reference< XNamingService > xDynamicContext( xContext, UNO_QUERY ); - DBG_ASSERT( xDynamicContext.is(), "lcl_implCreateAndInsert: missing an interface on the context (XNamingService)!" ); - if (xDynamicContext.is()) + DBG_ASSERT( xContext.is(), "lcl_implCreateAndInsert: missing an interface on the context (XNamingService)!" ); + if (xContext.is()) { // xDynamicContext->registerObject( _rName, xNewDataSource ); _rxNewDataSource = xNewDataSource; diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index f4cfa2b7bb6c..3509dc0ca873 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -90,10 +90,10 @@ Reference< XConnection > getConnection(const OUString& _rURL) Reference< XDatabaseContext > xNamingContext = DatabaseContext::create(xContext); if (xNamingContext->hasByName(_rURL)) { - DBG_ASSERT(Reference< XNamingService > (xNamingContext, UNO_QUERY).is(), "::getDataSource : no NamingService interface on the sdb::DatabaseAccessContext !"); + DBG_ASSERT(xNamingContext.is(), "::getDataSource : no NamingService interface on the sdb::DatabaseAccessContext !"); try { - xDataSource = Reference< XDataSource > (Reference< XNamingService > (xNamingContext, UNO_QUERY)->getRegisteredObject(_rURL), UNO_QUERY); + xDataSource = Reference< XDataSource > (xNamingContext->getRegisteredObject(_rURL), UNO_QUERY); } catch (const Exception&) { diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index 0937f1440454..cf199753581c 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -2053,10 +2053,7 @@ namespace pcr Reference< XForm > xAsForm( m_xComponent, UNO_QUERY ); if ( xAsForm.is() ) { - Reference< XChild > xFormAsChild( xAsForm, UNO_QUERY ); - Reference< XForm > xFormsParent; - if ( xFormAsChild.is() ) - xFormsParent = xFormsParent.query( xFormAsChild->getParent() ); + Reference< XForm > xFormsParent = xFormsParent.query( xAsForm->getParent() ); m_bComponentIsSubForm = xFormsParent.is(); } diff --git a/extensions/source/propctrlr/formgeometryhandler.cxx b/extensions/source/propctrlr/formgeometryhandler.cxx index 6738b66ae02c..ae513295893f 100644 --- a/extensions/source/propctrlr/formgeometryhandler.cxx +++ b/extensions/source/propctrlr/formgeometryhandler.cxx @@ -686,8 +686,7 @@ namespace pcr Reference< XTableRows > xRows( xColsRows->getRows(), UNO_SET_THROW ); sal_Int32 nNewAnchorRow = lcl_getLowerBoundRowOrColumn( xRows.get(), true, aRelativePosition ); - Reference< XCellRange > xSheetCellRange( xSheet, UNO_QUERY_THROW ); - Any aNewAnchorCell( xSheetCellRange->getCellByPosition( nNewAnchorCol, nNewAnchorRow ) ); + Any aNewAnchorCell( xSheet->getCellByPosition( nNewAnchorCol, nNewAnchorRow ) ); m_xShapeProperties->setPropertyValue( PROPERTY_ANCHOR, aNewAnchorCell ); } break; diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx index 2fdf007266d1..079e6f0b8a15 100644 --- a/extensions/source/propctrlr/formlinkdialog.cxx +++ b/extensions/source/propctrlr/formlinkdialog.cxx @@ -363,8 +363,7 @@ namespace pcr String FormLinkDialog::getFormDataSourceType( const Reference< XPropertySet >& _rxForm ) const SAL_THROW(()) { String sReturn; - Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY ); - if ( !xFormProps.is() ) + if ( !_rxForm.is() ) return sReturn; try @@ -372,8 +371,8 @@ namespace pcr sal_Int32 nCommandType = CommandType::COMMAND; OUString sCommand; - xFormProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType; - xFormProps->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand; + _rxForm->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType; + _rxForm->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand; if ( ( nCommandType == CommandType::TABLE ) || ( nCommandType == CommandType::QUERY ) @@ -398,16 +397,15 @@ namespace pcr { WaitObject aWaitCursor( const_cast< FormLinkDialog* >( this ) ); - Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY ); - OSL_ENSURE( xFormProps.is(), "FormLinkDialog::getFormFields: invalid form!" ); + OSL_ENSURE( _rxForm.is(), "FormLinkDialog::getFormFields: invalid form!" ); sal_Int32 nCommandType = CommandType::COMMAND; - xFormProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType; - xFormProps->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand; + _rxForm->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType; + _rxForm->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand; Reference< XConnection > xConnection; - ensureFormConnection( xFormProps, xConnection ); + ensureFormConnection( _rxForm, xConnection ); _rNames = ::dbtools::getFieldNamesByCommandDescriptor( xConnection, |