sc/inc/PivotTableDataProvider.hxx                    |    7 +-
 sc/source/core/data/dpobject.cxx                     |    4 -
 sc/source/core/data/dpsave.cxx                       |    4 -
 sc/source/filter/xml/xmlexprt.cxx                    |    4 -
 sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx |   38 +++++------
 sc/source/ui/drawfunc/fuins2.cxx                     |    2 
 sc/source/ui/inc/AccessibleSpreadsheet.hxx           |    2 
 sc/source/ui/unoobj/PivotTableDataProvider.cxx       |   25 ++-----
 sc/source/ui/vba/vbaaxis.cxx                         |   30 ++++-----
 sc/source/ui/vba/vbaformatconditions.cxx             |    4 -
 sc/source/ui/vba/vbaformatconditions.hxx             |    3 
 sc/source/ui/vba/vbanames.cxx                        |    2 
 sc/source/ui/vba/vbarange.cxx                        |    4 -
 sw/source/core/access/acchyperlink.cxx               |   27 +++-----
 sw/source/core/access/accnotexthyperlink.cxx         |   24 +++----
 sw/source/core/unocore/unochart.cxx                  |   23 ++-----
 sw/source/core/unocore/unoflatpara.cxx               |   61 ++++++++-----------
 sw/source/core/unocore/unoidx.cxx                    |   15 +---
 sw/source/core/unocore/unoobj2.cxx                   |    4 -
 sw/source/core/unocore/unoport.cxx                   |    8 --
 sw/source/core/unocore/unotbl.cxx                    |   10 +--
 sw/source/filter/html/htmlform.cxx                   |    4 -
 sw/source/filter/xml/xmltexti.cxx                    |   24 +++----
 sw/source/ui/config/mailconfigpage.cxx               |    2 
 sw/source/ui/vba/vbacontentcontrol.cxx               |   26 +++-----
 sw/source/ui/vba/vbaformfield.cxx                    |   17 ++---
 sw/source/uibase/dbui/mailmergehelper.cxx            |    2 
 sw/source/uibase/uno/unotxvw.cxx                     |    8 --
 28 files changed, 168 insertions(+), 216 deletions(-)

New commits:
commit a0f4f4b5e476fa5c3c64fcdc2e3cb473969703f7
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Mar 7 14:55:06 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Mar 7 17:30:50 2025 +0100

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

diff --git a/sc/inc/PivotTableDataProvider.hxx 
b/sc/inc/PivotTableDataProvider.hxx
index a1df012ccad1..17442949b1bc 100644
--- a/sc/inc/PivotTableDataProvider.hxx
+++ b/sc/inc/PivotTableDataProvider.hxx
@@ -35,6 +35,7 @@ namespace sc
 {
 
 struct ValueAndFormat;
+class PivotTableDataSequence;
 
 typedef cppu::WeakImplHelper<css::chart2::data::XDataProvider,
                              css::chart2::data::XPivotTableDataProvider,
@@ -147,11 +148,11 @@ private:
 
     css::uno::Reference<css::chart2::data::XLabeledDataSequence> 
newLabeledDataSequence();
 
-    css::uno::Reference<css::chart2::data::XDataSequence> 
assignLabelsToDataSequence(size_t nIndex);
+    rtl::Reference<PivotTableDataSequence> assignLabelsToDataSequence(size_t 
nIndex);
 
-    css::uno::Reference<css::chart2::data::XDataSequence> 
assignValuesToDataSequence(size_t nIndex);
+    rtl::Reference<PivotTableDataSequence> assignValuesToDataSequence(size_t 
nIndex);
 
-    css::uno::Reference<css::chart2::data::XDataSequence> 
assignFirstCategoriesToDataSequence();
+    rtl::Reference<PivotTableDataSequence> 
assignFirstCategoriesToDataSequence();
 
     void collectPivotTableData();
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index c96ccaa7de74..512a4a52cbb3 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2039,7 +2039,7 @@ void ScDPObject::ToggleDetails(const 
DataPilotTableHeaderData& rElemDesc, ScDPOb
     //  query old state
 
     tools::Long nHierCount = 0;
-    uno::Reference<container::XIndexAccess> xHiers;
+    rtl::Reference<ScNameToIndexAccess> xHiers;
     uno::Reference<sheet::XHierarchiesSupplier> xHierSupp( xDim, 
uno::UNO_QUERY );
     if ( xHierSupp.is() )
     {
@@ -2054,7 +2054,7 @@ void ScDPObject::ToggleDetails(const 
DataPilotTableHeaderData& rElemDesc, ScDPOb
     if ( !xHier.is() ) return;
 
     tools::Long nLevCount = 0;
-    uno::Reference<container::XIndexAccess> xLevels;
+    rtl::Reference<ScNameToIndexAccess> xLevels;
     uno::Reference<sheet::XLevelsSupplier> xLevSupp( xHier, uno::UNO_QUERY );
     if ( xLevSupp.is() )
     {
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 6e1d5c56f085..82494c99431b 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -517,7 +517,7 @@ void ScDPSaveDimension::WriteToSource( const 
uno::Reference<uno::XInterface>& xD
     tools::Long nCount = maMemberHash.size();
 
     tools::Long nHierCount = 0;
-    uno::Reference<container::XIndexAccess> xHiers;
+    rtl::Reference<ScNameToIndexAccess> xHiers;
     uno::Reference<sheet::XHierarchiesSupplier> xHierSupp( xDim, 
uno::UNO_QUERY );
     if ( xHierSupp.is() )
     {
@@ -530,7 +530,7 @@ void ScDPSaveDimension::WriteToSource( const 
uno::Reference<uno::XInterface>& xD
     for (tools::Long nHier=0; nHier<nHierCount; nHier++)
     {
         tools::Long nLevCount = 0;
-        uno::Reference<container::XIndexAccess> xLevels;
+        rtl::Reference<ScNameToIndexAccess> xLevels;
         uno::Reference<sheet::XLevelsSupplier> 
xLevSupp(xHiers->getByIndex(nHier), uno::UNO_QUERY);
         if ( xLevSupp.is() )
         {
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index e41e3ece60c4..aa139c4f6d06 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -5321,7 +5321,7 @@ void 
ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&
     }
 
     bool bVBACompat = false;
-    uno::Reference <container::XNameAccess> xCodeNameAccess;
+    rtl::Reference<XMLCodeNameProvider> xCodeNameAccess;
     OSL_ENSURE( pDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" 
);
     // tdf#71271 - add code names regardless of VBA compatibility mode
     if (pDoc)
@@ -5359,7 +5359,7 @@ void 
ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&
     if( xCodeNameAccess.is() )
     {
         pProps[nCount].Name = "ScriptConfiguration";
-        pProps[nCount].Value <<= xCodeNameAccess;
+        pProps[nCount].Value <<= 
uno::Reference<container::XNameAccess>(xCodeNameAccess);
         ++nCount;
     }
 }
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx 
b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index 0bad15e85566..f418ca2d2bb9 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -597,24 +597,24 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& 
rBC, const SfxHint& rHint
                     {
                         CommitFocusCell(aNewCell);
                     }
-                    uno::Reference< XAccessible > xChild ;
+                    rtl::Reference< ScAccessibleCell > xChild ;
                     if (bNewPosCellFocus)
                     {
-                        xChild = mpAccCell.get();
+                        xChild = mpAccCell;
                     }
                     else
                     {
                         mpAccCell = 
GetAccessibleCellAt(aNewCell.Row(),aNewCell.Col());
-                        xChild = mpAccCell.get();
+                        xChild = mpAccCell;
 
                         maActiveCell = aNewCell;
                         aEvent.EventId = 
AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS;
-                        aEvent.NewValue <<= xChild;
+                        aEvent.NewValue <<= uno::Reference< XAccessible 
>(xChild);
                         aEvent.OldValue <<= uno::Reference< XAccessible >();
                         CommitChange(aEvent);
                     }
                     aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
-                    aEvent.NewValue <<= xChild;
+                    aEvent.NewValue <<= uno::Reference< XAccessible >(xChild);
                     CommitChange(aEvent);
                     OSL_ASSERT(m_mapSelectionSend.count(aNewCell) == 0 );
                     m_mapSelectionSend.emplace(aNewCell,xChild);
@@ -645,15 +645,15 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& 
rBC, const SfxHint& rHint
                         {
                             for(const auto& rAddr : vecNew)
                             {
-                                uno::Reference< XAccessible > xChild = 
getAccessibleCellAt(rAddr.Row(),rAddr.Col());
+                                rtl::Reference< ScAccessibleCell > xChild = 
GetAccessibleCellAt(rAddr.Row(),rAddr.Col());
                                 if (!(bNewPosCellFocus && rAddr == aNewCell) )
                                 {
                                     aEvent.EventId = 
AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS;
-                                    aEvent.NewValue <<= xChild;
+                                    aEvent.NewValue <<= uno::Reference< 
XAccessible >(xChild);
                                     CommitChange(aEvent);
                                 }
                                 aEvent.EventId = 
AccessibleEventId::SELECTION_CHANGED_ADD;
-                                aEvent.NewValue <<= xChild;
+                                aEvent.NewValue <<= uno::Reference< 
XAccessible >(xChild);
                                 CommitChange(aEvent);
                                 m_mapSelectionSend.emplace(rAddr,xChild);
                             }
@@ -757,7 +757,7 @@ void ScAccessibleSpreadsheet::RemoveSelection(const 
ScMarkData &refScMarkData)
             continue;
         }
         aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
-        aEvent.NewValue <<= miRemove->second;
+        aEvent.NewValue <<= uno::Reference< XAccessible >(miRemove->second);
         CommitChange(aEvent);
         miRemove = m_mapSelectionSend.erase(miRemove);
     }
@@ -1576,13 +1576,13 @@ void ScAccessibleSpreadsheet::NotifyRefMode()
         aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
         aEvent.OldValue <<= uno::Reference<XAccessible>(m_pAccFormulaCell);
         m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(), 
aFormulaAddr.Col());
-        uno::Reference< XAccessible > xNew = m_pAccFormulaCell;
-        aEvent.NewValue <<= xNew;
+        rtl::Reference< ScAccessibleCell > xNew = m_pAccFormulaCell;
+        aEvent.NewValue <<= uno::Reference< XAccessible >(xNew);
         CommitChange(aEvent);
         if (nRefStartX == nRefEndX && nRefStartY == nRefEndY)
         {//Selection Single
             aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
-            aEvent.NewValue <<= xNew;
+            aEvent.NewValue <<= uno::Reference< XAccessible >(xNew);
             CommitChange(aEvent);
             m_mapFormulaSelectionSend.emplace(aFormulaAddr,xNew);
             m_vecFormulaLastMyAddr.clear();
@@ -1617,20 +1617,20 @@ void ScAccessibleSpreadsheet::NotifyRefMode()
             {
                 for(const auto& rAddr : vecNew)
                 {
-                    uno::Reference< XAccessible > xChild;
+                    rtl::Reference< ScAccessibleCell > xChild;
                     if (rAddr == aFormulaAddr)
                     {
-                        xChild = m_pAccFormulaCell.get();
+                        xChild = m_pAccFormulaCell;
                     }
                     else
                     {
-                        xChild = getAccessibleCellAt(rAddr.Row(),rAddr.Col());
+                        xChild = GetAccessibleCellAt(rAddr.Row(),rAddr.Col());
                         aEvent.EventId = 
AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS;
-                        aEvent.NewValue <<= xChild;
+                        aEvent.NewValue <<= uno::Reference< XAccessible 
>(xChild);
                         CommitChange(aEvent);
                     }
                     aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD;
-                    aEvent.NewValue <<= xChild;
+                    aEvent.NewValue <<= uno::Reference< XAccessible >(xChild);
                     CommitChange(aEvent);
                     m_mapFormulaSelectionSend.emplace(rAddr,xChild);
                 }
@@ -1645,7 +1645,7 @@ void ScAccessibleSpreadsheet::RemoveFormulaSelection(bool 
bRemoveAll )
 {
     AccessibleEventObject aEvent;
     aEvent.Source = uno::Reference< XAccessible >(this);
-    MAP_ADDR_XACC::iterator miRemove = m_mapFormulaSelectionSend.begin();
+    auto miRemove = m_mapFormulaSelectionSend.begin();
     while (miRemove != m_mapFormulaSelectionSend.end())
     {
         if( !bRemoveAll && IsScAddrFormulaSel(miRemove->first) )
@@ -1654,7 +1654,7 @@ void ScAccessibleSpreadsheet::RemoveFormulaSelection(bool 
bRemoveAll )
             continue;
         }
         aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
-        aEvent.NewValue <<= miRemove->second;
+        aEvent.NewValue <<= uno::Reference< XAccessible >(miRemove->second);
         CommitChange(aEvent);
         miRemove = m_mapFormulaSelectionSend.erase(miRemove);
     }
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index cc373117bfa2..12594eb7379b 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -137,7 +137,7 @@ void lcl_ChartInit(const uno::Reference 
<embed::XEmbeddedObject>& xObj, ScViewDa
     }
     else
     {
-        xDataProvider.set(new ScChart2DataProvider(&rScDoc));
+        xDataProvider = new ScChart2DataProvider(&rScDoc);
     }
 
     xReceiver->attachDataProvider(xDataProvider);
diff --git a/sc/source/ui/inc/AccessibleSpreadsheet.hxx 
b/sc/source/ui/inc/AccessibleSpreadsheet.hxx
index 49c9f1c27946..ec5228c5bc84 100644
--- a/sc/source/ui/inc/AccessibleSpreadsheet.hxx
+++ b/sc/source/ui/inc/AccessibleSpreadsheet.hxx
@@ -251,7 +251,7 @@ private:
     bool            mbIsSpreadsheet;
     bool            mbDelIns;
     bool            mbIsFocusSend;
-    typedef std::map<ScMyAddress,css::uno::Reference< 
css::accessibility::XAccessible > >
+    typedef std::map<ScMyAddress, rtl::Reference<ScAccessibleCell> >
         MAP_ADDR_XACC;
     MAP_ADDR_XACC m_mapSelectionSend;
     bool          m_bFormulaMode;
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx 
b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
index cbd7ebbecda5..0083cbdeabf8 100644
--- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
@@ -575,27 +575,23 @@ void PivotTableDataProvider::collectPivotTableData()
     m_bNeedsUpdate = false;
 }
 
-uno::Reference<chart2::data::XDataSequence>
+rtl::Reference<PivotTableDataSequence>
 PivotTableDataProvider::assignValuesToDataSequence(size_t nIndex)
 {
-    uno::Reference<chart2::data::XDataSequence> xDataSequence;
     if (nIndex >= m_aDataRowVector.size())
-        return xDataSequence;
+        return nullptr;
 
     OUString sDataID = lcl_identifierForData(nIndex);
 
     std::vector<ValueAndFormat> const & rRowOfData = m_aDataRowVector[nIndex];
     rtl::Reference<PivotTableDataSequence> pSequence(new 
PivotTableDataSequence(m_pDocument, sDataID, std::vector(rRowOfData)));
     pSequence->setRole(u"values-y"_ustr);
-    xDataSequence = pSequence;
-    return xDataSequence;
+    return pSequence;
 }
 
-uno::Reference<chart2::data::XDataSequence>
+rtl::Reference<PivotTableDataSequence>
 PivotTableDataProvider::assignLabelsToDataSequence(size_t nIndex)
 {
-    uno::Reference<chart2::data::XDataSequence> xDataSequence;
-
     OUString sLabelID = lcl_identifierForLabel(nIndex);
 
     OUStringBuffer aLabel;
@@ -626,26 +622,21 @@ PivotTableDataProvider::assignLabelsToDataSequence(size_t 
nIndex)
     rtl::Reference<PivotTableDataSequence> pSequence(new 
PivotTableDataSequence(m_pDocument,
                                                std::move(sLabelID), 
std::move(aLabelVector)));
     pSequence->setRole(u"values-y"_ustr);
-    xDataSequence = pSequence;
-    return xDataSequence;
+    return pSequence;
 }
 
-css::uno::Reference<css::chart2::data::XDataSequence>
+rtl::Reference<PivotTableDataSequence>
     PivotTableDataProvider::assignFirstCategoriesToDataSequence()
 {
-    uno::Reference<chart2::data::XDataSequence> xDataSequence;
-
     if (m_aCategoriesColumnOrientation.empty())
-        return xDataSequence;
+        return nullptr;
 
     std::vector<ValueAndFormat> const & rCategories = 
m_aCategoriesColumnOrientation.back();
 
     rtl::Reference<PivotTableDataSequence> pSequence(new 
PivotTableDataSequence(m_pDocument,
                                                lcl_identifierForCategories(), 
std::vector(rCategories)));
     pSequence->setRole(u"categories"_ustr);
-    xDataSequence = pSequence;
-
-    return xDataSequence;
+    return pSequence;
 }
 
 uno::Reference<chart2::data::XDataSource>
diff --git a/sc/source/ui/vba/vbaaxis.cxx b/sc/source/ui/vba/vbaaxis.cxx
index 46a5db7f0eb6..2fb718d27392 100644
--- a/sc/source/ui/vba/vbaaxis.cxx
+++ b/sc/source/ui/vba/vbaaxis.cxx
@@ -78,26 +78,26 @@ ScVbaAxis::Delete(  )
  uno::Reference< ::ooo::vba::excel::XAxisTitle > SAL_CALL
 ScVbaAxis::getAxisTitle(  )
 {
-    uno::Reference< excel::XAxisTitle > xAxisTitle;
+    rtl::Reference< ScVbaAxisTitle > xAxisTitle;
     try
     {
         ScVbaChart* pChart = getChartPtr();
 
-        if (getHasTitle() )
+        if (!getHasTitle() )
+            return nullptr;
+
+        int nType = getType();
+        switch(nType)
         {
-            int nType = getType();
-            switch(nType)
-            {
-                case xlCategory:
-                    xAxisTitle =  new ScVbaAxisTitle(this, mxContext, 
pChart->xAxisXSupplier->getXAxisTitle());
-                    break;
-                case xlSeriesAxis:
-                    xAxisTitle = new ScVbaAxisTitle(this, mxContext, 
pChart->xAxisZSupplier->getZAxisTitle());
-                    break;
-                default: // xlValue:
-                    xAxisTitle = new ScVbaAxisTitle(this, mxContext, 
pChart->xAxisYSupplier->getYAxisTitle());
-                    break;
-            }
+            case xlCategory:
+                xAxisTitle =  new ScVbaAxisTitle(this, mxContext, 
pChart->xAxisXSupplier->getXAxisTitle());
+                break;
+            case xlSeriesAxis:
+                xAxisTitle = new ScVbaAxisTitle(this, mxContext, 
pChart->xAxisZSupplier->getZAxisTitle());
+                break;
+            default: // xlValue:
+                xAxisTitle = new ScVbaAxisTitle(this, mxContext, 
pChart->xAxisYSupplier->getYAxisTitle());
+                break;
         }
     }
     catch (const uno::Exception& e)
diff --git a/sc/source/ui/vba/vbaformatconditions.cxx 
b/sc/source/ui/vba/vbaformatconditions.cxx
index 64f82e003610..ad326f61c672 100644
--- a/sc/source/ui/vba/vbaformatconditions.cxx
+++ b/sc/source/ui/vba/vbaformatconditions.cxx
@@ -134,7 +134,7 @@ ScVbaFormatConditions::Add( ::sal_Int32 _nType, const 
uno::Any& _aOperator, cons
     return Add( _nType, _aOperator, _aFormula1, _aFormula2, uno::Reference< 
excel::XStyle >() );
 }
 
-uno::Reference< excel::XFormatCondition >
+rtl::Reference< ScVbaFormatCondition >
 ScVbaFormatConditions::Add( ::sal_Int32 _nType, const uno::Any& _aOperator, 
const uno::Any& _aFormula1, const uno::Any& _aFormula2, const 
css::uno::Reference< excel::XStyle >& _xStyle  )
 {
     // #TODO
@@ -145,7 +145,7 @@ ScVbaFormatConditions::Add( ::sal_Int32 _nType, const 
uno::Any& _aOperator, cons
     // [*] reason: getA1Formula method below is just a hook and just
     // returns what it gets ( e.g. doesn't convert anything )
     uno::Reference< excel::XStyle > xStyle( _xStyle );
-    uno::Reference< excel::XFormatCondition > xFormatCondition;
+    rtl::Reference< ScVbaFormatCondition > xFormatCondition;
     try
     {
         OUString sStyleName;
diff --git a/sc/source/ui/vba/vbaformatconditions.hxx 
b/sc/source/ui/vba/vbaformatconditions.hxx
index 8fe7cfabb83f..54721192fdb4 100644
--- a/sc/source/ui/vba/vbaformatconditions.hxx
+++ b/sc/source/ui/vba/vbaformatconditions.hxx
@@ -29,6 +29,7 @@ namespace ooo::vba::excel { class XRange; }
 namespace ooo::vba::excel { class XStyle; }
 namespace ooo::vba::excel { class XStyles; }
 class ScVbaStyles;
+class ScVbaFormatCondition;
 
 // This class is used only as a target for casting, it seems,
 // and no objects of this type are created as such, I think.
@@ -44,7 +45,7 @@ public:
     void notifyRange();
     /// @throws css::script::BasicErrorException
     /// @throws css::uno::RuntimeException
-    css::uno::Reference< ov::excel::XFormatCondition > Add( ::sal_Int32 Type, 
const css::uno::Any& Operator, const css::uno::Any& Formula1, const 
css::uno::Any& Formula2, const css::uno::Reference< ov::excel::XStyle >& 
_xCalcStyle );
+    rtl::Reference< ScVbaFormatCondition > Add( ::sal_Int32 Type, const 
css::uno::Any& Operator, const css::uno::Any& Formula1, const css::uno::Any& 
Formula2, const css::uno::Reference< ov::excel::XStyle >& _xCalcStyle );
     /// @throws css::script::BasicErrorException
     static OUString getA1Formula(const css::uno::Any& _aFormula);
     OUString getStyleName();
diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
index 4e316e83f481..a90505a6662f 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -116,7 +116,7 @@ ScVbaNames::Add( const css::uno::Any& Name ,
                 throw uno::RuntimeException( u"This Name is not valid ."_ustr 
);
         }
     }
-    uno::Reference< table::XCellRange > xUnoRange;
+    rtl::Reference< ScCellRangeObj > xUnoRange;
     if ( RefersTo.hasValue() || RefersToR1C1.hasValue() || 
RefersToR1C1Local.hasValue() )
     {
         OUString sFormula;
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 433b069fa6d0..e0562dc7f0f2 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -197,9 +197,9 @@ static uno::Any lcl_makeRange( const uno::Reference< 
XHelperInterface >& rParent
     return uno::Any( uno::Reference< excel::XRange >( new ScVbaRange( rParent, 
rContext, xCellRange, bIsRows, bIsColumns ) ) );
 }
 
-static uno::Reference< excel::XRange > lcl_makeXRangeFromSheetCellRanges( 
const uno::Reference< XHelperInterface >& xParent, const uno::Reference< 
uno::XComponentContext >& xContext, const uno::Reference< 
sheet::XSheetCellRanges >& xLocSheetCellRanges, ScDocShell* pDoc )
+static rtl::Reference< ScVbaRange > lcl_makeXRangeFromSheetCellRanges( const 
uno::Reference< XHelperInterface >& xParent, const uno::Reference< 
uno::XComponentContext >& xContext, const uno::Reference< 
sheet::XSheetCellRanges >& xLocSheetCellRanges, ScDocShell* pDoc )
 {
-    uno::Reference< excel::XRange > xRange;
+    rtl::Reference< ScVbaRange > xRange;
     const uno::Sequence< table::CellRangeAddress  > sAddresses = 
xLocSheetCellRanges->getRangeAddresses();
     ScRangeList aCellRanges;
     if ( sAddresses.hasElements() )
commit a0ac8d313c9e8469b4545f5d4fc30894a3719004
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Mar 7 14:52:51 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Mar 7 17:30:39 2025 +0100

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

diff --git a/sw/source/core/access/acchyperlink.cxx 
b/sw/source/core/access/acchyperlink.cxx
index db06b0830ea9..d22577f0c2b1 100644
--- a/sw/source/core/access/acchyperlink.cxx
+++ b/sw/source/core/access/acchyperlink.cxx
@@ -118,21 +118,18 @@ OUString SAL_CALL 
SwAccessibleHyperlink::getAccessibleActionDescription(
 uno::Reference< XAccessibleKeyBinding > SAL_CALL
     SwAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 )
 {
-    uno::Reference< XAccessibleKeyBinding > xKeyBinding;
-
-    if( isValid() )
-    {
-        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 );
-    }
+    if( !isValid() )
+        return nullptr;
+
+    rtl::Reference<::comphelper::OAccessibleKeyBindingHelper> xKeyBinding =
+           new ::comphelper::OAccessibleKeyBindingHelper();
+
+    awt::KeyStroke aKeyStroke;
+    aKeyStroke.Modifiers = 0;
+    aKeyStroke.KeyCode = KEY_RETURN;
+    aKeyStroke.KeyChar = 0;
+    aKeyStroke.KeyFunc = 0;
+    xKeyBinding->AddKeyBinding( aKeyStroke );
 
     return xKeyBinding;
 }
diff --git a/sw/source/core/access/accnotexthyperlink.cxx 
b/sw/source/core/access/accnotexthyperlink.cxx
index df4afc4b9c3d..1cc4354f83b6 100644
--- a/sw/source/core/access/accnotexthyperlink.cxx
+++ b/sw/source/core/access/accnotexthyperlink.cxx
@@ -120,7 +120,6 @@ Reference< XAccessibleKeyBinding > SAL_CALL
 {
     SolarMutexGuard g;
 
-    Reference< XAccessibleKeyBinding > xKeyBinding;
 
     if(nIndex < 0 || nIndex >= getAccessibleActionCount())
         throw lang::IndexOutOfBoundsException();
@@ -137,19 +136,18 @@ Reference< XAccessibleKeyBinding > SAL_CALL
     else if (!aURL.GetURL().isEmpty())
         bIsValid = true;
 
-    if(bIsValid)
-    {
-        rtl::Reference<::comphelper::OAccessibleKeyBindingHelper> 
pKeyBindingHelper =
+    if(!bIsValid)
+        return nullptr;
+
+    rtl::Reference< ::comphelper::OAccessibleKeyBindingHelper > xKeyBinding =
             new ::comphelper::OAccessibleKeyBindingHelper();
-        xKeyBinding = pKeyBindingHelper;
-
-        css::awt::KeyStroke aKeyStroke;
-        aKeyStroke.Modifiers = 0;
-        aKeyStroke.KeyCode = KEY_RETURN;
-        aKeyStroke.KeyChar = 0;
-        aKeyStroke.KeyFunc = 0;
-        pKeyBindingHelper->AddKeyBinding( aKeyStroke );
-    }
+
+    css::awt::KeyStroke aKeyStroke;
+    aKeyStroke.Modifiers = 0;
+    aKeyStroke.KeyCode = KEY_RETURN;
+    aKeyStroke.KeyChar = 0;
+    aKeyStroke.KeyFunc = 0;
+    xKeyBinding->AddKeyBinding( aKeyStroke );
 
     return xKeyBinding;
 }
diff --git a/sw/source/core/unocore/unochart.cxx 
b/sw/source/core/unocore/unochart.cxx
index dbfaa99c9671..8b298df6f9c2 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -521,8 +521,6 @@ uno::Reference< chart2::data::XDataSource > 
SwChartDataProvider::Impl_createData
     if (m_bDisposed)
         throw lang::DisposedException();
 
-    uno::Reference< chart2::data::XDataSource > xRes;
-
     if (!m_pDoc)
         throw uno::RuntimeException(u"Not connected to a document."_ustr);
 
@@ -537,7 +535,7 @@ uno::Reference< chart2::data::XDataSource > 
SwChartDataProvider::Impl_createData
     sal_Int32 nArgs = rArguments.getLength();
     OSL_ENSURE( nArgs != 0, "no properties provided" );
     if (nArgs == 0)
-        return xRes;
+        return nullptr;
     for (const beans::PropertyValue& rArg : rArguments)
     {
         if ( rArg.Name == "DataRowSource" )
@@ -608,14 +606,14 @@ uno::Reference< chart2::data::XDataSource > 
SwChartDataProvider::Impl_createData
             //Therefore we need to shift the range one row up
             SwRangeDescriptor aDesc;
             if (aRangeRepresentation.isEmpty())
-                return xRes;        // we can't handle this thus returning an 
empty references
+                return nullptr;        // we can't handle this thus returning 
an empty references
 
             aRangeRepresentation = aRangeRepresentation.copy( 1 ); // get rid 
of '.' to have only the cell range left
             FillRangeDescriptor( aDesc, aRangeRepresentation );
             aDesc.Normalize();
 
             if (aDesc.nTop <= 0)    // no chance to shift the range one row up?
-                return xRes;        // we can't handle this thus returning an 
empty references
+                return nullptr;        // we can't handle this thus returning 
an empty references
 
             aDesc.nTop      -= 1;
             aDesc.nBottom   -= 1;
@@ -643,7 +641,7 @@ uno::Reference< chart2::data::XDataSource > 
SwChartDataProvider::Impl_createData
 
     SwTable* pTable = SwTable::FindTable(pTableFormat);
     if (pTable->IsTableComplex())
-        return xRes; // we can't handle this thus returning an empty references
+        return nullptr; // we can't handle this thus returning an empty 
references
 
     // get a character map in the size of the table to mark
     // all the ranges to use in
@@ -771,7 +769,7 @@ uno::Reference< chart2::data::XDataSource > 
SwChartDataProvider::Impl_createData
     // now we should have all necessary data to build a proper DataSource
     // thus if we came this far there should be no further problem
     if (bTestOnly)
-        return xRes;    // have createDataSourcePossible return true
+        return nullptr;    // have createDataSourcePossible return true
 
     // create data source from found label and data sequences
     uno::Sequence<uno::Reference<chart2::data::XDataSequence>> 
aLabelSeqs(nNumLDS);
@@ -884,8 +882,7 @@ uno::Reference< chart2::data::XDataSource > 
SwChartDataProvider::Impl_createData
         OSL_ENSURE(nNewCnt == nNumLDS, "unexpected size of resulting 
sequence");
     }
 
-    xRes = new SwChartDataSource(aLDS);
-    return xRes;
+    return new SwChartDataSource(aLDS);
 }
 
 sal_Bool SAL_CALL SwChartDataProvider::createDataSourcePossible(
@@ -1303,11 +1300,9 @@ uno::Reference< chart2::data::XDataSequence > 
SwChartDataProvider::Impl_createDa
     if (aDesc.nTop != aDesc.nBottom  &&  aDesc.nLeft != aDesc.nRight)
         throw lang::IllegalArgumentException();
 
-    uno::Reference< chart2::data::XDataSequence > xDataSeq;
-    if (!bTestOnly)
-        xDataSeq = new SwChartDataSequence( *this, *pTableFormat, pUnoCursor );
-
-    return xDataSeq;
+    if (bTestOnly)
+        return nullptr;
+    return new SwChartDataSequence( *this, *pTableFormat, pUnoCursor );
 }
 
 sal_Bool SAL_CALL 
SwChartDataProvider::createDataSequenceByRangeRepresentationPossible(
diff --git a/sw/source/core/unocore/unoflatpara.cxx 
b/sw/source/core/unocore/unoflatpara.cxx
index e4fa19223519..b78db11beeb7 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -366,9 +366,8 @@ uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getNextPara()
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference< text::XFlatParagraph > xRet;
     if (!mpDoc)
-        return xRet;
+        return nullptr;
 
     SwTextNode* pRet = nullptr;
     if ( mbAutomatic )
@@ -386,7 +385,7 @@ uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getNextPara()
                 // this method is supposed to return an empty paragraph in 
case Online Checking is disabled
                 if ( ( mnType == text::TextMarkupType::PROOFREADING || mnType 
== text::TextMarkupType::SPELLCHECK )
                     && !pViewShell->GetViewOptions()->IsOnlineSpell() )
-                    return xRet;
+                    return nullptr;
 
                 // search for invalid content:
                 SwContentFrame* pCnt = pCurrentPage->ContainsContent();
@@ -479,16 +478,14 @@ uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getNextPara()
         }
     }
 
-    if ( pRet )
-    {
-        // Expand the string:
-        const ModelToViewHelper aConversionMap(*pRet, 
mpDoc->getIDocumentLayoutAccess().GetCurrentLayout());
-        const OUString& aExpandText = aConversionMap.getViewText();
+    if ( !pRet )
+        return nullptr;
 
-        xRet = new SwXFlatParagraph( *pRet, aExpandText, aConversionMap );
-    }
+    // Expand the string:
+    const ModelToViewHelper aConversionMap(*pRet, 
mpDoc->getIDocumentLayoutAccess().GetCurrentLayout());
+    const OUString& aExpandText = aConversionMap.getViewText();
 
-    return xRet;
+    return new SwXFlatParagraph( *pRet, aExpandText, aConversionMap );
 }
 
 uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getLastPara()
@@ -500,19 +497,18 @@ uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getParaAfter(co
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference< text::XFlatParagraph > xRet;
     if (!mpDoc)
-        return xRet;
+        return nullptr;
 
     SwXFlatParagraph* const 
pFlatParagraph(dynamic_cast<SwXFlatParagraph*>(xPara.get()));
     SAL_WARN_IF(!pFlatParagraph, "sw.core", "invalid argument");
     if ( !pFlatParagraph )
-        return xRet;
+        return nullptr;
 
     SwTextNode const*const pCurrentNode = pFlatParagraph->GetTextNode();
 
     if ( !pCurrentNode )
-        return xRet;
+        return nullptr;
 
     SwTextNode* pNextTextNode = nullptr;
     const SwNodes& rNodes = pCurrentNode->GetDoc().GetNodes();
@@ -525,35 +521,32 @@ uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getParaAfter(co
             break;
     }
 
-    if ( pNextTextNode )
-    {
-        // Expand the string:
-        const ModelToViewHelper aConversionMap(*pNextTextNode, 
mpDoc->getIDocumentLayoutAccess().GetCurrentLayout());
-        const OUString& aExpandText = aConversionMap.getViewText();
+    if ( !pNextTextNode )
+        return nullptr;
 
-        xRet = new SwXFlatParagraph( *pNextTextNode, aExpandText, 
aConversionMap );
-    }
+    // Expand the string:
+    const ModelToViewHelper aConversionMap(*pNextTextNode, 
mpDoc->getIDocumentLayoutAccess().GetCurrentLayout());
+    const OUString& aExpandText = aConversionMap.getViewText();
 
-    return xRet;
+    return new SwXFlatParagraph( *pNextTextNode, aExpandText, aConversionMap );
 }
 
 uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getParaBefore(const uno::Reference< 
text::XFlatParagraph > & xPara )
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference< text::XFlatParagraph > xRet;
     if (!mpDoc)
-        return xRet;
+        return nullptr;
 
     SwXFlatParagraph* const 
pFlatParagraph(dynamic_cast<SwXFlatParagraph*>(xPara.get()));
     SAL_WARN_IF(!pFlatParagraph, "sw.core", "invalid argument");
     if ( !pFlatParagraph )
-        return xRet;
+        return nullptr;
 
     SwTextNode const*const pCurrentNode = pFlatParagraph->GetTextNode();
 
     if ( !pCurrentNode )
-        return xRet;
+        return nullptr;
 
     SwTextNode* pPrevTextNode = nullptr;
     const SwNodes& rNodes = pCurrentNode->GetDoc().GetNodes();
@@ -566,16 +559,14 @@ uno::Reference< text::XFlatParagraph > 
SwXFlatParagraphIterator::getParaBefore(c
             break;
     }
 
-    if ( pPrevTextNode )
-    {
-        // Expand the string:
-        const ModelToViewHelper aConversionMap(*pPrevTextNode, 
mpDoc->getIDocumentLayoutAccess().GetCurrentLayout());
-        const OUString& aExpandText = aConversionMap.getViewText();
+    if ( !pPrevTextNode )
+        return nullptr;
 
-        xRet = new SwXFlatParagraph( *pPrevTextNode, aExpandText, 
aConversionMap );
-    }
+    // Expand the string:
+    const ModelToViewHelper aConversionMap(*pPrevTextNode, 
mpDoc->getIDocumentLayoutAccess().GetCurrentLayout());
+    const OUString& aExpandText = aConversionMap.getViewText();
 
-    return xRet;
+    return new SwXFlatParagraph( *pPrevTextNode, aExpandText, aConversionMap );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unoidx.cxx 
b/sw/source/core/unocore/unoidx.cxx
index fe901fd6e62c..e0e739c03384 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -1970,15 +1970,12 @@ SwXDocumentIndexMark::getAnchor()
     {
         aPam.GetPoint()->AdjustContent(1);
     }
-    uno::Reference< text::XTextRange > xRet;
-    if(SwDocShell* pShell = m_pImpl->m_pDoc->GetDocShell())
-    {
-        const rtl::Reference< SwXTextDocument > xModel =
-            pShell->GetBaseModel();
-        xRet = new SwXTextRange(aPam, xModel->getText());
-    }
-
-    return xRet;
+    SwDocShell* pShell = m_pImpl->m_pDoc->GetDocShell();
+    if (!pShell)
+        return nullptr;
+    const rtl::Reference< SwXTextDocument > xModel =
+        pShell->GetBaseModel();
+    return new SwXTextRange(aPam, xModel->getText());
 }
 
 void SAL_CALL
diff --git a/sw/source/core/unocore/unoobj2.cxx 
b/sw/source/core/unocore/unoobj2.cxx
index d68a10cbb2cb..bc704d8bb8a7 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -941,7 +941,7 @@ SwXTextRange::getStart()
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference< text::XTextRange >  xRet;
+    rtl::Reference< SwXTextRange >  xRet;
     ::sw::mark::MarkBase const * const pBkmk = m_pMark;
     if (!m_xParentText.is())
     {
@@ -978,7 +978,7 @@ SwXTextRange::getEnd()
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference< text::XTextRange >  xRet;
+    rtl::Reference< SwXTextRange >  xRet;
     ::sw::mark::MarkBase const * const pBkmk = m_pMark;
     if (!m_xParentText.is())
     {
diff --git a/sw/source/core/unocore/unoport.cxx 
b/sw/source/core/unocore/unoport.cxx
index 54c58c112207..1ba9d3416d1c 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -147,25 +147,21 @@ uno::Reference< text::XText >  SwXTextPortion::getText()
 uno::Reference< text::XTextRange >  SwXTextPortion::getStart()
 {
     SolarMutexGuard aGuard;
-    uno::Reference< text::XTextRange >  xRet;
     SwUnoCursor& rUnoCursor = GetCursor();
 
     SwPaM aPam(*rUnoCursor.Start());
     uno::Reference< text::XText > xParent = getText();
-    xRet = new SwXTextRange(aPam, xParent);
-    return xRet;
+    return new SwXTextRange(aPam, xParent);
 }
 
 uno::Reference< text::XTextRange >  SwXTextPortion::getEnd()
 {
     SolarMutexGuard aGuard;
-    uno::Reference< text::XTextRange >  xRet;
     SwUnoCursor& rUnoCursor = GetCursor();
 
     SwPaM aPam(*rUnoCursor.End());
     uno::Reference< text::XText > xParent = getText();
-    xRet = new SwXTextRange(aPam, xParent);
-    return xRet;
+    return new SwXTextRange(aPam, xParent);
 }
 
 OUString SwXTextPortion::getString()
diff --git a/sw/source/core/unocore/unotbl.cxx 
b/sw/source/core/unocore/unotbl.cxx
index aceb8e1da977..12d22961a795 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3237,23 +3237,21 @@ uno::Reference<table::XCell> SAL_CALL
 SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
 {
     SolarMutexGuard aGuard;
-    uno::Reference< table::XCell >  aRet;
+    rtl::Reference< SwXCell >  pXCell;
     SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
     if(pFormat)
     {
         if(nColumn >= 0 && nRow >= 0 &&
              m_pImpl->GetColumnCount() > nColumn && m_pImpl->GetRowCount() > 
nRow )
         {
-            rtl::Reference<SwXCell> pXCell = lcl_CreateXCell(pFormat,
+            pXCell = lcl_CreateXCell(pFormat,
                     m_pImpl->m_RangeDescriptor.nLeft + nColumn,
                     m_pImpl->m_RangeDescriptor.nTop + nRow);
-            if(pXCell)
-                aRet = pXCell;
         }
     }
-    if(!aRet.is())
+    if(!pXCell.is())
         throw lang::IndexOutOfBoundsException();
-    return aRet;
+    return pXCell;
 }
 
 uno::Reference<table::XCellRange> SAL_CALL
diff --git a/sw/source/filter/html/htmlform.cxx 
b/sw/source/filter/html/htmlform.cxx
index a387f019d51f..8e3ba7fea86f 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -1029,7 +1029,7 @@ uno::Reference< drawing::XShape > 
SwHTMLParser::InsertControl(
             rFCompPropSet->setPropertyValue( sPropName, aTmp );
         }
 
-        uno::Reference< text::XTextRange >  xTextRg;
+        rtl::Reference< SwXTextRange >  xTextRg;
         text::TextContentAnchorType nAnchorType = 
text::TextContentAnchorType_AS_CHARACTER;
         bool bSetPos = false, bSetSurround = false;
         sal_Int32 nXPos = 0, nYPos = 0;
@@ -1127,7 +1127,7 @@ uno::Reference< drawing::XShape > 
SwHTMLParser::InsertControl(
                 xTextRg = new SwXTextRange( *m_pPam, xDummyTextRef );
             }
 
-            aTmp <<= xTextRg;
+            aTmp <<= uno::Reference< text::XTextRange >(xTextRg);
             xShapePropSet->setPropertyValue(u"TextRange"_ustr, aTmp );
         }
 
diff --git a/sw/source/filter/xml/xmltexti.cxx 
b/sw/source/filter/xml/xmltexti.cxx
index 93d698cac9eb..bd3ea53780b0 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -202,16 +202,14 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertOLEObject(
     // this method will modify the document directly -> lock SolarMutex
     SolarMutexGuard aGuard;
 
-    uno::Reference < XPropertySet > xPropSet;
-
     sal_Int32 nPos = rHRef.indexOf( ':' );
     if( -1 == nPos )
-        return xPropSet;
+        return nullptr;
 
     OUString aObjName( rHRef.copy( nPos+1) );
 
     if( aObjName.isEmpty() )
-        return xPropSet;
+        return nullptr;
 
     OTextCursorHelper* pTextCursor = 
dynamic_cast<OTextCursorHelper*>(GetCursor().get());
     SAL_WARN_IF(!pTextCursor, "sw.uno", "SwXTextCursor missing");
@@ -322,7 +320,7 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertOLEObject(
     }
 
     if( !pFrameFormat )
-        return xPropSet;
+        return nullptr;
 
     if( IsInsertMode() )
     {
@@ -332,7 +330,7 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertOLEObject(
             pOLENd->SetOLESizeInvalid( true );
     }
 
-    xPropSet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
+    rtl::Reference<SwXTextEmbeddedObject> xPropSet = 
SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
                 *pDoc, pFrameFormat);
     if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
     {
@@ -511,8 +509,6 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertOOoLink(
     // this method will modify the document directly -> lock SolarMutex
     SolarMutexGuard aGuard;
 
-    uno::Reference < XPropertySet > xPropSet;
-
     OTextCursorHelper* pTextCursor = 
dynamic_cast<OTextCursorHelper*>(GetCursor().get());
     assert( pTextCursor && "SwXTextCursor missing" );
     SwDoc *pDoc = static_cast<SwXMLImport&>(rImport).getDoc();
@@ -529,8 +525,9 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertOOoLink(
                      aURLObj.SetURL( URIHelper::SmartRel2Abs(
                                 INetURLObject( GetXMLImport().GetBaseURL() ), 
rHRef ) );
     if( !bValidURL )
-        return xPropSet;
+        return nullptr;
 
+    rtl::Reference < SwXTextEmbeddedObject > xPropSet;
     uno::Reference < embed::XStorage > xStorage = 
comphelper::OStorageHelper::GetTemporaryStorage();
     try
     {
@@ -602,7 +599,6 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertApplet(
     // this method will modify the document directly -> lock SolarMutex
     SolarMutexGuard aGuard;
 
-    uno::Reference < XPropertySet > xPropSet;
     OTextCursorHelper* pTextCursor = 
dynamic_cast<OTextCursorHelper*>(GetCursor().get());
     assert( pTextCursor && "SwXTextCursor missing" );
     SwDoc *pDoc = pTextCursor->GetDoc();
@@ -628,7 +624,7 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertApplet(
         pDoc->getIDocumentContentOperations().InsertEmbObject( 
*pTextCursor->GetPaM(),
         ::svt::EmbeddedObjectRef(aAppletImpl.GetApplet(), 
embed::Aspects::MSOLE_CONTENT),
         &aAppletImpl.GetItemSet());
-    xPropSet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
+    rtl::Reference<SwXTextEmbeddedObject> xPropSet = 
SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
                 *pDoc, pFrameFormat);
     if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
     {
@@ -644,7 +640,6 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertPlugin(
         const OUString& rHRef,
         sal_Int32 nWidth, sal_Int32 nHeight )
 {
-    uno::Reference < XPropertySet > xPropSet;
     OTextCursorHelper* pTextCursor = 
dynamic_cast<OTextCursorHelper*>(GetCursor().get());
     assert( pTextCursor && "SwXTextCursor missing" );
     SwDoc *pDoc = pTextCursor->GetDoc();
@@ -661,8 +656,9 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertPlugin(
                      aURLObj.SetURL( URIHelper::SmartRel2Abs( INetURLObject( 
GetXMLImport().GetBaseURL() ), rHRef ) );
     bool bValidMimeType = !rMimeType.isEmpty();
     if( !bValidURL && !bValidMimeType )
-        return xPropSet;
+        return nullptr;
 
+    rtl::Reference < SwXTextEmbeddedObject > xPropSet;
     uno::Reference < embed::XStorage > xStorage = 
comphelper::OStorageHelper::GetTemporaryStorage();
     try
     {
@@ -721,7 +717,7 @@ uno::Reference< XPropertySet > 
SwXMLTextImportHelper::createAndInsertFloatingFra
     // this method will modify the document directly -> lock SolarMutex
     SolarMutexGuard aGuard;
 
-    uno::Reference < XPropertySet > xPropSet;
+    rtl::Reference < SwXTextEmbeddedObject > xPropSet;
     OTextCursorHelper* pTextCursor = 
dynamic_cast<OTextCursorHelper*>(GetCursor().get());
     assert( pTextCursor && "SwXTextCursor missing" );
     SwDoc *pDoc = pTextCursor->GetDoc();
diff --git a/sw/source/ui/config/mailconfigpage.cxx 
b/sw/source/ui/config/mailconfigpage.cxx
index 77d0850f9c03..4e40badaa21b 100644
--- a/sw/source/ui/config/mailconfigpage.cxx
+++ b/sw/source/ui/config/mailconfigpage.cxx
@@ -356,7 +356,7 @@ void SwTestAccountSettingsDialog::Test()
         }
         if(m_bStop)
             return;
-        uno::Reference<XAuthenticator> xAuthenticator;
+        rtl::Reference<SwAuthenticator> xAuthenticator;
         if(m_pParent->m_pConfigItem->IsAuthentication() &&
                 !m_pParent->m_pConfigItem->IsSMTPAfterPOP() &&
                 !m_pParent->m_pConfigItem->GetMailUserName().isEmpty())
diff --git a/sw/source/ui/vba/vbacontentcontrol.cxx 
b/sw/source/ui/vba/vbacontentcontrol.cxx
index 90c313422b49..1839b6afc82f 100644
--- a/sw/source/ui/vba/vbacontentcontrol.cxx
+++ b/sw/source/ui/vba/vbacontentcontrol.cxx
@@ -548,21 +548,19 @@ sal_Bool SwVbaContentControl::getShowingPlaceholderText() 
{ return m_pCC->GetSho
 
 uno::Reference<word::XRange> SwVbaContentControl::getRange()
 {
-    uno::Reference<word::XRange> xRet;
     SwTextNode* pTextNode = m_pCC->GetTextNode();
-    if (pTextNode && m_pCC->GetTextAttr())
-    {
-        // Don't select the text attribute itself at the start.
-        SwPosition aStart(*pTextNode, m_pCC->GetTextAttr()->GetStart() + 1);
-        // Don't select the CH_TXTATR_BREAKWORD itself at the end.
-        SwPosition aEnd(*pTextNode, *m_pCC->GetTextAttr()->End() - 1);
-        rtl::Reference<SwXTextRange> xText(
-            SwXTextRange::CreateXTextRange(pTextNode->GetDoc(), aStart, 
&aEnd));
-        if (xText.is())
-            xRet = new SwVbaRange(mxParent, mxContext, mxTextDocument, 
xText->getStart(),
-                                  xText->getEnd());
-    }
-    return xRet;
+    if (!pTextNode || !m_pCC->GetTextAttr())
+        return nullptr;
+
+    // Don't select the text attribute itself at the start.
+    SwPosition aStart(*pTextNode, m_pCC->GetTextAttr()->GetStart() + 1);
+    // Don't select the CH_TXTATR_BREAKWORD itself at the end.
+    SwPosition aEnd(*pTextNode, *m_pCC->GetTextAttr()->End() - 1);
+    rtl::Reference<SwXTextRange> xText(
+        SwXTextRange::CreateXTextRange(pTextNode->GetDoc(), aStart, &aEnd));
+    if (!xText.is())
+        return nullptr;
+    return new SwVbaRange(mxParent, mxContext, mxTextDocument, 
xText->getStart(), xText->getEnd());
 }
 
 OUString SwVbaContentControl::getRepeatingSectionItemTitle()
diff --git a/sw/source/ui/vba/vbaformfield.cxx 
b/sw/source/ui/vba/vbaformfield.cxx
index 5d2cd5d0b183..1caf2201dfe3 100644
--- a/sw/source/ui/vba/vbaformfield.cxx
+++ b/sw/source/ui/vba/vbaformfield.cxx
@@ -120,17 +120,14 @@ uno::Any SwVbaFormField::Next()
 
 uno::Reference<word::XRange> SwVbaFormField::Range()
 {
-    uno::Reference<word::XRange> xRet;
     SwDoc* pDoc = m_xTextDocument->GetDocShell()->GetDoc();
-    if (pDoc)
-    {
-        rtl::Reference<SwXTextRange> xText(SwXTextRange::CreateXTextRange(
-            *pDoc, m_rFormField.GetMarkStart(), &m_rFormField.GetMarkEnd()));
-        if (xText.is())
-            xRet = new SwVbaRange(mxParent, mxContext, m_xTextDocument, 
xText->getStart(),
-                                  xText->getEnd());
-    }
-    return xRet;
+    if (!pDoc)
+        return nullptr;
+    rtl::Reference<SwXTextRange> xText(SwXTextRange::CreateXTextRange(
+        *pDoc, m_rFormField.GetMarkStart(), &m_rFormField.GetMarkEnd()));
+    if (!xText.is())
+        return nullptr;
+    return new SwVbaRange(mxParent, mxContext, m_xTextDocument, 
xText->getStart(), xText->getEnd());
 }
 
 OUString SwVbaFormField::getDefaultPropertyName() { return u"Type"_ustr; }
diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx 
b/sw/source/uibase/dbui/mailmergehelper.cxx
index 00932257d595..e3e1534204b2 100644
--- a/sw/source/uibase/dbui/mailmergehelper.cxx
+++ b/sw/source/uibase/dbui/mailmergehelper.cxx
@@ -130,7 +130,7 @@ uno::Reference< mail::XSmtpService > ConnectToSmtpServer(
             xInMailService->connect(xConnectionContext, xAuthenticator);
             rxInMailService = std::move(xInMailService);
         }
-        uno::Reference< mail::XAuthenticator> xAuthenticator;
+        rtl::Reference<SwAuthenticator> xAuthenticator;
         if(rConfigItem.IsAuthentication() &&
                 !rConfigItem.IsSMTPAfterPOP() &&
                 !rConfigItem.GetMailUserName().isEmpty())
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index 1d4470d06990..f7da6ab5186f 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -1273,7 +1273,6 @@ uno::Reference< text::XText >  
SwXTextViewCursor::getText()
 uno::Reference< text::XTextRange > SwXTextViewCursor::getStart()
 {
     SolarMutexGuard aGuard;
-    uno::Reference< text::XTextRange >  xRet;
     if(!m_pView)
         throw uno::RuntimeException();
 
@@ -1283,15 +1282,13 @@ uno::Reference< text::XTextRange > 
SwXTextViewCursor::getStart()
     SwWrtShell& rSh = m_pView->GetWrtShell();
     SwPaM* pShellCursor = rSh.GetCursor();
     SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
-    xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->Start(), 
nullptr);
 
-    return xRet;
+    return SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->Start(), 
nullptr);
 }
 
 uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd()
 {
     SolarMutexGuard aGuard;
-    rtl::Reference<SwXTextRange> xRet;
     if(!m_pView)
         throw uno::RuntimeException();
 
@@ -1301,9 +1298,8 @@ uno::Reference< text::XTextRange > 
SwXTextViewCursor::getEnd()
     SwWrtShell& rSh = m_pView->GetWrtShell();
     SwPaM* pShellCursor = rSh.GetCursor();
     SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
-    xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->End(), 
nullptr);
 
-    return xRet;
+    return SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->End(), 
nullptr);
 }
 
 OUString SwXTextViewCursor::getString()

Reply via email to