From 6595240f39c34fa9ae5cd1bb319f6287206e4b92 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 19 Jul 2019 15:32:58 +0200 Subject: loplugin:referencecasting in forms..fpicker Change-Id: I0aa040b6d3264d2efde5797f79994d3d65ceaddf Reviewed-on: https://gerrit.libreoffice.org/75957 Tested-by: Jenkins Reviewed-by: Noel Grandin --- forms/source/component/ComboBox.cxx | 9 ++++--- forms/source/component/FormComponent.cxx | 4 ++-- forms/source/component/RadioButton.cxx | 6 ++--- forms/source/helper/commandimageprovider.cxx | 2 +- forms/source/helper/controlfeatureinterception.cxx | 5 ++-- forms/source/runtime/formoperations.cxx | 28 +++++++++------------- forms/source/xforms/binding.cxx | 8 +++---- forms/source/xforms/model.cxx | 2 +- forms/source/xforms/model_ui.cxx | 8 +++---- forms/source/xforms/submission.cxx | 2 +- .../xforms/submission/serialization_app_xml.cxx | 2 +- .../xforms/submission/serialization_urlencoded.cxx | 2 +- 12 files changed, 32 insertions(+), 46 deletions(-) (limited to 'forms/source') diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx index 06f5f4234c0d..03d46288a6bf 100644 --- a/forms/source/component/ComboBox.cxx +++ b/forms/source/component/ComboBox.cxx @@ -474,10 +474,9 @@ void OComboBoxModel::loadData( bool _bForce ) return; // Get Connection - Reference xForm(m_xCursor, UNO_QUERY); - if (!xForm.is()) + if (!m_xCursor.is()) return; - Reference xConnection = getConnection(xForm); + Reference xConnection = getConnection(m_xCursor); if (!xConnection.is()) return; @@ -518,7 +517,7 @@ void OComboBoxModel::loadData( bool _bForce ) else { // otherwise look for the alias - Reference xFormProp(xForm,UNO_QUERY); + Reference xFormProp(m_xCursor,UNO_QUERY); Reference< XColumnsSupplier > xSupplyFields; xFormProp->getPropertyValue("SingleSelectQueryComposer") >>= xSupplyFields; @@ -627,7 +626,7 @@ void OComboBoxModel::loadData( bool _bForce ) if ( !xDataField.is() ) return; - ::dbtools::FormattedColumnValue aValueFormatter( getContext(), xForm, xDataField ); + ::dbtools::FormattedColumnValue aValueFormatter( getContext(), m_xCursor, xDataField ); // Fill Lists sal_Int16 i = 0; diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 6d46f3a9825e..eb4cbf3f9598 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -259,7 +259,7 @@ void OControl::impl_resetStateGuard_nothrow() try { xWindow.set( getPeer(), UNO_QUERY ); - xModel.set( getModel(), UNO_QUERY ); + xModel = getModel(); } catch( const Exception& ) { @@ -1920,7 +1920,7 @@ void OBoundControlModel::connectToField(const Reference& rForm) DBG_ASSERT(xColumnsSupplier.is(), "OBoundControlModel::connectToField : the row set should support the css::sdb::ResultSet service !"); if (xColumnsSupplier.is()) { - Reference xColumns(xColumnsSupplier->getColumns(), UNO_QUERY); + Reference xColumns = xColumnsSupplier->getColumns(); if (xColumns.is() && xColumns->hasByName(m_aControlSource)) { OSL_VERIFY( xColumns->getByName(m_aControlSource) >>= xFieldCandidate ); diff --git a/forms/source/component/RadioButton.cxx b/forms/source/component/RadioButton.cxx index 0fac875bb2a1..5505ee92ea85 100644 --- a/forms/source/component/RadioButton.cxx +++ b/forms/source/component/RadioButton.cxx @@ -126,8 +126,7 @@ void ORadioButtonModel::SetSiblingPropsTo(const OUString& rPropName, const Any& Reference xIndexAccess(getParent(), UNO_QUERY); if (xIndexAccess.is()) { - Reference xMyProps( - static_cast(this), css::uno::UNO_QUERY); + Reference xMyProps = this; OUString sCurrentGroup; sal_Int32 nNumSiblings = xIndexAccess->getCount(); for (sal_Int32 i=0; i>= sGroupName; getPropertyValue(PROPERTY_NAME) >>= sName; - Reference xMyProps( - static_cast(this), css::uno::UNO_QUERY); + Reference xMyProps = this; for (sal_Int32 i=0; igetCount(); ++i) { Reference xSiblingProperties(xIndexAccess->getByIndex(i), UNO_QUERY); diff --git a/forms/source/helper/commandimageprovider.cxx b/forms/source/helper/commandimageprovider.cxx index 570d58abe94d..a40783149416 100644 --- a/forms/source/helper/commandimageprovider.cxx +++ b/forms/source/helper/commandimageprovider.cxx @@ -82,7 +82,7 @@ namespace frm try { Reference< XUIConfigurationManagerSupplier > xSuppUIConfig( _rxDocument, UNO_QUERY_THROW ); - Reference< XUIConfigurationManager > xUIConfig( xSuppUIConfig->getUIConfigurationManager(), UNO_QUERY ); + Reference< XUIConfigurationManager > xUIConfig = xSuppUIConfig->getUIConfigurationManager(); m_xDocumentImageManager.set( xUIConfig->getImageManager(), UNO_QUERY_THROW ); } catch( const Exception& ) diff --git a/forms/source/helper/controlfeatureinterception.cxx b/forms/source/helper/controlfeatureinterception.cxx index 5e79a5c65995..16fa4154935d 100644 --- a/forms/source/helper/controlfeatureinterception.cxx +++ b/forms/source/helper/controlfeatureinterception.cxx @@ -48,9 +48,8 @@ namespace frm if ( m_xFirstDispatchInterceptor.is() ) { // there is already an interceptor; the new one will become its master - Reference< XDispatchProvider > xFirstProvider( m_xFirstDispatchInterceptor, UNO_QUERY ); - _rxInterceptor->setSlaveDispatchProvider( xFirstProvider ); - m_xFirstDispatchInterceptor->setMasterDispatchProvider( xFirstProvider ); + _rxInterceptor->setSlaveDispatchProvider( m_xFirstDispatchInterceptor ); + m_xFirstDispatchInterceptor->setMasterDispatchProvider( m_xFirstDispatchInterceptor ); } // we are the master of the chain's first interceptor diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index adb5cf877f79..eb4133ee5493 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -259,8 +259,7 @@ namespace frm case FormFeature::ReloadForm: { // there must be an active connection - Reference< XRowSet > xCursorRowSet( m_xCursor, UNO_QUERY ); - aState.Enabled = ::dbtools::getConnection( xCursorRowSet ).is(); + aState.Enabled = ::dbtools::getConnection( m_xCursor ).is(); // and an active command OUString sActiveCommand; @@ -480,14 +479,12 @@ namespace frm { bool shouldCommit(true); assert(xCntrl.is()); - Reference< XIndexAccess > xSubForms(xCntrl, UNO_QUERY); - assert(xSubForms.is()); - if(xSubForms.is()) + if(xCntrl.is()) { - const sal_Int32 cnt = xSubForms->getCount(); + const sal_Int32 cnt = xCntrl->getCount(); for(int i=0; i < cnt; ++i) { - Reference< XFormController > xSubForm(xSubForms->getByIndex(i), UNO_QUERY); + Reference< XFormController > xSubForm(xCntrl->getByIndex(i), UNO_QUERY); assert(xSubForm.is()); if (xSubForm.is()) { @@ -1091,9 +1088,8 @@ namespace frm m_xCursorProperties->removePropertyChangeListener( PROPERTY_ISNEW, this ); } - Reference< XModifyBroadcaster > xBroadcaster( m_xController, UNO_QUERY ); - if ( xBroadcaster.is() ) - xBroadcaster->removeModifyListener( this ); + if ( m_xController.is() ) + m_xController->removeModifyListener( this ); } catch( const Exception& ) { @@ -1127,9 +1123,8 @@ namespace frm impl_initFromForm_throw(); - Reference< XModifyBroadcaster > xBroadcaster( m_xController, UNO_QUERY ); - if ( xBroadcaster.is() ) - xBroadcaster->addModifyListener( this ); + if ( m_xController.is() ) + m_xController->addModifyListener( this ); } @@ -1691,13 +1686,12 @@ namespace frm css::uno::Reference xDialogParent; //tdf#122152 extract parent for dialog - css::uno::Reference xTabController(m_xController, css::uno::UNO_QUERY); - if (xTabController.is()) + if (m_xController.is()) { - css::uno::Reference xContainerControl(xTabController->getContainer(), css::uno::UNO_QUERY); + css::uno::Reference xContainerControl(m_xController->getContainer(), css::uno::UNO_QUERY); if (xContainerControl.is()) { - css::uno::Reference xContainerPeer(xContainerControl->getPeer(), css::uno::UNO_QUERY); + css::uno::Reference xContainerPeer = xContainerControl->getPeer(); xDialogParent = css::uno::Reference(xContainerPeer, css::uno::UNO_QUERY); } } diff --git a/forms/source/xforms/binding.cxx b/forms/source/xforms/binding.cxx index b36d2bf074df..d2c1be56aa7b 100644 --- a/forms/source/xforms/binding.cxx +++ b/forms/source/xforms/binding.cxx @@ -543,10 +543,8 @@ void Binding::bind( bool bForceRebind ) aContext.mxNamespaces ) ) { aContext.mxContextNode->appendChild( - Reference( aContext.mxContextNode->getOwnerDocument()->createElement( - maBindingExpression.getExpression() ), - UNO_QUERY ) ); + maBindingExpression.getExpression() ) ); maBindingExpression.evaluate( aContext ); OSL_ENSURE( maBindingExpression.getNode().is(), "we should bind to the newly inserted node!" ); @@ -751,8 +749,8 @@ css::uno::Reference Binding::getDataType() OSL_ENSURE( getModel().is(), "need model" ); OSL_ENSURE( getModel()->getDataTypeRepository().is(), "need types" ); - Reference xRepository( - getModel()->getDataTypeRepository(), UNO_QUERY ); + Reference xRepository = + getModel()->getDataTypeRepository(); OUString sTypeName = maMIP.getTypeName(); return ( xRepository.is() && xRepository->hasByName( sTypeName ) ) diff --git a/forms/source/xforms/model.cxx b/forms/source/xforms/model.cxx index 2bddfea5db30..0b5b4cbd245f 100644 --- a/forms/source/xforms/model.cxx +++ b/forms/source/xforms/model.cxx @@ -113,7 +113,7 @@ EvaluationContext Model::getEvaluationContext() // the default context is the top-level element node. A default // node (instanceData' is inserted when there is no default node Reference xInstance = getDefaultInstance(); - Reference xElement( xInstance->getDocumentElement(), UNO_QUERY ); + Reference xElement = xInstance->getDocumentElement(); // no element found? Then insert default element 'instanceData' if( ! xElement.is() ) diff --git a/forms/source/xforms/model_ui.cxx b/forms/source/xforms/model_ui.cxx index e37dfa3d490b..b2ffffa2ec0c 100644 --- a/forms/source/xforms/model_ui.cxx +++ b/forms/source/xforms/model_ui.cxx @@ -550,8 +550,7 @@ css::uno::Reference Model::createElement( const css::uno:: && isValidXMLName( sName ) ) { // TODO: implement proper namespace handling - xNode.set( xParent->getOwnerDocument()->createElement( sName ), - UNO_QUERY ); + xNode = xParent->getOwnerDocument()->createElement( sName ); } return xNode; } @@ -575,8 +574,7 @@ css::uno::Reference Model::createAttribute( const css::uno } // TODO: implement proper namespace handling - xNode.set( xParent->getOwnerDocument()->createAttribute( sUniqueName ), - UNO_QUERY ); + xNode = xParent->getOwnerDocument()->createAttribute( sUniqueName ); } return xNode; } @@ -603,7 +601,7 @@ css::uno::Reference Model::renameNode( const css::uno::Ref if( xNode->getNodeType() == NodeType_ELEMENT_NODE ) { Reference xElem = xDoc->createElement( sName ); - xNew.set( xElem, UNO_QUERY ); + xNew = xElem; // iterate over all attributes and append them to the new element Reference xOldElem( xNode, UNO_QUERY ); diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx index c4d786877674..f20b72f11973 100644 --- a/forms/source/xforms/submission.cxx +++ b/forms/source/xforms/submission.cxx @@ -558,7 +558,7 @@ Reference< XDocumentFragment > Submission::createSubmissionDocument(const Refere { aListItem = aList->item(i); if (aListItem->getNodeType()==NodeType_DOCUMENT_NODE) - aListItem.set( (Reference< XDocument >(aListItem, UNO_QUERY))->getDocumentElement(), UNO_QUERY); + aListItem = (Reference< XDocument >(aListItem, UNO_QUERY))->getDocumentElement(); // copy relevant nodes from instance into fragment cloneNodes(*getModelImpl(), aFragment, aListItem, bRemoveWSNodes); } diff --git a/forms/source/xforms/submission/serialization_app_xml.cxx b/forms/source/xforms/submission/serialization_app_xml.cxx index c8ad9ef642e3..afe23e63c426 100644 --- a/forms/source/xforms/submission/serialization_app_xml.cxx +++ b/forms/source/xforms/submission/serialization_app_xml.cxx @@ -67,7 +67,7 @@ CSerializationAppXML::getInputStream() { // The pipes output is provided through it's // XOutputStream interface aspect - return Reference< css::io::XInputStream >(m_xBuffer, UNO_QUERY); + return m_xBuffer; } void diff --git a/forms/source/xforms/submission/serialization_urlencoded.cxx b/forms/source/xforms/submission/serialization_urlencoded.cxx index 43dafdc714c6..51d29ceed0c9 100644 --- a/forms/source/xforms/submission/serialization_urlencoded.cxx +++ b/forms/source/xforms/submission/serialization_urlencoded.cxx @@ -173,7 +173,7 @@ void CSerializationURLEncoded::serialize() Reference< XInputStream > CSerializationURLEncoded::getInputStream() { - return Reference< XInputStream >(m_aPipe, UNO_QUERY); + return m_aPipe; } -- cgit