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 /svx | |
parent | 697a007c61b9cabceb9767fad87cd5822b300452 (diff) |
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 'svx')
-rw-r--r-- | svx/source/dialog/rubydialog.cxx | 5 | ||||
-rw-r--r-- | svx/source/form/filtnav.cxx | 9 | ||||
-rw-r--r-- | svx/source/form/fmobj.cxx | 4 | ||||
-rw-r--r-- | svx/source/form/fmpgeimp.cxx | 8 | ||||
-rw-r--r-- | svx/source/form/fmshimp.cxx | 6 | ||||
-rw-r--r-- | svx/source/form/fmtools.cxx | 7 | ||||
-rw-r--r-- | svx/source/form/fmundo.cxx | 6 | ||||
-rw-r--r-- | svx/source/form/fmvwimp.cxx | 8 | ||||
-rw-r--r-- | svx/source/form/formcontroller.cxx | 18 | ||||
-rw-r--r-- | svx/source/form/formcontrolling.cxx | 3 | ||||
-rw-r--r-- | svx/source/form/navigatortree.cxx | 4 | ||||
-rw-r--r-- | svx/source/form/navigatortreemodel.cxx | 2 |
12 files changed, 31 insertions, 49 deletions
diff --git a/svx/source/dialog/rubydialog.cxx b/svx/source/dialog/rubydialog.cxx index 2a19a5332561..23778c8dbc8c 100644 --- a/svx/source/dialog/rubydialog.cxx +++ b/svx/source/dialog/rubydialog.cxx @@ -337,10 +337,9 @@ void SvxRubyDialog::Activate() aName >>= sName; } } - Reference<XNamed> xNamed(xStyle, UNO_QUERY); - if(xNamed.is()) + if(xStyle.is()) { - sCoreName = xNamed->getName(); + sCoreName = xStyle->getName(); if(sName.isEmpty()) sName = sCoreName; } diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 8b665eb9a508..efa44e784330 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -393,8 +393,7 @@ namespace OUString sLabelName; try { - Reference< XControl > xControl( _rxControl, UNO_SET_THROW ); - Reference< XPropertySet > xModel( xControl->getModel(), UNO_QUERY_THROW ); + Reference< XPropertySet > xModel( _rxControl->getModel(), UNO_QUERY_THROW ); sLabelName = getLabelName( xModel ); } catch( const Exception& ) @@ -409,8 +408,7 @@ namespace Reference< XPropertySet > xField; try { - Reference< XControl > xControl( _rxControl, UNO_SET_THROW ); - Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW ); + Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY_THROW ); xField.set( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW ); } catch( const Exception& ) @@ -672,8 +670,7 @@ void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, FmPar } // now add dependent controllers - Reference< XIndexAccess > xControllerAsIndex( xController, UNO_QUERY ); - Update( xControllerAsIndex, pFormItem ); + Update( xController, pFormItem ); } } catch( const Exception& ) diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index 34949302dc9f..d7738dbc4128 100644 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -287,7 +287,7 @@ void FmFormObj::SetPage(SdrPage* _pNewPage) Reference< XIndexContainer > xOldParent(xMeAsFormComp->getParent(), UNO_QUERY); if (xOldParent.is()) { - sal_Int32 nPos = getElementPos(Reference< XIndexAccess > (xOldParent, UNO_QUERY), xMeAsFormComp); + sal_Int32 nPos = getElementPos(xOldParent, xMeAsFormComp); if (nPos > -1) xOldParent->removeByIndex(nPos); } @@ -586,7 +586,7 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > } while ( nTokIndex >= 0 ); - return Reference< XInterface > (xDestContainer, UNO_QUERY); + return xDestContainer; } //------------------------------------------------------------------ diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx index eebc4aba5749..de8b2b215bab 100644 --- a/svx/source/form/fmpgeimp.cxx +++ b/svx/source/form/fmpgeimp.cxx @@ -440,14 +440,13 @@ Reference< XForm > FmFormPageImpl::getDefaultForm() OUString sName = String( SVX_RES( RID_STR_STDFORMNAME ) ); xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) ); - Reference< XIndexContainer > xContainer( xForms, UNO_QUERY ); if( pModel->IsUndoEnabled() ) { pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel, FmUndoContainerAction::Inserted, - xContainer, + xForms, xForm, - xContainer->getCount())); + xForms->getCount())); } xForms->insertByName( sName, makeAny( xForm ) ); xCurrentForm = xForm; @@ -649,8 +648,7 @@ OUString FmFormPageImpl::setUniqueName(const Reference< XFormComponent > & xForm #if OSL_DEBUG_LEVEL > 0 try { - Reference< XChild > xChild( xFormComponent, UNO_QUERY_THROW ); - OSL_ENSURE( !xChild->getParent().is(), "FmFormPageImpl::setUniqueName: to be called before insertion!" ); + OSL_ENSURE( !xFormComponent->getParent().is(), "FmFormPageImpl::setUniqueName: to be called before insertion!" ); } catch( const Exception& ) { diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 78de8a7e69a4..1a38d5018beb 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -2542,7 +2542,7 @@ IMPL_LINK(FmXFormShell, OnSearchContextRequest, FmSearchContext*, pfmscContextIn m_arrRelativeGridColumn.push_back(-1); // and for the formatted search... - pfmscContextInfo->arrFields.push_back(Reference< XInterface>(xControl, UNO_QUERY)); + pfmscContextInfo->arrFields.push_back(xControl); } } } @@ -2731,7 +2731,7 @@ void FmXFormShell::selectionChanged(const EventObject& rEvent) throw(::com::sun: Reference< XForm > xNewForm( GetForm( rEvent.Source ) ); InterfaceBag aNewSelection; - aNewSelection.insert( Reference< XInterface >( xSelObj, UNO_QUERY ) ); + aNewSelection.insert( xSelObj ); if ( setCurrentSelection( aNewSelection ) && IsPropBrwOpen() ) ShowSelectionProperties( sal_True ); @@ -3571,7 +3571,7 @@ void FmXFormShell::CreateExternalView() Reference< XResultSet> xForm(xCurrentNavController->getModel(), UNO_QUERY); aArg.Value <<= xForm; - m_xExternalDisplayedForm = Reference< XResultSet>(xForm, UNO_QUERY); + m_xExternalDisplayedForm = xForm; // do this before dispatching the "attach" command, as the atach may result in a call to our queryDispatch (for the FormSlots) // whichs needs the m_xExternalDisplayedForm diff --git a/svx/source/form/fmtools.cxx b/svx/source/form/fmtools.cxx index ddeb875695ac..da7f05fb5800 100644 --- a/svx/source/form/fmtools.cxx +++ b/svx/source/form/fmtools.cxx @@ -177,9 +177,8 @@ sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAcce return nIndex; - Reference< XInterface > xNormalized( xElement, UNO_QUERY ); - DBG_ASSERT( xNormalized.is(), "getElementPos: invalid element!" ); - if ( xNormalized.is() ) + DBG_ASSERT( xElement.is(), "getElementPos: invalid element!" ); + if ( xElement.is() ) { // Feststellen an welcher Position sich das Kind befindet nIndex = xCont->getCount(); @@ -190,7 +189,7 @@ sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAcce Reference< XInterface > xCurrent(xCont->getByIndex( nIndex ),UNO_QUERY); DBG_ASSERT( xCurrent.get() == Reference< XInterface >( xCurrent, UNO_QUERY ).get(), "getElementPos: container element not normalized!" ); - if ( xNormalized.get() == xCurrent.get() ) + if ( xElement.get() == xCurrent.get() ) break; } catch(Exception&) diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index 29ef91a77aa5..cf1567b73ba1 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -805,8 +805,7 @@ void FmXUndoEnvironment::AddForms(const Reference< XNameContainer > & rForms) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::AddForms" ); Lock(); - Reference< XInterface > xInt(rForms, UNO_QUERY); - AddElement(xInt); + AddElement(rForms); UnLock(); } @@ -815,8 +814,7 @@ void FmXUndoEnvironment::RemoveForms(const Reference< XNameContainer > & rForms) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::RemoveForms" ); Lock(); - Reference< XInterface > xInt(rForms, UNO_QUERY); - RemoveElement(xInt); + RemoveElement(rForms); UnLock(); } diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 3dc99ea74da4..c309bb850631 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -221,8 +221,7 @@ void FormViewPageWindowAdapter::dispose() } // dispose the formcontroller - Reference< XComponent > xComp( xController, UNO_QUERY_THROW ); - xComp->dispose(); + xController->dispose(); } catch (const Exception&) { @@ -301,7 +300,7 @@ Reference< XFormController > getControllerSearchChildren( const Reference< XInd return xController; else { - xController = getControllerSearchChildren(Reference< XIndexAccess > (xController, UNO_QUERY), xModel); + xController = getControllerSearchChildren(xController, xModel); if ( xController.is() ) return xController; } @@ -370,8 +369,7 @@ void FormViewPageWindowAdapter::setController(const Reference< XForm > & xForm, // attaching the events Reference< XEventAttacherManager > xEventManager( xForm->getParent(), UNO_QUERY ); - Reference< XInterface > xIfc(xController, UNO_QUERY); - xEventManager->attach(m_aControllerList.size() - 1, xIfc, makeAny(xController) ); + xEventManager->attach(m_aControllerList.size() - 1, xController, makeAny(xController) ); } // jetzt die Subforms durchgehen diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index 0fbe0dc9c5d4..1382e0296637 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -276,8 +276,7 @@ ColumnInfoCache::ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSup { m_aColumns.clear(); - Reference< XColumnsSupplier > xSupplyCols( _rxColSupplier, UNO_SET_THROW ); - Reference< XIndexAccess > xColumns( xSupplyCols->getColumns(), UNO_QUERY_THROW ); + Reference< XIndexAccess > xColumns( _rxColSupplier->getColumns(), UNO_QUERY_THROW ); sal_Int32 nColumnCount = xColumns->getCount(); m_aColumns.reserve( nColumnCount ); @@ -354,8 +353,6 @@ void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > lcl_resetColumnControlInfo( *col ); - Reference< XInterface > xNormColumn( col->xColumn, UNO_QUERY_THROW ); - const Reference< XControl >* pControl( _rControls.getConstArray() ); const Reference< XControl >* pControlEnd( pControl + _rControls.getLength() ); for ( ; pControl != pControlEnd; ++pControl ) @@ -377,7 +374,7 @@ void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > { Reference< XPropertySet > xGridColumnModel( xGridColAccess->getByIndex( gridCol ), UNO_QUERY_THROW ); - if ( !lcl_isBoundTo( xGridColumnModel, xNormColumn ) + if ( !lcl_isBoundTo( xGridColumnModel, col->xColumn ) || !lcl_isInputRequired( xGridColumnModel ) ) continue; // with next grid column @@ -397,7 +394,7 @@ void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > } if ( !xModelPSI->hasPropertyByName( FM_PROP_BOUNDFIELD ) - || !lcl_isBoundTo( xModel, xNormColumn ) + || !lcl_isBoundTo( xModel, col->xColumn ) || !lcl_isInputRequired( xModel ) ) continue; // with next control @@ -2019,8 +2016,7 @@ void FormController::addToEventAttacher(const Reference< XControl > & xControl) m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get()) { - Reference< XInterface > xIfc(xControl, UNO_QUERY); - m_xModelAsManager->attach( nPos, xIfc, makeAny(xControl) ); + m_xModelAsManager->attach( nPos, xControl, makeAny(xControl) ); break; } } @@ -2047,8 +2043,7 @@ void FormController::removeFromEventAttacher(const Reference< XControl > & xCont m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get()) { - Reference< XInterface > xIfc(xControl, UNO_QUERY); - m_xModelAsManager->detach( nPos, xIfc ); + m_xModelAsManager->detach( nPos, xControl ); break; } } @@ -3055,8 +3050,7 @@ void SAL_CALL FormController::addChildController( const Reference< XFormControll m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; if ( xFormOfChild == xTemp ) { - Reference< XInterface > xIfc( _ChildController, UNO_QUERY ); - m_xModelAsManager->attach( nPos, xIfc, makeAny( _ChildController) ); + m_xModelAsManager->attach( nPos, _ChildController, makeAny( _ChildController) ); break; } } diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx index b344483c1748..bd5e5336cf43 100644 --- a/svx/source/form/formcontrolling.cxx +++ b/svx/source/form/formcontrolling.cxx @@ -252,8 +252,7 @@ namespace svx // to prevent the controller from displaying any error messages which happen while we operate on it, // we add ourself as XSQLErrorListener. By contract, a FormController displays errors if and only if // no SQLErrorListeners are registered. - Reference< XSQLErrorBroadcaster > xErrorBroadcast( _rxController, UNO_QUERY_THROW ); - xErrorBroadcast->addSQLErrorListener( this ); + _rxController->addSQLErrorListener( this ); } catch( const Exception& ) { diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx index 828054700dc4..768facd272e8 100644 --- a/svx/source/form/navigatortree.cxx +++ b/svx/source/form/navigatortree.cxx @@ -1102,7 +1102,7 @@ namespace svxform GetNavModel()->GetRootList()->remove( pCurrentUserData ); // aus dem Container entfernen - sal_Int32 nIndex = getElementPos(Reference< XIndexAccess > (xContainer, UNO_QUERY), xCurrentChild); + sal_Int32 nIndex = getElementPos(xContainer, xCurrentChild); GetNavModel()->m_pPropChangeList->Lock(); // die Undo-Action fuer das Rausnehmen if ( bUndo && GetNavModel()->m_pPropChangeList->CanUndo()) @@ -1400,7 +1400,7 @@ namespace svxform if( pFormShell ) { InterfaceBag aSelection; - aSelection.insert( Reference< XInterface >( xNewForm, UNO_QUERY ) ); + aSelection.insert( xNewForm ); pFormShell->GetImpl()->setCurrentSelection( aSelection ); pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_PROPERTIES,sal_True,sal_True); diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx index 01dc44a1422e..c2de01badeab 100644 --- a/svx/source/form/navigatortreemodel.cxx +++ b/svx/source/form/navigatortreemodel.cxx @@ -960,7 +960,7 @@ namespace svxform { FmFormData* pFormData = (FmFormData*)pEntryData; Reference< XForm > xForm( pFormData->GetFormIface()); - xFormComponent = Reference< XFormComponent > (xForm, UNO_QUERY); + xFormComponent = xForm; } if( pEntryData->ISA(FmControlData) ) |