diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-20 13:29:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-21 08:49:01 +0200 |
commit | 17db60eb46b31b6e4b7e664b01e6f7bb6a3016ab (patch) | |
tree | a2f64eca956aa2daf0e74de31bc2d419f769f2c0 | |
parent | 8a3912c8eb25d1acacbc0a18355f2ca75d418908 (diff) |
loplugin:referencecasting in slideshow..svtools
Change-Id: Id0f0332d5d66c0bce309643bf42059b9bdc7d448
Reviewed-on: https://gerrit.libreoffice.org/75997
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | slideshow/source/engine/opengl/TransitionerImpl.cxx | 2 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/shapeimporter.cxx | 4 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/viewmediashape.cxx | 9 | ||||
-rw-r--r-- | slideshow/source/engine/slide/slideimpl.cxx | 3 | ||||
-rw-r--r-- | slideshow/source/engine/slideshowimpl.cxx | 7 | ||||
-rw-r--r-- | slideshow/source/engine/soundplayer.cxx | 5 | ||||
-rw-r--r-- | starmath/source/document.cxx | 5 | ||||
-rw-r--r-- | starmath/source/mathmlexport.cxx | 6 | ||||
-rw-r--r-- | starmath/source/mathmlimport.cxx | 5 | ||||
-rw-r--r-- | starmath/source/view.cxx | 5 | ||||
-rw-r--r-- | stoc/source/inspect/introspection.cxx | 12 | ||||
-rw-r--r-- | svl/source/fsstor/fsstorage.cxx | 5 | ||||
-rw-r--r-- | svtools/source/dialogs/ServerDetailsControls.cxx | 9 | ||||
-rw-r--r-- | svtools/source/dialogs/addresstemplate.cxx | 2 | ||||
-rw-r--r-- | svtools/source/misc/embedhlp.cxx | 38 | ||||
-rw-r--r-- | svtools/source/uno/framestatuslistener.cxx | 11 | ||||
-rw-r--r-- | svtools/source/uno/statusbarcontroller.cxx | 8 |
17 files changed, 54 insertions, 82 deletions
diff --git a/slideshow/source/engine/opengl/TransitionerImpl.cxx b/slideshow/source/engine/opengl/TransitionerImpl.cxx index 461b00c0053f..f66d1402ee24 100644 --- a/slideshow/source/engine/opengl/TransitionerImpl.cxx +++ b/slideshow/source/engine/opengl/TransitionerImpl.cxx @@ -298,7 +298,7 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta if (isDisposed()) return false; - mxView.set( xView, UNO_QUERY ); + mxView = xView; if( !mxView.is() ) return false; diff --git a/slideshow/source/engine/shapes/shapeimporter.cxx b/slideshow/source/engine/shapes/shapeimporter.cxx index 67cd654f3e63..619da5d4af1c 100644 --- a/slideshow/source/engine/shapes/shapeimporter.cxx +++ b/slideshow/source/engine/shapes/shapeimporter.cxx @@ -361,9 +361,7 @@ bool ShapeImporter::isSkip( if(xLayer.is()) { OUString layerName; - uno::Reference<beans::XPropertySet> xPropLayerSet( - xLayer, uno::UNO_QUERY ); - const uno::Any& a(xPropLayerSet->getPropertyValue("Name") ); + const uno::Any& a(xLayer->getPropertyValue("Name") ); bool const bRet = (a >>= layerName); if(bRet) { diff --git a/slideshow/source/engine/shapes/viewmediashape.cxx b/slideshow/source/engine/shapes/viewmediashape.cxx index e966709df748..491b773fde02 100644 --- a/slideshow/source/engine/shapes/viewmediashape.cxx +++ b/slideshow/source/engine/shapes/viewmediashape.cxx @@ -127,11 +127,7 @@ namespace slideshow // shutdown player window if( mxPlayerWindow.is() ) { - uno::Reference< lang::XComponent > xComponent( mxPlayerWindow, uno::UNO_QUERY ); - - if( xComponent.is() ) - xComponent->dispose(); - + mxPlayerWindow->dispose(); mxPlayerWindow.clear(); } @@ -382,8 +378,7 @@ namespace slideshow { if( !rMediaURL.isEmpty() ) { - mxPlayer.set( avmedia::MediaWindow::createPlayer( rMediaURL, ""/*TODO!*/, &rMimeType ), - uno::UNO_QUERY ); + mxPlayer = avmedia::MediaWindow::createPlayer( rMediaURL, ""/*TODO!*/, &rMimeType ); } } catch( uno::RuntimeException& ) diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index 4d74c69804fa..13b1181f48c9 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -980,8 +980,7 @@ bool SlideImpl::loadShapes() if( xMasterPageTarget.is() ) { xMasterPage = xMasterPageTarget->getMasterPage(); - xMasterPageShapes.set( xMasterPage, - uno::UNO_QUERY ); + xMasterPageShapes = xMasterPage; if( xMasterPage.is() && xMasterPageShapes.is() ) { diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx index e1ba69e398d9..b3d21f3fff3a 100644 --- a/slideshow/source/engine/slideshowimpl.cxx +++ b/slideshow/source/engine/slideshowimpl.cxx @@ -1410,20 +1410,19 @@ void SlideShowImpl::registerUserPaintPolygons( const uno::Reference< lang::XMult uno::Reference< drawing::XLayerManager > xLayerManager(xNameAccess, uno::UNO_QUERY); // create a layer and set its properties uno::Reference< drawing::XLayer > xDrawnInSlideshow = xLayerManager->insertNewByIndex(xLayerManager->getCount()); - uno::Reference< beans::XPropertySet > xLayerPropSet(xDrawnInSlideshow, uno::UNO_QUERY); //Layer Name which enables to catch annotations OUString layerName = "DrawnInSlideshow"; uno::Any aPropLayer; aPropLayer <<= layerName; - xLayerPropSet->setPropertyValue("Name", aPropLayer); + xDrawnInSlideshow->setPropertyValue("Name", aPropLayer); aPropLayer <<= true; - xLayerPropSet->setPropertyValue("IsVisible", aPropLayer); + xDrawnInSlideshow->setPropertyValue("IsVisible", aPropLayer); aPropLayer <<= false; - xLayerPropSet->setPropertyValue("IsLocked", aPropLayer); + xDrawnInSlideshow->setPropertyValue("IsLocked", aPropLayer); //Register polygons for each slide for( const auto& rPoly : maPolygons ) diff --git a/slideshow/source/engine/soundplayer.cxx b/slideshow/source/engine/soundplayer.cxx index 18a1948089f9..5a602ac921bc 100644 --- a/slideshow/source/engine/soundplayer.cxx +++ b/slideshow/source/engine/soundplayer.cxx @@ -104,9 +104,8 @@ namespace slideshow mpMediaTempFile = rMediaFileManager.getMediaTempFile(rSoundURL); } const INetURLObject aURL( mpMediaTempFile ? mpMediaTempFile->m_TempFileURL : rSoundURL ); - mxPlayer.set( avmedia::MediaWindow::createPlayer( - aURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ), ""/*TODO!*/ ), - uno::UNO_QUERY); + mxPlayer = avmedia::MediaWindow::createPlayer( + aURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ), ""/*TODO!*/ ); } catch( uno::RuntimeException& ) { diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index da0411cbd974..b8222e2c0a02 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -717,14 +717,13 @@ bool SmDocShell::Load( SfxMedium& rMedium ) if( SfxObjectShell::Load( rMedium )) { uno::Reference < embed::XStorage > xStorage = GetMedium()->GetStorage(); - uno::Reference < container::XNameAccess > xAccess (xStorage, uno::UNO_QUERY); if ( ( - xAccess->hasByName( "content.xml" ) && + xStorage->hasByName( "content.xml" ) && xStorage->isStreamElement( "content.xml" ) ) || ( - xAccess->hasByName( "Content.xml" ) && + xStorage->hasByName( "Content.xml" ) && xStorage->isStreamElement( "Content.xml" ) ) ) diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index e5523c7ed122..aa850f62f29b 100644 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -95,7 +95,7 @@ bool SmXMLExportWrapper::Export(SfxMedium &rMedium) uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext()); //Get model - uno::Reference< lang::XComponent > xModelComp(xModel, uno::UNO_QUERY ); + uno::Reference< lang::XComponent > xModelComp = xModel; bool bEmbedded = false; uno::Reference <lang::XUnoTunnel> xTunnel(xModel,uno::UNO_QUERY); @@ -263,10 +263,8 @@ bool SmXMLExportWrapper::WriteThroughComponent( xSaxWriter->setOutputStream( xOutputStream ); // prepare arguments (prepend doc handler to given arguments) - Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY); - Sequence<Any> aArgs( 2 ); - aArgs[0] <<= xDocHandler; + aArgs[0] <<= xSaxWriter; aArgs[1] <<= rPropSet; // get filter component diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index 4f9510aaac12..fcc4a6c45bd4 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -100,7 +100,7 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium &rMedium) uno::Reference<uno::XComponentContext> xContext( comphelper::getProcessComponentContext() ); //Make a model component from our SmModel - uno::Reference< lang::XComponent > xModelComp( xModel, uno::UNO_QUERY ); + uno::Reference< lang::XComponent > xModelComp = xModel; OSL_ENSURE( xModelComp.is(), "XMLReader::Read: got no model" ); // try to get an XStatusIndicator from the Medium @@ -366,8 +366,7 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent( // open stream (and set parser input) OUString sStreamName = OUString::createFromAscii(pStreamName); - uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY ); - if ( !xAccess->hasByName(sStreamName) || !xStorage->isStreamElement(sStreamName) ) + if ( !xStorage->hasByName(sStreamName) || !xStorage->isStreamElement(sStreamName) ) { // stream name not found! Then try the compatibility name. // do we even have an alternative name? diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 96874023c9dc..195b4506bd54 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1330,10 +1330,9 @@ void SmViewShell::Insert( SfxMedium& rMedium ) bool bRet = false; uno::Reference <embed::XStorage> xStorage = rMedium.GetStorage(); - uno::Reference <container::XNameAccess> xNameAccess(xStorage, uno::UNO_QUERY); - if (xNameAccess.is() && xNameAccess->getElementNames().hasElements()) + if (xStorage.is() && xStorage->getElementNames().hasElements()) { - if (xNameAccess->hasByName("content.xml") || xNameAccess->hasByName("Content.xml")) + if (xStorage->hasByName("content.xml") || xStorage->hasByName("Content.xml")) { // is this a fabulous math package ? Reference<css::frame::XModel> xModel(pDoc->GetModel()); diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index 2637c7ede5dc..79df9d25a542 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -813,13 +813,13 @@ void ImplIntrospectionAccess::cacheXNameContainer() if (mpStaticImpl->mbNameContainer) { xNameContainer.set( mxIface, UNO_QUERY ); - xNameReplace.set( xNameContainer, UNO_QUERY ); - xNameAccess.set( xNameContainer, UNO_QUERY ); + xNameReplace = xNameContainer; + xNameAccess = xNameContainer; } else if (mpStaticImpl->mbNameReplace) { xNameReplace.set( mxIface, UNO_QUERY ); - xNameAccess.set( xNameReplace, UNO_QUERY ); + xNameAccess = xNameReplace; } else if (mpStaticImpl->mbNameAccess) { @@ -881,13 +881,13 @@ void ImplIntrospectionAccess::cacheXIndexContainer() if (mpStaticImpl->mbIndexContainer) { xIndexContainer.set( mxIface, UNO_QUERY ); - xIndexReplace.set( xIndexContainer, UNO_QUERY ); - xIndexAccess.set( xIndexContainer, UNO_QUERY ); + xIndexReplace = xIndexContainer; + xIndexAccess = xIndexContainer; } else if (mpStaticImpl->mbIndexReplace) { xIndexReplace.set( mxIface, UNO_QUERY ); - xIndexAccess.set( xIndexReplace, UNO_QUERY ); + xIndexAccess = xIndexReplace; } else if (mpStaticImpl->mbIndexAccess) { diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx index 344553b67c5f..6ba2a66baf3b 100644 --- a/svl/source/fsstor/fsstorage.cxx +++ b/svl/source/fsstor/fsstorage.cxx @@ -453,10 +453,7 @@ uno::Reference< embed::XStorage > SAL_CALL FSStorage::openStorageElement( throw io::IOException(); // there is no such folder ::ucbhelper::Content aResultContent( aFolderURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xDummyEnv, comphelper::getProcessComponentContext() ); - xResult.set( static_cast< OWeakObject* >( new FSStorage( aResultContent, - nStorageMode, - m_pImpl->m_xContext ) ), - uno::UNO_QUERY ); + xResult = new FSStorage( aResultContent, nStorageMode, m_pImpl->m_xContext ); } catch( embed::InvalidStorageException& ) { diff --git a/svtools/source/dialogs/ServerDetailsControls.cxx b/svtools/source/dialogs/ServerDetailsControls.cxx index 9011f4784136..e63aeae088cc 100644 --- a/svtools/source/dialogs/ServerDetailsControls.cxx +++ b/svtools/source/dialogs/ServerDetailsControls.cxx @@ -285,8 +285,8 @@ CmisDetailsContainer::CmisDetailsContainer(PlaceEditDialog* pParentDialog, OUStr m_xParentDialog(pParentDialog->getDialog()->GetXWindow()) { Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - Reference< XInteractionHandler > xGlobalInteractionHandler( - InteractionHandler::createWithParent(xContext, m_xParentDialog), UNO_QUERY); + Reference< XInteractionHandler > xGlobalInteractionHandler = + InteractionHandler::createWithParent(xContext, m_xParentDialog); m_xCmdEnv = new ucbhelper::CommandEnvironment( xGlobalInteractionHandler, Reference< XProgressHandler >() ); set_visible( false ); @@ -435,9 +435,8 @@ IMPL_LINK_NOARG( CmisDetailsContainer, RefreshReposHdl, weld::Button&, void ) { if( !sUrl.isEmpty() && !m_sUsername.isEmpty() && !m_sPassword.isEmpty() ) { - Reference< XInteractionHandler > xInteractionHandler( - InteractionHandler::createWithParent(xContext, m_xParentDialog), - UNO_QUERY ); + Reference< XInteractionHandler > xInteractionHandler = + InteractionHandler::createWithParent(xContext, m_xParentDialog); Sequence<OUString> aPasswd { m_sPassword }; diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index 84606e549750..8e5b6ea9b229 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -780,7 +780,7 @@ void AssignmentPersistentData::ImplCommit() Reference< XTablesSupplier > xSupplTables(xConn, UNO_QUERY); if (xSupplTables.is()) { - m_xCurrentDatasourceTables.set(xSupplTables->getTables(), UNO_QUERY); + m_xCurrentDatasourceTables = xSupplTables->getTables(); if (m_xCurrentDatasourceTables.is()) aTableNames = m_xCurrentDatasourceTables->getElementNames(); } diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index 0e7728156f7b..077ed200e48d 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -93,12 +93,12 @@ rtl::Reference<EmbedEventListener_Impl> EmbedEventListener_Impl::Create( Embedde { p->GetObject()->addStateChangeListener( pRet.get() ); - uno::Reference < util::XCloseable > xClose( p->GetObject(), uno::UNO_QUERY ); + uno::Reference < util::XCloseable > xClose = p->GetObject(); DBG_ASSERT( xClose.is(), "Object does not support XCloseable!" ); if ( xClose.is() ) xClose->addCloseListener( pRet.get() ); - uno::Reference < document::XEventBroadcaster > xBrd( p->GetObject(), uno::UNO_QUERY ); + uno::Reference < document::XEventBroadcaster > xBrd = p->GetObject(); if ( xBrd.is() ) xBrd->addEventListener( pRet.get() ); @@ -320,31 +320,23 @@ void EmbeddedObjectRef::Clear() { mpImpl->mxObj->removeStateChangeListener(mpImpl->mxListener.get()); - uno::Reference<util::XCloseable> xClose(mpImpl->mxObj, uno::UNO_QUERY); - if ( xClose.is() ) - xClose->removeCloseListener( mpImpl->mxListener.get() ); - - uno::Reference<document::XEventBroadcaster> xBrd(mpImpl->mxObj, uno::UNO_QUERY); - if ( xBrd.is() ) - xBrd->removeEventListener( mpImpl->mxListener.get() ); + mpImpl->mxObj->removeCloseListener( mpImpl->mxListener.get() ); + mpImpl->mxObj->removeEventListener( mpImpl->mxListener.get() ); if ( mpImpl->bIsLocked ) { - if ( xClose.is() ) + try { - try - { - mpImpl->mxObj->changeState(embed::EmbedStates::LOADED); - xClose->close( true ); - } - catch (const util::CloseVetoException&) - { - // there's still someone who needs the object! - } - catch (const uno::Exception&) - { - TOOLS_WARN_EXCEPTION("svtools.misc", "Error on switching of the object to loaded state and closing"); - } + mpImpl->mxObj->changeState(embed::EmbedStates::LOADED); + mpImpl->mxObj->close( true ); + } + catch (const util::CloseVetoException&) + { + // there's still someone who needs the object! + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("svtools.misc", "Error on switching of the object to loaded state and closing"); } } } diff --git a/svtools/source/uno/framestatuslistener.cxx b/svtools/source/uno/framestatuslistener.cxx index 1e4cba141faa..ba158c2ddcf3 100644 --- a/svtools/source/uno/framestatuslistener.cxx +++ b/svtools/source/uno/framestatuslistener.cxx @@ -79,13 +79,12 @@ void SAL_CALL FrameStatusListener::release() throw () // XComponent void SAL_CALL FrameStatusListener::dispose() { - Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY ); + Reference< XComponent > xThis = this; SolarMutexGuard aSolarMutexGuard; if ( m_bDisposed ) throw DisposedException(); - Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); for (auto const& listener : m_aListenerMap) { try @@ -96,8 +95,8 @@ void SAL_CALL FrameStatusListener::dispose() aTargetURL.Complete = listener.first; xURLTransformer->parseStrict( aTargetURL ); - if ( xDispatch.is() && xStatusListener.is() ) - xDispatch->removeStatusListener( xStatusListener, aTargetURL ); + if ( xDispatch.is() ) + xDispatch->removeStatusListener( this, aTargetURL ); } catch (const Exception&) { @@ -165,7 +164,7 @@ void FrameStatusListener::addStatusListener( const OUString& aCommandURL ) xURLTransformer->parseStrict( aTargetURL ); xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); - xStatusListener.set( static_cast< OWeakObject* >( this ), UNO_QUERY ); + xStatusListener = this; URLToDispatchMap::iterator aIter = m_aListenerMap.find( aCommandURL ); if ( aIter != m_aListenerMap.end() ) { @@ -210,7 +209,7 @@ void FrameStatusListener::bindListener() Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); if ( m_xContext.is() && xDispatchProvider.is() ) { - xStatusListener.set( static_cast< OWeakObject* >( this ), UNO_QUERY ); + xStatusListener = this; for (auto & listener : m_aListenerMap) { Reference< XURLTransformer > xURLTransformer( css::util::URLTransformer::create( m_xContext ) ); diff --git a/svtools/source/uno/statusbarcontroller.cxx b/svtools/source/uno/statusbarcontroller.cxx index 88c07535dd16..d22dc8e69a98 100644 --- a/svtools/source/uno/statusbarcontroller.cxx +++ b/svtools/source/uno/statusbarcontroller.cxx @@ -184,7 +184,7 @@ void SAL_CALL StatusbarController::update() // XComponent void SAL_CALL StatusbarController::dispose() { - Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY ); + Reference< XComponent > xThis = this; { SolarMutexGuard aSolarMutexGuard; @@ -196,7 +196,7 @@ void SAL_CALL StatusbarController::dispose() m_aListenerContainer.disposeAndClear( aEvent ); SolarMutexGuard aSolarMutexGuard; - Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); + Reference< XStatusListener > xStatusListener = this; Reference< XURLTransformer > xURLTransformer = getURLTransformer(); css::util::URL aTargetURL; for (auto const& listener : m_aListenerMap) @@ -369,7 +369,7 @@ void StatusbarController::addStatusListener( const OUString& aCommandURL ) xURLTransformer->parseStrict( aTargetURL ); xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); - xStatusListener.set( static_cast< OWeakObject* >( this ), UNO_QUERY ); + xStatusListener = this; URLToDispatchMap::iterator aIter = m_aListenerMap.find( aCommandURL ); if ( aIter != m_aListenerMap.end() ) { @@ -417,7 +417,7 @@ void StatusbarController::bindListener() Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); if ( m_xContext.is() && xDispatchProvider.is() ) { - xStatusListener.set( static_cast< OWeakObject* >( this ), UNO_QUERY ); + xStatusListener = this; for (auto & listener : m_aListenerMap) { Reference< XURLTransformer > xURLTransformer = getURLTransformer(); |