summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-05-02 10:36:43 +0200
committerNoel Grandin <noelgrandin@gmail.com>2013-05-22 10:44:29 +0000
commit6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37 (patch)
tree2746468845d6f1159e3759ee2cf7a620fca15b6e /dbaccess
parent697a007c61b9cabceb9767fad87cd5822b300452 (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 'dbaccess')
-rw-r--r--dbaccess/source/core/dataaccess/ModelImpl.cxx6
-rw-r--r--dbaccess/source/core/dataaccess/connection.cxx2
-rw-r--r--dbaccess/source/core/dataaccess/datasource.cxx6
-rw-r--r--dbaccess/source/core/dataaccess/documentdefinition.cxx9
-rw-r--r--dbaccess/source/core/recovery/subcomponentloader.cxx4
-rw-r--r--dbaccess/source/ext/macromigration/migrationengine.cxx6
-rw-r--r--dbaccess/source/ui/app/subcomponentmanager.cxx5
-rw-r--r--dbaccess/source/ui/browser/exsrcbrw.cxx15
-rw-r--r--dbaccess/source/ui/dlg/dbwizsetup.cxx3
9 files changed, 23 insertions, 33 deletions
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index e015e7cbfa78..e269f19ec7c8 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -223,8 +223,7 @@ Reference< XStorage > DocumentStorageAccess::impl_openSubStorage_nothrow( const
sal_Int32 nRealMode = m_pModelImplementation->m_bDocumentReadOnly ? ElementModes::READ : _nDesiredMode;
if ( nRealMode == ElementModes::READ )
{
- Reference< XNameAccess > xSubStorageNames( xRootStorage, UNO_QUERY );
- if ( xSubStorageNames.is() && !xSubStorageNames->hasByName( _rStorageName ) )
+ if ( xRootStorage.is() && !xRootStorage->hasByName( _rStorageName ) )
return xStorage;
}
@@ -331,8 +330,7 @@ Sequence< OUString > SAL_CALL DocumentStorageAccess::getDocumentSubStoragesNames
::std::vector< OUString > aNames;
- Reference< XNameAccess > xNames( xRootStor, UNO_QUERY_THROW );
- Sequence< OUString > aElementNames( xNames->getElementNames() );
+ Sequence< OUString > aElementNames( xRootStor->getElementNames() );
for ( sal_Int32 i=0; i<aElementNames.getLength(); ++i )
{
if ( xRootStor->isStorageElement( aElementNames[i] ) )
diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx
index 8691098954ef..3f70b12d9706 100644
--- a/dbaccess/source/core/dataaccess/connection.cxx
+++ b/dbaccess/source/core/dataaccess/connection.cxx
@@ -694,7 +694,7 @@ Reference< XInterface > SAL_CALL OConnection::createInstance( const OUString& _s
return aFind->second;
}
}
- return Reference< XInterface >(xRet,UNO_QUERY);
+ return xRet;
}
Reference< XInterface > SAL_CALL OConnection::createInstanceWithArguments( const OUString& _sServiceSpecifier, const Sequence< Any >& /*Arguments*/ ) throw (Exception, RuntimeException)
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index 2b3147b82120..d8e24d7b6f83 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -895,12 +895,10 @@ namespace
try
{
// obtain all properties currently known at the bag
- Reference< XPropertySet > xPropertySet( _rxPropertyBag, UNO_QUERY_THROW );
- Reference< XPropertySetInfo > xPSI( xPropertySet->getPropertySetInfo(), UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPSI( _rxPropertyBag->getPropertySetInfo(), UNO_QUERY_THROW );
Sequence< Property > aAllExistentProperties( xPSI->getProperties() );
Reference< XPropertyState > xPropertyState( _rxPropertyBag, UNO_QUERY_THROW );
- Reference< XPropertyContainer > xPropertyContainer( _rxPropertyBag, UNO_QUERY_THROW );
// loop through them, and reset resp. default properties which are not to be set
const Property* pExistentProperty( aAllExistentProperties.getConstArray() );
@@ -913,7 +911,7 @@ namespace
// this property is not to be set, but currently exists in the bag.
// -> Remove it, or reset it to the default.
if ( ( pExistentProperty->Attributes & PropertyAttribute::REMOVABLE ) != 0 )
- xPropertyContainer->removeProperty( pExistentProperty->Name );
+ _rxPropertyBag->removeProperty( pExistentProperty->Name );
else
xPropertyState->setPropertyToDefault( pExistentProperty->Name );
}
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx
index 6ea9709132e2..1e9b62c87ef2 100644
--- a/dbaccess/source/core/dataaccess/documentdefinition.cxx
+++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx
@@ -150,9 +150,8 @@ namespace dbaccess
OUString sContentType;
try
{
- Reference< XStorage > xContainerStorage( _rxContainerStorage, UNO_QUERY_THROW );
::utl::SharedUNOComponent< XPropertySet > xStorageProps(
- xContainerStorage->openStorageElement( _rEntityName, ElementModes::READ ), UNO_QUERY_THROW );
+ _rxContainerStorage->openStorageElement( _rEntityName, ElementModes::READ ), UNO_QUERY_THROW );
OSL_VERIFY( xStorageProps->getPropertyValue( INFO_MEDIATYPE ) >>= sContentType );
}
catch( const Exception& )
@@ -1170,8 +1169,7 @@ namespace
{
try
{
- Reference< XComponentSupplier > xCompProv( _rxEmbeddedObject, UNO_QUERY_THROW );
- Reference< XDrawPageSupplier > xSuppPage( xCompProv->getComponent(), UNO_QUERY_THROW );
+ Reference< XDrawPageSupplier > xSuppPage( _rxEmbeddedObject->getComponent(), UNO_QUERY_THROW );
// if this interface does not exist, then either getComponent returned NULL,
// or the document is a multi-page document. The latter is allowed, but currently
// simply not handled by this code, as it would not normally happen.
@@ -1390,8 +1388,7 @@ sal_Bool ODocumentDefinition::saveAs()
Reference< XStorage> xStorage = getContainerStorage();
const static OUString sBaseName("Obj");
- Reference<XNameAccess> xElements(xStorage,UNO_QUERY_THROW);
- OUString sPersistentName = ::dbtools::createUniqueName(xElements,sBaseName);
+ OUString sPersistentName = ::dbtools::createUniqueName(xStorage,sBaseName);
xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xStorage,sPersistentName);
OUString sOldName = m_pImpl->m_aProps.aTitle;
diff --git a/dbaccess/source/core/recovery/subcomponentloader.cxx b/dbaccess/source/core/recovery/subcomponentloader.cxx
index 85ae960dea4a..5dd294daa6c2 100644
--- a/dbaccess/source/core/recovery/subcomponentloader.cxx
+++ b/dbaccess/source/core/recovery/subcomponentloader.cxx
@@ -61,14 +61,14 @@ namespace dbaccess
Reference< XWindow > xAppComponentWindow;
SubComponentLoader_Data( const Reference< XCommandProcessor >& i_rDocumentDefinition )
- :xDocDefCommands( i_rDocumentDefinition, UNO_SET_THROW )
+ :xDocDefCommands( i_rDocumentDefinition )
,xNonDocComponent()
{
}
SubComponentLoader_Data( const Reference< XComponent >& i_rNonDocumentComponent )
:xDocDefCommands()
- ,xNonDocComponent( i_rNonDocumentComponent, UNO_SET_THROW )
+ ,xNonDocComponent( i_rNonDocumentComponent )
{
}
};
diff --git a/dbaccess/source/ext/macromigration/migrationengine.cxx b/dbaccess/source/ext/macromigration/migrationengine.cxx
index 7c5a37df3721..85d2aed7b08e 100644
--- a/dbaccess/source/ext/macromigration/migrationengine.cxx
+++ b/dbaccess/source/ext/macromigration/migrationengine.cxx
@@ -523,8 +523,8 @@ namespace dbmm
const Reference< XEventAttacherManager >& _rxManager,
const sal_Int32 _nIndex
)
- :m_xComponent( _rxComponent, UNO_SET_THROW )
- ,m_xManager( _rxManager, UNO_SET_THROW )
+ :m_xComponent( _rxComponent )
+ ,m_xManager( _rxManager )
,m_nIndex( _nIndex )
{
}
@@ -557,7 +557,7 @@ namespace dbmm
{
public:
FormComponentIterator( const Reference< XIndexAccess >& _rxContainer )
- :m_xContainer( _rxContainer, UNO_SET_THROW )
+ :m_xContainer( _rxContainer )
,m_xEventManager( _rxContainer, UNO_QUERY_THROW )
,m_nElementCount( _rxContainer->getCount() )
,m_nCurrentElement( 0 )
diff --git a/dbaccess/source/ui/app/subcomponentmanager.cxx b/dbaccess/source/ui/app/subcomponentmanager.cxx
index 5ed65de095ee..24b20c388877 100644
--- a/dbaccess/source/ui/app/subcomponentmanager.cxx
+++ b/dbaccess/source/ui/app/subcomponentmanager.cxx
@@ -290,12 +290,11 @@ namespace dbaui
bool bSuccess = false;
try
{
- Reference< XCommandProcessor > xCommandProcessor( _rxCommandProcessor, UNO_SET_THROW );
- sal_Int32 nCommandIdentifier = xCommandProcessor->createCommandIdentifier();
+ sal_Int32 nCommandIdentifier = _rxCommandProcessor->createCommandIdentifier();
Command aCommand;
aCommand.Name = OUString( "close" );
- xCommandProcessor->execute( aCommand, nCommandIdentifier, NULL );
+ _rxCommandProcessor->execute( aCommand, nCommandIdentifier, NULL );
bSuccess = true;
}
catch( const Exception& )
diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx b/dbaccess/source/ui/browser/exsrcbrw.cxx
index 7ae47ed6f318..b45555b18fb7 100644
--- a/dbaccess/source/ui/browser/exsrcbrw.cxx
+++ b/dbaccess/source/ui/browser/exsrcbrw.cxx
@@ -347,7 +347,6 @@ void SbaExternalSourceBrowser::Attach(const Reference< XRowSet > & xMaster)
sal_Bool bWasInsertRow = sal_False;
sal_Bool bBeforeFirst = sal_True;
sal_Bool bAfterLast = sal_True;
- Reference< XResultSet > xResultSet(xMaster, UNO_QUERY);
Reference< XRowLocate > xCursor(xMaster, UNO_QUERY);
Reference< XPropertySet > xMasterProps(xMaster, UNO_QUERY);
@@ -359,10 +358,10 @@ void SbaExternalSourceBrowser::Attach(const Reference< XRowSet > & xMaster)
// the grid will move the form's cursor to the first record, but we want the form to remain unchanged
// restore the old position
- if (xCursor.is() && xResultSet.is())
+ if (xCursor.is() && xMaster.is())
{
- bBeforeFirst = xResultSet->isBeforeFirst();
- bAfterLast = xResultSet->isAfterLast();
+ bBeforeFirst = xMaster->isBeforeFirst();
+ bAfterLast = xMaster->isAfterLast();
if(!bBeforeFirst && !bAfterLast)
aOldPos = xCursor->getBookmark();
}
@@ -402,10 +401,10 @@ void SbaExternalSourceBrowser::Attach(const Reference< XRowSet > & xMaster)
xUpdate->moveToInsertRow();
else if (xCursor.is() && aOldPos.hasValue())
xCursor->moveToBookmark(aOldPos);
- else if(bBeforeFirst && xResultSet.is())
- xResultSet->beforeFirst();
- else if(bAfterLast && xResultSet.is())
- xResultSet->afterLast();
+ else if(bBeforeFirst && xMaster.is())
+ xMaster->beforeFirst();
+ else if(bAfterLast && xMaster.is())
+ xMaster->afterLast();
}
catch(Exception&)
{
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index e16813fc2b31..2679257de5f3 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -853,10 +853,9 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument()
{
Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
Reference< XDatabaseContext > xDatabaseContext( DatabaseContext::create(getORB()) );
- Reference< XNameAccess > xNameAccessDatabaseContext(xDatabaseContext, UNO_QUERY_THROW );
INetURLObject aURL( _sPath );
OUString sFilename = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
- OUString sDatabaseName = ::dbtools::createUniqueName(xNameAccessDatabaseContext, sFilename,sal_False);
+ OUString sDatabaseName = ::dbtools::createUniqueName(xDatabaseContext, sFilename,sal_False);
xDatabaseContext->registerObject(sDatabaseName, xDatasource);
}