diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-20 13:30:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-20 17:59:20 +0200 |
commit | f44bd7bb0ce23535f5e0ced7966677f4fff943fc (patch) | |
tree | 4e1801a7713e31b2b0f8f9d4fd586d5873511d2e /svx/source/form | |
parent | b1ef3c043d66e7cd529fc4fb13a3d2e8fdb4f2ee (diff) |
loplugin:referencecasting in svx
Change-Id: I2f6bc2467fa7689d186bc2bc45d2071ea0a38e63
Reviewed-on: https://gerrit.libreoffice.org/75998
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/form')
-rw-r--r-- | svx/source/form/datanavi.cxx | 24 | ||||
-rw-r--r-- | svx/source/form/filtnav.cxx | 2 | ||||
-rw-r--r-- | svx/source/form/fmPropBrw.cxx | 4 | ||||
-rw-r--r-- | svx/source/form/fmpgeimp.cxx | 18 | ||||
-rw-r--r-- | svx/source/form/fmservs.cxx | 2 | ||||
-rw-r--r-- | svx/source/form/fmshimp.cxx | 37 | ||||
-rw-r--r-- | svx/source/form/fmundo.cxx | 2 | ||||
-rw-r--r-- | svx/source/form/fmvwimp.cxx | 11 | ||||
-rw-r--r-- | svx/source/form/navigatortree.cxx | 4 | ||||
-rw-r--r-- | svx/source/form/navigatortreemodel.cxx | 4 |
10 files changed, 49 insertions, 59 deletions
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx index d0af70020036..8390adda415c 100644 --- a/svx/source/form/datanavi.cxx +++ b/svx/source/form/datanavi.cxx @@ -495,10 +495,9 @@ namespace svxform try { Reference< css::xforms::XSubmission > xNewSubmission = aDlg.GetNewSubmission(); - Reference< XSet > xSubmissions( xModel->getSubmissions(), UNO_QUERY ); + Reference< XSet > xSubmissions = xModel->getSubmissions(); xSubmissions->insert( makeAny( xNewSubmission ) ); - Reference< XPropertySet > xNewPropSet( xNewSubmission, UNO_QUERY ); - SvTreeListEntry* pEntry = AddEntry( xNewPropSet ); + SvTreeListEntry* pEntry = AddEntry( xNewSubmission ); m_pItemList->Select( pEntry ); bIsDocModified = true; } @@ -612,7 +611,7 @@ namespace svxform { pResId = RID_STR_DATANAV_ADD_BINDING; xNewBinding = xModel->createBinding(); - Reference< XSet > xBindings( xModel->getBindings(), UNO_QUERY ); + Reference< XSet > xBindings = xModel->getBindings(); xBindings->insert( makeAny( xNewBinding ) ); pNode.reset(new ItemNode( xNewBinding )); eType = DITBinding; @@ -667,7 +666,7 @@ namespace svxform { try { - Reference< XSet > xBindings( xModel->getBindings(), UNO_QUERY ); + Reference< XSet > xBindings = xModel->getBindings(); xBindings->remove( makeAny( xNewBinding ) ); } catch ( Exception const & ) @@ -1092,7 +1091,7 @@ namespace svxform if ( xContainer.is() ) m_pNaviWin->AddContainerBroadcaster( xContainer ); - Reference< XEnumerationAccess > xNumAccess( _xModel->getInstances(), UNO_QUERY ); + Reference< XEnumerationAccess > xNumAccess = _xModel->getInstances(); if ( xNumAccess.is() ) { Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); @@ -1139,7 +1138,7 @@ namespace svxform if ( xContainer.is() ) m_pNaviWin->AddContainerBroadcaster( xContainer ); - Reference< XEnumerationAccess > xNumAccess( _xModel->getSubmissions(), UNO_QUERY ); + Reference< XEnumerationAccess > xNumAccess = _xModel->getSubmissions(); if ( xNumAccess.is() ) { Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); @@ -1172,7 +1171,7 @@ namespace svxform if ( xContainer.is() ) m_pNaviWin->AddContainerBroadcaster( xContainer ); - Reference< XEnumerationAccess > xNumAccess( _xModel->getBindings(), UNO_QUERY ); + Reference< XEnumerationAccess > xNumAccess = _xModel->getBindings(); if ( xNumAccess.is() ) { Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); @@ -1417,8 +1416,7 @@ namespace svxform // get our frame DBG_ASSERT( pBindings != nullptr, "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame" ); - m_xFrame.set( pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), - UNO_QUERY ); + m_xFrame = pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(); DBG_ASSERT( m_xFrame.is(), "DataNavigatorWindow::LoadModels(): no frame" ); // add frameaction listener Reference< XFrameActionListener > xListener( @@ -1973,7 +1971,7 @@ namespace svxform Reference< css::xforms::XModel > xModel; if ( aAny >>= xModel ) { - Reference< XEnumerationAccess > xNumAccess( xModel->getInstances(), UNO_QUERY ); + Reference< XEnumerationAccess > xNumAccess = xModel->getInstances(); if ( xNumAccess.is() ) { Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); @@ -3088,7 +3086,7 @@ namespace svxform try { m_xNewSubmission = xModel->createSubmission(); - m_xSubmission.set( m_xNewSubmission, UNO_QUERY ); + m_xSubmission = m_xNewSubmission; } catch ( Exception const & ) { @@ -3143,7 +3141,7 @@ namespace svxform { try { - Reference< XEnumerationAccess > xNumAccess( xModel->getBindings(), UNO_QUERY ); + Reference< XEnumerationAccess > xNumAccess = xModel->getBindings(); if ( xNumAccess.is() ) { Reference < XEnumeration > xNum = xNumAccess->createEnumeration(); diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index dc406e6bd9ea..27d7c2d61a37 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -1810,7 +1810,7 @@ void FmFilterNavigatorWin::UpdateContent(FmFormShell const * pFormShell) Reference< XIndexAccess > xContainer; if (xController.is()) { - Reference< XChild > xChild(xController, UNO_QUERY); + Reference< XChild > xChild = xController; for (Reference< XInterface > xParent(xChild->getParent()); xParent.is(); xParent = xChild.is() ? xChild->getParent() : Reference< XInterface > ()) diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx index e03e9cb98d85..1674c5806824 100644 --- a/svx/source/form/fmPropBrw.cxx +++ b/svx/source/form/fmPropBrw.cxx @@ -559,10 +559,10 @@ void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ) : DefaultFormComponentInspectorModel::createDefault( m_xInspectorContext ); // an object inspector - m_xBrowserController.set( + m_xBrowserController = ObjectInspector::createWithModel( m_xInspectorContext, m_xInspectorModel - ), css::uno::UNO_QUERY); + ); if ( !m_xBrowserController.is() ) { diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx index 7011a4c3faef..9146fe6605fd 100644 --- a/svx/source/form/fmpgeimp.cxx +++ b/svx/source/form/fmpgeimp.cxx @@ -239,7 +239,7 @@ namespace void lcl_insertFormObject_throw( const FmFormObj& _object, const Reference< XMap >& _map ) { // the control model - Reference< XControlModel > xControlModel( _object.GetUnoControlModel(), UNO_QUERY ); + Reference< XControlModel > xControlModel = _object.GetUnoControlModel(); OSL_ENSURE( xControlModel.is(), "lcl_insertFormObject_throw: suspicious: no control model!" ); if ( !xControlModel.is() ) return; @@ -255,7 +255,7 @@ namespace void lcl_removeFormObject_throw( const FmFormObj& _object, const Reference< XMap >& _map ) { // the control model - Reference< XControlModel > xControlModel( _object.GetUnoControlModel(), UNO_QUERY ); + Reference< XControlModel > xControlModel = _object.GetUnoControlModel(); OSL_ENSURE( xControlModel.is(), "lcl_removeFormObject: suspicious: no control model!" ); if ( !xControlModel.is() ) { @@ -276,10 +276,10 @@ Reference< XMap > FmFormPageImpl::impl_createControlShapeMap_nothrow() try { - xMap.set( EnumerableMap::create( comphelper::getProcessComponentContext(), + xMap = EnumerableMap::create( comphelper::getProcessComponentContext(), ::cppu::UnoType< XControlModel >::get(), ::cppu::UnoType< XControlShape >::get() - ).get(), UNO_SET_THROW ); + ); SdrObjListIter aPageIter( &m_rPage ); while ( aPageIter.IsMore() ) @@ -344,9 +344,7 @@ bool FmFormPageImpl::validateCurForm() if ( !xCurrentForm.is() ) return false; - Reference< XChild > xAsChild( xCurrentForm, UNO_QUERY ); - DBG_ASSERT( xAsChild.is(), "FmFormPageImpl::validateCurForm: a form which is no child??" ); - if ( !xAsChild.is() || !xAsChild->getParent().is() ) + if ( !xCurrentForm->getParent().is() ) xCurrentForm.clear(); return xCurrentForm.is(); @@ -464,7 +462,7 @@ Reference< css::form::XForm > FmFormPageImpl::findPlaceInFormComponentHierarchy // first search in the current form xForm = findFormForDataSource( xCurrentForm, rDatabase, rCursorSource, nCommandType ); - Reference< css::container::XIndexAccess > xFormsByIndex( getForms(), UNO_QUERY ); + Reference< css::container::XIndexAccess > xFormsByIndex = getForms(); DBG_ASSERT(xFormsByIndex.is(), "FmFormPageImpl::findPlaceInFormComponentHierarchy : no index access for my forms collection !"); sal_Int32 nCount = xFormsByIndex->getCount(); for (sal_Int32 i = 0; !xForm.is() && i < nCount; i++) @@ -506,7 +504,7 @@ Reference< css::form::XForm > FmFormPageImpl::findPlaceInFormComponentHierarchy xFormProps->setPropertyValue(FM_PROP_COMMAND,makeAny(rCursorSource)); xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny(nCommandType)); - Reference< css::container::XNameAccess > xNamedSet( getForms(), UNO_QUERY ); + Reference< css::container::XNameAccess > xNamedSet = getForms(); const bool bTableOrQuery = ( CommandType::TABLE == nCommandType ) || ( CommandType::QUERY == nCommandType ); OUString sName = FormControlFactory::getUniqueName( xNamedSet, @@ -516,7 +514,7 @@ Reference< css::form::XForm > FmFormPageImpl::findPlaceInFormComponentHierarchy if( bUndo ) { - Reference< css::container::XIndexContainer > xContainer( getForms(), UNO_QUERY ); + Reference< css::container::XIndexContainer > xContainer = getForms(); rModel.AddUndo( std::make_unique<FmUndoContainerAction>( static_cast< FmFormModel& >(rModel), diff --git a/svx/source/form/fmservs.cxx b/svx/source/form/fmservs.cxx index 5cd0b79991b6..86b6960ad1e4 100644 --- a/svx/source/form/fmservs.cxx +++ b/svx/source/form/fmservs.cxx @@ -38,7 +38,7 @@ namespace svxform { void ImplSmartRegisterUnoServices() { - uno::Reference< lang::XMultiServiceFactory > xServiceFactory(::comphelper::getProcessServiceFactory(), uno::UNO_QUERY); + uno::Reference< lang::XMultiServiceFactory > xServiceFactory = ::comphelper::getProcessServiceFactory(); uno::Reference< container::XSet > xSet(xServiceFactory, uno::UNO_QUERY); if (!xSet.is()) return; diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index cd0474fd5fad..5f796a94e9ab 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -752,9 +752,8 @@ void SAL_CALL FmXFormShell::disposing(const lang::EventObject& e) if (xFormController.is()) xFormController->removeActivateListener(static_cast<XFormControllerListener*>(this)); - Reference< css::lang::XComponent> xComp(m_xExternalViewController, UNO_QUERY); - if (xComp.is()) - xComp->removeEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this))); + if (m_xExternalViewController.is()) + m_xExternalViewController->removeEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this))); m_xExternalViewController = nullptr; m_xExternalDisplayedForm = nullptr; @@ -1522,7 +1521,7 @@ void FmXFormShell::ExecuteSearch_Lock() Reference< XGridPeer> xGridPeer(xActiveControl->getPeer(), UNO_QUERY); Reference< XIndexAccess> xColumns; if (xGridPeer.is()) - xColumns.set(xGridPeer->getColumns(),UNO_QUERY); + xColumns = xGridPeer->getColumns(); sal_Int16 nViewCol = xGrid->getCurrentColumnPosition(); sal_Int32 nModelCol = GridView2ModelPos(xColumns, nViewCol); @@ -1645,7 +1644,7 @@ void FmXFormShell::SetY2KState_Lock(sal_uInt16 n) if (!xCurrentForms.is()) { // in the alive mode, my forms are not set, but the ones on the page are if (m_pShell->GetCurPage()) - xCurrentForms.set( m_pShell->GetCurPage()->GetForms( false ), UNO_QUERY ); + xCurrentForms = m_pShell->GetCurPage()->GetForms( false ); } if (!xCurrentForms.is()) return; @@ -1797,14 +1796,13 @@ void FmXFormShell::ExecuteFormSlot_Lock( sal_Int32 _nSlot ) void FmXFormShell::impl_switchActiveControllerListening_Lock(const bool _bListen) { - Reference< XComponent> xComp( m_xActiveController, UNO_QUERY ); - if ( !xComp.is() ) + if ( !m_xActiveController.is() ) return; if ( _bListen ) - xComp->addEventListener( static_cast<XFormControllerListener*>(this) ); + m_xActiveController->addEventListener( static_cast<XFormControllerListener*>(this) ); else - xComp->removeEventListener( static_cast<XFormControllerListener*>(this) ); + m_xActiveController->removeEventListener( static_cast<XFormControllerListener*>(this) ); } @@ -2079,7 +2077,7 @@ void FmXFormShell::startListening_Lock() case NavigationBarMode_PARENT: { // search for the controller via which navigation is possible - Reference< XChild> xChild(m_xActiveController, UNO_QUERY); + Reference< XChild> xChild = m_xActiveController; Reference< runtime::XFormController > xParent; while (xChild.is()) { @@ -2380,7 +2378,7 @@ IMPL_LINK(FmXFormShell, OnSearchContextRequest_Lock, FmSearchContext&, rfmscCont if (!xPeerContainer.is()) break; - Reference< XIndexAccess> xModelColumns(xGridPeer->getColumns(), UNO_QUERY); + Reference< XIndexAccess> xModelColumns = xGridPeer->getColumns(); DBG_ASSERT(xModelColumns.is(), "FmXFormShell::OnSearchContextRequest : there is a grid control without columns !"); // the case 'no columns' should be indicated with an empty container, I think ... DBG_ASSERT(xModelColumns->getCount() >= xPeerContainer->getCount(), "FmXFormShell::OnSearchContextRequest : impossible : have more view than model columns !"); @@ -2543,7 +2541,7 @@ void FmXFormShell::UpdateForms_Lock(bool _bInvalidate) FmFormPage* pPage = m_pShell->GetCurPage(); if ( pPage && m_pShell->m_bDesignMode ) - xForms.set(pPage->GetForms( false ), css::uno::UNO_QUERY); + xForms = pPage->GetForms( false ); if ( m_xForms != xForms ) { @@ -2965,13 +2963,12 @@ static void saveFilter(const Reference< runtime::XFormController >& _rxControlle { Reference< XPropertySet> xFormAsSet(_rxController->getModel(), UNO_QUERY); Reference< XPropertySet> xControllerAsSet(_rxController, UNO_QUERY); - Reference< XIndexAccess> xControllerAsIndex(_rxController, UNO_QUERY); // call the subcontroller Reference< runtime::XFormController > xController; - for (sal_Int32 i = 0, nCount = xControllerAsIndex->getCount(); i < nCount; ++i) + for (sal_Int32 i = 0, nCount = _rxController->getCount(); i < nCount; ++i) { - xControllerAsIndex->getByIndex(i) >>= xController; + _rxController->getByIndex(i) >>= xController; saveFilter(xController); } @@ -3157,9 +3154,8 @@ void FmXFormShell::CreateExternalView_Lock() if (xExternalViewFrame.is()) { m_xExternalViewController = xExternalViewFrame->getController(); - Reference< css::lang::XComponent> xComp(m_xExternalViewController, UNO_QUERY); - if (xComp.is()) - xComp->addEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this))); + if (m_xExternalViewController.is()) + m_xExternalViewController->addEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this))); } } else @@ -3663,7 +3659,7 @@ void FmXFormShell::impl_defaultCurrentForm_nothrow_Lock() try { - Reference< XIndexAccess > xForms( pPage->GetForms( false ), UNO_QUERY ); + Reference< XIndexAccess > xForms = pPage->GetForms( false ); if ( !xForms.is() || !xForms->hasElements() ) return; @@ -3807,8 +3803,7 @@ void FmXFormShell::loadForms_Lock(FmFormPage* _pPage, const LoadFormsFlags _nBeh rFmFormModel.GetUndoEnv().Lock(); // load all forms - Reference< XIndexAccess > xForms; - xForms.set(_pPage->GetForms( false ), css::uno::UNO_QUERY); + Reference< XIndexAccess > xForms = _pPage->GetForms( false ); if ( xForms.is() ) { diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index 397b5efc5f45..56c57f529fc5 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -1039,7 +1039,7 @@ FmUndoContainerAction::FmUndoContainerAction(FmFormModel& _rMod, if ( xCont.is() && xElem.is() ) { // normalize - m_xElement.set(xElem, css::uno::UNO_QUERY); + m_xElement = xElem; if ( m_eAction == Removed ) { if (m_nIndex >= 0) diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 588c6757f55a..2e48c95e7950 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -378,7 +378,7 @@ void FormViewPageWindowAdapter::updateTabOrder( const Reference< XForm >& _rxFor // there is a parent form -> look for the respective controller Reference< XFormController > xParentController; if ( xParentForm.is() ) - xParentController.set( getController( xParentForm ), UNO_QUERY ); + xParentController = getController( xParentForm ); setController( _rxForm, xParentController ); } @@ -661,16 +661,15 @@ namespace if(xController == xActiveController && isActivableDatabaseForm(xController)) return xController; - Reference< XIndexAccess > xSubControllers( xController, UNO_QUERY ); - if ( !xSubControllers.is() ) + if ( !xController.is() ) { SAL_WARN( "svx.form", "FmXFormView::OnActivate: a form controller which does not have children?" ); return nullptr; } - for(sal_Int32 i = 0; i < xSubControllers->getCount(); ++i) + for(sal_Int32 i = 0; i < xController->getCount(); ++i) { - const Any a(xSubControllers->getByIndex(i)); + const Any a(xController->getByIndex(i)); Reference < XFormController > xI; if ((a >>= xI) && xI.is()) { @@ -920,7 +919,7 @@ IMPL_LINK_NOARG(FmXFormView, OnAutoFocus, void*, void) SdrPage *pSdrPage = pPageView ? pPageView->GetPage() : nullptr; // get the forms collection of the page we belong to FmFormPage* pPage = dynamic_cast<FmFormPage*>( pSdrPage ); - Reference< XIndexAccess > xForms( pPage ? Reference< XIndexAccess >( pPage->GetForms(), UNO_QUERY ) : Reference< XIndexAccess >() ); + Reference< XIndexAccess > xForms( pPage ? Reference< XIndexAccess >( pPage->GetForms() ) : Reference< XIndexAccess >() ); const PFormViewPageWindowAdapter pAdapter = m_aPageWindowAdapters.empty() ? nullptr : m_aPageWindowAdapters[0]; const vcl::Window* pWindow = pAdapter.get() ? pAdapter->getWindow() : nullptr; diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx index 1884b7a03f09..d1e12886d6ab 100644 --- a/svx/source/form/navigatortree.cxx +++ b/svx/source/form/navigatortree.cxx @@ -1038,7 +1038,7 @@ namespace svxform FmEntryData* pCurrentUserData = static_cast<FmEntryData*>(pCurrent->GetUserData()); - Reference< XChild > xCurrentChild(pCurrentUserData->GetChildIFace(), UNO_QUERY); + Reference< XChild > xCurrentChild = pCurrentUserData->GetChildIFace(); Reference< XIndexContainer > xContainer(xCurrentChild->getParent(), UNO_QUERY); FmFormData* pCurrentParentUserData = static_cast<FmFormData*>(pCurrentUserData->GetParent()); @@ -1081,7 +1081,7 @@ namespace svxform if (pTargetData) xContainer.set(pTargetData->GetElement(), UNO_QUERY); else - xContainer.set(GetNavModel()->GetForms(), UNO_QUERY); + xContainer = GetNavModel()->GetForms(); // always insert at the end nIndex = xContainer->getCount(); diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx index cdbdeaac4e6b..c58c79f1e3a3 100644 --- a/svx/source/form/navigatortreemodel.cxx +++ b/svx/source/form/navigatortreemodel.cxx @@ -270,7 +270,7 @@ namespace svxform if (pFolder) xContainer.set(pFolder->GetFormIface(), UNO_QUERY); else - xContainer.set(GetForms(), UNO_QUERY); + xContainer = GetForms(); bool bUndo = m_pFormModel->IsUndoEnabled(); @@ -487,7 +487,7 @@ namespace svxform // insert forms from root if( pFormData == nullptr ) { - Reference< XIndexContainer > xForms(GetForms(), UNO_QUERY); + Reference< XIndexContainer > xForms = GetForms(); if (!xForms.is()) return; |