framework/inc/dispatch/interceptionhelper.hxx                     |    3 
 framework/source/accelerators/presethandler.cxx                   |   16 +---
 framework/source/dispatch/closedispatcher.cxx                     |    2 
 framework/source/dispatch/dispatchprovider.cxx                    |    6 -
 framework/source/dispatch/interceptionhelper.cxx                  |    6 -
 framework/source/dispatch/startmoduledispatcher.cxx               |    4 -
 framework/source/fwe/classes/framelistanalyzer.cxx                |    2 
 framework/source/fwe/classes/rootactiontriggercontainer.cxx       |    3 
 framework/source/fwe/helper/titlehelper.cxx                       |    8 +-
 framework/source/fwi/helper/mischelper.cxx                        |    2 
 framework/source/helper/ocomponentaccess.cxx                      |    8 +-
 framework/source/helper/oframes.cxx                               |    4 -
 framework/source/jobs/helponstartup.cxx                           |    5 -
 framework/source/layoutmanager/helpers.cxx                        |    4 -
 framework/source/layoutmanager/layoutmanager.cxx                  |   16 ++--
 framework/source/layoutmanager/toolbarlayoutmanager.cxx           |   11 +--
 framework/source/loadenv/loadenv.cxx                              |   16 ++--
 framework/source/services/autorecovery.cxx                        |    6 -
 framework/source/services/desktop.cxx                             |   17 ++--
 framework/source/services/dispatchhelper.cxx                      |    2 
 framework/source/services/frame.cxx                               |   28 
+++-----
 framework/source/tabwin/tabwindow.cxx                             |   17 ++--
 framework/source/uiconfiguration/moduleuicfgsupplier.cxx          |    3 
 framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx |   25 
++-----
 framework/source/uiconfiguration/uiconfigurationmanager.cxx       |   25 
++-----
 framework/source/uielement/buttontoolbarcontroller.cxx            |    2 
 framework/source/uielement/menubarmanager.cxx                     |   14 ++--
 framework/source/uielement/menubarwrapper.cxx                     |    2 
 framework/source/uielement/newmenucontroller.cxx                  |    2 
 framework/source/uielement/popuptoolbarcontroller.cxx             |    2 
 framework/source/uielement/progressbarwrapper.cxx                 |   10 +-
 framework/source/uielement/statusbarmanager.cxx                   |    3 
 framework/source/uielement/toolbarmanager.cxx                     |    2 
 linguistic/source/convdic.cxx                                     |    3 
 linguistic/source/convdiclist.cxx                                 |    8 +-
 linguistic/source/dlistimp.cxx                                    |    7 --
 linguistic/source/gciterator.cxx                                  |    4 -
 linguistic/source/lngsvcmgr.cxx                                   |   35 
++--------
 linguistic/source/misc.cxx                                        |    2 
 linguistic/source/spelldta.cxx                                    |    2 
 40 files changed, 142 insertions(+), 195 deletions(-)

New commits:
commit defdd8bebe40b48d8abc4d893ac9a82b550c5d19
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jul 19 20:07:42 2019 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jul 20 07:55:53 2019 +0200

    loplugin:referencecasting in linguistic
    
    Change-Id: Iff53942bebb1481666ae4469e16089d54669954f
    Reviewed-on: https://gerrit.libreoffice.org/75973
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/linguistic/source/convdic.cxx b/linguistic/source/convdic.cxx
index 7c2c602a79fa..482ae2f2c880 100644
--- a/linguistic/source/convdic.cxx
+++ b/linguistic/source/convdic.cxx
@@ -257,8 +257,7 @@ void ConvDic::Save()
         xSaxWriter->setOutputStream( xStream->getOutputStream() );
 
         // prepare arguments (prepend doc handler to given arguments)
-        uno::Reference< xml::sax::XDocumentHandler > xDocHandler( xSaxWriter, 
UNO_QUERY );
-        rtl::Reference<ConvDicXMLExport> pExport = new ConvDicXMLExport( 
*this, aMainURL, xDocHandler );
+        rtl::Reference<ConvDicXMLExport> pExport = new ConvDicXMLExport( 
*this, aMainURL, xSaxWriter );
         bool bRet = pExport->Export();     // write entries to file
         DBG_ASSERT( !pStream->GetError(), "I/O error while writing to stream" 
);
         if (bRet)
diff --git a/linguistic/source/convdiclist.cxx 
b/linguistic/source/convdiclist.cxx
index 50f1799423d2..da4236dc610c 100644
--- a/linguistic/source/convdiclist.cxx
+++ b/linguistic/source/convdiclist.cxx
@@ -391,10 +391,10 @@ ConvDicNameContainer & ConvDicList::GetNameContainer()
 
         // since there is no UI to active/deactivate the dictionaries
         // for chinese text conversion they should be activated by default
-        uno::Reference< XConversionDictionary > xS2TDic(
-                    mxNameContainer->GetByName( "ChineseS2T" ), UNO_QUERY );
-        uno::Reference< XConversionDictionary > xT2SDic(
-                    mxNameContainer->GetByName( "ChineseT2S" ), UNO_QUERY );
+        uno::Reference< XConversionDictionary > xS2TDic =
+                    mxNameContainer->GetByName( "ChineseS2T" );
+        uno::Reference< XConversionDictionary > xT2SDic =
+                    mxNameContainer->GetByName( "ChineseT2S" );
         if (xS2TDic.is())
             xS2TDic->setActive( true );
         if (xT2SDic.is())
diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx
index 115fdca74669..e9b5da8d4e95 100644
--- a/linguistic/source/dlistimp.cxx
+++ b/linguistic/source/dlistimp.cxx
@@ -156,10 +156,9 @@ void SAL_CALL DicEvtListenerHelper::processDictionaryEvent(
 
     // assert that there is a corresponding dictionary entry if one was
     // added or deleted
-    uno::Reference< XDictionaryEntry > xDicEntry( rDicEvent.xDictionaryEntry, 
UNO_QUERY );
     DBG_ASSERT( !(rDicEvent.nEvent &
                     (DictionaryEventFlags::ADD_ENTRY | 
DictionaryEventFlags::DEL_ENTRY))
-                || xDicEntry.is(),
+                || rDicEvent.xDictionaryEntry.is(),
                 "lng : missing dictionary entry" );
 
     // evaluate DictionaryEvents and update data for next DictionaryListEvent
@@ -167,11 +166,11 @@ void SAL_CALL 
DicEvtListenerHelper::processDictionaryEvent(
     DBG_ASSERT(eDicType != DictionaryType_MIXED,
         "lng : unexpected dictionary type");
     if ((rDicEvent.nEvent & DictionaryEventFlags::ADD_ENTRY) && 
xDic->isActive())
-        nCondensedEvt |= xDicEntry->isNegative() ?
+        nCondensedEvt |= rDicEvent.xDictionaryEntry->isNegative() ?
             DictionaryListEventFlags::ADD_NEG_ENTRY :
             DictionaryListEventFlags::ADD_POS_ENTRY;
     if ((rDicEvent.nEvent & DictionaryEventFlags::DEL_ENTRY) && 
xDic->isActive())
-        nCondensedEvt |= xDicEntry->isNegative() ?
+        nCondensedEvt |= rDicEvent.xDictionaryEntry->isNegative() ?
             DictionaryListEventFlags::DEL_NEG_ENTRY :
             DictionaryListEventFlags::DEL_POS_ENTRY;
     if ((rDicEvent.nEvent & DictionaryEventFlags::ENTRIES_CLEARED) && 
xDic->isActive())
diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 9c8aed2a49a7..43ee3ca21ffd 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -624,8 +624,8 @@ void GrammarCheckingIterator::DequeueAndCheck()
                                            || nSuggestedEnd > nStartPos,
                                        "nSuggestedEndOfSentencePos calculation 
failed?");
 
-                            uno::Reference<linguistic2::XProofreader> xGC(
-                                GetGrammarChecker(aCurLocale), uno::UNO_QUERY);
+                            uno::Reference<linguistic2::XProofreader> xGC =
+                                GetGrammarChecker(aCurLocale);
                             if (xGC.is())
                             {
                                 aGuard.clear();
diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx
index 2f87177c2f1a..2ecb7ba7387d 100644
--- a/linguistic/source/lngsvcmgr.cxx
+++ b/linguistic/source/lngsvcmgr.cxx
@@ -1014,12 +1014,8 @@ void LngSvcMgr::GetAvailableSpellSvcs_Impl()
                     if (xInfo.is())
                         aImplName = xInfo->getImplementationName();
                     SAL_WARN_IF( aImplName.isEmpty(), "linguistic", "empty 
implementation name" );
-                    uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( 
xSvc, uno::UNO_QUERY );
-                    SAL_WARN_IF( !xSuppLoc.is(), "linguistic", "interfaces not 
supported" );
-                    if (xSuppLoc.is()) {
-                        uno::Sequence<lang::Locale> 
aLocaleSequence(xSuppLoc->getLocales());
-                        aLanguages = LocaleSeqToLangVec( aLocaleSequence );
-                    }
+                    uno::Sequence<lang::Locale> 
aLocaleSequence(xSvc->getLocales());
+                    aLanguages = LocaleSeqToLangVec( aLocaleSequence );
 
                     pAvailSpellSvcs->push_back( std::make_unique<SvcInfo>( 
aImplName, aLanguages ) );
                 }
@@ -1076,13 +1072,8 @@ void LngSvcMgr::GetAvailableGrammarSvcs_Impl()
                     if (xInfo.is())
                         aImplName = xInfo->getImplementationName();
                     SAL_WARN_IF( aImplName.isEmpty(), "linguistic", "empty 
implementation name" );
-                    uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( 
xSvc, uno::UNO_QUERY );
-                    SAL_WARN_IF( !xSuppLoc.is(), "linguistic", "interfaces not 
supported" );
-                    if (xSuppLoc.is())
-                    {
-                        uno::Sequence<lang::Locale> 
aLocaleSequence(xSuppLoc->getLocales());
-                        aLanguages = LocaleSeqToLangVec( aLocaleSequence );
-                    }
+                    uno::Sequence<lang::Locale> 
aLocaleSequence(xSvc->getLocales());
+                    aLanguages = LocaleSeqToLangVec( aLocaleSequence );
 
                     pAvailGrammarSvcs->push_back( std::make_unique<SvcInfo>( 
aImplName, aLanguages ) );
                 }
@@ -1137,13 +1128,8 @@ void LngSvcMgr::GetAvailableHyphSvcs_Impl()
                     if (xInfo.is())
                         aImplName = xInfo->getImplementationName();
                     SAL_WARN_IF( aImplName.isEmpty(), "linguistic", "empty 
implementation name" );
-                    uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( 
xSvc, uno::UNO_QUERY );
-                    SAL_WARN_IF( !xSuppLoc.is(), "linguistic", "interfaces not 
supported" );
-                    if (xSuppLoc.is())
-                    {
-                        uno::Sequence<lang::Locale> 
aLocaleSequence(xSuppLoc->getLocales());
-                        aLanguages = LocaleSeqToLangVec( aLocaleSequence );
-                    }
+                    uno::Sequence<lang::Locale> 
aLocaleSequence(xSvc->getLocales());
+                    aLanguages = LocaleSeqToLangVec( aLocaleSequence );
                     pAvailHyphSvcs->push_back( std::make_unique<SvcInfo>( 
aImplName, aLanguages ) );
                 }
             }
@@ -1198,13 +1184,8 @@ void LngSvcMgr::GetAvailableThesSvcs_Impl()
                     if (xInfo.is())
                         aImplName = xInfo->getImplementationName();
                     SAL_WARN_IF( aImplName.isEmpty(), "linguistic", "empty 
implementation name" );
-                    uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( 
xSvc, uno::UNO_QUERY );
-                    SAL_WARN_IF( !xSuppLoc.is(), "linguistic", "interfaces not 
supported" );
-                    if (xSuppLoc.is())
-                    {
-                        uno::Sequence<lang::Locale> 
aLocaleSequence(xSuppLoc->getLocales());
-                        aLanguages = LocaleSeqToLangVec( aLocaleSequence );
-                    }
+                    uno::Sequence<lang::Locale> 
aLocaleSequence(xSvc->getLocales());
+                    aLanguages = LocaleSeqToLangVec( aLocaleSequence );
 
                     pAvailThesSvcs->push_back( std::make_unique<SvcInfo>( 
aImplName, aLanguages ) );
                 }
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx
index 29ad163ca912..61dc3506aa68 100644
--- a/linguistic/source/misc.cxx
+++ b/linguistic/source/misc.cxx
@@ -282,7 +282,7 @@ uno::Reference< XDictionaryEntry > SearchDicList(
     sal_Int32 i;
     for (i = 0;  i < nDics;  i++)
     {
-        uno::Reference< XDictionary > axDic( pDic[i], UNO_QUERY );
+        uno::Reference< XDictionary > axDic = pDic[i];
 
         DictionaryType  eType = axDic->getDictionaryType();
         LanguageType    nLang = LinguLocaleToLanguage( axDic->getLocale() );
diff --git a/linguistic/source/spelldta.cxx b/linguistic/source/spelldta.cxx
index da7818d9acaf..8b29c334f12b 100644
--- a/linguistic/source/spelldta.cxx
+++ b/linguistic/source/spelldta.cxx
@@ -74,7 +74,7 @@ void SearchSimilarText( const OUString &rText, LanguageType 
nLanguage,
 
     for (sal_Int32 i = 0;  i < nDics;  i++)
     {
-        Reference< XDictionary > xDic( pDic[i], UNO_QUERY );
+        Reference< XDictionary > xDic = pDic[i];
 
         LanguageType nLang = LinguLocaleToLanguage( xDic->getLocale() );
 
commit 952b806c22f798977f5478dd630131acf1a5f068
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jul 19 20:06:30 2019 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jul 20 07:55:40 2019 +0200

    loplugin:referencecasting in framework
    
    Change-Id: I49aee4023fdb3173d842c19a53f9170ca1e725e4
    Reviewed-on: https://gerrit.libreoffice.org/75972
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/framework/inc/dispatch/interceptionhelper.hxx 
b/framework/inc/dispatch/interceptionhelper.hxx
index 446ba2537354..fd8e342c4c34 100644
--- a/framework/inc/dispatch/interceptionhelper.hxx
+++ b/framework/inc/dispatch/interceptionhelper.hxx
@@ -88,11 +88,10 @@ class InterceptionHelper : public  ::cppu::WeakImplHelper<
               */
             iterator findByReference(const css::uno::Reference< 
css::frame::XDispatchProviderInterceptor >& xInterceptor)
             {
-                css::uno::Reference< css::frame::XDispatchProviderInterceptor 
> xProviderInterface(xInterceptor, css::uno::UNO_QUERY);
                 iterator pIt;
                 for (pIt=begin(); pIt!=end(); ++pIt)
                 {
-                    if (pIt->xInterceptor == xProviderInterface)
+                    if (pIt->xInterceptor == xInterceptor)
                         return pIt;
                 }
                 return end();
diff --git a/framework/source/accelerators/presethandler.cxx 
b/framework/source/accelerators/presethandler.cxx
index 156f1d0b91b7..c40c22cbc5bd 100644
--- a/framework/source/accelerators/presethandler.cxx
+++ b/framework/source/accelerators/presethandler.cxx
@@ -437,7 +437,6 @@ void PresetHandler::connectToResource(      
PresetHandler::EConfigType
     }
 
     // read content of level 3 (presets, targets)
-    css::uno::Reference< css::container::XNameAccess > xAccess;
     css::uno::Sequence< OUString > lNames;
     const OUString*       pNames;
     sal_Int32             c;
@@ -446,10 +445,9 @@ void PresetHandler::connectToResource(      
PresetHandler::EConfigType
     std::vector<OUString> lTargets;
 
     // read preset names of share layer
-    xAccess.set(xShare, css::uno::UNO_QUERY);
-    if (xAccess.is())
+    if (xShare.is())
     {
-        lNames  = xAccess->getElementNames();
+        lNames  = xShare->getElementNames();
         pNames  = lNames.getConstArray();
         c       = lNames.getLength();
 
@@ -464,10 +462,9 @@ void PresetHandler::connectToResource(      
PresetHandler::EConfigType
     }
 
     // read preset names of user layer
-    xAccess.set(xUser, css::uno::UNO_QUERY);
-    if (xAccess.is())
+    if (xUser.is())
     {
-        lNames  = xAccess->getElementNames();
+        lNames  = xUser->getElementNames();
         pNames  = lNames.getConstArray();
         c       = lNames.getLength();
 
@@ -761,12 +758,11 @@ css::uno::Reference< css::embed::XStorage > 
PresetHandler::impl_openLocalizedPat
 
 ::std::vector< OUString > PresetHandler::impl_getSubFolderNames(const 
css::uno::Reference< css::embed::XStorage >& xFolder)
 {
-    css::uno::Reference< css::container::XNameAccess > xAccess(xFolder, 
css::uno::UNO_QUERY);
-    if (!xAccess.is())
+    if (!xFolder.is())
         return ::std::vector< OUString >();
 
     ::std::vector< OUString >      lSubFolders;
-    const css::uno::Sequence< OUString > lNames = xAccess->getElementNames();
+    const css::uno::Sequence< OUString > lNames = xFolder->getElementNames();
     const OUString*                      pNames = lNames.getConstArray();
     sal_Int32                            c      = lNames.getLength();
     sal_Int32                            i      = 0;
diff --git a/framework/source/dispatch/closedispatcher.cxx 
b/framework/source/dispatch/closedispatcher.cxx
index 09023554928e..46ed7d59ebd2 100644
--- a/framework/source/dispatch/closedispatcher.cxx
+++ b/framework/source/dispatch/closedispatcher.cxx
@@ -593,7 +593,7 @@ css::uno::Reference< css::frame::XFrame > 
CloseDispatcher::static_impl_searchRig
         // c) try to find better results on parent frame
         //    If no parent frame exists (because this frame is used outside 
the desktop tree)
         //    the given frame must be used directly.
-        css::uno::Reference< css::frame::XFrame > 
xParent(xTarget->getCreator(), css::uno::UNO_QUERY);
+        css::uno::Reference< css::frame::XFrame > xParent = 
xTarget->getCreator();
         if ( ! xParent.is())
             return xTarget;
 
diff --git a/framework/source/dispatch/dispatchprovider.cxx 
b/framework/source/dispatch/dispatchprovider.cxx
index 57fcb9972d0e..69213d42eb6d 100644
--- a/framework/source/dispatch/dispatchprovider.cxx
+++ b/framework/source/dispatch/dispatchprovider.cxx
@@ -525,8 +525,7 @@ css::uno::Reference< css::frame::XDispatch > 
DispatchProvider::implts_getOrCreat
 
         case E_BLANKDISPATCHER :
                 {
-                    css::uno::Reference< css::frame::XFrame > xDesktop( 
xOwner, css::uno::UNO_QUERY );
-                    if (xDesktop.is())
+                    if (xOwner.is())
                     {
                         LoadDispatcher* pDispatcher = new 
LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_BLANK, 0);
                         xDispatchHelper.set( static_cast< ::cppu::OWeakObject* 
>(pDispatcher), css::uno::UNO_QUERY );
@@ -536,8 +535,7 @@ css::uno::Reference< css::frame::XDispatch > 
DispatchProvider::implts_getOrCreat
 
         case E_DEFAULTDISPATCHER :
                 {
-                    css::uno::Reference< css::frame::XFrame > xDesktop( 
xOwner, css::uno::UNO_QUERY );
-                    if (xDesktop.is())
+                    if (xOwner.is())
                     {
                         LoadDispatcher* pDispatcher = new 
LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_DEFAULT, 0);
                         xDispatchHelper.set( static_cast< ::cppu::OWeakObject* 
>(pDispatcher), css::uno::UNO_QUERY );
diff --git a/framework/source/dispatch/interceptionhelper.cxx 
b/framework/source/dispatch/interceptionhelper.cxx
index c1ef179b0e69..899ce2440946 100644
--- a/framework/source/dispatch/interceptionhelper.cxx
+++ b/framework/source/dispatch/interceptionhelper.cxx
@@ -107,7 +107,7 @@ void SAL_CALL 
InterceptionHelper::registerDispatchProviderInterceptor(const css:
     // If no list exist register these interceptor for all dispatch events 
with "*"!
     InterceptorInfo aInfo;
 
-    aInfo.xInterceptor.set(xInterceptor, css::uno::UNO_QUERY);
+    aInfo.xInterceptor = xInterceptor;
     css::uno::Reference< css::frame::XInterceptorInfo > xInfo(xInterceptor, 
css::uno::UNO_QUERY);
     if (xInfo.is())
         aInfo.lURLPattern = xInfo->getInterceptedURLs();
@@ -176,8 +176,8 @@ void SAL_CALL 
InterceptionHelper::releaseDispatchProviderInterceptor(const css::
     InterceptorList::iterator pIt = 
m_lInterceptionRegs.findByReference(xInterceptor);
     if (pIt != m_lInterceptionRegs.end())
     {
-        css::uno::Reference< css::frame::XDispatchProvider >            
xSlaveD  (xInterceptor->getSlaveDispatchProvider() , css::uno::UNO_QUERY);
-        css::uno::Reference< css::frame::XDispatchProvider >            
xMasterD (xInterceptor->getMasterDispatchProvider(), css::uno::UNO_QUERY);
+        css::uno::Reference< css::frame::XDispatchProvider >            
xSlaveD  = xInterceptor->getSlaveDispatchProvider();
+        css::uno::Reference< css::frame::XDispatchProvider >            
xMasterD = xInterceptor->getMasterDispatchProvider();
         css::uno::Reference< css::frame::XDispatchProviderInterceptor > 
xSlaveI  (xSlaveD                                  , css::uno::UNO_QUERY);
         css::uno::Reference< css::frame::XDispatchProviderInterceptor > 
xMasterI (xMasterD                                 , css::uno::UNO_QUERY);
 
diff --git a/framework/source/dispatch/startmoduledispatcher.cxx 
b/framework/source/dispatch/startmoduledispatcher.cxx
index f6538f701be3..8d24ff9ae5c0 100644
--- a/framework/source/dispatch/startmoduledispatcher.cxx
+++ b/framework/source/dispatch/startmoduledispatcher.cxx
@@ -100,8 +100,8 @@ bool StartModuleDispatcher::implts_isBackingModePossible()
     if ( ! 
SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::STARTMODULE))
         return false;
 
-    css::uno::Reference< css::frame::XFramesSupplier > xDesktop(
-        css::frame::Desktop::create( m_xContext ), css::uno::UNO_QUERY);
+    css::uno::Reference< css::frame::XFramesSupplier > xDesktop =
+        css::frame::Desktop::create( m_xContext );
 
     FrameListAnalyzer aCheck(
         xDesktop,
diff --git a/framework/source/fwe/classes/framelistanalyzer.cxx 
b/framework/source/fwe/classes/framelistanalyzer.cxx
index 322b47d03e76..ee0587cb8b28 100644
--- a/framework/source/fwe/classes/framelistanalyzer.cxx
+++ b/framework/source/fwe/classes/framelistanalyzer.cxx
@@ -75,7 +75,7 @@ void FrameListAnalyzer::impl_analyze()
     m_xBackingComponent.clear();
 
     // try to get the task container by using the given supplier
-    css::uno::Reference< css::container::XIndexAccess > 
xFrameContainer(m_xSupplier->getFrames(), css::uno::UNO_QUERY);
+    css::uno::Reference< css::container::XIndexAccess > xFrameContainer = 
m_xSupplier->getFrames();
 
     // All return list get an initial size to include all possible frames.
     // They will be packed at the end of this method ... using the actual step 
positions then.
diff --git a/framework/source/fwe/classes/rootactiontriggercontainer.cxx 
b/framework/source/fwe/classes/rootactiontriggercontainer.cxx
index 583ec6dc61ca..a2dd82f9bc5a 100644
--- a/framework/source/fwe/classes/rootactiontriggercontainer.cxx
+++ b/framework/source/fwe/classes/rootactiontriggercontainer.cxx
@@ -243,9 +243,8 @@ Sequence< sal_Int8 > SAL_CALL 
RootActionTriggerContainer::getImplementationId()
 void RootActionTriggerContainer::FillContainer()
 {
     m_bContainerCreated = true;
-    Reference<XIndexContainer> xXIndexContainer( static_cast<OWeakObject 
*>(this), UNO_QUERY );
     ActionTriggerHelper::FillActionTriggerContainerFromMenu(
-        xXIndexContainer,
+        this,
         m_pMenu );
 }
 OUString RootActionTriggerContainer::getName()
diff --git a/framework/source/fwe/helper/titlehelper.cxx 
b/framework/source/fwe/helper/titlehelper.cxx
index 35fb1a4f6b92..a09605ecc18a 100644
--- a/framework/source/fwe/helper/titlehelper.cxx
+++ b/framework/source/fwe/helper/titlehelper.cxx
@@ -234,7 +234,7 @@ void SAL_CALL TitleHelper::disposing(const 
css::lang::EventObject& aEvent)
     {
         osl::MutexGuard aLock(m_aMutex);
 
-        xOwner.set(m_xOwner.get()          , css::uno::UNO_QUERY);
+        xOwner = m_xOwner;
         xNumbers.set(m_xUntitledNumbers.get(), css::uno::UNO_QUERY);
         nLeasedNumber = m_nLeasedNumber;
     }
@@ -340,7 +340,7 @@ void TitleHelper::impl_updateTitleForModel (const 
css::uno::Reference< css::fram
         if (m_bExternalTitle)
             return;
 
-        xOwner.set     (m_xOwner.get()          , css::uno::UNO_QUERY);
+        xOwner = m_xOwner;
         xNumbers.set   (m_xUntitledNumbers.get(), css::uno::UNO_QUERY);
         nLeasedNumber = m_nLeasedNumber;
     }
@@ -423,7 +423,7 @@ void TitleHelper::impl_updateTitleForController (const 
css::uno::Reference< css:
         if (m_bExternalTitle)
             return;
 
-        xOwner.set      (m_xOwner.get()          , css::uno::UNO_QUERY);
+        xOwner = m_xOwner;
         xNumbers.set    (m_xUntitledNumbers.get(), css::uno::UNO_QUERY);
         nLeasedNumber = m_nLeasedNumber;
     }
@@ -442,7 +442,7 @@ void TitleHelper::impl_updateTitleForController (const 
css::uno::Reference< css:
         nLeasedNumber = xNumbers->leaseNumber (xOwner);
 
     css::uno::Reference< css::frame::XTitle > 
xModelTitle(xController->getModel (), css::uno::UNO_QUERY);
-    css::uno::Reference< css::frame::XModel > xModel(xController->getModel (), 
css::uno::UNO_QUERY);
+    css::uno::Reference< css::frame::XModel > xModel = xController->getModel 
();
     if (!xModelTitle.is ())
         xModelTitle.set(xController, css::uno::UNO_QUERY);
     if (xModelTitle.is ())
diff --git a/framework/source/fwi/helper/mischelper.cxx 
b/framework/source/fwi/helper/mischelper.cxx
index f551aa40af7c..55a2ed886b4c 100644
--- a/framework/source/fwi/helper/mischelper.cxx
+++ b/framework/source/fwi/helper/mischelper.cxx
@@ -110,7 +110,7 @@ void FillLangItems( std::set< OUString > &rLangItems,
     Reference< css::frame::XModel > xModel;
     if ( rxFrame.is() )
     {
-       Reference< css::frame::XController > xController( 
rxFrame->getController(), UNO_QUERY );
+       Reference< css::frame::XController > xController = 
rxFrame->getController();
        if ( xController.is() )
            xModel = xController->getModel();
     }
diff --git a/framework/source/helper/ocomponentaccess.cxx 
b/framework/source/helper/ocomponentaccess.cxx
index 81904523350d..b170ae5258a0 100644
--- a/framework/source/helper/ocomponentaccess.cxx
+++ b/framework/source/helper/ocomponentaccess.cxx
@@ -141,21 +141,21 @@ css::uno::Reference< XComponent > 
OComponentAccess::impl_getFrameComponent( cons
     if ( !xController.is() )
     {
         // Controller not exist - use the VCL-component.
-        xComponent.set( xFrame->getComponentWindow(), UNO_QUERY );
+        xComponent = xFrame->getComponentWindow();
     }
     else
     {
         // Does no model exists?
-        css::uno::Reference< XModel > xModel( xController->getModel(), 
UNO_QUERY );
+        css::uno::Reference< XModel > xModel = xController->getModel();
         if ( xModel.is() )
         {
             // Model exist - use the model as component.
-            xComponent.set( xModel, UNO_QUERY );
+            xComponent = xModel;
         }
         else
         {
             // Model not exist - use the controller as component.
-            xComponent.set( xController, UNO_QUERY );
+            xComponent = xController;
         }
     }
 
diff --git a/framework/source/helper/oframes.cxx 
b/framework/source/helper/oframes.cxx
index 1425325f7673..5c9b06e1138a 100644
--- a/framework/source/helper/oframes.cxx
+++ b/framework/source/helper/oframes.cxx
@@ -140,7 +140,7 @@ Sequence< css::uno::Reference< XFrame > > SAL_CALL 
OFrames::queryFrames( sal_Int
             // Add parent to list ... if any exist!
             if( nSearchFlags & FrameSearchFlag::PARENT )
             {
-                css::uno::Reference< XFrame > xParent( xOwner->getCreator(), 
UNO_QUERY );
+                css::uno::Reference< XFrame > xParent = xOwner->getCreator();
                 if( xParent.is() )
                 {
                     Sequence< css::uno::Reference< XFrame > > seqParent( 1 );
@@ -164,7 +164,7 @@ Sequence< css::uno::Reference< XFrame > > SAL_CALL 
OFrames::queryFrames( sal_Int
                 // Protect this instance against recursive calls from parents.
                 m_bRecursiveSearchProtection = true;
                 // Ask parent of my owner for frames and append results to 
return list.
-                css::uno::Reference< XFramesSupplier > xParent( 
xOwner->getCreator(), UNO_QUERY );
+                css::uno::Reference< XFramesSupplier > xParent = 
xOwner->getCreator();
                 // If a parent exist ...
                 if ( xParent.is() )
                 {
diff --git a/framework/source/jobs/helponstartup.cxx 
b/framework/source/jobs/helponstartup.cxx
index c318bad1a660..69dc69eacc0d 100644
--- a/framework/source/jobs/helponstartup.cxx
+++ b/framework/source/jobs/helponstartup.cxx
@@ -84,9 +84,8 @@ DEFINE_INIT_SERVICE(HelpOnStartup,
                         xComponent.set(m_xModuleManager, css::uno::UNO_QUERY);
                         if (xComponent.is())
                             xComponent->addEventListener(static_cast< 
css::lang::XEventListener* >(this));
-                        xComponent.set(m_xDesktop, css::uno::UNO_QUERY);
-                        if (xComponent.is())
-                            xComponent->addEventListener(static_cast< 
css::lang::XEventListener* >(this));
+                        if (m_xDesktop.is())
+                            m_xDesktop->addEventListener(static_cast< 
css::lang::XEventListener* >(this));
                         xComponent.set(m_xConfig, css::uno::UNO_QUERY);
                         if (xComponent.is())
                             xComponent->addEventListener(static_cast< 
css::lang::XEventListener* >(this));
diff --git a/framework/source/layoutmanager/helpers.cxx 
b/framework/source/layoutmanager/helpers.cxx
index 739d9ed60a32..bb858b33b5e7 100644
--- a/framework/source/layoutmanager/helpers.cxx
+++ b/framework/source/layoutmanager/helpers.cxx
@@ -169,7 +169,7 @@ uno::Reference< awt::XWindowPeer > createToolkitWindow( 
const uno::Reference< un
     aDescriptor.Type                =   awt::WindowClass_SIMPLE;
     aDescriptor.WindowServiceName   =   OUString::createFromAscii( pService );
     aDescriptor.ParentIndex         =   -1;
-    aDescriptor.Parent.set( rParent, uno::UNO_QUERY );
+    aDescriptor.Parent = rParent;
     aDescriptor.Bounds              =   awt::Rectangle(0,0,0,0);
     aDescriptor.WindowAttributes    =   0;
 
@@ -252,7 +252,7 @@ uno::Reference< frame::XModel > impl_getModelFromFrame( 
const uno::Reference< fr
     uno::Reference< frame::XModel > xModel;
     if ( rFrame.is() )
     {
-        uno::Reference< frame::XController > xController( 
rFrame->getController(), uno::UNO_QUERY );
+        uno::Reference< frame::XController > xController = 
rFrame->getController();
         if ( xController.is() )
             xModel = xController->getModel();
     }
diff --git a/framework/source/layoutmanager/layoutmanager.cxx 
b/framework/source/layoutmanager/layoutmanager.cxx
index 685b2ce9a3eb..b78b0b476c5a 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -789,7 +789,7 @@ void LayoutManager::implts_updateUIElementsVisibleState( 
bool bSetVisible )
         implts_notifyListeners( frame::LayoutManagerEvents::INVISIBLE, a );
 
     SolarMutexResettableGuard aWriteLock;
-    Reference< XUIElement >   xMenuBar( m_xMenuBar, UNO_QUERY );
+    Reference< XUIElement >   xMenuBar = m_xMenuBar;
     Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
     rtl::Reference< MenuBarManager > xInplaceMenuBar( m_xInplaceMenuBar );
     aWriteLock.clear();
@@ -903,8 +903,8 @@ void LayoutManager::implts_createProgressBar()
     Reference< awt::XWindow > xContainerWindow;
 
     SolarMutexResettableGuard aWriteLock;
-    xStatusBar.set( m_aStatusBarElement.m_xUIElement, UNO_QUERY );
-    xProgressBar.set( m_aProgressBarElement.m_xUIElement, UNO_QUERY );
+    xStatusBar = m_aStatusBarElement.m_xUIElement;
+    xProgressBar = m_aProgressBarElement.m_xUIElement;
     xProgressBarBackup = m_xProgressBarBackup;
     m_xProgressBarBackup.clear();
     xContainerWindow = m_xContainerWindow;
@@ -995,8 +995,8 @@ void LayoutManager::implts_setStatusBarPosSize( const 
::Point& rPos, const ::Siz
 
     /* SAFE AREA 
-----------------------------------------------------------------------------------------------
 */
     SolarMutexClearableGuard aReadLock;
-    xStatusBar.set( m_aStatusBarElement.m_xUIElement, UNO_QUERY );
-    xProgressBar.set( m_aProgressBarElement.m_xUIElement, UNO_QUERY );
+    xStatusBar = m_aStatusBarElement.m_xUIElement;
+    xProgressBar = m_aProgressBarElement.m_xUIElement;
     xContainerWindow = m_xContainerWindow;
 
     Reference< awt::XWindow > xWindow;
@@ -1034,8 +1034,8 @@ bool LayoutManager::implts_showProgressBar()
 
     /* SAFE AREA 
-----------------------------------------------------------------------------------------------
 */
     SolarMutexGuard aWriteLock;
-    xStatusBar.set( m_aStatusBarElement.m_xUIElement, UNO_QUERY );
-    xProgressBar.set( m_aProgressBarElement.m_xUIElement, UNO_QUERY );
+    xStatusBar = m_aStatusBarElement.m_xUIElement;
+    xProgressBar = m_aProgressBarElement.m_xUIElement;
     bool bVisible( m_bVisible );
 
     m_aProgressBarElement.m_bVisible = true;
@@ -1075,7 +1075,7 @@ bool LayoutManager::implts_hideProgressBar()
     bool bHideStatusBar( false );
 
     SolarMutexGuard g;
-    xProgressBar.set( m_aProgressBarElement.m_xUIElement, UNO_QUERY );
+    xProgressBar = m_aProgressBarElement.m_xUIElement;
 
     bool bInternalStatusBar( false );
     if ( xProgressBar.is() )
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx 
b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index 3ba5ece25409..f8e244a0d148 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -270,10 +270,9 @@ tools::Rectangle 
ToolbarLayoutManager::implts_calcDockingArea()
 
     for (auto const& window : aWindowVector)
     {
-        uno::Reference< ui::XUIElement > xUIElement( window.m_xUIElement, 
uno::UNO_QUERY );
-        if ( xUIElement.is() )
+        if ( window.m_xUIElement.is() )
         {
-            uno::Reference< awt::XWindow > xWindow( 
xUIElement->getRealInterface(), uno::UNO_QUERY );
+            uno::Reference< awt::XWindow > xWindow( 
window.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
             uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, 
uno::UNO_QUERY );
             if ( xWindow.is() && xDockWindow.is() )
             {
@@ -1191,8 +1190,8 @@ void ToolbarLayoutManager::implts_createCustomToolBars()
         return;
 
     uno::Reference< frame::XFrame > xFrame( m_xFrame );
-    uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr( 
m_xModuleCfgMgr, uno::UNO_QUERY );
-    uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr, 
uno::UNO_QUERY );
+    uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr = 
m_xModuleCfgMgr;
+    uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr = m_xDocCfgMgr;
     aReadLock.clear();
 
     if ( xFrame.is() )
@@ -3866,7 +3865,7 @@ void SAL_CALL ToolbarLayoutManager::elementInserted( 
const ui::ConfigurationEven
 void SAL_CALL ToolbarLayoutManager::elementRemoved( const 
ui::ConfigurationEvent& rEvent )
 {
     SolarMutexClearableGuard aReadLock;
-    uno::Reference< awt::XWindow > xContainerWindow( m_xContainerWindow, 
uno::UNO_QUERY );
+    uno::Reference< awt::XWindow > xContainerWindow = m_xContainerWindow;
     uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr( 
m_xModuleCfgMgr );
     uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr );
     aReadLock.clear();
diff --git a/framework/source/loadenv/loadenv.cxx 
b/framework/source/loadenv/loadenv.cxx
index 412ffef4d8ac..6fe947adc645 100644
--- a/framework/source/loadenv/loadenv.cxx
+++ b/framework/source/loadenv/loadenv.cxx
@@ -444,13 +444,13 @@ css::uno::Reference< css::lang::XComponent > 
LoadEnv::getTargetComponent() const
 
     css::uno::Reference< css::frame::XController > xController = 
m_xTargetFrame->getController();
     if (!xController.is())
-        return css::uno::Reference< css::lang::XComponent 
>(m_xTargetFrame->getComponentWindow(), css::uno::UNO_QUERY);
+        return m_xTargetFrame->getComponentWindow();
 
     css::uno::Reference< css::frame::XModel > xModel = xController->getModel();
     if (!xModel.is())
-        return css::uno::Reference< css::lang::XComponent >(xController, 
css::uno::UNO_QUERY);
+        return xController;
 
-    return css::uno::Reference< css::lang::XComponent >(xModel, 
css::uno::UNO_QUERY);
+    return xModel;
 }
 
 void SAL_CALL LoadEnvListener::loadFinished(const css::uno::Reference< 
css::frame::XFrameLoader >&)
@@ -1291,7 +1291,7 @@ css::uno::Reference< css::frame::XFrame > 
LoadEnv::impl_searchAlreadyLoaded()
     // otherwise - iterate through the tasks of the desktop container
     // to find out, which of them might contains the requested document
     css::uno::Reference< css::frame::XDesktop2 >  xSupplier = 
css::frame::Desktop::create( m_xContext );
-    css::uno::Reference< css::container::XIndexAccess > 
xTaskList(xSupplier->getFrames()                      , css::uno::UNO_QUERY);
+    css::uno::Reference< css::container::XIndexAccess > xTaskList = 
xSupplier->getFrames();
 
     if (!xTaskList.is())
         return css::uno::Reference< css::frame::XFrame >(); // task list can 
be empty!
@@ -1422,7 +1422,7 @@ css::uno::Reference< css::frame::XFrame > 
LoadEnv::impl_searchRecycleTarget()
     if 
(m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(),
 false))
         return css::uno::Reference< css::frame::XFrame >();
 
-    css::uno::Reference< css::frame::XFramesSupplier > xSupplier( 
css::frame::Desktop::create( m_xContext ), css::uno::UNO_QUERY);
+    css::uno::Reference< css::frame::XFramesSupplier > xSupplier = 
css::frame::Desktop::create( m_xContext );
     FrameListAnalyzer aTasksAnalyzer(xSupplier, css::uno::Reference< 
css::frame::XFrame >(), FrameAnalyzerFlags::BackingComponent);
     if (aTasksAnalyzer.m_xBackingComponent.is())
     {
@@ -1616,15 +1616,13 @@ void LoadEnv::impl_reactForLoadingState()
     {
         // close empty frames
         css::uno::Reference< css::util::XCloseable > xCloseable 
(m_xTargetFrame, css::uno::UNO_QUERY);
-        css::uno::Reference< css::lang::XComponent > 
xDisposable(m_xTargetFrame, css::uno::UNO_QUERY);
 
         try
         {
             if (xCloseable.is())
                 xCloseable->close(true);
-            else
-            if (xDisposable.is())
-                xDisposable->dispose();
+            else if (m_xTargetFrame.is())
+                m_xTargetFrame->dispose();
         }
         catch(const css::util::CloseVetoException&)
         {}
diff --git a/framework/source/services/autorecovery.cxx 
b/framework/source/services/autorecovery.cxx
index a3ffb3a47481..cb9726ae1a01 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -2155,7 +2155,7 @@ void AutoRecovery::implts_stopListening()
     // May be we must work with our configuration, but don't wish to be 
informed
     // about changes any longer. Needed e.g. during EMERGENCY_SAVE!
     xCFG.set                   (m_xRecoveryCFG      , css::uno::UNO_QUERY);
-    xGlobalEventBroadcaster.set(m_xNewDocBroadcaster, css::uno::UNO_QUERY);
+    xGlobalEventBroadcaster = m_xNewDocBroadcaster;
     } /* SAFE */
 
     if (xGlobalEventBroadcaster.is() && m_bListenForDocEvents)
@@ -2667,7 +2667,7 @@ AutoRecovery::TDocumentList::iterator 
AutoRecovery::impl_searchDocument(      Au
 
 void lcl_changeVisibility( const css::uno::Reference< 
css::frame::XFramesSupplier >& i_rFrames, bool i_bVisible )
 {
-    css::uno::Reference< css::container::XIndexAccess > xFramesContainer( 
i_rFrames->getFrames(), css::uno::UNO_QUERY );
+    css::uno::Reference< css::container::XIndexAccess > xFramesContainer = 
i_rFrames->getFrames();
     const sal_Int32 count = xFramesContainer->getCount();
 
     Any aElement;
@@ -2690,7 +2690,7 @@ void lcl_changeVisibility( const css::uno::Reference< 
css::frame::XFramesSupplie
 
 void AutoRecovery::implts_changeAllDocVisibility(bool bVisible)
 {
-    css::uno::Reference< css::frame::XFramesSupplier > xDesktop( 
css::frame::Desktop::create(m_xContext), css::uno::UNO_QUERY);
+    css::uno::Reference< css::frame::XFramesSupplier > xDesktop = 
css::frame::Desktop::create(m_xContext);
     lcl_changeVisibility( xDesktop, bVisible );
 }
 
diff --git a/framework/source/services/desktop.cxx 
b/framework/source/services/desktop.cxx
index 3814cfb5f9ce..c9fa016790cf 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -589,7 +589,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL 
Desktop::getCurrentFrame()
             xNext.set( xNext->getActiveFrame(), css::uno::UNO_QUERY );
         }
     }
-    return css::uno::Reference< css::frame::XFrame >( xLast, 
css::uno::UNO_QUERY );
+    return xLast;
 }
 
 
/*-************************************************************************************************************
@@ -1546,21 +1546,21 @@ css::uno::Reference< css::lang::XComponent > 
Desktop::impl_getFrameComponent( co
     if( !xController.is() )
     {
         // Controller not exist - use the VCL-component.
-        xComponent.set( xFrame->getComponentWindow(), css::uno::UNO_QUERY );
+        xComponent = xFrame->getComponentWindow();
     }
     else
     {
         // Does no model exists?
-        css::uno::Reference< css::frame::XModel > xModel( 
xController->getModel(), css::uno::UNO_QUERY );
+        css::uno::Reference< css::frame::XModel > xModel = 
xController->getModel();
         if( xModel.is() )
         {
             // Model exist - use the model as component.
-            xComponent.set( xModel, css::uno::UNO_QUERY );
+            xComponent = xModel;
         }
         else
         {
             // Model not exist - use the controller as component.
-            xComponent.set( xController, css::uno::UNO_QUERY );
+            xComponent = xController;
         }
     }
 
@@ -1716,7 +1716,7 @@ bool Desktop::impl_closeFrames(bool bAllowUI)
             // XController.suspend() will show a UI ...
             // Use it in case it was allowed from outside only.
             bool                                       bSuspended = false;
-            css::uno::Reference< css::frame::XController > xController( 
xFrame->getController(), css::uno::UNO_QUERY );
+            css::uno::Reference< css::frame::XController > xController = 
xFrame->getController();
             if ( bAllowUI && xController.is() )
             {
                 bSuspended = xController->suspend( true );
@@ -1761,9 +1761,8 @@ bool Desktop::impl_closeFrames(bool bAllowUI)
 
             // XClosable not supported ?
             // Then we have to dispose these frame hardly.
-            css::uno::Reference< css::lang::XComponent > xDispose( xFrame, 
css::uno::UNO_QUERY );
-            if ( xDispose.is() )
-                xDispose->dispose();
+            if ( xFrame.is() )
+                xFrame->dispose();
 
             // Don't remove these frame from our child container!
             // A frame do it by itself inside close()/dispose() method.
diff --git a/framework/source/services/dispatchhelper.cxx 
b/framework/source/services/dispatchhelper.cxx
index ef534a9f67ba..2a28d9cebdae 100644
--- a/framework/source/services/dispatchhelper.cxx
+++ b/framework/source/services/dispatchhelper.cxx
@@ -141,7 +141,7 @@ DispatchHelper::executeDispatch(const 
css::uno::Reference<css::frame::XDispatch>
             /* SAFE { */
             {
                 osl::MutexGuard aWriteLock(m_mutex);
-                m_xBroadcaster.set(xNotifyDispatch, css::uno::UNO_QUERY);
+                m_xBroadcaster = xNotifyDispatch;
                 m_aBlock.reset();
             }
             /* } SAFE */
diff --git a/framework/source/services/frame.cxx 
b/framework/source/services/frame.cxx
index 5a11cc806189..3bd44ff45b94 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -977,7 +977,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL 
XFrameImpl::findFrame( const
     // get threadsafe some necessary member which are necessary for following 
functionality
     /* SAFE { */
     SolarMutexResettableGuard aReadLock;
-    css::uno::Reference< css::frame::XFrame > xParent ( m_xParent, 
css::uno::UNO_QUERY );
+    css::uno::Reference< css::frame::XFrame > xParent = m_xParent;
     bool bIsTopFrame  = m_bIsFrameTop;
     bool bIsTopWindow = WindowHelper::isTopWindow(m_xContainerWindow);
     aReadLock.clear();
@@ -1125,7 +1125,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL 
XFrameImpl::findFrame( const
                 css::uno::Reference< css::frame::XFramesSupplier > xSupplier( 
xParent, css::uno::UNO_QUERY );
                 if (xSupplier.is())
                 {
-                    css::uno::Reference< css::container::XIndexAccess > 
xContainer( xSupplier->getFrames(), css::uno::UNO_QUERY );
+                    css::uno::Reference< css::container::XIndexAccess > 
xContainer = xSupplier->getFrames();
                     if (xContainer.is())
                     {
                         sal_Int32 nCount = xContainer->getCount();
@@ -1240,7 +1240,7 @@ void SAL_CALL XFrameImpl::activate()
     // It's not necessary for m_aChildFrameContainer ... because
     // he is threadsafe himself and live if we live.
     css::uno::Reference< css::frame::XFrame >           xActiveChild    = 
m_aChildFrameContainer.getActive();
-    css::uno::Reference< css::frame::XFramesSupplier >  xParent         ( 
m_xParent, css::uno::UNO_QUERY );
+    css::uno::Reference< css::frame::XFramesSupplier >  xParent         = 
m_xParent;
     css::uno::Reference< css::frame::XFrame >           xThis           ( 
static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
     EActiveState                                        eState          = 
m_eActiveState;
 
@@ -1318,7 +1318,7 @@ void SAL_CALL XFrameImpl::deactivate()
 
     // Copy necessary member and free the lock.
     css::uno::Reference< css::frame::XFrame > xActiveChild = 
m_aChildFrameContainer.getActive();
-    css::uno::Reference< css::frame::XFramesSupplier > xParent ( m_xParent, 
css::uno::UNO_QUERY );
+    css::uno::Reference< css::frame::XFramesSupplier > xParent = m_xParent;
     css::uno::Reference< css::frame::XFrame > xThis ( static_cast< 
::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
     EActiveState eState = m_eActiveState;
 
@@ -1485,12 +1485,11 @@ sal_Bool SAL_CALL XFrameImpl::setComponent(const 
css::uno::Reference< css::awt::
         }
         /* } SAFE */
 
-        css::uno::Reference< css::lang::XComponent > xDisposable( 
xOldController, css::uno::UNO_QUERY );
-        if (xDisposable.is())
+        if (xOldController.is())
         {
             try
             {
-                xDisposable->dispose();
+                xOldController->dispose();
             }
             catch(const css::lang::DisposedException&)
                 {}
@@ -1515,12 +1514,11 @@ sal_Bool SAL_CALL XFrameImpl::setComponent(const 
css::uno::Reference< css::awt::
         }
         /* } SAFE */
 
-        css::uno::Reference< css::lang::XComponent > xDisposable( 
xOldComponentWindow, css::uno::UNO_QUERY );
-        if (xDisposable.is())
+        if (xOldComponentWindow.is())
         {
             try
             {
-                xDisposable->dispose();
+                xOldComponentWindow->dispose();
             }
             catch(const css::lang::DisposedException&)
             {
@@ -2162,8 +2160,8 @@ void SAL_CALL XFrameImpl::disposing()
     css::uno::Reference< css::lang::XComponent > xDisposableComp;
     {
         SolarMutexGuard g;
-        xDisposableCtrl.set( m_xController, css::uno::UNO_QUERY );
-        xDisposableComp.set( m_xComponentWindow, css::uno::UNO_QUERY );
+        xDisposableCtrl = m_xController;
+        xDisposableComp = m_xComponentWindow;
     }
     if (xDisposableCtrl.is())
         xDisposableCtrl->dispose();
@@ -2496,7 +2494,7 @@ void SAL_CALL XFrameImpl::windowDeactivated( const 
css::lang::EventObject& )
     /* SAFE AREA 
-----------------------------------------------------------------------------------------------
 */
     SolarMutexClearableGuard aReadLock;
 
-    css::uno::Reference< css::frame::XFrame > xParent          ( m_xParent, 
css::uno::UNO_QUERY );
+    css::uno::Reference< css::frame::XFrame > xParent          = m_xParent;
     css::uno::Reference< css::awt::XWindow >  xContainerWindow = 
m_xContainerWindow;
     EActiveState                              eActiveState     = 
m_eActiveState;
 
@@ -3004,8 +3002,8 @@ void XFrameImpl::implts_setIconOnWindow()
     /* SAFE AREA 
-----------------------------------------------------------------------------------------------
 */
     // Make snapshot of necessary members and release lock.
     SolarMutexClearableGuard aReadLock;
-    css::uno::Reference< css::awt::XWindow > xContainerWindow( 
m_xContainerWindow, css::uno::UNO_QUERY );
-    css::uno::Reference< css::frame::XController > xController( m_xController, 
css::uno::UNO_QUERY );
+    css::uno::Reference< css::awt::XWindow > xContainerWindow = 
m_xContainerWindow;
+    css::uno::Reference< css::frame::XController > xController = m_xController;
     aReadLock.clear();
     /* UNSAFE AREA 
---------------------------------------------------------------------------------------------
 */
 
diff --git a/framework/source/tabwin/tabwindow.cxx 
b/framework/source/tabwin/tabwindow.cxx
index 4f42d0960136..79afbb74258b 100644
--- a/framework/source/tabwin/tabwindow.cxx
+++ b/framework/source/tabwin/tabwindow.cxx
@@ -413,8 +413,7 @@ void SAL_CALL TabWindow::initialize( const 
css::uno::Sequence< css::uno::Any >&
 void SAL_CALL TabWindow::dispose()
 {
     // Send message to all listener and forget her references.
-    css::uno::Reference< css::lang::XComponent > xThis(
-        static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
+    css::uno::Reference< css::lang::XComponent > xThis = this;
     css::lang::EventObject aEvent( xThis );
 
     m_aListenerContainer.disposeAndClear( aEvent );
@@ -430,15 +429,13 @@ void SAL_CALL TabWindow::dispose()
     aLock.clear();
     /* SAFE AREA 
-----------------------------------------------------------------------------------------------
 */
 
-    css::uno::Reference< css::lang::XComponent > xComponent( 
xTabControlWindow, css::uno::UNO_QUERY );
-    if ( xComponent.is() )
-        xComponent->dispose();
+    if ( xTabControlWindow.is() )
+        xTabControlWindow->dispose();
 
-    xComponent.set( xContainerWindow, css::uno::UNO_QUERY );
-    if ( xComponent.is() )
-        xComponent->dispose();
+    if ( xContainerWindow.is() )
+        xContainerWindow->dispose();
 
-    xComponent.set( xTopWindow, css::uno::UNO_QUERY );
+    css::uno::Reference< css::lang::XComponent > xComponent( xTopWindow, 
css::uno::UNO_QUERY );
     if ( xComponent.is() )
         xComponent->dispose();
 
@@ -531,7 +528,7 @@ void SAL_CALL TabWindow::windowOpened( const 
css::lang::EventObject& )
 
 void SAL_CALL TabWindow::windowClosing( const css::lang::EventObject& )
 {
-    css::uno::Reference< css::lang::XComponent > xComponent( 
static_cast<OWeakObject *>(this), css::uno::UNO_QUERY );
+    css::uno::Reference< css::lang::XComponent > xComponent = this;
     if ( xComponent.is() )
         xComponent->dispose();
 }
diff --git a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx 
b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
index 095fcb5b0f66..7a9c27964d25 100644
--- a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
+++ b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
@@ -152,8 +152,7 @@ Reference< XUIConfigurationManager > SAL_CALL 
ModuleUIConfigurationManagerSuppli
         try
         {
             Sequence< PropertyValue > lProps;
-            Reference< XNameAccess > xCont(m_xModuleMgr, UNO_QUERY);
-            xCont->getByName(sModuleIdentifier) >>= lProps;
+            m_xModuleMgr->getByName(sModuleIdentifier) >>= lProps;
             for (sal_Int32 i=0; i<lProps.getLength(); ++i)
             {
                 if ( lProps[i].Name == "ooSetupFactoryShortName" )
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx 
b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 866679cffc2a..ba205d0420bc 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -549,7 +549,7 @@ void 
ModuleUIConfigurationManager::impl_storeElementTypeData( const Reference< X
             }
             else
             {
-                Reference< XStream > xStream( xStorage->openStreamElement( 
rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE ), UNO_QUERY );
+                Reference< XStream > xStream = xStorage->openStreamElement( 
rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE );
                 Reference< XOutputStream > xOutputStream( 
xStream->getOutputStream() );
 
                 if ( xOutputStream.is() )
@@ -628,7 +628,6 @@ void 
ModuleUIConfigurationManager::impl_resetElementTypeData(
 
     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;
 
     // Make copies of the event structures to be thread-safe. We have to 
unlock our mutex before calling
@@ -638,7 +637,7 @@ void 
ModuleUIConfigurationManager::impl_resetElementTypeData(
         UIElementData& rElement = elem.second;
         if ( !rElement.bDefault )
         {
-            if ( xDefaultNameAccess->hasByName( rElement.aName ))
+            if ( rDefaultElementType.xStorage->hasByName( rElement.aName ))
             {
                 // Replace settings with data from default layer
                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
@@ -688,8 +687,6 @@ void 
ModuleUIConfigurationManager::impl_reloadElementTypeData(
     ConfigEventNotifyContainer& rReplaceNotifyContainer )
 {
     UIElementDataHashMap& rHashMap          = 
rUserElementType.aElementsHashMap;
-    Reference< XNameAccess > xUserNameAccess( rUserElementType.xStorage, 
UNO_QUERY );
-    Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, 
UNO_QUERY );
 
     Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( 
this ), UNO_QUERY );
     Reference< XInterface > xIfac( xThis, UNO_QUERY );
@@ -700,7 +697,7 @@ void 
ModuleUIConfigurationManager::impl_reloadElementTypeData(
         UIElementData& rElement = elem.second;
         if ( rElement.bModified )
         {
-            if ( xUserNameAccess->hasByName( rElement.aName ))
+            if ( rUserElementType.xStorage->hasByName( rElement.aName ))
             {
                 // Replace settings with data from user layer
                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
@@ -718,7 +715,7 @@ void 
ModuleUIConfigurationManager::impl_reloadElementTypeData(
 
                 rElement.bModified = false;
             }
-            else if ( xDefaultNameAccess->hasByName( rElement.aName ))
+            else if ( rDefaultElementType.xStorage->hasByName( rElement.aName 
))
             {
                 // Replace settings with data from default layer
                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
@@ -985,21 +982,20 @@ void SAL_CALL ModuleUIConfigurationManager::reset()
             for ( int i = 1; i < css::ui::UIElementType::COUNT; i++ )
             {
                 UIElementType&        rElementType = 
m_aUIElements[LAYER_USERDEFINED][i];
-                Reference< XStorage > xSubStorage( rElementType.xStorage, 
UNO_QUERY );
 
-                if ( xSubStorage.is() )
+                if ( rElementType.xStorage.is() )
                 {
                     bool bCommitSubStorage( false );
-                    Sequence< OUString > aUIElementStreamNames = 
xSubStorage->getElementNames();
+                    Sequence< OUString > aUIElementStreamNames = 
rElementType.xStorage->getElementNames();
                     for ( sal_Int32 j = 0; j < 
aUIElementStreamNames.getLength(); j++ )
                     {
-                        xSubStorage->removeElement( aUIElementStreamNames[j] );
+                        rElementType.xStorage->removeElement( 
aUIElementStreamNames[j] );
                         bCommitSubStorage = true;
                     }
 
                     if ( bCommitSubStorage )
                     {
-                        Reference< XTransactedObject > xTransactedObject( 
xSubStorage, UNO_QUERY );
+                        Reference< XTransactedObject > xTransactedObject( 
rElementType.xStorage, UNO_QUERY );
                         if ( xTransactedObject.is() )
                             xTransactedObject->commit();
                         m_pStorageHandler[i]->commitUserChanges();
@@ -1554,11 +1550,10 @@ void SAL_CALL ModuleUIConfigurationManager::store()
             try
             {
                 UIElementType&        rElementType = 
m_aUIElements[LAYER_USERDEFINED][i];
-                Reference< XStorage > xStorage( rElementType.xStorage, 
UNO_QUERY );
 
-                if ( rElementType.bModified && xStorage.is() )
+                if ( rElementType.bModified && rElementType.xStorage.is() )
                 {
-                    impl_storeElementTypeData( xStorage, rElementType );
+                    impl_storeElementTypeData( rElementType.xStorage, 
rElementType );
                     m_pStorageHandler[i]->commitUserChanges();
                 }
             }
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx 
b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index 75e42e4d7911..c5aa509242e9 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -460,7 +460,7 @@ void UIConfigurationManager::impl_storeElementTypeData( 
Reference< XStorage > co
             }
             else
             {
-                Reference< XStream > xStream( xStorage->openStreamElement( 
rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE ), UNO_QUERY );
+                Reference< XStream > xStream = xStorage->openStreamElement( 
rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE );
                 Reference< XOutputStream > xOutputStream( 
xStream->getOutputStream() );
 
                 if ( xOutputStream.is() )
@@ -766,22 +766,21 @@ void SAL_CALL UIConfigurationManager::reset()
             for ( int i = 1; i < css::ui::UIElementType::COUNT; i++ )
             {
                 UIElementType&        rElementType = m_aUIElements[i];
-                Reference< XStorage > xSubStorage( rElementType.xStorage, 
UNO_QUERY );
 
-                if ( xSubStorage.is() )
+                if ( rElementType.xStorage.is() )
                 {
                     bool bCommitSubStorage( false );
-                    Sequence< OUString > aUIElementStreamNames = 
xSubStorage->getElementNames();
+                    Sequence< OUString > aUIElementStreamNames = 
rElementType.xStorage->getElementNames();
                     for ( sal_Int32 j = 0; j < 
aUIElementStreamNames.getLength(); j++ )
                     {
-                        xSubStorage->removeElement( aUIElementStreamNames[j] );
+                        rElementType.xStorage->removeElement( 
aUIElementStreamNames[j] );
                         bCommitSubStorage = true;
                         bCommit = true;
                     }
 
                     if ( bCommitSubStorage )
                     {
-                        Reference< XTransactedObject > xTransactedObject( 
xSubStorage, UNO_QUERY );
+                        Reference< XTransactedObject > xTransactedObject( 
rElementType.xStorage, UNO_QUERY );
                         if ( xTransactedObject.is() )
                             xTransactedObject->commit();
                     }
@@ -1166,9 +1165,7 @@ void SAL_CALL UIConfigurationManager::setStorage( const 
Reference< XStorage >& S
         try
         {
             // Dispose old storage to be sure that it will be closed
-            Reference< XComponent > xComponent( m_xDocConfigStorage, UNO_QUERY 
);
-            if ( xComponent.is() )
-                xComponent->dispose();
+            m_xDocConfigStorage->dispose();
         }
         catch ( const Exception& )
         {
@@ -1179,9 +1176,8 @@ void SAL_CALL UIConfigurationManager::setStorage( const 
Reference< XStorage >& S
     m_xDocConfigStorage = Storage;
     m_bReadOnly         = true;
 
-    Reference< XUIConfigurationStorage > xAccUpdate(m_xAccConfig, UNO_QUERY);
-    if ( xAccUpdate.is() )
-        xAccUpdate->setStorage( m_xDocConfigStorage );
+    if ( m_xAccConfig.is() )
+        m_xAccConfig->setStorage( m_xDocConfigStorage );
 
     if ( m_xImageManager.is() )
     {
@@ -1279,10 +1275,9 @@ void SAL_CALL UIConfigurationManager::store()
             try
             {
                 UIElementType& rElementType = m_aUIElements[i];
-                Reference< XStorage > xStorage( rElementType.xStorage, 
UNO_QUERY );
 
-                if ( rElementType.bModified && xStorage.is() )
-                    impl_storeElementTypeData( xStorage, rElementType );
+                if ( rElementType.bModified && rElementType.xStorage.is() )
+                    impl_storeElementTypeData( rElementType.xStorage, 
rElementType );
             }
             catch ( const Exception& )
             {
diff --git a/framework/source/uielement/buttontoolbarcontroller.cxx 
b/framework/source/uielement/buttontoolbarcontroller.cxx
index 6df84e0c9696..1a37d33df159 100644
--- a/framework/source/uielement/buttontoolbarcontroller.cxx
+++ b/framework/source/uielement/buttontoolbarcontroller.cxx
@@ -137,7 +137,7 @@ void SAL_CALL ButtonToolbarController::initialize(
 // XComponent
 void SAL_CALL ButtonToolbarController::dispose()
 {
-    Reference< XComponent > xThis( static_cast< OWeakObject* >(this), 
UNO_QUERY );
+    Reference< XComponent > xThis = this;
 
     {
         SolarMutexGuard aSolarMutexGuard;
diff --git a/framework/source/uielement/menubarmanager.cxx 
b/framework/source/uielement/menubarmanager.cxx
index fd61a275caeb..ae83e530c00b 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -851,7 +851,7 @@ IMPL_LINK( MenuBarManager, Select, Menu *, pMenu, bool )
                 Reference< XDesktop2 > xDesktop = css::frame::Desktop::create( 
m_xContext );
 
                 sal_uInt16 nTaskId = START_ITEMID_WINDOWLIST;
-                Reference< XIndexAccess > xList( xDesktop->getFrames(), 
UNO_QUERY );
+                Reference< XIndexAccess > xList = xDesktop->getFrames();
                 sal_Int32 nCount = xList->getCount();
                 for ( sal_Int32 i=0; i<nCount; ++i )
                 {
@@ -1084,7 +1084,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const 
Reference< XFrame >& rF
                 VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu;
                 PopupMenu* pNewPopupMenu = static_cast<PopupMenu 
*>(pVCLXPopupMenu->GetMenu());
                 pMenu->SetPopupMenu( nItemId, pNewPopupMenu );
-                pItemHandler->xPopupMenu.set( static_cast<OWeakObject 
*>(pVCLXPopupMenu), UNO_QUERY );
+                pItemHandler->xPopupMenu = pVCLXPopupMenu;
                 pItemHandler->aMenuItemURL = aItemCommand;
                 m_aMenuItemHandlerVector.push_back( 
std::unique_ptr<MenuItemHandler>(pItemHandler) );
                 pPopup.disposeAndClear();
@@ -1160,7 +1160,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const 
Reference< XFrame >& rF
                 VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu;
                 PopupMenu* pPopupMenu = static_cast<PopupMenu 
*>(pVCLXPopupMenu->GetMenu());
                 pMenu->SetPopupMenu( pItemHandler->nItemId, pPopupMenu );
-                pItemHandler->xPopupMenu.set( static_cast<OWeakObject 
*>(pVCLXPopupMenu), UNO_QUERY );
+                pItemHandler->xPopupMenu = pVCLXPopupMenu;
 
                 if ( bAccessibilityEnabled && CreatePopupMenuController( 
pItemHandler.get() ) )
                 {
@@ -1255,7 +1255,7 @@ void MenuBarManager::RetrieveShortcuts( std::vector< 
std::unique_ptr<MenuItemHan
                         Reference< XUIConfigurationManagerSupplier > 
xSupplier( xModel, UNO_QUERY );
                         if ( xSupplier.is() )
                         {
-                            Reference< XUIConfigurationManager > xDocUICfgMgr( 
xSupplier->getUIConfigurationManager(), UNO_QUERY );
+                            Reference< XUIConfigurationManager > xDocUICfgMgr 
= xSupplier->getUIConfigurationManager();
                             if ( xDocUICfgMgr.is() )
                             {
                                 xDocAccelCfg = 
xDocUICfgMgr->getShortCutManager();
@@ -1335,7 +1335,7 @@ void MenuBarManager::RetrieveImageManagers()
                 Reference< XUIConfigurationManagerSupplier > xSupplier( 
xModel, UNO_QUERY );
                 if ( xSupplier.is() )
                 {
-                    Reference< XUIConfigurationManager > xDocUICfgMgr( 
xSupplier->getUIConfigurationManager(), UNO_QUERY );
+                    Reference< XUIConfigurationManager > xDocUICfgMgr = 
xSupplier->getUIConfigurationManager();
                     m_xDocImageManager.set( xDocUICfgMgr->getImageManager(), 
UNO_QUERY );
                     m_xDocImageManager->addConfigurationListener(
                                             Reference< 
XUIConfigurationListener >(
@@ -1754,7 +1754,7 @@ void MenuBarManager::Init(const Reference< XFrame >& 
rFrame, Menu* pAddonMenu, b
                         VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu;
                         PopupMenu* pCtlPopupMenu = static_cast<PopupMenu 
*>(pVCLXPopupMenu->GetMenu());
                         pAddonMenu->SetPopupMenu( pMenuItemHandler->nItemId, 
pCtlPopupMenu );
-                        pMenuItemHandler->xPopupMenu.set( 
static_cast<OWeakObject *>(pVCLXPopupMenu), UNO_QUERY );
+                        pMenuItemHandler->xPopupMenu = pVCLXPopupMenu;
 
                     }
                 }
@@ -1787,7 +1787,7 @@ void MenuBarManager::UpdateSpecialWindowMenu( Menu* 
pMenu,const Reference< XComp
     sal_uInt16  nItemId = START_ITEMID_WINDOWLIST;
 
     Reference< XFrame > xCurrentFrame = xDesktop->getCurrentFrame();
-    Reference< XIndexAccess > xList( xDesktop->getFrames(), UNO_QUERY );
+    Reference< XIndexAccess > xList = xDesktop->getFrames();
     sal_Int32 nFrameCount = xList->getCount();
     aNewWindowListVector.reserve(nFrameCount);
     for (sal_Int32 i=0; i<nFrameCount; ++i )
diff --git a/framework/source/uielement/menubarwrapper.cxx 
b/framework/source/uielement/menubarwrapper.cxx
index 36abce496d54..0ea69d657e0f 100644
--- a/framework/source/uielement/menubarwrapper.cxx
+++ b/framework/source/uielement/menubarwrapper.cxx
@@ -191,7 +191,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< 
Any >& aArguments )
             // Initialize toolkit menu bar implementation to have 
awt::XMenuBar for data exchange.
             // Don't use this toolkit menu bar or one of its functions. It is 
only used as a data container!
             pAwtMenuBar = new VCLXMenuBar( pVCLMenuBar );
-            m_xMenuBar.set( static_cast< OWeakObject *>( pAwtMenuBar ), 
UNO_QUERY );
+            m_xMenuBar = pAwtMenuBar;
         }
     }
 }
diff --git a/framework/source/uielement/newmenucontroller.cxx 
b/framework/source/uielement/newmenucontroller.cxx
index eb84177a2fee..fc013759ae71 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -176,7 +176,7 @@ void NewMenuController::setAccelerators( PopupMenu* 
pPopupMenu )
                         Reference< XUIConfigurationManagerSupplier > 
xSupplier( xModel, UNO_QUERY );
                         if ( xSupplier.is() )
                         {
-                            Reference< XUIConfigurationManager > xDocUICfgMgr( 
xSupplier->getUIConfigurationManager(), UNO_QUERY );
+                            Reference< XUIConfigurationManager > xDocUICfgMgr 
= xSupplier->getUIConfigurationManager();
                             if ( xDocUICfgMgr.is() )
                             {
                                 xDocAccelCfg = 
xDocUICfgMgr->getShortCutManager();
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx 
b/framework/source/uielement/popuptoolbarcontroller.cxx
index 5defb5e88ea2..25037a4b9866 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -442,7 +442,7 @@ void SaveToolbarController::initialize( const 
css::uno::Sequence< css::uno::Any
     if ( !getToolboxId( nId, &pToolBox ) )
         return;
 
-    css::uno::Reference< css::frame::XController > xController( 
m_xFrame->getController(), css::uno::UNO_QUERY );
+    css::uno::Reference< css::frame::XController > xController = 
m_xFrame->getController();
     if ( xController.is() )
         m_xModifiable.set( xController->getModel(), css::uno::UNO_QUERY );
 
diff --git a/framework/source/uielement/progressbarwrapper.cxx 
b/framework/source/uielement/progressbarwrapper.cxx
index 76e2dda4c262..294d8ae32989 100644
--- a/framework/source/uielement/progressbarwrapper.cxx
+++ b/framework/source/uielement/progressbarwrapper.cxx
@@ -56,11 +56,10 @@ void ProgressBarWrapper::setStatusBar( const 
uno::Reference< awt::XWindow >& rSt
     if ( m_bOwnsInstance )
     {
         // dispose XWindow reference of our status bar
-        uno::Reference< lang::XComponent > xComponent( m_xStatusBar, 
uno::UNO_QUERY );
         try
         {
-            if ( xComponent.is() )
-                xComponent->dispose();
+            if ( m_xStatusBar.is() )
+                m_xStatusBar->dispose();
         }
         catch ( const uno::Exception& )
         {
@@ -273,9 +272,8 @@ void SAL_CALL ProgressBarWrapper::dispose()
         {
             try
             {
-                uno::Reference< lang::XComponent > xComponent( m_xStatusBar, 
uno::UNO_QUERY );
-                if ( xComponent.is() )
-                    xComponent->dispose();
+                if ( m_xStatusBar.is() )
+                    m_xStatusBar->dispose();
             }
             catch ( const lang::DisposedException& )
             {
diff --git a/framework/source/uielement/statusbarmanager.cxx 
b/framework/source/uielement/statusbarmanager.cxx
index 9c4a6c7b8496..89e237c32d56 100644
--- a/framework/source/uielement/statusbarmanager.cxx
+++ b/framework/source/uielement/statusbarmanager.cxx
@@ -373,8 +373,7 @@ void StatusBarManager::CreateControllers()
                 }
             }
 
-            xController.set(static_cast< ::cppu::OWeakObject *>( pController ),
-                            uno::UNO_QUERY );
+            xController = pController;
         }
 
         m_aControllerMap[nId] = xController;
diff --git a/framework/source/uielement/toolbarmanager.cxx 
b/framework/source/uielement/toolbarmanager.cxx
index 6e8fc6993d96..e9dc5ef78745 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -932,7 +932,7 @@ void ToolBarManager::InitImageManager()
             Reference< XUIConfigurationManagerSupplier > xSupplier( xModel, 
UNO_QUERY );
             if ( xSupplier.is() )
             {
-                Reference< XUIConfigurationManager > xDocUICfgMgr( 
xSupplier->getUIConfigurationManager(), UNO_QUERY );
+                Reference< XUIConfigurationManager > xDocUICfgMgr = 
xSupplier->getUIConfigurationManager();
                 m_xDocImageManager.set( xDocUICfgMgr->getImageManager(), 
UNO_QUERY );
                 m_xDocImageManager->addConfigurationListener(
                                         Reference< XUIConfigurationListener >(
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to