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>
This commit is contained in:
Noel Grandin 2019-07-20 13:29:51 +02:00
parent 8a3912c8eb
commit 17db60eb46
17 changed files with 54 additions and 82 deletions

View File

@ -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;

View File

@ -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)
{

View File

@ -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& )

View File

@ -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() )
{

View File

@ -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 )

View File

@ -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& )
{

View File

@ -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" )
)
)

View File

@ -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

View File

@ -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?

View File

@ -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());

View File

@ -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)
{

View File

@ -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& )
{

View File

@ -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 };

View File

@ -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();
}

View File

@ -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");
}
}
}

View File

@ -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 ) );

View File

@ -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();