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; Reference< XInteractionHandler > xInteractions;
try try
{ {
xInteractions.set( xInteractions = InteractionHandler::createWithParent(m_pImpl->xORB, nullptr);
InteractionHandler::createWithParent(m_pImpl->xORB, nullptr),
UNO_QUERY);
} }
catch(const Exception&) catch(const Exception&)
{ {

View File

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

View File

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

View File

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

View File

@@ -281,7 +281,7 @@ namespace dbp
void OControlWizard::implDetermineShape() 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!"); DBG_ASSERT(xPageObjects.is(), "OControlWizard::implDetermineShape: invalid page!");
// for comparing the model // for comparing the model

View File

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

View File

@@ -209,11 +209,10 @@ namespace pcr
// and set as property values // and set as property values
try try
{ {
Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY ); if ( m_xDetailForm.is() )
if ( xDetailFormProps.is() )
{ {
xDetailFormProps->setPropertyValue( PROPERTY_DETAILFIELDS, makeAny( Sequence< OUString >( aDetailFields.data(), aDetailFields.size() ) ) ); m_xDetailForm->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_MASTERFIELDS, makeAny( Sequence< OUString >( aMasterFields.data(), aMasterFields.size() ) ) );
} }
} }
catch( const Exception& ) catch( const Exception& )
@@ -303,11 +302,10 @@ namespace pcr
Sequence< OUString > aDetailFields; Sequence< OUString > aDetailFields;
Sequence< OUString > aMasterFields; Sequence< OUString > aMasterFields;
Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY ); if ( m_xDetailForm.is() )
if ( xDetailFormProps.is() )
{ {
xDetailFormProps->getPropertyValue( PROPERTY_DETAILFIELDS ) >>= aDetailFields; m_xDetailForm->getPropertyValue( PROPERTY_DETAILFIELDS ) >>= aDetailFields;
xDetailFormProps->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields; m_xDetailForm->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields;
} }
std::vector< OUString > aDetailFields1; std::vector< OUString > aDetailFields1;
@@ -543,24 +541,22 @@ namespace pcr
void FormLinkDialog::initializeSuggest() void FormLinkDialog::initializeSuggest()
{ {
Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY ); if ( !m_xDetailForm.is() || !m_xMasterForm.is() )
Reference< XPropertySet > xMasterFormProps( m_xMasterForm, UNO_QUERY );
if ( !xDetailFormProps.is() || !xMasterFormProps.is() )
return; return;
try try
{ {
// only show the button when both forms are based on the same data source // only show the button when both forms are based on the same data source
OUString sMasterDS, sDetailDS; OUString sMasterDS, sDetailDS;
xMasterFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sMasterDS; m_xMasterForm->getPropertyValue( PROPERTY_DATASOURCE ) >>= sMasterDS;
xDetailFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDetailDS; m_xDetailForm->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDetailDS;
bool bEnable = ( sMasterDS == sDetailDS ); bool bEnable = ( sMasterDS == sDetailDS );
// only show the button when the connection supports relations // only show the button when the connection supports relations
if ( bEnable ) if ( bEnable )
{ {
Reference< XDatabaseMetaData > xMeta; 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!" ); OSL_ENSURE( xMeta.is(), "FormLinkDialog::initializeSuggest: unable to retrieve the meta data for the connection!" );
try try
{ {
@@ -576,8 +572,8 @@ namespace pcr
Reference< XPropertySet > xDetailTable, xMasterTable; Reference< XPropertySet > xDetailTable, xMasterTable;
if ( bEnable ) if ( bEnable )
{ {
xDetailTable = getCanonicUnderlyingTable( xDetailFormProps ); xDetailTable = getCanonicUnderlyingTable( m_xDetailForm );
xMasterTable = getCanonicUnderlyingTable( xMasterFormProps ); xMasterTable = getCanonicUnderlyingTable( m_xMasterForm );
bEnable = xDetailTable.is() && xMasterTable.is(); 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) // don't delete explicitly (this is done by the frame we reside in)
m_pView = nullptr; m_pView = nullptr;
Reference< XComponent > xViewAsComp( m_xView, UNO_QUERY ); if ( m_xView.is() )
if ( xViewAsComp.is() ) m_xView->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
xViewAsComp->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
m_xView.clear( ); m_xView.clear( );
m_aInspectedObjects.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 // and this disposal _deletes_ the view, so it would be deadly if we use our m_pView member
// after that // after that
m_xView = VCLUnoHelper::GetInterface(m_pView); m_xView = VCLUnoHelper::GetInterface(m_pView);
Reference< XComponent > xViewAsComp(m_xView, UNO_QUERY); if (m_xView.is())
if (xViewAsComp.is()) m_xView->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
xViewAsComp->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
getPropertyBox().SetLineListener(this); getPropertyBox().SetLineListener(this);
getPropertyBox().SetControlObserver(this); getPropertyBox().SetControlObserver(this);

View File

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

View File

@@ -250,13 +250,15 @@ namespace pcr
OUString sOldDataTypeName; OUString sOldDataTypeName;
OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_XSD_DATA_TYPE ) >>= sOldDataTypeName ); OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_XSD_DATA_TYPE ) >>= sOldDataTypeName );
Reference< XPropertySet > xOldType; 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 // set the new data type name
xBinding->setPropertyValue( PROPERTY_XSD_DATA_TYPE, makeAny( _rName ) ); xBinding->setPropertyValue( PROPERTY_XSD_DATA_TYPE, makeAny( _rName ) );
// retrieve the new data type object // 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 // fire any changes in the properties which result from this new type
std::set< OUString > aFilter; aFilter.insert( PROPERTY_NAME ); std::set< OUString > aFilter; aFilter.insert( PROPERTY_NAME );