UnoControls/source/controls/OConnectionPointContainerHelper.cxx |    3 
 animations/source/animcore/animcore.cxx                         |   26 -
 avmedia/source/gstreamer/gstplayer.cxx                          |  143 +++----
 basctl/source/basicide/unomodel.cxx                             |   12 
 comphelper/source/container/embeddedobjectcontainer.cxx         |   33 -
 editeng/source/accessibility/AccessibleEditableTextPara.cxx     |    2 
 editeng/source/accessibility/AccessibleHyperlink.cxx            |   25 -
 editeng/source/uno/unotext.cxx                                  |  189 
++++------
 extensions/source/logging/logger.cxx                            |    9 
 forms/source/component/Grid.cxx                                 |    9 
 forms/source/component/Grid.hxx                                 |    2 
 package/source/xstor/owriteablestream.cxx                       |    2 
 package/source/xstor/xstorage.cxx                               |   13 
 package/source/zipapi/ZipFile.cxx                               |    7 
 reportdesign/source/core/api/Group.cxx                          |    4 
 scripting/source/basprov/basprov.cxx                            |    2 
 scripting/source/stringresource/stringresource.cxx              |   13 
 sfx2/source/appl/appdispatchprovider.cxx                        |   18 
 sfx2/source/control/thumbnailviewacc.cxx                        |   20 -
 sfx2/source/control/thumbnailviewitemacc.cxx                    |    8 
 sot/source/sdstor/ucbstorage.cxx                                |    6 
 starmath/source/mathml/import.cxx                               |    4 
 svl/source/fsstor/fsstorage.cxx                                 |    4 
 svtools/source/brwbox/editbrowsebox2.cxx                        |   18 
 svtools/source/control/accessibletabbarpagelist.cxx             |    2 
 svtools/source/control/valueacc.cxx                             |   30 -
 svx/source/accessibility/charmapacc.cxx                         |   11 
 ucb/source/ucp/webdav-curl/webdavresponseparser.cxx             |    3 
 unotools/source/ucbhelper/ucblockbytes.cxx                      |    2 
 unoxml/source/dom/attributesmap.cxx                             |   88 ++--
 vcl/source/treelist/svtabbx.cxx                                 |    2 
 xmlscript/source/xml_helper/xml_impctx.cxx                      |    3 
 xmlsecurity/source/helper/xsecverify.cxx                        |   25 -
 xmlsecurity/source/xmlsec/nss/nssinitializer.cxx                |   15 
 34 files changed, 347 insertions(+), 406 deletions(-)

New commits:
commit 22f46bd89f6afc95438acf09fb5ff948f4ca8e02
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Mar 10 10:54:46 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 10 14:18:35 2025 +0100

    use more concrete UNO classes
    
    Change-Id: Id10786bbf7985adbb251224b45f9dabcc84d0a3d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182721
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/UnoControls/source/controls/OConnectionPointContainerHelper.cxx 
b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx
index 110174812a3e..8f5a484eb36b 100644
--- a/UnoControls/source/controls/OConnectionPointContainerHelper.cxx
+++ b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx
@@ -23,6 +23,7 @@
 
 #include <cppuhelper/queryinterface.hxx>
 #include <comphelper/sequence.hxx>
+#include <rtl/ref.hxx>
 
 //  namespaces
 
@@ -98,7 +99,7 @@ Sequence< Type > SAL_CALL 
OConnectionPointContainerHelper::getConnectionPointTyp
 Reference< XConnectionPoint > SAL_CALL 
OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType )
 {
     // Set default return value, if method failed.
-    Reference< XConnectionPoint > xConnectionPoint;
+    rtl::Reference< OConnectionPointHelper > xConnectionPoint;
 
     // Get all elements of the container, which have the searched type.
     comphelper::OInterfaceContainerHelper2* pSpecialContainer = 
m_aMultiTypeContainer.getContainer( aType );
diff --git a/animations/source/animcore/animcore.cxx 
b/animations/source/animcore/animcore.cxx
index 76bac60014c0..0c61b951f71a 100644
--- a/animations/source/animcore/animcore.cxx
+++ b/animations/source/animcore/animcore.cxx
@@ -1214,29 +1214,25 @@ Reference< XCloneable > SAL_CALL 
AnimationNode::createClone()
 {
     std::unique_lock aGuard( m_aMutex );
 
-    Reference< XCloneable > xNewNode;
+    rtl::Reference< AnimationNode > xNewNode;
     try
     {
         xNewNode = new AnimationNode( *this );
 
         if( !maChildren.empty() )
         {
-            Reference< XTimeContainer > xContainer( xNewNode, UNO_QUERY );
-            if( xContainer.is() )
+            for (auto const& child : maChildren)
             {
-                for (auto const& child : maChildren)
+                Reference< XCloneable > xCloneable(child, UNO_QUERY );
+                if( xCloneable.is() ) try
                 {
-                    Reference< XCloneable > xCloneable(child, UNO_QUERY );
-                    if( xCloneable.is() ) try
-                    {
-                        Reference< XAnimationNode > xNewChildNode( 
xCloneable->createClone(), UNO_QUERY );
-                        if( xNewChildNode.is() )
-                            xContainer->appendChild( xNewChildNode );
-                    }
-                    catch(const Exception&)
-                    {
-                        SAL_INFO("animations", 
"animations::AnimationNode::createClone(), exception caught!");
-                    }
+                    Reference< XAnimationNode > xNewChildNode( 
xCloneable->createClone(), UNO_QUERY );
+                    if( xNewChildNode.is() )
+                        xNewNode->appendChild( xNewChildNode );
+                }
+                catch(const Exception&)
+                {
+                    SAL_INFO("animations", 
"animations::AnimationNode::createClone(), exception caught!");
                 }
             }
         }
diff --git a/avmedia/source/gstreamer/gstplayer.cxx 
b/avmedia/source/gstreamer/gstplayer.cxx
index bf547d37b10b..65371ec547ea 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -830,8 +830,6 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL 
Player::createPlayerWindow( co
 {
     ::osl::MutexGuard aGuard(m_aMutex);
 
-    uno::Reference< ::media::XPlayerWindow >    xRet;
-
     if (rArguments.getLength() > 1)
        rArguments[1] >>= maArea;
 
@@ -842,93 +840,92 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL 
Player::createPlayerWindow( co
 
     SAL_INFO( "avmedia.gstreamer", AVVERSION "Player::createPlayerWindow " << 
aSize.Width << "x" << aSize.Height << " length: " << rArguments.getLength() );
 
-    if( aSize.Width > 0 && aSize.Height > 0 )
+    if( aSize.Width <= 0 || aSize.Height <= 0 )
+        return nullptr;
+
+    if (rArguments.getLength() <= 2)
     {
-        if (rArguments.getLength() <= 2)
-        {
-            xRet = new ::avmedia::gstreamer::Window;
-            return xRet;
-        }
+        return new ::avmedia::gstreamer::Window;
+    }
 
-        sal_IntPtr pIntPtr = 0;
-        rArguments[ 2 ] >>= pIntPtr;
-        SystemChildWindow *pParentWindow = reinterpret_cast< 
SystemChildWindow* >( pIntPtr );
-        if (!pParentWindow)
-            return nullptr;
+    sal_IntPtr pIntPtr = 0;
+    rArguments[ 2 ] >>= pIntPtr;
+    SystemChildWindow *pParentWindow = reinterpret_cast< SystemChildWindow* >( 
pIntPtr );
+    if (!pParentWindow)
+        return nullptr;
 
-        const SystemEnvData* pEnvData = pParentWindow->GetSystemData();
-        if (!pEnvData)
-            return nullptr;
+    const SystemEnvData* pEnvData = pParentWindow->GetSystemData();
+    if (!pEnvData)
+        return nullptr;
 
-        // tdf#124027: the position of embedded window is identical w/ the 
position
-        // of media object in all other vclplugs (kf5, gen), in gtk3 w/o 
gtksink it
-        // needs to be translated
-        if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
-        {
-            Point aPoint = pParentWindow->GetPosPixel();
-            maArea.X = aPoint.getX();
-            maArea.Y = aPoint.getY();
-        }
+    // tdf#124027: the position of embedded window is identical w/ the position
+    // of media object in all other vclplugs (kf5, gen), in gtk3 w/o gtksink it
+    // needs to be translated
+    if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
+    {
+        Point aPoint = pParentWindow->GetPosPixel();
+        maArea.X = aPoint.getX();
+        maArea.Y = aPoint.getY();
+    }
 
-        mbUseGtkSink = false;
+    mbUseGtkSink = false;
 
-        GstElement *pVideosink = 
static_cast<GstElement*>(pParentWindow->CreateGStreamerSink());
-        if (pVideosink)
-        {
-            if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
-                mbUseGtkSink = true;
-        }
+    GstElement *pVideosink = 
static_cast<GstElement*>(pParentWindow->CreateGStreamerSink());
+    if (pVideosink)
+    {
+        if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
+            mbUseGtkSink = true;
+    }
+    else
+    {
+        if (pEnvData->platform == SystemEnvData::Platform::Wayland)
+            pVideosink = gst_element_factory_make("waylandsink", 
"video-output");
         else
-        {
-            if (pEnvData->platform == SystemEnvData::Platform::Wayland)
-                pVideosink = gst_element_factory_make("waylandsink", 
"video-output");
-            else
-                pVideosink = gst_element_factory_make("autovideosink", 
"video-output");
-            if (!pVideosink)
-                return nullptr;
-        }
+            pVideosink = gst_element_factory_make("autovideosink", 
"video-output");
+        if (!pVideosink)
+            return nullptr;
+    }
 
-        xRet = new ::avmedia::gstreamer::Window;
+    rtl::Reference< ::avmedia::gstreamer::Window > xRet = new 
::avmedia::gstreamer::Window;
 
-        g_object_set(G_OBJECT(mpPlaybin), "video-sink", pVideosink, nullptr);
-        g_object_set(G_OBJECT(mpPlaybin), "force-aspect-ratio", FALSE, 
nullptr);
+    g_object_set(G_OBJECT(mpPlaybin), "video-sink", pVideosink, nullptr);
+    g_object_set(G_OBJECT(mpPlaybin), "force-aspect-ratio", FALSE, nullptr);
 
-        if ((rArguments.getLength() >= 4) && (rArguments[3] >>= pIntPtr) && 
pIntPtr)
+    if ((rArguments.getLength() >= 4) && (rArguments[3] >>= pIntPtr) && 
pIntPtr)
+    {
+        auto pItem = reinterpret_cast<const avmedia::MediaItem*>(pIntPtr);
+        Graphic aGraphic = pItem->getGraphic();
+        const text::GraphicCrop& rCrop = pItem->getCrop();
+        if (!aGraphic.IsNone() && (rCrop.Bottom > 0 || rCrop.Left > 0 || 
rCrop.Right > 0 || rCrop.Top > 0))
         {
-            auto pItem = reinterpret_cast<const avmedia::MediaItem*>(pIntPtr);
-            Graphic aGraphic = pItem->getGraphic();
-            const text::GraphicCrop& rCrop = pItem->getCrop();
-            if (!aGraphic.IsNone() && (rCrop.Bottom > 0 || rCrop.Left > 0 || 
rCrop.Right > 0 || rCrop.Top > 0))
+            // The media item has a non-empty cropping set. Try to crop the 
video accordingly.
+            Size aPref = aGraphic.GetPrefSize();
+            Size aPixel = aGraphic.GetSizePixel();
+            tools::Long nLeft = aPixel.getWidth() * rCrop.Left / 
aPref.getWidth();
+            tools::Long nTop = aPixel.getHeight() * rCrop.Top / 
aPref.getHeight();
+            tools::Long nRight = aPixel.getWidth() * rCrop.Right / 
aPref.getWidth();
+            tools::Long nBottom = aPixel.getHeight() * rCrop.Bottom / 
aPref.getHeight();
+            GstElement* pVideoFilter = gst_element_factory_make("videocrop", 
nullptr);
+            if (pVideoFilter)
             {
-                // The media item has a non-empty cropping set. Try to crop 
the video accordingly.
-                Size aPref = aGraphic.GetPrefSize();
-                Size aPixel = aGraphic.GetSizePixel();
-                tools::Long nLeft = aPixel.getWidth() * rCrop.Left / 
aPref.getWidth();
-                tools::Long nTop = aPixel.getHeight() * rCrop.Top / 
aPref.getHeight();
-                tools::Long nRight = aPixel.getWidth() * rCrop.Right / 
aPref.getWidth();
-                tools::Long nBottom = aPixel.getHeight() * rCrop.Bottom / 
aPref.getHeight();
-                GstElement* pVideoFilter = 
gst_element_factory_make("videocrop", nullptr);
-                if (pVideoFilter)
-                {
-                    g_object_set(G_OBJECT(pVideoFilter), "left", nLeft, 
nullptr);
-                    g_object_set(G_OBJECT(pVideoFilter), "top", nTop, nullptr);
-                    g_object_set(G_OBJECT(pVideoFilter), "right", nRight, 
nullptr);
-                    g_object_set(G_OBJECT(pVideoFilter), "bottom", nBottom, 
nullptr);
-                    g_object_set(G_OBJECT(mpPlaybin), "video-filter", 
pVideoFilter, nullptr);
-                }
+                g_object_set(G_OBJECT(pVideoFilter), "left", nLeft, nullptr);
+                g_object_set(G_OBJECT(pVideoFilter), "top", nTop, nullptr);
+                g_object_set(G_OBJECT(pVideoFilter), "right", nRight, nullptr);
+                g_object_set(G_OBJECT(pVideoFilter), "bottom", nBottom, 
nullptr);
+                g_object_set(G_OBJECT(mpPlaybin), "video-filter", 
pVideoFilter, nullptr);
             }
         }
+    }
 
-        if (!mbUseGtkSink)
-        {
-            mnWindowID = 
pEnvData->GetWindowHandle(pParentWindow->ImplGetFrame());
-            mpDisplay = pEnvData->pDisplay;
-            SAL_INFO( "avmedia.gstreamer", AVVERSION "set window id to " << 
static_cast<int>(mnWindowID) << " XOverlay " << mpXOverlay);
-        }
-        gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
-        if (!mbUseGtkSink && mpXOverlay)
-            gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID );
+    if (!mbUseGtkSink)
+    {
+        mnWindowID = pEnvData->GetWindowHandle(pParentWindow->ImplGetFrame());
+        mpDisplay = pEnvData->pDisplay;
+        SAL_INFO( "avmedia.gstreamer", AVVERSION "set window id to " << 
static_cast<int>(mnWindowID) << " XOverlay " << mpXOverlay);
     }
+    gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
+    if (!mbUseGtkSink && mpXOverlay)
+        gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID );
 
     return xRet;
 }
diff --git a/basctl/source/basicide/unomodel.cxx 
b/basctl/source/basicide/unomodel.cxx
index 595798fc49b8..9f6ca6c98deb 100644
--- a/basctl/source/basicide/unomodel.cxx
+++ b/basctl/source/basicide/unomodel.cxx
@@ -120,15 +120,11 @@ void  SIDEModel::notImplemented()
 css::uno::Reference< css::uno::XInterface > SAL_CALL 
SIDEModel::getCurrentSelection()
 {
     SolarMutexGuard aGuard;
-    uno::Reference<container::XEnumeration> xEnum;
     Shell* pShell = GetShell();
-
-    if (pShell)
-    {
-        OUString sText = GetShell()->GetSelectionText(false);
-        xEnum = new SelectionEnumeration(sText);
-    }
-    return xEnum;
+    if (!pShell)
+        return nullptr;
+    OUString sText = GetShell()->GetSelectionText(false);
+    return uno::Reference<container::XEnumeration>(new 
SelectionEnumeration(sText));
 }
 
 } // namespace basctl
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx 
b/comphelper/source/container/embeddedobjectcontainer.cxx
index 7c01ee23bd92..b21da5a3924a 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -47,6 +47,7 @@
 #include <comphelper/propertyvalue.hxx>
 #include <cppuhelper/weakref.hxx>
 #include <sal/log.hxx>
+#include <rtl/ref.hxx>
 
 #include <officecfg/Office/Common.hxx>
 
@@ -1433,23 +1434,23 @@ uno::Reference< io::XInputStream > 
EmbeddedObjectContainer::GetGraphicReplacemen
                                                                 const 
uno::Reference< embed::XEmbeddedObject >& xObj,
                                                                 OUString* 
pMediaType )
 {
-    uno::Reference< io::XInputStream > xInStream;
-    if ( xObj.is() )
-    {
-        try
-        {
-            // retrieving of the visual representation can switch object to 
running state
-            embed::VisualRepresentation aRep = 
xObj->getPreferredVisualRepresentation( nViewAspect );
-            if ( pMediaType )
-                *pMediaType = aRep.Flavor.MimeType;
+    if ( !xObj.is() )
+        return nullptr;
 
-            uno::Sequence < sal_Int8 > aSeq;
-            aRep.Data >>= aSeq;
-            xInStream = new ::comphelper::SequenceInputStream( aSeq );
-        }
-        catch (const uno::Exception&)
-        {
-        }
+    rtl::Reference< ::comphelper::SequenceInputStream > xInStream;
+    try
+    {
+        // retrieving of the visual representation can switch object to 
running state
+        embed::VisualRepresentation aRep = 
xObj->getPreferredVisualRepresentation( nViewAspect );
+        if ( pMediaType )
+            *pMediaType = aRep.Flavor.MimeType;
+
+        uno::Sequence < sal_Int8 > aSeq;
+        aRep.Data >>= aSeq;
+        xInStream = new ::comphelper::SequenceInputStream( aSeq );
+    }
+    catch (const uno::Exception&)
+    {
     }
 
     return xInStream;
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx 
b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index 887648433d36..81872f50a969 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -2510,7 +2510,7 @@ namespace accessibility
 
     css::uno::Reference< css::accessibility::XAccessibleHyperlink > SAL_CALL 
AccessibleEditableTextPara::getHyperLink( ::sal_Int32 nLinkIndex )
     {
-        css::uno::Reference< css::accessibility::XAccessibleHyperlink > xRef;
+        rtl::Reference< AccessibleHyperlink > xRef;
 
         SvxAccessibleTextAdapter& rT = GetTextForwarder();
         const sal_Int32 nPara = GetParagraphIndex();
diff --git a/editeng/source/accessibility/AccessibleHyperlink.cxx 
b/editeng/source/accessibility/AccessibleHyperlink.cxx
index 25d9683fceff..52f45dc44ff3 100644
--- a/editeng/source/accessibility/AccessibleHyperlink.cxx
+++ b/editeng/source/accessibility/AccessibleHyperlink.cxx
@@ -78,22 +78,19 @@ namespace accessibility
 
     uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL 
AccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex )
     {
-        uno::Reference< css::accessibility::XAccessibleKeyBinding > 
xKeyBinding;
+        if( !isValid() || ( nIndex != 0 ) )
+            return nullptr;
 
-        if( isValid() && ( nIndex == 0 ) )
-        {
-            rtl::Reference<::comphelper::OAccessibleKeyBindingHelper> 
pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
-            xKeyBinding = pKeyBindingHelper;
-
-            awt::KeyStroke aKeyStroke;
-            aKeyStroke.Modifiers = 0;
-            aKeyStroke.KeyCode = KEY_RETURN;
-            aKeyStroke.KeyChar = 0;
-            aKeyStroke.KeyFunc = 0;
-            pKeyBindingHelper->AddKeyBinding( aKeyStroke );
-        }
+        rtl::Reference<::comphelper::OAccessibleKeyBindingHelper> 
pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
+
+        awt::KeyStroke aKeyStroke;
+        aKeyStroke.Modifiers = 0;
+        aKeyStroke.KeyCode = KEY_RETURN;
+        aKeyStroke.KeyChar = 0;
+        aKeyStroke.KeyFunc = 0;
+        pKeyBindingHelper->AddKeyBinding( aKeyStroke );
 
-        return xKeyBinding;
+        return pKeyBindingHelper;
     }
 
     // XAccessibleHyperlink
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 4b64daeefa7a..91efa5db50c0 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -300,53 +300,47 @@ uno::Reference< text::XTextRange > SAL_CALL 
SvxUnoTextRangeBase::getStart()
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference< text::XTextRange > xRange;
-
     SvxTextForwarder* pForwarder = mpEditSource ? 
mpEditSource->GetTextForwarder() : nullptr;
-    if( pForwarder )
-    {
-        CheckSelection( maSelection, pForwarder );
+    if( !pForwarder )
+        return nullptr;
 
-        SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( 
getText() );
+    CheckSelection( maSelection, pForwarder );
 
-        if(pText == nullptr)
-            throw uno::RuntimeException(u"Failed to retrieve a valid text base 
object from the Uno Tunnel"_ustr);
+    SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( 
getText() );
 
-        rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *pText );
-        xRange = pRange;
+    if(pText == nullptr)
+        throw uno::RuntimeException(u"Failed to retrieve a valid text base 
object from the Uno Tunnel"_ustr);
 
-        ESelection aNewSel = maSelection;
-        aNewSel.CollapseToStart();
-        pRange->SetSelection( aNewSel );
-    }
+    rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *pText );
 
-    return xRange;
+    ESelection aNewSel = maSelection;
+    aNewSel.CollapseToStart();
+    pRange->SetSelection( aNewSel );
+
+    return pRange;
 }
 
 uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getEnd()
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference< text::XTextRange > xRet;
-
     SvxTextForwarder* pForwarder = mpEditSource ? 
mpEditSource->GetTextForwarder() : nullptr;
-    if( pForwarder )
-    {
-        CheckSelection( maSelection, pForwarder );
+    if( !pForwarder )
+        return nullptr;
 
-        SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( 
getText() );
+    CheckSelection( maSelection, pForwarder );
 
-        if(pText == nullptr)
-            throw uno::RuntimeException(u"Failed to retrieve a valid text base 
object from the Uno Tunnel"_ustr);
+    SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( 
getText() );
 
-        rtl::Reference<SvxUnoTextRange> pNew = new SvxUnoTextRange( *pText );
-        xRet = pNew;
+    if(pText == nullptr)
+        throw uno::RuntimeException(u"Failed to retrieve a valid text base 
object from the Uno Tunnel"_ustr);
 
-        ESelection aNewSel = maSelection;
-        aNewSel.CollapseToEnd();
-        pNew->SetSelection( aNewSel );
-    }
-    return xRet;
+    rtl::Reference<SvxUnoTextRange> pNew = new SvxUnoTextRange( *pText );
+
+    ESelection aNewSel = maSelection;
+    aNewSel.CollapseToEnd();
+    pNew->SetSelection( aNewSel );
+    return pNew;
 }
 
 OUString SAL_CALL SvxUnoTextRangeBase::getString()
@@ -2071,28 +2065,26 @@ uno::Reference< text::XTextRange > SAL_CALL 
SvxUnoTextBase::finishParagraph(
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference< text::XTextRange > xRet;
     SvxEditSource *pEditSource = GetEditSource();
     SvxTextForwarder *pTextForwarder = pEditSource ? 
pEditSource->GetTextForwarder() : nullptr;
-    if (pTextForwarder)
-    {
-        sal_Int32 nParaCount = pTextForwarder->GetParagraphCount();
-        DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
-        pTextForwarder->AppendParagraph();
-
-        // set properties for the previously last paragraph
-        sal_Int32 nPara = nParaCount - 1;
-        ESelection aSel(nPara, 0);
-        SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
-        SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
-                ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(), 
pTextForwarder, nPara );
-        pTextForwarder->QuickSetAttribs( aItemSet, aSel );
-        pEditSource->UpdateData();
-        rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *this );
-        xRet = pRange;
-        pRange->SetSelection( aSel );
-    }
-    return xRet;
+    if (!pTextForwarder)
+        return nullptr;
+
+    sal_Int32 nParaCount = pTextForwarder->GetParagraphCount();
+    DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
+    pTextForwarder->AppendParagraph();
+
+    // set properties for the previously last paragraph
+    sal_Int32 nPara = nParaCount - 1;
+    ESelection aSel(nPara, 0);
+    SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
+    SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
+            ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(), pTextForwarder, 
nPara );
+    pTextForwarder->QuickSetAttribs( aItemSet, aSel );
+    pEditSource->UpdateData();
+    rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *this );
+    pRange->SetSelection( aSel );
+    return pRange;
 }
 
 uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::insertTextPortion(
@@ -2102,38 +2094,35 @@ uno::Reference< text::XTextRange > SAL_CALL 
SvxUnoTextBase::insertTextPortion(
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference< text::XTextRange > xRet;
-
     if (!rTextRange.is())
-        return xRet;
+        return nullptr;
 
     SvxUnoTextRangeBase* pRange = 
comphelper::getFromUnoTunnel<SvxUnoTextRange>(rTextRange);
     if (!pRange)
-        return xRet;
+        return nullptr;
 
     SvxEditSource *pEditSource = GetEditSource();
     SvxTextForwarder *pTextForwarder = pEditSource ? 
pEditSource->GetTextForwarder() : nullptr;
 
-    if (pTextForwarder)
-    {
-        pRange->setString(rText);
-
-        ESelection aSelection(pRange->GetSelection());
-
-        pTextForwarder->RemoveAttribs(aSelection);
-        pEditSource->UpdateData();
-
-        SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
-        SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
-                ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, 
aSelection.start.nPara );
-        pTextForwarder->QuickSetAttribs( aItemSet, aSelection);
-        rtl::Reference<SvxUnoTextRange> pNewRange = new SvxUnoTextRange( *this 
);
-        xRet = pNewRange;
-        pNewRange->SetSelection(aSelection);
-        for( const beans::PropertyValue& rProp : rCharAndParaProps )
-            pNewRange->setPropertyValue( rProp.Name, rProp.Value );
-    }
-    return xRet;
+    if (!pTextForwarder)
+        return nullptr;
+
+    pRange->setString(rText);
+
+    ESelection aSelection(pRange->GetSelection());
+
+    pTextForwarder->RemoveAttribs(aSelection);
+    pEditSource->UpdateData();
+
+    SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
+    SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
+            ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, 
aSelection.start.nPara );
+    pTextForwarder->QuickSetAttribs( aItemSet, aSelection);
+    rtl::Reference<SvxUnoTextRange> pNewRange = new SvxUnoTextRange( *this );
+    pNewRange->SetSelection(aSelection);
+    for( const beans::PropertyValue& rProp : rCharAndParaProps )
+        pNewRange->setPropertyValue( rProp.Name, rProp.Value );
+    return pNewRange;
 }
 
 // css::text::XTextPortionAppend (new import API)
@@ -2145,33 +2134,31 @@ uno::Reference< text::XTextRange > SAL_CALL 
SvxUnoTextBase::appendTextPortion(
 
     SvxEditSource *pEditSource = GetEditSource();
     SvxTextForwarder *pTextForwarder = pEditSource ? 
pEditSource->GetTextForwarder() : nullptr;
-    uno::Reference< text::XTextRange > xRet;
-    if (pTextForwarder)
-    {
-        sal_Int32 nParaCount = pTextForwarder->GetParagraphCount();
-        DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
-        sal_Int32 nPara = nParaCount - 1;
-        SfxItemSet aSet( pTextForwarder->GetParaAttribs( nPara ) );
-        sal_Int32 nStart = pTextForwarder->AppendTextPortion( nPara, rText, 
aSet );
-        pEditSource->UpdateData();
-        sal_Int32 nEnd   = pTextForwarder->GetTextLen( nPara );
-
-        // set properties for the new text portion
-        ESelection aSel( nPara, nStart, nPara, nEnd );
-        pTextForwarder->RemoveAttribs( aSel );
-        pEditSource->UpdateData();
-
-        SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
-        SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
-                ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara );
-        pTextForwarder->QuickSetAttribs( aItemSet, aSel );
-        rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *this );
-        xRet = pRange;
-        pRange->SetSelection( aSel );
-        for( const beans::PropertyValue& rProp : rCharAndParaProps )
-            pRange->setPropertyValue( rProp.Name, rProp.Value );
-    }
-    return xRet;
+    if (!pTextForwarder)
+        return nullptr;
+
+    sal_Int32 nParaCount = pTextForwarder->GetParagraphCount();
+    DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
+    sal_Int32 nPara = nParaCount - 1;
+    SfxItemSet aSet( pTextForwarder->GetParaAttribs( nPara ) );
+    sal_Int32 nStart = pTextForwarder->AppendTextPortion( nPara, rText, aSet );
+    pEditSource->UpdateData();
+    sal_Int32 nEnd   = pTextForwarder->GetTextLen( nPara );
+
+    // set properties for the new text portion
+    ESelection aSel( nPara, nStart, nPara, nEnd );
+    pTextForwarder->RemoveAttribs( aSel );
+    pEditSource->UpdateData();
+
+    SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
+    SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
+            ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara );
+    pTextForwarder->QuickSetAttribs( aItemSet, aSel );
+    rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *this );
+    pRange->SetSelection( aSel );
+    for( const beans::PropertyValue& rProp : rCharAndParaProps )
+        pRange->setPropertyValue( rProp.Name, rProp.Value );
+    return pRange;
 }
 
 void SvxUnoTextBase::copyText(
diff --git a/extensions/source/logging/logger.cxx 
b/extensions/source/logging/logger.cxx
index c1d4d88ddfa2..fffef9f16122 100644
--- a/extensions/source/logging/logger.cxx
+++ b/extensions/source/logging/logger.cxx
@@ -32,6 +32,7 @@
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/weakref.hxx>
+#include <unotools/weakref.hxx>
 #include <map>
 #include <utility>
 
@@ -97,7 +98,7 @@ namespace logging
     private:
         ::osl::Mutex                    m_aMutex;
         Reference<XComponentContext>    m_xContext;
-        std::map< OUString, WeakReference<XLogger> > m_aLoggerMap;
+        std::map< OUString, unotools::WeakReference<EventLogger> > 
m_aLoggerMap;
 
     public:
         explicit LoggerPool( const Reference< XComponentContext >& _rxContext 
);
@@ -236,13 +237,13 @@ namespace logging
     {
         ::osl::MutexGuard aGuard( m_aMutex );
 
-        WeakReference< XLogger >& rLogger( m_aLoggerMap[ _rName ] );
-        Reference< XLogger > xLogger( rLogger );
+        unotools::WeakReference< EventLogger >& rLogger( m_aLoggerMap[ _rName 
] );
+        rtl::Reference< EventLogger > xLogger( rLogger );
         if ( !xLogger.is() )
         {
             // never requested before, or already dead
             xLogger = new EventLogger( m_xContext, _rName );
-            rLogger = xLogger;
+            rLogger = xLogger.get();
         }
 
         return xLogger;
diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx
index 7b41dec828d8..41935d366959 100644
--- a/forms/source/component/Grid.cxx
+++ b/forms/source/component/Grid.cxx
@@ -311,9 +311,9 @@ Reference<XPropertySet> SAL_CALL 
OGridControlModel::createColumn(const OUString&
     const Sequence< OUString >& rColumnTypes = frm::getColumnTypes();
     return createColumnById( ::detail::findPos( ColumnType, rColumnTypes ) );
 }
-Reference<XPropertySet>  OGridControlModel::createColumnById(sal_Int32 
nTypeId) const
+rtl::Reference<OGridColumn>  OGridControlModel::createColumnById(sal_Int32 
nTypeId) const
 {
-    Reference<XPropertySet>  xReturn;
+    rtl::Reference<OGridColumn>  xReturn;
     switch (nTypeId)
     {
         case TYPE_CHECKBOX:         xReturn = new CheckBoxColumn( getContext() 
); break;
@@ -863,7 +863,7 @@ void OGridControlModel::read(const 
Reference<XObjectInputStream>& _rxInStream)
             // reading the model names
             OUString sModelName;
             _rxInStream >> sModelName;
-            Reference<XPropertySet>  
xCol(createColumnById(getColumnTypeByModelName(sModelName)));
+            rtl::Reference<OGridColumn> 
xCol(createColumnById(getColumnTypeByModelName(sModelName)));
             DBG_ASSERT(xCol.is(), "OGridControlModel::read : unknown column 
type !");
             sal_Int32 nObjLen = _rxInStream->readLong();
             if (nObjLen)
@@ -871,8 +871,7 @@ void OGridControlModel::read(const 
Reference<XObjectInputStream>& _rxInStream)
                 sal_Int32 nMark = xMark->createMark();
                 if (xCol.is())
                 {
-                    OGridColumn* pCol = 
comphelper::getFromUnoTunnel<OGridColumn>(xCol);
-                    pCol->read(_rxInStream);
+                    xCol->read(_rxInStream);
                 }
                 xMark->jumpToMark(nMark);
                 _rxInStream->skipBytes(nObjLen);
diff --git a/forms/source/component/Grid.hxx b/forms/source/component/Grid.hxx
index 6ee7174da3a4..02cfef64ffb1 100644
--- a/forms/source/component/Grid.hxx
+++ b/forms/source/component/Grid.hxx
@@ -176,7 +176,7 @@ private:
             ElementDescription* _pElement
         ) override;
 
-    css::uno::Reference< css::beans::XPropertySet>  createColumnById(sal_Int32 
nTypeId) const;
+    rtl::Reference<OGridColumn> createColumnById(sal_Int32 nTypeId) const;
 
     virtual ElementDescription* createElementMetaData( ) override;
 
diff --git a/package/source/xstor/owriteablestream.cxx 
b/package/source/xstor/owriteablestream.cxx
index 798fafa808a1..1de93efe4ddb 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -738,7 +738,7 @@ void OWriteStream_Impl::Commit()
         if ( m_pAntiImpl )
             m_pAntiImpl->DeInit();
 
-        uno::Reference< io::XInputStream > xInStream;
+        rtl::Reference< OSelfTerminateFileStream > xInStream;
         try
         {
             xInStream = new OSelfTerminateFileStream(m_xContext, 
std::move(*m_oTempFile));
diff --git a/package/source/xstor/xstorage.cxx 
b/package/source/xstor/xstorage.cxx
index 1fca7c3df634..eee9ee466f13 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -3364,7 +3364,7 @@ uno::Reference< io::XInputStream > SAL_CALL 
OStorage::getRawEncrStreamElement(
     if ( sStreamName.isEmpty() || 
!::comphelper::OStorageHelper::IsValidZipEntryFileName( sStreamName, false ) )
         throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry 
name syntax.", uno::Reference< uno::XInterface >(), 1 );
 
-    uno::Reference < io::XInputStream > xTempIn;
+    rtl::Reference < utl::TempFileFastService > xTempIn;
     try
     {
         SotElement_Impl* pElement = m_pImpl->FindElement( sStreamName );
@@ -3385,16 +3385,15 @@ uno::Reference< io::XInputStream > SAL_CALL 
OStorage::getRawEncrStreamElement(
         if ( !xRawInStream.is() )
             throw io::IOException( THROW_WHERE );
 
-        rtl::Reference < utl::TempFileFastService > xTempFile = new 
utl::TempFileFastService;
-        xTempIn = xTempFile;
+        xTempIn = new utl::TempFileFastService;
 
-        if ( !xTempFile )
+        if ( !xTempIn )
             throw io::IOException( THROW_WHERE );
 
         // Copy temporary file to a new one
-        ::comphelper::OStorageHelper::CopyInputToOutput( xRawInStream, 
xTempFile );
-        xTempFile->closeOutput();
-        xTempFile->seek( 0 );
+        ::comphelper::OStorageHelper::CopyInputToOutput( xRawInStream, xTempIn 
);
+        xTempIn->closeOutput();
+        xTempIn->seek( 0 );
 
     }
     catch( const embed::InvalidStorageException& )
diff --git a/package/source/zipapi/ZipFile.cxx 
b/package/source/zipapi/ZipFile.cxx
index 63097ccb8710..d03140f1804b 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -733,7 +733,6 @@ uno::Reference< XInputStream > 
ZipFile::createStreamForZipEntry(
     if (!bUseBufferedStream)
         return xSrcStream;
 
-    uno::Reference<io::XInputStream> xBufStream;
 #ifndef EMSCRIPTEN
     static const sal_Int32 nThreadingThreshold = 10000;
 
@@ -748,13 +747,11 @@ uno::Reference< XInputStream > 
ZipFile::createStreamForZipEntry(
             || !rData.is()
             || rData->m_nEncAlg != xml::crypto::CipherID::AES_GCM_W3C))
     {
-        xBufStream = new XBufferedThreadedStream(xSrcStream, 
xSrcStream->getSize());
+        return new XBufferedThreadedStream(xSrcStream, xSrcStream->getSize());
     }
-    else
 #endif
-        xBufStream = new XBufferedStream(xSrcStream);
 
-    return xBufStream;
+    return new XBufferedStream(xSrcStream);
 }
 
 uno::Reference< XInputStream > ZipFile::StaticGetDataFromRawStream(
diff --git a/reportdesign/source/core/api/Group.cxx 
b/reportdesign/source/core/api/Group.cxx
index fbb3f6915754..e4e626600205 100644
--- a/reportdesign/source/core/api/Group.cxx
+++ b/reportdesign/source/core/api/Group.cxx
@@ -139,7 +139,7 @@ void SAL_CALL OGroup::setFooterOn( sal_Bool _footeron )
 
 uno::Reference< report::XSection > SAL_CALL OGroup::getHeader()
 {
-    uno::Reference< report::XSection > xRet;
+    rtl::Reference< OSection > xRet;
     {
         ::osl::MutexGuard aGuard(m_aMutex);
         xRet = m_xHeader;
@@ -152,7 +152,7 @@ uno::Reference< report::XSection > SAL_CALL 
OGroup::getHeader()
 
 uno::Reference< report::XSection > SAL_CALL OGroup::getFooter()
 {
-    uno::Reference< report::XSection > xRet;
+    rtl::Reference< OSection > xRet;
     {
         ::osl::MutexGuard aGuard(m_aMutex);
         xRet = m_xFooter;
diff --git a/scripting/source/basprov/basprov.cxx 
b/scripting/source/basprov/basprov.cxx
index 0271ddaab64c..1d2e2506607e 100644
--- a/scripting/source/basprov/basprov.cxx
+++ b/scripting/source/basprov/basprov.cxx
@@ -265,7 +265,7 @@ namespace basprov
 
         SolarMutexGuard aGuard;
 
-        Reference< provider::XScript > xScript;
+        rtl::Reference< BasicScriptImpl > xScript;
         Reference< uri::XUriReferenceFactory > xFac ( 
uri::UriReferenceFactory::create( m_xContext )  );
 
         Reference<  uri::XUriReference > uriRef = xFac->parse( scriptURI );
diff --git a/scripting/source/stringresource/stringresource.cxx 
b/scripting/source/stringresource/stringresource.cxx
index ca9d55ba3f79..ec304ffc1d0b 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -1252,7 +1252,7 @@ class BinaryInput
 public:
     BinaryInput( const Sequence< ::sal_Int8 >& aData );
 
-    Reference< io::XInputStream > getInputStreamForSection( sal_Int32 nSize );
+    rtl::Reference< utl::TempFileFastService > getInputStreamForSection( 
sal_Int32 nSize );
 
     void seek( sal_Int32 nPos );
     sal_Int32 getPosition() const
@@ -1274,21 +1274,20 @@ BinaryInput::BinaryInput( const Sequence< ::sal_Int8 >& 
aData )
     m_nSize = m_aData.getLength();
 }
 
-Reference< io::XInputStream > BinaryInput::getInputStreamForSection( sal_Int32 
nSize )
+rtl::Reference< utl::TempFileFastService > 
BinaryInput::getInputStreamForSection( sal_Int32 nSize )
 {
-    Reference< io::XInputStream > xIn;
+    rtl::Reference< utl::TempFileFastService > xTempOut;
     if( m_nCurPos + nSize <= m_nSize )
     {
-        rtl::Reference< utl::TempFileFastService > xTempOut = new 
utl::TempFileFastService;
+        xTempOut = new utl::TempFileFastService;
         Sequence< sal_Int8 > aSection( m_pData + m_nCurPos, nSize );
         xTempOut->writeBytes( aSection );
         xTempOut->seek( 0 );
-        xIn = xTempOut;
     }
     else
         OSL_FAIL( "BinaryInput::getInputStreamForSection(): Read past end" );
 
-    return xIn;
+    return xTempOut;
 }
 
 void BinaryInput::seek( sal_Int32 nPos )
@@ -1403,7 +1402,7 @@ void StringResourcePersistenceImpl::importBinary( const 
Sequence< ::sal_Int8 >&
 
         sal_Int32 nAfterStringPos = aIn.getPosition();
         sal_Int32 nSize = pPositions[i+1] - nAfterStringPos;
-        Reference< io::XInputStream > xInput = aIn.getInputStreamForSection( 
nSize );
+        rtl::Reference< utl::TempFileFastService > xInput = 
aIn.getInputStreamForSection( nSize );
         if( xInput.is() )
         {
             LocaleItem* pLocaleItem = new LocaleItem( std::move(aLocale) );
diff --git a/sfx2/source/appl/appdispatchprovider.cxx 
b/sfx2/source/appl/appdispatchprovider.cxx
index 9cdc6f21ba25..354d979abb04 100644
--- a/sfx2/source/appl/appdispatchprovider.cxx
+++ b/sfx2/source/appl/appdispatchprovider.cxx
@@ -109,11 +109,10 @@ Reference < XDispatch > SAL_CALL 
SfxAppDispatchProvider::queryDispatch(
     SolarMutexGuard guard;
 
     bool                bMasterCommand( false );
-    Reference < XDispatch > xDisp;
     const SfxSlot* pSlot = nullptr;
     SfxApplication* pApp = SfxGetpApp();
     if ( !pApp )
-        return xDisp;
+        return nullptr;
     SfxDispatcher* pAppDisp = pApp->GetAppDispatcher_Impl();
     if ( aURL.Protocol == "slot:" || aURL.Protocol == "commandId:" )
     {
@@ -131,15 +130,14 @@ Reference < XDispatch > SAL_CALL 
SfxAppDispatchProvider::queryDispatch(
             pSlot = pAppDisp->GetSlot( aURL.Main );
     }
 
-    if ( pSlot )
-    {
-        rtl::Reference<SfxOfficeDispatch> pDispatch = new SfxOfficeDispatch( 
pAppDisp, pSlot, aURL ) ;
-        pDispatch->SetFrame(m_xFrame);
-        pDispatch->SetMasterUnoCommand( bMasterCommand );
-        xDisp = pDispatch;
-    }
+    if ( !pSlot )
+        return nullptr;
+
+    rtl::Reference<SfxOfficeDispatch> pDispatch = new SfxOfficeDispatch( 
pAppDisp, pSlot, aURL ) ;
+    pDispatch->SetFrame(m_xFrame);
+    pDispatch->SetMasterUnoCommand( bMasterCommand );
 
-    return xDisp;
+    return pDispatch;
 }
 
 Sequence< Reference < XDispatch > > SAL_CALL 
SfxAppDispatchProvider::queryDispatches( const Sequence < DispatchDescriptor >& 
seqDescriptor )
diff --git a/sfx2/source/control/thumbnailviewacc.cxx 
b/sfx2/source/control/thumbnailviewacc.cxx
index b15ecca3b743..cd29f0e94836 100644
--- a/sfx2/source/control/thumbnailviewacc.cxx
+++ b/sfx2/source/control/thumbnailviewacc.cxx
@@ -191,19 +191,17 @@ uno::Reference< accessibility::XAccessible > SAL_CALL 
ThumbnailViewAcc::getAcces
 {
     ThrowIfDisposed();
     const SolarMutexGuard aSolarGuard;
+
     const sal_uInt16 nItemId = mpThumbnailView->GetItemId(Point(aPoint.X, 
aPoint.Y));
-    uno::Reference< accessibility::XAccessible >    xRet;
+    if ( !nItemId )
+        return nullptr;
 
-    if ( nItemId )
-    {
-        const size_t nItemPos = mpThumbnailView->GetItemPos(nItemId);
+    const size_t nItemPos = mpThumbnailView->GetItemPos(nItemId);
+    if( THUMBNAILVIEW_ITEM_NONEITEM == nItemPos )
+        return nullptr;
 
-        if( THUMBNAILVIEW_ITEM_NONEITEM != nItemPos )
-        {
-            ThumbnailViewItem* const pItem = 
mpThumbnailView->mFilteredItemList[nItemPos];
-            xRet = pItem->GetAccessible();
-        }
-    }
+    ThumbnailViewItem* const pItem = 
mpThumbnailView->mFilteredItemList[nItemPos];
+    rtl::Reference<ThumbnailViewItemAcc> xRet = pItem->GetAccessible();
 
     return xRet;
 }
@@ -307,7 +305,7 @@ uno::Reference< accessibility::XAccessible > SAL_CALL 
ThumbnailViewAcc::getSelec
 {
     ThrowIfDisposed();
     const SolarMutexGuard aSolarGuard;
-    uno::Reference< accessibility::XAccessible >    xRet;
+    rtl::Reference< ThumbnailViewItemAcc > xRet;
 
     for( sal_uInt16 i = 0, nCount = getItemCount(), nSel = 0; ( i < nCount ) 
&& !xRet.is(); i++ )
     {
diff --git a/sfx2/source/control/thumbnailviewitemacc.cxx 
b/sfx2/source/control/thumbnailviewitemacc.cxx
index 4e8baf3bc89d..a78ad3cb5293 100644
--- a/sfx2/source/control/thumbnailviewitemacc.cxx
+++ b/sfx2/source/control/thumbnailviewitemacc.cxx
@@ -69,12 +69,10 @@ uno::Reference< accessibility::XAccessible > SAL_CALL 
ThumbnailViewItemAcc::getA
 uno::Reference< accessibility::XAccessible > SAL_CALL 
ThumbnailViewItemAcc::getAccessibleParent()
 {
     const SolarMutexGuard aSolarGuard;
-    uno::Reference< accessibility::XAccessible >    xRet;
 
-    if (mpThumbnailViewItem)
-        xRet = mpThumbnailViewItem->mrParent.getAccessible();
-
-    return xRet;
+    if (!mpThumbnailViewItem)
+        return nullptr;
+    return mpThumbnailViewItem->mrParent.getAccessible();
 }
 
 sal_Int64 SAL_CALL ThumbnailViewItemAcc::getAccessibleIndexInParent()
diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx
index 178194bba87d..8b13a54641bd 100644
--- a/sot/source/sdstor/ucbstorage.cxx
+++ b/sot/source/sdstor/ucbstorage.cxx
@@ -654,7 +654,7 @@ UCBStorageStream_Impl::UCBStorageStream_Impl( const 
OUString& rName, StreamMode
     try
     {
         // create the content
-        Reference< css::ucb::XCommandEnvironment > xComEnv;
+        rtl::Reference< ::ucbhelper::CommandEnvironment > xComEnv;
 
         OUString aTemp( rName );
 
@@ -1656,7 +1656,7 @@ void UCBStorage_Impl::CreateContent()
     try
     {
         // create content; where to put StreamMode ?! ( already done when 
opening the file of the package ? )
-        Reference< css::ucb::XCommandEnvironment > xComEnv;
+        rtl::Reference< ::ucbhelper::CommandEnvironment > xComEnv;
 
         OUString aTemp( m_aURL );
 
@@ -1728,7 +1728,7 @@ void UCBStorage_Impl::ReadContent()
                     // streams can be external OLE objects, so they are now 
folders, but storages!
                     OUString aName( m_aURL + "/" + xRow->getString(1));
 
-                    Reference< css::ucb::XCommandEnvironment > xComEnv;
+                    rtl::Reference< ::ucbhelper::CommandEnvironment > xComEnv;
                     if ( m_bRepairPackage )
                     {
                         xComEnv = new ::ucbhelper::CommandEnvironment( 
Reference< css::task::XInteractionHandler >(),
diff --git a/starmath/source/mathml/import.cxx 
b/starmath/source/mathml/import.cxx
index 59d58ea0035d..9c3392fa2b38 100644
--- a/starmath/source/mathml/import.cxx
+++ b/starmath/source/mathml/import.cxx
@@ -670,9 +670,7 @@ public:
 uno::Reference<XFastContextHandler> SAL_CALL
 SmMLImportContext::createFastChildContext(sal_Int32, const 
uno::Reference<XFastAttributeList>&)
 {
-    uno::Reference<xml::sax::XFastContextHandler> xContext;
-    xContext = new SmMLImportContext(static_cast<SmMLImport&>(GetImport()), 
&m_pElement);
-    return xContext;
+    return new SmMLImportContext(static_cast<SmMLImport&>(GetImport()), 
&m_pElement);
 }
 
 void SmMLImportContext::declareMlError()
diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index a3be4b3f3e80..d1de291d2efc 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -413,7 +413,7 @@ uno::Reference< embed::XStorage > 
FSStorage::openStorageElementImpl(
         throw io::IOException(); // TODO:
 
     uno::Reference< ucb::XCommandEnvironment > xDummyEnv; // TODO: provide 
InteractionHandler if any
-    uno::Reference< embed::XStorage > xResult;
+    rtl::Reference< FSStorage > xResult;
     try
     {
         if ( nStorageMode & embed::ElementModes::WRITE )
@@ -478,7 +478,7 @@ uno::Reference< io::XStream > SAL_CALL 
FSStorage::cloneStreamElement( const OUSt
     INetURLObject aFileURL( m_aURL );
     aFileURL.Append( aStreamName );
 
-    uno::Reference < io::XStream > xTempResult;
+    rtl::Reference < utl::TempFileFastService > xTempResult;
     try
     {
         uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
diff --git a/svtools/source/brwbox/editbrowsebox2.cxx 
b/svtools/source/brwbox/editbrowsebox2.cxx
index 4396297ba700..47a1bca8b217 100644
--- a/svtools/source/brwbox/editbrowsebox2.cxx
+++ b/svtools/source/brwbox/editbrowsebox2.cxx
@@ -40,17 +40,15 @@ namespace svt
 Reference< XAccessible > EditBrowseBox::CreateAccessibleCheckBoxCell(sal_Int32 
_nRow, sal_uInt16 _nColumnPos,const TriState& eState)
 {
     Reference< XAccessible > xAccessible( GetAccessible() );
-    Reference< XAccessibleContext > xAccContext;
-    if ( xAccessible.is() )
-        xAccContext = xAccessible->getAccessibleContext();
+    if ( !xAccessible.is() )
+        return nullptr;
 
-    Reference< XAccessible > xReturn;
-    if ( xAccContext.is() )
-    {
-        xReturn = new 
AccessibleCheckBoxCell(xAccContext->getAccessibleChild(::vcl::BBINDEX_TABLE),
-                                             *this, _nRow, _nColumnPos, 
eState, true);
-    }
-    return xReturn;
+    Reference< XAccessibleContext > xAccContext = 
xAccessible->getAccessibleContext();
+    if ( !xAccContext.is() )
+        return nullptr;
+
+    return new 
AccessibleCheckBoxCell(xAccContext->getAccessibleChild(::vcl::BBINDEX_TABLE),
+                                         *this, _nRow, _nColumnPos, eState, 
true);
 }
 
 sal_Int32 EditBrowseBox::GetAccessibleControlCount() const
diff --git a/svtools/source/control/accessibletabbarpagelist.cxx 
b/svtools/source/control/accessibletabbarpagelist.cxx
index 9e1edc0efa1b..4d1790c7980a 100644
--- a/svtools/source/control/accessibletabbarpagelist.cxx
+++ b/svtools/source/control/accessibletabbarpagelist.cxx
@@ -483,7 +483,7 @@ namespace accessibility
     {
         OExternalLockGuard aGuard( this );
 
-        Reference< XAccessible > xChild;
+        rtl::Reference< AccessibleTabBarPage > xChild;
         for ( size_t i = 0; i < m_aAccessibleChildren.size(); ++i )
         {
             rtl::Reference< AccessibleTabBarPage > xAcc = 
getAccessibleChildImpl( i );
diff --git a/svtools/source/control/valueacc.cxx 
b/svtools/source/control/valueacc.cxx
index 2faeeccc5ff3..ab71010dff37 100644
--- a/svtools/source/control/valueacc.cxx
+++ b/svtools/source/control/valueacc.cxx
@@ -98,12 +98,10 @@ uno::Reference< accessibility::XAccessible > SAL_CALL 
ValueItemAcc::getAccessibl
 uno::Reference< accessibility::XAccessible > SAL_CALL 
ValueItemAcc::getAccessibleParent()
 {
     const SolarMutexGuard aSolarGuard;
-    uno::Reference< accessibility::XAccessible >    xRet;
 
-    if (mpValueSetItem)
-        xRet = mpValueSetItem->mrParent.mxAccessible;
-
-    return xRet;
+    if (!mpValueSetItem)
+        return nullptr;
+    return mpValueSetItem->mrParent.mxAccessible;
 }
 
 
@@ -497,21 +495,17 @@ uno::Reference< accessibility::XAccessible > SAL_CALL 
ValueSetAcc::getAccessible
 {
     ThrowIfDisposed();
     const SolarMutexGuard aSolarGuard;
+
     const sal_uInt16 nItemId = mpValueSet->GetItemId(Point(aPoint.X, 
aPoint.Y));
-    uno::Reference< accessibility::XAccessible >    xRet;
+    if ( !nItemId )
+        return nullptr;
 
-    if ( nItemId )
-    {
-        const size_t nItemPos = mpValueSet->GetItemPos(nItemId);
+    const size_t nItemPos = mpValueSet->GetItemPos(nItemId);
+    if( VALUESET_ITEM_NONEITEM == nItemPos )
+        return nullptr;
 
-        if( VALUESET_ITEM_NONEITEM != nItemPos )
-        {
-            ValueSetItem* const pItem = mpValueSet->mItemList[nItemPos].get();
-            xRet = pItem->GetAccessible();
-        }
-    }
-
-    return xRet;
+    ValueSetItem* const pItem = mpValueSet->mItemList[nItemPos].get();
+    return pItem->GetAccessible();
 }
 
 awt::Rectangle ValueSetAcc::implGetBounds()
@@ -633,7 +627,7 @@ uno::Reference< accessibility::XAccessible > SAL_CALL 
ValueSetAcc::getSelectedAc
 {
     ThrowIfDisposed();
     const SolarMutexGuard aSolarGuard;
-    uno::Reference< accessibility::XAccessible >    xRet;
+    rtl::Reference< ValueItemAcc >    xRet;
 
     for( sal_uInt16 i = 0, nCount = getItemCount(), nSel = 0; ( i < nCount ) 
&& !xRet.is(); i++ )
     {
diff --git a/svx/source/accessibility/charmapacc.cxx 
b/svx/source/accessibility/charmapacc.cxx
index 616e3af9a23a..cf74a68428dc 100644
--- a/svx/source/accessibility/charmapacc.cxx
+++ b/svx/source/accessibility/charmapacc.cxx
@@ -222,16 +222,13 @@ uno::Reference< css::accessibility::XAccessible > 
SAL_CALL SvxShowCharSetAcc::ge
 {
     OExternalLockGuard aGuard( this );
 
-    uno::Reference< css::accessibility::XAccessible >    xRet;
     const sal_uInt16 nItemId = sal::static_int_cast<sal_uInt16>(
         m_pParent->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) ));
 
-    if( sal_uInt16(-1) != nItemId )
-    {
-        SvxShowCharSetItem* pItem = m_pParent->ImplGetItem( nItemId );
-        xRet = pItem->GetAccessible();
-    }
-    return xRet;
+    if( sal_uInt16(-1) == nItemId )
+        return nullptr;
+    SvxShowCharSetItem* pItem = m_pParent->ImplGetItem( nItemId );
+    return pItem->GetAccessible();
 }
 
 void SAL_CALL SvxShowCharSetAcc::grabFocus()
diff --git a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx 
b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
index 3a1028764a90..38caa42f6527 100644
--- a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx
@@ -954,8 +954,7 @@ namespace
                 // create parser; connect parser and filter
                 rtl::Reference<WebDAVResponseParser> const 
pWebDAVResponseParser(
                         new WebDAVResponseParser(eWebDAVResponseParserMode));
-                uno::Reference< xml::sax::XDocumentHandler > 
xWebDAVHdl(pWebDAVResponseParser);
-                xParser->setDocumentHandler(xWebDAVHdl);
+                xParser->setDocumentHandler(pWebDAVResponseParser);
 
                 // finally, parse the stream
                 xParser->parseStream(myInputSource);
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx 
b/unotools/source/ucbhelper/ucblockbytes.cxx
index e56c058c1b69..9eb7cf16ee59 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -661,7 +661,7 @@ static bool UCBOpenContentSync(
          !aScheme.equalsIgnoreAsciiCase( "https" ) )
         xLockBytes->SetStreamValid();
 
-    Reference< XPropertiesChangeListener > xListener;
+    rtl::Reference< UcbPropertiesChangeListener_Impl > xListener;
     Reference< XPropertiesChangeNotifier > xProps(xContent,UNO_QUERY);
     if(xProps.is()) {
         xListener =
diff --git a/unoxml/source/dom/attributesmap.cxx 
b/unoxml/source/dom/attributesmap.cxx
index ee0308b40255..64fdd1f9f637 100644
--- a/unoxml/source/dom/attributesmap.cxx
+++ b/unoxml/source/dom/attributesmap.cxx
@@ -68,23 +68,23 @@ namespace DOM
     {
         ::osl::MutexGuard const g(m_rMutex);
 
-        Reference< XNode > aNode;
         xmlNodePtr pNode = m_pElement->GetNodePtr();
-        if (pNode != nullptr)
+        if (pNode == nullptr)
+            return nullptr;
+
+        rtl::Reference< CNode > aNode;
+        OString o1 = OUStringToOString(name, RTL_TEXTENCODING_UTF8);
+        xmlChar const * pName = reinterpret_cast<xmlChar const *>(o1.getStr());
+        xmlAttrPtr cur = pNode->properties;
+        while (cur != nullptr)
         {
-            OString o1 = OUStringToOString(name, RTL_TEXTENCODING_UTF8);
-            xmlChar const * pName = reinterpret_cast<xmlChar const 
*>(o1.getStr());
-            xmlAttrPtr cur = pNode->properties;
-            while (cur != nullptr)
+            if( strcmp(reinterpret_cast<char const *>(pName), 
reinterpret_cast<char const *>(cur->name)) == 0)
             {
-                if( strcmp(reinterpret_cast<char const *>(pName), 
reinterpret_cast<char const *>(cur->name)) == 0)
-                {
-                    aNode = m_pElement->GetOwnerDocument().GetCNode(
-                                   reinterpret_cast<xmlNodePtr>(cur));
-                    break;
-                }
-                cur = cur->next;
+                aNode = m_pElement->GetOwnerDocument().GetCNode(
+                               reinterpret_cast<xmlNodePtr>(cur));
+                break;
             }
+            cur = cur->next;
         }
         return aNode;
     }
@@ -98,28 +98,28 @@ namespace DOM
     {
         ::osl::MutexGuard const g(m_rMutex);
 
-        Reference< XNode > aNode;
         xmlNodePtr pNode = m_pElement->GetNodePtr();
-        if (pNode != nullptr)
+        if (pNode == nullptr)
+            return nullptr;
+
+        rtl::Reference< CNode > aNode;
+        OString o1 = OUStringToOString(localName, RTL_TEXTENCODING_UTF8);
+        xmlChar const * pName = reinterpret_cast<xmlChar const *>(o1.getStr());
+        OString o2 = OUStringToOString(namespaceURI, RTL_TEXTENCODING_UTF8);
+        xmlChar const* pSearchNs =
+            reinterpret_cast<xmlChar const*>(o2.getStr());
+        xmlNsPtr const pNs = xmlSearchNsByHref(pNode->doc, pNode, pSearchNs);
+        xmlAttrPtr cur = pNode->properties;
+        while (cur != nullptr && pNs != nullptr)
         {
-            OString o1 = OUStringToOString(localName, RTL_TEXTENCODING_UTF8);
-            xmlChar const * pName = reinterpret_cast<xmlChar const 
*>(o1.getStr());
-            OString o2 = OUStringToOString(namespaceURI, 
RTL_TEXTENCODING_UTF8);
-            xmlChar const* pSearchNs =
-                reinterpret_cast<xmlChar const*>(o2.getStr());
-            xmlNsPtr const pNs = xmlSearchNsByHref(pNode->doc, pNode, 
pSearchNs);
-            xmlAttrPtr cur = pNode->properties;
-            while (cur != nullptr && pNs != nullptr)
+            if( strcmp(reinterpret_cast<char const *>(pName), 
reinterpret_cast<char const *>(cur->name)) == 0 &&
+                cur->ns == pNs)
             {
-                if( strcmp(reinterpret_cast<char const *>(pName), 
reinterpret_cast<char const *>(cur->name)) == 0 &&
-                    cur->ns == pNs)
-                {
-                    aNode = m_pElement->GetOwnerDocument().GetCNode(
-                                  reinterpret_cast<xmlNodePtr>(cur));
-                    break;
-                }
-                cur = cur->next;
+                aNode = m_pElement->GetOwnerDocument().GetCNode(
+                              reinterpret_cast<xmlNodePtr>(cur));
+                break;
             }
+            cur = cur->next;
         }
         return aNode;
     }
@@ -132,23 +132,23 @@ namespace DOM
     {
         ::osl::MutexGuard const g(m_rMutex);
 
-        Reference< XNode > aNode;
         xmlNodePtr pNode = m_pElement->GetNodePtr();
-        if (pNode != nullptr)
+        if (pNode == nullptr)
+            return nullptr;
+
+        rtl::Reference< CNode > aNode;
+        xmlAttrPtr cur = pNode->properties;
+        sal_Int32 count = 0;
+        while (cur != nullptr)
         {
-            xmlAttrPtr cur = pNode->properties;
-            sal_Int32 count = 0;
-            while (cur != nullptr)
+            if (count == index)
             {
-                if (count == index)
-                {
-                    aNode = m_pElement->GetOwnerDocument().GetCNode(
-                                reinterpret_cast<xmlNodePtr>(cur));
-                    break;
-                }
-                count++;
-                cur = cur->next;
+                aNode = m_pElement->GetOwnerDocument().GetCNode(
+                            reinterpret_cast<xmlNodePtr>(cur));
+                break;
             }
+            count++;
+            cur = cur->next;
         }
         return aNode;
     }
diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx
index 64c5632dd8c3..51be79fec92b 100644
--- a/vcl/source/treelist/svtabbx.cxx
+++ b/vcl/source/treelist/svtabbx.cxx
@@ -836,7 +836,7 @@ Reference< XAccessible > 
SvHeaderTabListBox::CreateAccessibleCell( sal_Int32 _nR
 {
     OSL_ENSURE(m_xAccessible.is(), "Invalid call: Accessible is null");
 
-    Reference< XAccessible > xChild;
+    rtl::Reference< AccessibleBrowseBoxCell > xChild;
 
     TriState eState = TRISTATE_INDET;
     bool bIsCheckBox = IsCellCheckBox( _nRow, _nColumnPos, eState );
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx 
b/xmlscript/source/xml_helper/xml_impctx.cxx
index fc437d68dbfa..0cdce34182be 100644
--- a/xmlscript/source/xml_helper/xml_impctx.cxx
+++ b/xmlscript/source/xml_helper/xml_impctx.cxx
@@ -29,6 +29,7 @@
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <sal/log.hxx>
+#include <rtl/ref.hxx>
 
 #include <memory>
 #include <mutex>
@@ -418,7 +419,7 @@ void DocumentHandlerImpl::startElement(
     Reference< xml::sax::XAttributeList > const & xAttribs )
 {
     Reference< xml::input::XElement > xCurrentElement;
-    Reference< xml::input::XAttributes > xAttributes;
+    rtl::Reference< ExtendedAttributes > xAttributes;
     sal_Int32 nUid;
     OUString aLocalName;
     ElementEntry elementEntry;
diff --git a/xmlsecurity/source/helper/xsecverify.cxx 
b/xmlsecurity/source/helper/xsecverify.cxx
index 553486ca8d36..0cc6528cb175 100644
--- a/xmlsecurity/source/helper/xsecverify.cxx
+++ b/xmlsecurity/source/helper/xsecverify.cxx
@@ -58,20 +58,15 @@ css::uno::Reference< 
css::xml::crypto::sax::XReferenceResolvedListener > XSecCon
         return nullptr;
     }
 
-    sal_Int32 nIdOfSignatureElementCollector;
-    css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > 
xReferenceResolvedListener;
-
-    nIdOfSignatureElementCollector =
+    sal_Int32 nIdOfSignatureElementCollector =
         m_xSAXEventKeeper->addSecurityElementCollector( 
css::xml::crypto::sax::ElementMarkPriority_BEFOREMODIFY, false);
 
     m_xSAXEventKeeper->setSecurityId(nIdOfSignatureElementCollector, 
nSecurityId);
 
-        /*
-         * create a SignatureVerifier
-         */
-    xReferenceResolvedListener = new SignatureVerifierImpl;
-
-    css::uno::Reference<css::lang::XInitialization> 
xInitialization(xReferenceResolvedListener, css::uno::UNO_QUERY);
+    /*
+     * create a SignatureVerifier
+     */
+    rtl::Reference< SignatureVerifierImpl > xReferenceResolvedListener = new 
SignatureVerifierImpl;
 
     css::uno::Sequence<css::uno::Any> args
     {
@@ -81,19 +76,15 @@ css::uno::Reference< 
css::xml::crypto::sax::XReferenceResolvedListener > XSecCon
         Any(m_xSecurityContext),
         Any(m_xXMLSignature)
     };
-    xInitialization->initialize(args);
-
-    css::uno::Reference< 
css::xml::crypto::sax::XSignatureVerifyResultBroadcaster >
-        signatureVerifyResultBroadcaster(xReferenceResolvedListener, 
css::uno::UNO_QUERY);
+    xReferenceResolvedListener->initialize(args);
 
-    signatureVerifyResultBroadcaster->addSignatureVerifyResultListener( this );
+    xReferenceResolvedListener->addSignatureVerifyResultListener( this );
 
     m_xSAXEventKeeper->addReferenceResolvedListener(
         nIdOfSignatureElementCollector,
         xReferenceResolvedListener);
 
-    css::uno::Reference<css::xml::crypto::sax::XKeyCollector> keyCollector 
(xReferenceResolvedListener, css::uno::UNO_QUERY);
-    keyCollector->setKeyId(0);
+    xReferenceResolvedListener->setKeyId(0);
 
     return xReferenceResolvedListener;
 }
diff --git a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx 
b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
index 2647f7991657..4c74aaddf449 100644
--- a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
+++ b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
@@ -570,15 +570,14 @@ css::uno::Reference< css::xml::crypto::XDigestContext > 
SAL_CALL ONSSInitializer
     if ( aParams.hasElements() )
         throw css::lang::IllegalArgumentException(u"Unexpected arguments 
provided for digest creation."_ustr, css::uno::Reference< css::uno::XInterface 
>(), 2 );
 
-    css::uno::Reference< css::xml::crypto::XDigestContext > xResult;
-    if( initNSS( m_xContext ) )
-    {
-        PK11Context* pContext = PK11_CreateDigestContext( nNSSDigestID );
-        if ( pContext && PK11_DigestBegin( pContext ) == SECSuccess )
-            xResult = new ODigestContext( pContext, nDigestLength, b1KData );
-    }
+    if( !initNSS( m_xContext ) )
+        return nullptr;
 
-    return xResult;
+    PK11Context* pContext = PK11_CreateDigestContext( nNSSDigestID );
+    if ( !pContext || PK11_DigestBegin( pContext ) != SECSuccess )
+        return nullptr;
+
+    return new ODigestContext( pContext, nDigestLength, b1KData );
 }
 
 css::uno::Reference< css::xml::crypto::XCipherContext > SAL_CALL 
ONSSInitializer::getCipherContext( ::sal_Int32 nCipherID, const 
css::uno::Sequence< ::sal_Int8 >& aKey, const css::uno::Sequence< ::sal_Int8 >& 
aInitializationVector, sal_Bool bEncryption, const css::uno::Sequence< 
css::beans::NamedValue >& aParams )

Reply via email to