loplugin:referencecasting in extensions

Change-Id: Ib03be019b2fedc67b3114c107162722eabce0218
Reviewed-on: https://gerrit.libreoffice.org/75955
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2019-07-19 15:31:54 +02:00
parent 6595240f39
commit 8c26800ff8
10 changed files with 29 additions and 36 deletions

View File

@@ -521,9 +521,7 @@ namespace abp
Reference< XInteractionHandler > xInteractions;
try
{
xInteractions.set(
InteractionHandler::createWithParent(m_pImpl->xORB, nullptr),
UNO_QUERY);
xInteractions = InteractionHandler::createWithParent(m_pImpl->xORB, nullptr);
}
catch(const Exception&)
{

View File

@@ -901,7 +901,7 @@ void BibDataManager::setActiveDataSource(const OUString& rURL)
aPropertySet->setPropertyValue("FetchSize", aVal);
OUString aString("SELECT * FROM ");
// quote the table name which may contain catalog.schema.table
Reference<XDatabaseMetaData> xMetaData(xConnection->getMetaData(),UNO_QUERY);
Reference<XDatabaseMetaData> xMetaData = xConnection->getMetaData();
aQuoteChar = xMetaData->getIdentifierQuoteString();
OUString sCatalog, sSchema, sName;

View File

@@ -398,8 +398,7 @@ void BibGeneralPage::RemoveListeners()
{
if(aControl.is())
{
uno::Reference< awt::XWindow > xCtrWin(aControl, uno::UNO_QUERY );
xCtrWin->removeFocusListener( mxBibGeneralPageFocusListener.get() );
aControl->removeFocusListener( mxBibGeneralPageFocusListener.get() );
aControl = nullptr;
}
}

View File

@@ -324,7 +324,7 @@ namespace dbp
Reference< XTablesSupplier > xSupplTables(xConn, UNO_QUERY);
if ( xSupplTables.is() )
{
Reference< XNameAccess > xTables(xSupplTables->getTables(), UNO_QUERY);
Reference< XNameAccess > xTables = xSupplTables->getTables();
if (xTables.is())
aTableNames = xTables->getElementNames();
}
@@ -333,7 +333,7 @@ namespace dbp
Reference< XQueriesSupplier > xSuppQueries( xConn, UNO_QUERY );
if ( xSuppQueries.is() )
{
Reference< XNameAccess > xQueries( xSuppQueries->getQueries(), UNO_QUERY );
Reference< XNameAccess > xQueries = xSuppQueries->getQueries();
if ( xQueries.is() )
aQueryNames = xQueries->getElementNames();
}

View File

@@ -281,7 +281,7 @@ namespace dbp
void OControlWizard::implDetermineShape()
{
Reference< XIndexAccess > xPageObjects(m_aContext.xDrawPage, UNO_QUERY);
Reference< XIndexAccess > xPageObjects = m_aContext.xDrawPage;
DBG_ASSERT(xPageObjects.is(), "OControlWizard::implDetermineShape: invalid page!");
// for comparing the model

View File

@@ -59,7 +59,7 @@ namespace dbp
void OOptionGroupLayouter::doLayout(const OControlWizardContext& _rContext, const OOptionGroupSettings& _rSettings)
{
Reference< XShapes > xPageShapes(_rContext.xDrawPage, UNO_QUERY);
Reference< XShapes > xPageShapes = _rContext.xDrawPage;
if (!xPageShapes.is())
{
OSL_FAIL("OOptionGroupLayouter::OOptionGroupLayouter: missing the XShapes interface for the page!");

View File

@@ -209,11 +209,10 @@ namespace pcr
// and set as property values
try
{
Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
if ( xDetailFormProps.is() )
if ( m_xDetailForm.is() )
{
xDetailFormProps->setPropertyValue( PROPERTY_DETAILFIELDS, makeAny( Sequence< OUString >( aDetailFields.data(), aDetailFields.size() ) ) );
xDetailFormProps->setPropertyValue( PROPERTY_MASTERFIELDS, makeAny( Sequence< OUString >( aMasterFields.data(), aMasterFields.size() ) ) );
m_xDetailForm->setPropertyValue( PROPERTY_DETAILFIELDS, makeAny( Sequence< OUString >( aDetailFields.data(), aDetailFields.size() ) ) );
m_xDetailForm->setPropertyValue( PROPERTY_MASTERFIELDS, makeAny( Sequence< OUString >( aMasterFields.data(), aMasterFields.size() ) ) );
}
}
catch( const Exception& )
@@ -303,11 +302,10 @@ namespace pcr
Sequence< OUString > aDetailFields;
Sequence< OUString > aMasterFields;
Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
if ( xDetailFormProps.is() )
if ( m_xDetailForm.is() )
{
xDetailFormProps->getPropertyValue( PROPERTY_DETAILFIELDS ) >>= aDetailFields;
xDetailFormProps->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields;
m_xDetailForm->getPropertyValue( PROPERTY_DETAILFIELDS ) >>= aDetailFields;
m_xDetailForm->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields;
}
std::vector< OUString > aDetailFields1;
@@ -543,24 +541,22 @@ namespace pcr
void FormLinkDialog::initializeSuggest()
{
Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
Reference< XPropertySet > xMasterFormProps( m_xMasterForm, UNO_QUERY );
if ( !xDetailFormProps.is() || !xMasterFormProps.is() )
if ( !m_xDetailForm.is() || !m_xMasterForm.is() )
return;
try
{
// only show the button when both forms are based on the same data source
OUString sMasterDS, sDetailDS;
xMasterFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sMasterDS;
xDetailFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDetailDS;
m_xMasterForm->getPropertyValue( PROPERTY_DATASOURCE ) >>= sMasterDS;
m_xDetailForm->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDetailDS;
bool bEnable = ( sMasterDS == sDetailDS );
// only show the button when the connection supports relations
if ( bEnable )
{
Reference< XDatabaseMetaData > xMeta;
getConnectionMetaData( xDetailFormProps, xMeta );
getConnectionMetaData( m_xDetailForm, xMeta );
OSL_ENSURE( xMeta.is(), "FormLinkDialog::initializeSuggest: unable to retrieve the meta data for the connection!" );
try
{
@@ -576,8 +572,8 @@ namespace pcr
Reference< XPropertySet > xDetailTable, xMasterTable;
if ( bEnable )
{
xDetailTable = getCanonicUnderlyingTable( xDetailFormProps );
xMasterTable = getCanonicUnderlyingTable( xMasterFormProps );
xDetailTable = getCanonicUnderlyingTable( m_xDetailForm );
xMasterTable = getCanonicUnderlyingTable( m_xMasterForm );
bEnable = xDetailTable.is() && xMasterTable.is();
}

View File

@@ -510,9 +510,8 @@ namespace pcr
// don't delete explicitly (this is done by the frame we reside in)
m_pView = nullptr;
Reference< XComponent > xViewAsComp( m_xView, UNO_QUERY );
if ( xViewAsComp.is() )
xViewAsComp->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
if ( m_xView.is() )
m_xView->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
m_xView.clear( );
m_aInspectedObjects.clear();
@@ -672,9 +671,8 @@ namespace pcr
// and this disposal _deletes_ the view, so it would be deadly if we use our m_pView member
// after that
m_xView = VCLUnoHelper::GetInterface(m_pView);
Reference< XComponent > xViewAsComp(m_xView, UNO_QUERY);
if (xViewAsComp.is())
xViewAsComp->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
if (m_xView.is())
m_xView->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
getPropertyBox().SetLineListener(this);
getPropertyBox().SetControlObserver(this);

View File

@@ -168,8 +168,8 @@ namespace pcr
try
{
Reference< XPropertySet > xSource( _pSourceType->getUnoDataType(), UNO_QUERY );
Reference< XPropertySet > xDest( getUnoDataType(), UNO_QUERY );
Reference< XPropertySet > xSource = _pSourceType->getUnoDataType();
Reference< XPropertySet > xDest = getUnoDataType();
lcl_copyProperties( xSource, xDest );
}
catch( const Exception& )

View File

@@ -250,13 +250,15 @@ namespace pcr
OUString sOldDataTypeName;
OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_XSD_DATA_TYPE ) >>= sOldDataTypeName );
Reference< XPropertySet > xOldType;
try { xOldType.set(getDataType( sOldDataTypeName ), css::uno::UNO_QUERY); } catch( const Exception& ) { }
try {
xOldType = getDataType( sOldDataTypeName );
} catch( const Exception& ) { }
// set the new data type name
xBinding->setPropertyValue( PROPERTY_XSD_DATA_TYPE, makeAny( _rName ) );
// retrieve the new data type object
Reference< XPropertySet > xNewType( getDataType( _rName ), UNO_QUERY );
Reference< XPropertySet > xNewType = getDataType( _rName );
// fire any changes in the properties which result from this new type
std::set< OUString > aFilter; aFilter.insert( PROPERTY_NAME );