diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-02 10:36:43 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2013-05-22 10:44:29 +0000 |
commit | 6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37 (patch) | |
tree | 2746468845d6f1159e3759ee2cf7a620fca15b6e /framework | |
parent | 697a007c61b9cabceb9767fad87cd5822b300452 (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 'framework')
12 files changed, 35 insertions, 56 deletions
diff --git a/framework/source/fwe/helper/actiontriggerhelper.cxx b/framework/source/fwe/helper/actiontriggerhelper.cxx index 08f01d366d55..67fdd65ff413 100644 --- a/framework/source/fwe/helper/actiontriggerhelper.cxx +++ b/framework/source/fwe/helper/actiontriggerhelper.cxx @@ -100,18 +100,17 @@ void GetMenuItemAttributes( Reference< XPropertySet > xActionTriggerPropertySet, void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, Reference< XIndexContainer > xActionTriggerContainer ) { - Reference< XIndexAccess > xIndexAccess( xActionTriggerContainer, UNO_QUERY ); - if ( xIndexAccess.is() ) + if ( xActionTriggerContainer.is() ) { AddonsOptions aAddonOptions; OUString aSlotURL( "slot:" ); - for ( sal_Int32 i = 0; i < xIndexAccess->getCount(); i++ ) + for ( sal_Int32 i = 0; i < xActionTriggerContainer->getCount(); i++ ) { try { Reference< XPropertySet > xPropSet; - if (( xIndexAccess->getByIndex( i ) >>= xPropSet ) && ( xPropSet.is() )) + if (( xActionTriggerContainer->getByIndex( i ) >>= xPropSet ) && ( xPropSet.is() )) { if ( IsSeparator( xPropSet )) { diff --git a/framework/source/fwe/helper/documentundoguard.cxx b/framework/source/fwe/helper/documentundoguard.cxx index 470eb0285dcd..cec4c0a253a3 100644 --- a/framework/source/fwe/helper/documentundoguard.cxx +++ b/framework/source/fwe/helper/documentundoguard.cxx @@ -56,7 +56,7 @@ namespace framework { public: UndoManagerContextListener( const Reference< XUndoManager >& i_undoManager ) - :m_xUndoManager( i_undoManager, UNO_QUERY_THROW ) + :m_xUndoManager( i_undoManager ) ,m_nRelativeContextDepth( 0 ) ,m_documentDisposed( false ) { diff --git a/framework/source/fwe/xml/menuconfiguration.cxx b/framework/source/fwe/xml/menuconfiguration.cxx index 0f0e894eb69d..3e3600128517 100644 --- a/framework/source/fwe/xml/menuconfiguration.cxx +++ b/framework/source/fwe/xml/menuconfiguration.cxx @@ -82,7 +82,7 @@ throw ( WrappedTargetException ) try { xParser->parseStream( aInputSource ); - return Reference< XIndexAccess >( xItemContainer, UNO_QUERY ); + return xItemContainer; } catch ( const RuntimeException& e ) { @@ -126,8 +126,7 @@ throw ( WrappedTargetException ) try { - Reference< XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW); - OWriteMenuDocumentHandler aWriteMenuDocumentHandler( rMenuBarConfiguration, xHandler ); + OWriteMenuDocumentHandler aWriteMenuDocumentHandler( rMenuBarConfiguration, xWriter ); aWriteMenuDocumentHandler.WriteMenuDocument(); } catch ( const RuntimeException& e ) diff --git a/framework/source/fwe/xml/statusbarconfiguration.cxx b/framework/source/fwe/xml/statusbarconfiguration.cxx index b2a4f8369655..22f2b8ba918e 100644 --- a/framework/source/fwe/xml/statusbarconfiguration.cxx +++ b/framework/source/fwe/xml/statusbarconfiguration.cxx @@ -89,8 +89,7 @@ sal_Bool StatusBarConfiguration::StoreStatusBar( try { - Reference< XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW); - OWriteStatusBarDocumentHandler aWriteStatusBarDocumentHandler( rStatusbarConfiguration, xHandler ); + OWriteStatusBarDocumentHandler aWriteStatusBarDocumentHandler( rStatusbarConfiguration, xWriter ); aWriteStatusBarDocumentHandler.WriteStatusBarDocument(); return sal_True; } diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 0c75daad2c5a..65cf4b7b83a6 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -269,7 +269,7 @@ void LayoutManager::implts_reset( sal_Bool bAttached ) OUString aOldModuleIdentifier( aModuleIdentifier ); try { - aModuleIdentifier = m_xModuleManager->identify( Reference< XInterface >( xFrame, UNO_QUERY ) ); + aModuleIdentifier = m_xModuleManager->identify( xFrame ); } catch( const Exception& ) {} diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index f18152b5ebea..5f03d48f4555 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -216,7 +216,7 @@ BackingWindow::BackingWindow( Window* i_pParent ) : // get dispatch provider Reference<XDesktop2> xDesktop = Desktop::create( comphelper::getProcessComponentContext() ); - mxDesktopDispatchProvider = Reference< XDispatchProvider >( xDesktop, UNO_QUERY ); + mxDesktopDispatchProvider = xDesktop; maWriterButton.SetHelpId( ".HelpId:StartCenter:WriterButton" ); maCalcButton.SetHelpId( ".HelpId:StartCenter:CalcButton" ); diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx index f4d6883cd6f9..5cf8482ced7e 100644 --- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx @@ -243,8 +243,7 @@ void ModuleUIConfigurationManager::impl_preloadUIElementTypeList( Layer eLayer, OUString aResURLPrefix( aBuf.makeStringAndClear() ); UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap; - Reference< XNameAccess > xNameAccess( xElementTypeStorage, UNO_QUERY ); - Sequence< OUString > aUIElementNames = xNameAccess->getElementNames(); + Sequence< OUString > aUIElementNames = xElementTypeStorage->getElementNames(); for ( sal_Int32 n = 0; n < aUIElementNames.getLength(); n++ ) { UIElementData aUIElementData; @@ -513,7 +512,6 @@ void ModuleUIConfigurationManager::impl_resetElementTypeData( UIElementDataHashMap::iterator pIter = rHashMap.begin(); Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY ); sal_Int16 nType = rUserElementType.nElementType; @@ -533,7 +531,7 @@ void ModuleUIConfigurationManager::impl_resetElementTypeData( ConfigurationEvent aReplaceEvent; aReplaceEvent.ResourceURL = rElement.aResourceURL; aReplaceEvent.Accessor <<= xThis; - aReplaceEvent.Source = xIfac; + aReplaceEvent.Source = xThis; aReplaceEvent.ReplacedElement <<= xOldSettings; aReplaceEvent.Element <<= rElement.xSettings; @@ -550,7 +548,7 @@ void ModuleUIConfigurationManager::impl_resetElementTypeData( ConfigurationEvent aEvent; aEvent.ResourceURL = rElement.aResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.Element <<= rElement.xSettings; rRemoveNotifyContainer.push_back( aEvent ); @@ -583,7 +581,6 @@ void ModuleUIConfigurationManager::impl_reloadElementTypeData( Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY ); Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); sal_Int16 nType = rUserElementType.nElementType; while ( pIter != rHashMap.end() ) @@ -602,7 +599,7 @@ void ModuleUIConfigurationManager::impl_reloadElementTypeData( aReplaceEvent.ResourceURL = rElement.aResourceURL; aReplaceEvent.Accessor <<= xThis; - aReplaceEvent.Source = xIfac; + aReplaceEvent.Source = xThis; aReplaceEvent.ReplacedElement <<= xOldSettings; aReplaceEvent.Element <<= rElement.xSettings; rReplaceNotifyContainer.push_back( aReplaceEvent ); @@ -620,7 +617,7 @@ void ModuleUIConfigurationManager::impl_reloadElementTypeData( aReplaceEvent.ResourceURL = rElement.aResourceURL; aReplaceEvent.Accessor <<= xThis; - aReplaceEvent.Source = xIfac; + aReplaceEvent.Source = xThis; aReplaceEvent.ReplacedElement <<= xOldSettings; aReplaceEvent.Element <<= rElement.xSettings; rReplaceNotifyContainer.push_back( aReplaceEvent ); @@ -637,7 +634,7 @@ void ModuleUIConfigurationManager::impl_reloadElementTypeData( aRemoveEvent.ResourceURL = rElement.aResourceURL; aRemoveEvent.Accessor <<= xThis; - aRemoveEvent.Source = xIfac; + aRemoveEvent.Source = xThis; aRemoveEvent.Element <<= rElement.xSettings; rRemoveNotifyContainer.push_back( aRemoveEvent ); @@ -905,8 +902,7 @@ void SAL_CALL ModuleUIConfigurationManager::reset() throw (::com::sun::star::uno if ( xSubStorage.is() ) { bool bCommitSubStorage( false ); - Reference< XNameAccess > xSubStorageNameAccess( xSubStorage, UNO_QUERY ); - Sequence< OUString > aUIElementStreamNames = xSubStorageNameAccess->getElementNames(); + Sequence< OUString > aUIElementStreamNames = xSubStorage->getElementNames(); for ( sal_Int32 j = 0; j < aUIElementStreamNames.getLength(); j++ ) { xSubStorage->removeElement( aUIElementStreamNames[j] ); @@ -1115,11 +1111,9 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la // Create event to notify listener about replaced element settings ConfigurationEvent aEvent; - Reference< XInterface > xIfac( xThis, UNO_QUERY ); - aEvent.ResourceURL = ResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.ReplacedElement <<= xOldSettings; aEvent.Element <<= pDataSettings->xSettings; @@ -1161,14 +1155,13 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la rElements.insert( UIElementDataHashMap::value_type( ResourceURL, aUIElementData )); Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); // Create event to notify listener about replaced element settings ConfigurationEvent aEvent; aEvent.ResourceURL = ResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.ReplacedElement <<= pDataSettings->xSettings; aEvent.Element <<= aUIElementData.xSettings; @@ -1221,7 +1214,6 @@ throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException rElementType.bModified = true; Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); // Check if we have settings in the default layer which replaces the user-defined one! UIElementData* pDefaultDataSettings = impl_findUIElementData( ResourceURL, nElementType ); @@ -1232,7 +1224,7 @@ throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException aEvent.ResourceURL = ResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.Element <<= xRemovedSettings; aEvent.ReplacedElement <<= pDefaultDataSettings->xSettings; @@ -1247,7 +1239,7 @@ throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException aEvent.ResourceURL = ResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.Element <<= xRemovedSettings; aGuard.unlock(); @@ -1305,14 +1297,13 @@ throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings ); Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); // Create event to notify listener about removed element settings ConfigurationEvent aEvent; aEvent.ResourceURL = NewResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.Element <<= xInsertSettings; aGuard.unlock(); @@ -1378,7 +1369,7 @@ Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getShortCutManage lArgs[0] <<= aProp; xInit->initialize(lArgs); - m_xModuleAcceleratorManager = Reference< XInterface >( xManager, UNO_QUERY ); + m_xModuleAcceleratorManager = xManager; } return m_xModuleAcceleratorManager; diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx index c32e2d90c452..51ee1de325f2 100644 --- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx @@ -190,8 +190,7 @@ void UIConfigurationManager::impl_preloadUIElementTypeList( sal_Int16 nElementTy OUString aResURLPrefix( aBuf.makeStringAndClear() ); UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap; - Reference< XNameAccess > xNameAccess( xElementTypeStorage, UNO_QUERY ); - Sequence< OUString > aUIElementNames = xNameAccess->getElementNames(); + Sequence< OUString > aUIElementNames = xElementTypeStorage->getElementNames(); for ( sal_Int32 n = 0; n < aUIElementNames.getLength(); n++ ) { UIElementData aUIElementData; @@ -443,7 +442,6 @@ void UIConfigurationManager::impl_resetElementTypeData( UIElementDataHashMap::iterator pIter = rHashMap.begin(); Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); // Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling // our listeners! @@ -456,7 +454,7 @@ void UIConfigurationManager::impl_resetElementTypeData( ConfigurationEvent aEvent; aEvent.ResourceURL = rElement.aResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.Element <<= rElement.xSettings; rRemoveNotifyContainer.push_back( aEvent ); @@ -483,10 +481,8 @@ void UIConfigurationManager::impl_reloadElementTypeData( UIElementDataHashMap& rHashMap = rDocElementType.aElementsHashMap; UIElementDataHashMap::iterator pIter = rHashMap.begin(); Reference< XStorage > xElementStorage( rDocElementType.xStorage ); - Reference< XNameAccess > xElementNameAccess( xElementStorage, UNO_QUERY ); Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); sal_Int16 nType = rDocElementType.nElementType; while ( pIter != rHashMap.end() ) @@ -494,7 +490,7 @@ void UIConfigurationManager::impl_reloadElementTypeData( UIElementData& rElement = pIter->second; if ( rElement.bModified ) { - if ( xElementNameAccess->hasByName( rElement.aName )) + if ( xElementStorage->hasByName( rElement.aName )) { // Replace settings with data from user layer Reference< XIndexAccess > xOldSettings( rElement.xSettings ); @@ -505,7 +501,7 @@ void UIConfigurationManager::impl_reloadElementTypeData( aReplaceEvent.ResourceURL = rElement.aResourceURL; aReplaceEvent.Accessor <<= xThis; - aReplaceEvent.Source = xIfac; + aReplaceEvent.Source = xThis; aReplaceEvent.ReplacedElement <<= xOldSettings; aReplaceEvent.Element <<= rElement.xSettings; rReplaceNotifyContainer.push_back( aReplaceEvent ); @@ -519,7 +515,7 @@ void UIConfigurationManager::impl_reloadElementTypeData( aRemoveEvent.ResourceURL = rElement.aResourceURL; aRemoveEvent.Accessor <<= xThis; - aRemoveEvent.Source = xIfac; + aRemoveEvent.Source = xThis; aRemoveEvent.Element <<= rElement.xSettings; rRemoveNotifyContainer.push_back( aRemoveEvent ); @@ -694,8 +690,7 @@ void SAL_CALL UIConfigurationManager::reset() throw (::com::sun::star::uno::Runt if ( xSubStorage.is() ) { bool bCommitSubStorage( false ); - Reference< XNameAccess > xSubStorageNameAccess( xSubStorage, UNO_QUERY ); - Sequence< OUString > aUIElementStreamNames = xSubStorageNameAccess->getElementNames(); + Sequence< OUString > aUIElementStreamNames = xSubStorage->getElementNames(); for ( sal_Int32 j = 0; j < aUIElementStreamNames.getLength(); j++ ) { xSubStorage->removeElement( aUIElementStreamNames[j] ); @@ -895,11 +890,10 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la // Create event to notify listener about replaced element settings ConfigurationEvent aEvent; - Reference< XInterface > xIfac( xThis, UNO_QUERY ); aEvent.ResourceURL = ResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.ReplacedElement <<= xOldSettings; aEvent.Element <<= pDataSettings->xSettings; @@ -950,14 +944,13 @@ throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException rElementType.bModified = true; Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); // Create event to notify listener about removed element settings ConfigurationEvent aEvent; aEvent.ResourceURL = ResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.Element <<= xRemovedSettings; aGuard.unlock(); @@ -1027,14 +1020,13 @@ throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings ); Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XInterface > xIfac( xThis, UNO_QUERY ); // Create event to notify listener about removed element settings ConfigurationEvent aEvent; aEvent.ResourceURL = NewResourceURL; aEvent.Accessor <<= xThis; - aEvent.Source = xIfac; + aEvent.Source = xThis; aEvent.Element <<= xInsertSettings; aGuard.unlock(); diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 05f15ba3fb2c..fdbb17ba8634 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -1969,7 +1969,7 @@ IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu ) try { xItemContainer->replaceByIndex( i, makeAny( aProp )); - xUIElementSettings->setSettings( Reference< XIndexAccess >( xItemContainer, UNO_QUERY )); + xUIElementSettings->setSettings( xItemContainer ); Reference< XPropertySet > xPropSet( xUIElementSettings, UNO_QUERY ); if ( xPropSet.is() ) { diff --git a/framework/source/uifactory/menubarfactory.cxx b/framework/source/uifactory/menubarfactory.cxx index 6cf90ce300e8..ef24e5567ae0 100644 --- a/framework/source/uifactory/menubarfactory.cxx +++ b/framework/source/uifactory/menubarfactory.cxx @@ -147,7 +147,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL if ( !bHasSettings ) { - OUString aModuleIdentifier = _xModuleManager->identify( Reference< XInterface >( xFrame, UNO_QUERY )); + OUString aModuleIdentifier = _xModuleManager->identify( xFrame ); if ( !aModuleIdentifier.isEmpty() ) { Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier = diff --git a/framework/source/uifactory/uielementfactorymanager.cxx b/framework/source/uifactory/uielementfactorymanager.cxx index 8669247b9b86..cf3237ac76eb 100644 --- a/framework/source/uifactory/uielementfactorymanager.cxx +++ b/framework/source/uifactory/uielementfactorymanager.cxx @@ -436,7 +436,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::l try { if ( xFrame.is() && xManager.is() ) - aModuleId = xManager->identify( Reference< XInterface >( xFrame, UNO_QUERY ) ); + aModuleId = xManager->identify( xFrame ); Reference< XUIElementFactory > xUIElementFactory = getFactory( ResourceURL, aModuleId ); if ( xUIElementFactory.is() ) diff --git a/framework/source/xml/imagesconfiguration.cxx b/framework/source/xml/imagesconfiguration.cxx index 5325dcb512f8..31bd8e6df753 100644 --- a/framework/source/xml/imagesconfiguration.cxx +++ b/framework/source/xml/imagesconfiguration.cxx @@ -90,8 +90,7 @@ sal_Bool ImagesConfiguration::StoreImages( try { - Reference< XDocumentHandler > xHandler( xWriter, UNO_QUERY_THROW ); - OWriteImagesDocumentHandler aWriteImagesDocumentHandler( rItems, xHandler ); + OWriteImagesDocumentHandler aWriteImagesDocumentHandler( rItems, xWriter ); aWriteImagesDocumentHandler.WriteImagesDocument(); return sal_True; } |