[Libreoffice-commits] core.git: 2 commits - slideshow/source starmath/source stoc/source svl/source svtools/source test/source toolkit/qa toolkit/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 21 06:50:04 UTC 2019


 slideshow/source/engine/opengl/TransitionerImpl.cxx   |    2 
 slideshow/source/engine/shapes/shapeimporter.cxx      |    4 -
 slideshow/source/engine/shapes/viewmediashape.cxx     |    9 ----
 slideshow/source/engine/slide/slideimpl.cxx           |    3 -
 slideshow/source/engine/slideshowimpl.cxx             |    7 +--
 slideshow/source/engine/soundplayer.cxx               |    5 --
 starmath/source/document.cxx                          |    5 --
 starmath/source/mathmlexport.cxx                      |    6 --
 starmath/source/mathmlimport.cxx                      |    5 --
 starmath/source/view.cxx                              |    5 --
 stoc/source/inspect/introspection.cxx                 |   12 ++---
 svl/source/fsstor/fsstorage.cxx                       |    5 --
 svtools/source/dialogs/ServerDetailsControls.cxx      |    9 +---
 svtools/source/dialogs/addresstemplate.cxx            |    2 
 svtools/source/misc/embedhlp.cxx                      |   38 +++++++-----------
 svtools/source/uno/framestatuslistener.cxx            |   11 ++---
 svtools/source/uno/statusbarcontroller.cxx            |    8 +--
 test/source/view/xformlayeraccess.cxx                 |    3 -
 toolkit/qa/cppunit/Dialog.cxx                         |    3 -
 toolkit/source/awt/animatedimagespeer.cxx             |    4 -
 toolkit/source/controls/controlmodelcontainerbase.cxx |   24 ++++-------
 toolkit/source/controls/roadmapcontrol.cxx            |    2 
 toolkit/source/controls/stdtabcontroller.cxx          |    6 --
 toolkit/source/controls/unocontrol.cxx                |    4 -
 toolkit/source/helper/unowrapper.cxx                  |    6 +-
 25 files changed, 75 insertions(+), 113 deletions(-)

New commits:
commit bda438ecedaa86ca44228a193d3acd37eef4f818
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sat Jul 20 18:24:37 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jul 21 08:49:13 2019 +0200

    loplugin:referencecasting in test..toolkit
    
    Change-Id: Ib1e6ba9c3849256b81fa5fa395e891226a044f7c
    Reviewed-on: https://gerrit.libreoffice.org/76029
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/test/source/view/xformlayeraccess.cxx b/test/source/view/xformlayeraccess.cxx
index 699da4882da8..de8053ba862e 100644
--- a/test/source/view/xformlayeraccess.cxx
+++ b/test/source/view/xformlayeraccess.cxx
@@ -30,8 +30,7 @@ void XFormLayerAccess::testGetFormController()
     // delibritly don't use UNO_QUERY_THROW, so we can use
     // uno::XInterface::is() in CPPUNIT_ASSERT()
     xFLA->setFormDesignMode(false);
-    uno::Reference<form::runtime::XFormController> xFC(xFLA->getFormController(m_xForm),
-                                                       uno::UNO_QUERY);
+    uno::Reference<form::runtime::XFormController> xFC = xFLA->getFormController(m_xForm);
     CPPUNIT_ASSERT(xFC.is());
 
     xFLA->setFormDesignMode(bCurrentMode);
diff --git a/toolkit/qa/cppunit/Dialog.cxx b/toolkit/qa/cppunit/Dialog.cxx
index 9e832a8c9175..0918b9e8d115 100644
--- a/toolkit/qa/cppunit/Dialog.cxx
+++ b/toolkit/qa/cppunit/Dialog.cxx
@@ -59,8 +59,7 @@ CPPUNIT_TEST_FIXTURE(DialogTest, testDialogSizeable)
 
     uno::Reference<awt::XUnoControlDialog> xControl = awt::UnoControlDialog::create(mxContext);
     xControl->setModel(xControlModel);
-    uno::Reference<awt::XWindow> xWindow(xControl, uno::UNO_QUERY);
-    xWindow->setVisible(true);
+    xControl->setVisible(true);
     xDialog.set(xControl, uno::UNO_QUERY_THROW);
     xDialog->execute();
 
diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx
index 5277841af3e6..f065c8efaebe 100644
--- a/toolkit/source/awt/animatedimagespeer.cxx
+++ b/toolkit/source/awt/animatedimagespeer.cxx
@@ -133,12 +133,12 @@ namespace toolkit
                 {
                     // try (to find) the high-contrast version of the graphic first
                     aMediaProperties.put( "URL", lcl_getHighContrastURL( i_cachedImage.sImageURL ) );
-                    i_cachedImage.xGraphic.set( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY );
+                    i_cachedImage.xGraphic = i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() );
                 }
                 if ( !i_cachedImage.xGraphic.is() )
                 {
                     aMediaProperties.put( "URL", i_cachedImage.sImageURL );
-                    i_cachedImage.xGraphic.set( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY );
+                    i_cachedImage.xGraphic = i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() );
                 }
             }
             return i_cachedImage.xGraphic.is();
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index 64472d39ea18..278cbf894711 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -1104,8 +1104,6 @@ void SAL_CALL ResourceListener::release() throw ()
 void ResourceListener::startListening(
     const Reference< resource::XStringResourceResolver  >& rResource )
 {
-    Reference< util::XModifyBroadcaster > xModifyBroadcaster( rResource, UNO_QUERY );
-
     {
         // --- SAFE ---
         ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
@@ -1124,12 +1122,11 @@ void ResourceListener::startListening(
         // --- SAFE ---
     }
 
-    Reference< util::XModifyListener > xThis( static_cast<OWeakObject*>( this ), UNO_QUERY );
-    if ( xModifyBroadcaster.is() )
+    if ( rResource.is() )
     {
         try
         {
-            xModifyBroadcaster->addModifyListener( xThis );
+            rResource->addModifyListener( this );
 
             // --- SAFE ---
             ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
@@ -1153,11 +1150,10 @@ void ResourceListener::stopListening()
     // --- SAFE ---
     ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
     if ( m_bListening && m_xResource.is() )
-        xModifyBroadcaster.set( m_xResource, UNO_QUERY );
+        xModifyBroadcaster = m_xResource;
     aGuard.clear();
     // --- SAFE ---
 
-    Reference< util::XModifyListener > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
     if ( xModifyBroadcaster.is() )
     {
         try
@@ -1169,7 +1165,7 @@ void ResourceListener::stopListening()
             aGuard.clear();
             // --- SAFE ---
 
-            xModifyBroadcaster->removeModifyListener( xThis );
+            xModifyBroadcaster->removeModifyListener( this );
         }
         catch (const RuntimeException&)
         {
@@ -1229,7 +1225,7 @@ void SAL_CALL ResourceListener::disposing(
         aGuard.reset();
         m_bListening = false;
         xResource = m_xResource;
-        xListener.set( m_xListener, UNO_QUERY );
+        xListener = m_xListener;
         m_xResource.clear();
         aGuard.clear();
         // --- SAFE ---
@@ -1254,7 +1250,7 @@ void SAL_CALL ResourceListener::disposing(
         // --- SAFE ---
         aGuard.reset();
         m_bListening = false;
-        xListener.set( m_xListener, UNO_QUERY );
+        xListener = m_xListener;
         xResource = m_xResource;
         m_xResource.clear();
         m_xListener.clear();
@@ -1262,13 +1258,11 @@ void SAL_CALL ResourceListener::disposing(
         // --- SAFE ---
 
         // Remove ourself as listener from resource resolver
-        Reference< util::XModifyBroadcaster > xModifyBroadcaster( xResource, UNO_QUERY );
-        Reference< util::XModifyListener > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
-        if ( xModifyBroadcaster.is() )
+        if ( xResource.is() )
         {
             try
             {
-                xModifyBroadcaster->removeModifyListener( xThis );
+                xResource->removeModifyListener( this );
             }
             catch (const RuntimeException&)
             {
@@ -1411,7 +1405,7 @@ void ControlContainerBase::dispose()
     // --- SAFE ---
 
     SolarMutexClearableGuard aGuard;
-    Reference< XEventListener > xListener( mxListener, UNO_QUERY );
+    Reference< XEventListener > xListener = mxListener;
     mxListener.clear();
     aGuard.clear();
     // --- SAFE ---
diff --git a/toolkit/source/controls/roadmapcontrol.cxx b/toolkit/source/controls/roadmapcontrol.cxx
index 230980f46e31..54dbb3e20683 100644
--- a/toolkit/source/controls/roadmapcontrol.cxx
+++ b/toolkit/source/controls/roadmapcontrol.cxx
@@ -441,7 +441,7 @@ void UnoRoadmapControl::elementReplaced( const ContainerEvent& rEvent )
 void SAL_CALL UnoRoadmapControl::itemStateChanged( const ItemEvent& rEvent )
 {
     sal_Int16 CurItemIndex = sal::static_int_cast< sal_Int16 >(rEvent.ItemId);
-    Reference< XControlModel > xModel( getModel( ), UNO_QUERY );
+    Reference< XControlModel > xModel = getModel( );
     Reference< XPropertySet > xPropertySet( xModel, UNO_QUERY );
     xPropertySet->setPropertyValue( GetPropertyName( BASEPROPERTY_CURRENTITEMID ), Any(CurItemIndex) );
     if ( maItemListeners.getLength() )
diff --git a/toolkit/source/controls/stdtabcontroller.cxx b/toolkit/source/controls/stdtabcontroller.cxx
index 61900b4d76ce..0bfdc6302ad7 100644
--- a/toolkit/source/controls/stdtabcontroller.cxx
+++ b/toolkit/source/controls/stdtabcontroller.cxx
@@ -133,8 +133,7 @@ bool StdTabController::ImplCreateComponentSequence(
 void StdTabController::ImplActivateControl( bool bFirst ) const
 {
     // HACK due to bug #53688#, map controls onto an interface if remote controls may occur
-    Reference< XTabController >  xTabController(const_cast< ::cppu::OWeakObject* >(static_cast< const ::cppu::OWeakObject* >(this)), UNO_QUERY);
-    Sequence< Reference< XControl > > aCtrls = xTabController->getControls();
+    Sequence< Reference< XControl > > aCtrls = const_cast<StdTabController*>(this)->getControls();
     const Reference< XControl > * pControls = aCtrls.getConstArray();
     sal_uInt32 nCount = aCtrls.getLength();
 
@@ -248,8 +247,7 @@ void StdTabController::autoTabOrder(  )
     Sequence< Reference< XWindow > > aCompSeq;
 
     // This may return a TabController, which returns desired list of controls faster
-    Reference< XTabController >  xTabController(static_cast< ::cppu::OWeakObject* >(this), UNO_QUERY);
-    Sequence< Reference< XControl > > aControls = xTabController->getControls();
+    Sequence< Reference< XControl > > aControls = getControls();
 
     // #58317# Some Models may be missing from the Container. Plus there is a
     // autoTabOrder call later on.
diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx
index 038a615cc228..2359ed44981b 100644
--- a/toolkit/source/controls/unocontrol.cxx
+++ b/toolkit/source/controls/unocontrol.cxx
@@ -470,10 +470,10 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent
     bool bNeedNewPeer = false;
         // some properties require a re-creation of the peer, 'cause they can't be changed on the fly
 
-    Reference< XControlModel > xOwnModel( getModel(), UNO_QUERY );
+    Reference< XControlModel > xOwnModel = getModel();
         // our own model for comparison
     Reference< XPropertySet > xPS( xOwnModel, UNO_QUERY );
-    Reference< XPropertySetInfo > xPSI( xPS->getPropertySetInfo(), UNO_QUERY );
+    Reference< XPropertySetInfo > xPSI = xPS->getPropertySetInfo();
     OSL_ENSURE( xPSI.is(), "UnoControl::ImplModelPropertiesChanged: should have property set meta data!" );
 
     sal_Int32 nLen = rEvents.getLength();
diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx
index c5184b295425..fb425f7bced8 100644
--- a/toolkit/source/helper/unowrapper.cxx
+++ b/toolkit/source/helper/unowrapper.cxx
@@ -231,7 +231,7 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow )
         VclPtr< vcl::Window > pClient = pChild->GetWindow( GetWindowType::Client );
         if ( pClient && pClient->GetWindowPeer() )
         {
-            css::uno::Reference< css::lang::XComponent > xComp( pClient->GetComponentInterface( false ), css::uno::UNO_QUERY );
+            css::uno::Reference< css::lang::XComponent > xComp = pClient->GetComponentInterface( false );
             xComp->dispose();
         }
 
@@ -250,7 +250,7 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow )
 
             if ( pClient && pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) )
             {
-                css::uno::Reference< css::lang::XComponent > xComp( pClient->GetComponentInterface( false ), css::uno::UNO_QUERY );
+                css::uno::Reference< css::lang::XComponent > xComp = pClient->GetComponentInterface( false );
                 xComp->dispose();
             }
 
@@ -265,7 +265,7 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow )
     }
 
     VCLXWindow* pWindowPeer = pWindow->GetWindowPeer();
-    uno::Reference< lang::XComponent > xWindowPeerComp( pWindow->GetComponentInterface( false ), uno::UNO_QUERY );
+    uno::Reference< lang::XComponent > xWindowPeerComp = pWindow->GetComponentInterface( false );
     OSL_ENSURE( ( pWindowPeer != nullptr ) == xWindowPeerComp.is(),
         "UnoWrapper::WindowDestroyed: inconsistency in the window's peers!" );
     if ( pWindowPeer )
commit 17db60eb46b31b6e4b7e664b01e6f7bb6a3016ab
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sat Jul 20 13:29:51 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jul 21 08:49:01 2019 +0200

    loplugin:referencecasting in slideshow..svtools
    
    Change-Id: Id0f0332d5d66c0bce309643bf42059b9bdc7d448
    Reviewed-on: https://gerrit.libreoffice.org/75997
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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


More information about the Libreoffice-commits mailing list