[Libreoffice-commits] core.git: sc/inc sc/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 26 14:34:38 UTC 2019


 sc/inc/miscuno.hxx                             |    2 
 sc/source/core/data/dpobject.cxx               |   67 ++++++++-----------------
 sc/source/core/data/dpoutput.cxx               |   24 ++------
 sc/source/core/data/dpsave.cxx                 |   16 ++---
 sc/source/ui/dataprovider/sqldataprovider.cxx  |    3 -
 sc/source/ui/dbgui/dapidata.cxx                |    3 -
 sc/source/ui/unoobj/PivotTableDataProvider.cxx |    9 +--
 sc/source/ui/unoobj/miscuno.cxx                |    9 ---
 sc/source/ui/unoobj/targuno.cxx                |    3 -
 sc/source/ui/vba/vbaapplication.cxx            |    3 -
 10 files changed, 46 insertions(+), 93 deletions(-)

New commits:
commit 830345be2d96d8f699e8cbf33646721fa8c65baf
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Mar 26 11:20:33 2019 +0100
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Mar 26 15:34:14 2019 +0100

    ScUnoHelpFunctions::AnyToInterface is redundant
    
    Change-Id: Ia61806f7781b49f29122ad9be75a5eb739918c37
    Reviewed-on: https://gerrit.libreoffice.org/69734
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sc/inc/miscuno.hxx b/sc/inc/miscuno.hxx
index e0391e431f43..365db0ace50b 100644
--- a/sc/inc/miscuno.hxx
+++ b/sc/inc/miscuno.hxx
@@ -127,8 +127,6 @@ public:
 class SC_DLLPUBLIC ScUnoHelpFunctions
 {
 public:
-    static css::uno::Reference<css::uno::XInterface>
-                            AnyToInterface( const css::uno::Any& rAny );
     static bool             GetBoolProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp,
                                             const OUString& rName, bool bDefault = false );
     static sal_Int16        GetShortProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp,
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 21f3bf6190c6..97644f1baa69 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -268,9 +268,8 @@ static sheet::DataPilotFieldOrientation lcl_GetDataGetOrientation( const uno::Re
         bool bFound = false;
         for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++)
         {
-            uno::Reference<uno::XInterface> xIntDim =
-                ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nIntDim) );
-            uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
+            uno::Reference<beans::XPropertySet> xDimProp(xIntDims->getByIndex(nIntDim),
+                                                         uno::UNO_QUERY);
             if ( xDimProp.is() )
             {
                 bFound = ScUnoHelpFunctions::GetBoolProperty( xDimProp,
@@ -1204,8 +1203,7 @@ OUString ScDPObject::GetDimName( long nDim, bool& rIsDataLayout, sal_Int32* pFla
         long nDimCount = xDims->getCount();
         if ( nDim < nDimCount )
         {
-            uno::Reference<uno::XInterface> xIntDim =
-                ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
+            uno::Reference<uno::XInterface> xIntDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
             uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
             uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
             if ( xDimName.is() && xDimProp.is() )
@@ -1247,9 +1245,7 @@ bool ScDPObject::IsDuplicated( long nDim )
         long nDimCount = xDims->getCount();
         if ( nDim < nDimCount )
         {
-            uno::Reference<uno::XInterface> xIntDim =
-                ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
-            uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
+            uno::Reference<beans::XPropertySet> xDimProp(xDims->getByIndex(nDim), uno::UNO_QUERY);
             if ( xDimProp.is() )
             {
                 try
@@ -1730,7 +1726,7 @@ bool ScDPObject::ParseFilters(
     sal_Int32 nDimCount = xIntDims->getCount();
     for ( sal_Int32 nDim = 0; nDim<nDimCount; nDim++ )
     {
-        uno::Reference<uno::XInterface> xIntDim = ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nDim) );
+        uno::Reference<uno::XInterface> xIntDim(xIntDims->getByIndex(nDim), uno::UNO_QUERY);
         uno::Reference<container::XNamed> xDim( xIntDim, uno::UNO_QUERY );
         uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
         uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDim, uno::UNO_QUERY );
@@ -1759,17 +1755,16 @@ bool ScDPObject::ParseFilters(
                 if ( nHierarchy >= xHiers->getCount() )
                     nHierarchy = 0;
 
-                uno::Reference<uno::XInterface> xHier = ScUnoHelpFunctions::AnyToInterface(
-                                                    xHiers->getByIndex(nHierarchy) );
-                uno::Reference<sheet::XLevelsSupplier> xHierSupp( xHier, uno::UNO_QUERY );
+                uno::Reference<sheet::XLevelsSupplier> xHierSupp(xHiers->getByIndex(nHierarchy),
+                                                                 uno::UNO_QUERY);
                 if ( xHierSupp.is() )
                 {
                     uno::Reference<container::XIndexAccess> xLevels = new ScNameToIndexAccess( xHierSupp->getLevels() );
                     sal_Int32 nLevCount = xLevels->getCount();
                     for (sal_Int32 nLev=0; nLev<nLevCount; nLev++)
                     {
-                        uno::Reference<uno::XInterface> xLevel = ScUnoHelpFunctions::AnyToInterface(
-                                                            xLevels->getByIndex(nLev) );
+                        uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(nLev),
+                                                               uno::UNO_QUERY);
                         uno::Reference<container::XNamed> xLevNam( xLevel, uno::UNO_QUERY );
                         uno::Reference<sheet::XMembersSupplier> xLevSupp( xLevel, uno::UNO_QUERY );
                         if ( xLevNam.is() && xLevSupp.is() )
@@ -1994,9 +1989,7 @@ void ScDPObject::ToggleDetails(const DataPilotTableHeaderData& rElemDesc, ScDPOb
     long nIntCount = xIntDims->getCount();
     if ( rElemDesc.Dimension < nIntCount )
     {
-        uno::Reference<uno::XInterface> xIntDim = ScUnoHelpFunctions::AnyToInterface(
-                                    xIntDims->getByIndex(rElemDesc.Dimension) );
-        xDim.set( xIntDim, uno::UNO_QUERY );
+        xDim.set(xIntDims->getByIndex(rElemDesc.Dimension), uno::UNO_QUERY);
     }
     OSL_ENSURE( xDim.is(), "dimension not found" );
     if ( !xDim.is() ) return;
@@ -2025,7 +2018,7 @@ void ScDPObject::ToggleDetails(const DataPilotTableHeaderData& rElemDesc, ScDPOb
     }
     uno::Reference<uno::XInterface> xHier;
     if ( rElemDesc.Hierarchy < nHierCount )
-        xHier = ScUnoHelpFunctions::AnyToInterface( xHiers->getByIndex(rElemDesc.Hierarchy) );
+        xHier.set(xHiers->getByIndex(rElemDesc.Hierarchy), uno::UNO_QUERY);
     OSL_ENSURE( xHier.is(), "hierarchy not found" );
     if ( !xHier.is() ) return;
 
@@ -2040,7 +2033,7 @@ void ScDPObject::ToggleDetails(const DataPilotTableHeaderData& rElemDesc, ScDPOb
     }
     uno::Reference<uno::XInterface> xLevel;
     if ( rElemDesc.Level < nLevCount )
-        xLevel = ScUnoHelpFunctions::AnyToInterface( xLevels->getByIndex(rElemDesc.Level) );
+        xLevel.set(xLevels->getByIndex(rElemDesc.Level), uno::UNO_QUERY);
     OSL_ENSURE( xLevel.is(), "level not found" );
     if ( !xLevel.is() ) return;
 
@@ -2056,9 +2049,8 @@ void ScDPObject::ToggleDetails(const DataPilotTableHeaderData& rElemDesc, ScDPOb
     {
         if ( xMembers->hasByName(rElemDesc.MemberName) )
         {
-            uno::Reference<uno::XInterface> xMemberInt = ScUnoHelpFunctions::AnyToInterface(
-                                            xMembers->getByName(rElemDesc.MemberName) );
-            uno::Reference<beans::XPropertySet> xMbrProp( xMemberInt, uno::UNO_QUERY );
+            uno::Reference<beans::XPropertySet> xMbrProp(xMembers->getByName(rElemDesc.MemberName),
+                                                         uno::UNO_QUERY);
             if ( xMbrProp.is() )
             {
                 bShowDetails = ScUnoHelpFunctions::GetBoolProperty( xMbrProp,
@@ -2100,14 +2092,12 @@ static PivotFunc lcl_FirstSubTotal( const uno::Reference<beans::XPropertySet>& x
         if ( nHierarchy >= xHiers->getCount() )
             nHierarchy = 0;
 
-        uno::Reference<uno::XInterface> xHier = ScUnoHelpFunctions::AnyToInterface(
-                                    xHiers->getByIndex(nHierarchy) );
-        uno::Reference<sheet::XLevelsSupplier> xHierSupp( xHier, uno::UNO_QUERY );
+        uno::Reference<sheet::XLevelsSupplier> xHierSupp(xHiers->getByIndex(nHierarchy),
+                                                         uno::UNO_QUERY);
         if ( xHierSupp.is() )
         {
             uno::Reference<container::XIndexAccess> xLevels = new ScNameToIndexAccess( xHierSupp->getLevels() );
-            uno::Reference<uno::XInterface> xLevel =
-                ScUnoHelpFunctions::AnyToInterface( xLevels->getByIndex( 0 ) );
+            uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(0), uno::UNO_QUERY);
             uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY );
             if ( xLevProp.is() )
             {
@@ -2171,12 +2161,8 @@ static void lcl_FillOldFields( ScPivotFieldVector& rFields,
     long nDimCount = xDims->getCount();
     for (long nDim = 0; nDim < nDimCount; ++nDim)
     {
-        // Get dimension object.
-        uno::Reference<uno::XInterface> xIntDim =
-            ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
-
         // dimension properties
-        uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
+        uno::Reference<beans::XPropertySet> xDimProp(xDims->getByIndex(nDim), uno::UNO_QUERY);
 
         // dimension orientation, hidden by default.
         sheet::DataPilotFieldOrientation nDimOrient = ScUnoHelpFunctions::GetEnumProperty(
@@ -2350,19 +2336,15 @@ static void lcl_FillLabelData( ScDPLabelData& rData, const uno::Reference< beans
         nHierarchy = 0;
     rData.mnUsedHier = nHierarchy;
 
-    uno::Reference<uno::XInterface> xHier =
-        ScUnoHelpFunctions::AnyToInterface(xHiers->getByIndex(nHierarchy));
-
-    uno::Reference<sheet::XLevelsSupplier> xHierSupp( xHier, uno::UNO_QUERY );
+    uno::Reference<sheet::XLevelsSupplier> xHierSupp(xHiers->getByIndex(nHierarchy),
+                                                     uno::UNO_QUERY);
     if (!xHierSupp.is())
         return;
 
     uno::Reference<container::XIndexAccess> xLevels =
         new ScNameToIndexAccess( xHierSupp->getLevels() );
 
-    uno::Reference<uno::XInterface> xLevel =
-        ScUnoHelpFunctions::AnyToInterface( xLevels->getByIndex(0) );
-    uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY );
+    uno::Reference<beans::XPropertySet> xLevProp(xLevels->getByIndex(0), uno::UNO_QUERY);
     if (!xLevProp.is())
         return;
 
@@ -2389,8 +2371,7 @@ static void lcl_FillLabelData( ScDPLabelData& rData, const uno::Reference< beans
 void ScDPObject::FillLabelDataForDimension(
     const uno::Reference<container::XIndexAccess>& xDims, sal_Int32 nDim, ScDPLabelData& rLabelData)
 {
-    uno::Reference<uno::XInterface> xIntDim =
-        ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
+    uno::Reference<uno::XInterface> xIntDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
     uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
     uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
 
@@ -2575,9 +2556,7 @@ OUString lcl_GetDimName( const uno::Reference<sheet::XDimensionsSupplier>& xSour
         long nDimCount = xDims->getCount();
         if ( nDim < nDimCount )
         {
-            uno::Reference<uno::XInterface> xIntDim =
-                ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
-            uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
+            uno::Reference<container::XNamed> xDimName(xDims->getByIndex(nDim), uno::UNO_QUERY);
             if (xDimName.is())
             {
                 try
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index dd8d5a1e1e36..f388ab506166 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -354,8 +354,7 @@ void lcl_FillNumberFormats( std::unique_ptr<sal_uInt32[]>& rFormats, long& rCoun
     sal_Int32 nDim = 0;
     for ( ; nDim < nDimCount ; nDim++)
     {
-        uno::Reference<uno::XInterface> xDim =
-                ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
+        uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
         uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
         uno::Reference<container::XNamed> xDimName( xDim, uno::UNO_QUERY );
         if ( xDimProp.is() && xDimName.is() )
@@ -418,9 +417,7 @@ sal_uInt32 lcl_GetFirstNumberFormat( const uno::Reference<container::XIndexAcces
     long nDimCount = xDims->getCount();
     for (long nDim=0; nDim<nDimCount; nDim++)
     {
-        uno::Reference<uno::XInterface> xDim =
-                ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
-        uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
+        uno::Reference<beans::XPropertySet> xDimProp(xDims->getByIndex(nDim), uno::UNO_QUERY);
         if ( xDimProp.is() )
         {
             sheet::DataPilotFieldOrientation eDimOrient =
@@ -536,8 +533,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
         long nDimCount = xDims->getCount();
         for (long nDim=0; nDim<nDimCount; nDim++)
         {
-            uno::Reference<uno::XInterface> xDim =
-                    ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
+            uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
             uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
             uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDim, uno::UNO_QUERY );
             if ( xDimProp.is() && xDimSupp.is() )
@@ -565,10 +561,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
                     if ( nHierarchy >= xHiers->getCount() )
                         nHierarchy = 0;
 
-                    uno::Reference<uno::XInterface> xHier =
-                            ScUnoHelpFunctions::AnyToInterface(
-                                                xHiers->getByIndex(nHierarchy) );
-                    uno::Reference<sheet::XLevelsSupplier> xHierSupp( xHier, uno::UNO_QUERY );
+                    uno::Reference<sheet::XLevelsSupplier> xHierSupp(xHiers->getByIndex(nHierarchy),
+                                                                     uno::UNO_QUERY);
                     if ( xHierSupp.is() )
                     {
                         uno::Reference<container::XIndexAccess> xLevels =
@@ -576,9 +570,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
                         long nLevCount = xLevels->getCount();
                         for (long nLev=0; nLev<nLevCount; nLev++)
                         {
-                            uno::Reference<uno::XInterface> xLevel =
-                                        ScUnoHelpFunctions::AnyToInterface(
-                                                            xLevels->getByIndex(nLev) );
+                            uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(nLev),
+                                                                   uno::UNO_QUERY);
                             uno::Reference<container::XNamed> xLevNam( xLevel, uno::UNO_QUERY );
                             uno::Reference<sheet::XDataPilotMemberResults> xLevRes(
                                     xLevel, uno::UNO_QUERY );
@@ -1244,8 +1237,7 @@ void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, s
         long nDimCount = xDims->getCount();
         for (long nDim=0; nDim<nDimCount; nDim++)
         {
-            uno::Reference<uno::XInterface> xDim =
-                    ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
+            uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
             uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
             if ( xDimProp.is() )
             {
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 5b9637d50607..7a2d7d45b27e 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -527,11 +527,9 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
 
     for (long nHier=0; nHier<nHierCount; nHier++)
     {
-        uno::Reference<uno::XInterface> xHierarchy = ScUnoHelpFunctions::AnyToInterface( xHiers->getByIndex(nHier) );
-
         long nLevCount = 0;
         uno::Reference<container::XIndexAccess> xLevels;
-        uno::Reference<sheet::XLevelsSupplier> xLevSupp( xHierarchy, uno::UNO_QUERY );
+        uno::Reference<sheet::XLevelsSupplier> xLevSupp(xHiers->getByIndex(nHier), uno::UNO_QUERY);
         if ( xLevSupp.is() )
         {
             uno::Reference<container::XNameAccess> xLevelsName = xLevSupp->getLevels();
@@ -541,7 +539,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
 
         for (long nLev=0; nLev<nLevCount; nLev++)
         {
-            uno::Reference<uno::XInterface> xLevel = ScUnoHelpFunctions::AnyToInterface( xLevels->getByIndex(nLev) );
+            uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(nLev), uno::UNO_QUERY);
             uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY );
             OSL_ENSURE( xLevProp.is(), "no properties at level" );
             if ( xLevProp.is() )
@@ -591,8 +589,8 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
                             OUString aMemberName = pMember->GetName();
                             if ( xMembers->hasByName( aMemberName ) )
                             {
-                                uno::Reference<uno::XInterface> xMemberInt = ScUnoHelpFunctions::AnyToInterface(
-                                    xMembers->getByName( aMemberName ) );
+                                uno::Reference<uno::XInterface> xMemberInt(
+                                    xMembers->getByName(aMemberName), uno::UNO_QUERY);
                                 pMember->WriteToSource( xMemberInt, nPosition );
 
                                 if ( nPosition >= 0 )
@@ -1020,8 +1018,7 @@ static void lcl_ResetOrient( const uno::Reference<sheet::XDimensionsSupplier>& x
     long nIntCount = xIntDims->getCount();
     for (long nIntDim=0; nIntDim<nIntCount; nIntDim++)
     {
-        uno::Reference<uno::XInterface> xIntDim = ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nIntDim) );
-        uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
+        uno::Reference<beans::XPropertySet> xDimProp(xIntDims->getByIndex(nIntDim), uno::UNO_QUERY);
         if (xDimProp.is())
         {
             xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, uno::Any(sheet::DataPilotFieldOrientation_HIDDEN) );
@@ -1090,7 +1087,8 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
             bool bFound = false;
             for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++)
             {
-                uno::Reference<uno::XInterface> xIntDim = ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nIntDim) );
+                uno::Reference<uno::XInterface> xIntDim(xIntDims->getByIndex(nIntDim),
+                                                        uno::UNO_QUERY);
                 if ( bData )
                 {
                     uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
diff --git a/sc/source/ui/dataprovider/sqldataprovider.cxx b/sc/source/ui/dataprovider/sqldataprovider.cxx
index b8b9c9d28a40..4e2ee80bea5b 100644
--- a/sc/source/ui/dataprovider/sqldataprovider.cxx
+++ b/sc/source/ui/dataprovider/sqldataprovider.cxx
@@ -70,8 +70,7 @@ void SQLFetchThread::execute()
             = sdb::DatabaseContext::create(comphelper::getProcessComponentContext());
         uno::Any aSourceAny = xContext->getByName(aDatabase);
 
-        uno::Reference<sdb::XCompletedConnection> xSource(
-            ScUnoHelpFunctions::AnyToInterface(aSourceAny), uno::UNO_QUERY);
+        uno::Reference<sdb::XCompletedConnection> xSource(aSourceAny, uno::UNO_QUERY);
         if (!xSource.is())
             return;
 
diff --git a/sc/source/ui/dbgui/dapidata.cxx b/sc/source/ui/dbgui/dapidata.cxx
index b433c31890f8..06d360a163ac 100644
--- a/sc/source/ui/dbgui/dapidata.cxx
+++ b/sc/source/ui/dbgui/dapidata.cxx
@@ -125,8 +125,7 @@ void ScDataPilotDatabaseDlg::FillObjects()
                 comphelper::getProcessComponentContext() );
 
         uno::Any aSourceAny = xContext->getByName( aDatabaseName );
-        uno::Reference<sdb::XCompletedConnection> xSource(
-                ScUnoHelpFunctions::AnyToInterface( aSourceAny ), uno::UNO_QUERY );
+        uno::Reference<sdb::XCompletedConnection> xSource(aSourceAny, uno::UNO_QUERY);
         if ( !xSource.is() ) return;
 
         uno::Reference<task::XInteractionHandler> xHandler(
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
index c72ab042b4cf..e6e4ce88d626 100644
--- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
@@ -338,7 +338,7 @@ void PivotTableDataProvider::collectPivotTableData()
 
     for (sal_Int32 nDim = 0; nDim < xDims->getCount(); nDim++)
     {
-        uno::Reference<uno::XInterface> xDim = ScUnoHelpFunctions::AnyToInterface(xDims->getByIndex(nDim));
+        uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
         uno::Reference<beans::XPropertySet> xDimProp(xDim, uno::UNO_QUERY);
         uno::Reference<sheet::XHierarchiesSupplier> xDimSupp(xDim, uno::UNO_QUERY);
 
@@ -357,9 +357,8 @@ void PivotTableDataProvider::collectPivotTableData()
         if (nHierarchy >= xHierarchies->getCount())
             nHierarchy = 0;
 
-        uno::Reference<uno::XInterface> xHierarchy = ScUnoHelpFunctions::AnyToInterface(xHierarchies->getByIndex(nHierarchy));
-
-        uno::Reference<sheet::XLevelsSupplier> xLevelsSupplier(xHierarchy, uno::UNO_QUERY);
+        uno::Reference<sheet::XLevelsSupplier> xLevelsSupplier(xHierarchies->getByIndex(nHierarchy),
+                                                               uno::UNO_QUERY);
 
         if (!xLevelsSupplier.is())
             continue;
@@ -368,7 +367,7 @@ void PivotTableDataProvider::collectPivotTableData()
 
         for (long nLevel = 0; nLevel < xLevels->getCount(); nLevel++)
         {
-            uno::Reference<uno::XInterface> xLevel = ScUnoHelpFunctions::AnyToInterface(xLevels->getByIndex(nLevel));
+            uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(nLevel), uno::UNO_QUERY);
             uno::Reference<container::XNamed> xLevelName(xLevel, uno::UNO_QUERY);
             uno::Reference<sheet::XDataPilotMemberResults> xLevelResult(xLevel, uno::UNO_QUERY );
 
diff --git a/sc/source/ui/unoobj/miscuno.cxx b/sc/source/ui/unoobj/miscuno.cxx
index 1a0e92f7eef7..28765aba1e60 100644
--- a/sc/source/ui/unoobj/miscuno.cxx
+++ b/sc/source/ui/unoobj/miscuno.cxx
@@ -32,15 +32,6 @@ using ::com::sun::star::uno::Any;
 
 SC_SIMPLE_SERVICE_INFO( ScNameToIndexAccess, "ScNameToIndexAccess", "stardiv.unknown" )
 
-uno::Reference<uno::XInterface> ScUnoHelpFunctions::AnyToInterface( const uno::Any& rAny )
-{
-    if ( rAny.getValueTypeClass() == uno::TypeClass_INTERFACE )
-    {
-        return uno::Reference<uno::XInterface>(rAny, uno::UNO_QUERY);
-    }
-    return uno::Reference<uno::XInterface>();   //! Exception?
-}
-
 bool ScUnoHelpFunctions::GetBoolProperty( const uno::Reference<beans::XPropertySet>& xProp,
                                             const OUString& rName, bool bDefault )
 {
diff --git a/sc/source/ui/unoobj/targuno.cxx b/sc/source/ui/unoobj/targuno.cxx
index 2dee47293af0..7a6fd5f0167b 100644
--- a/sc/source/ui/unoobj/targuno.cxx
+++ b/sc/source/ui/unoobj/targuno.cxx
@@ -262,12 +262,11 @@ ScLinkTargetsObj::~ScLinkTargetsObj()
 
 uno::Any SAL_CALL ScLinkTargetsObj::getByName(const OUString& aName)
 {
-    uno::Reference< beans::XPropertySet >  xProp( ScUnoHelpFunctions::AnyToInterface( xCollection->getByName(aName) ), uno::UNO_QUERY );
+    uno::Reference<beans::XPropertySet> xProp(xCollection->getByName(aName), uno::UNO_QUERY);
     if (xProp.is())
         return uno::makeAny(xProp);
 
     throw container::NoSuchElementException();
-//    return uno::Any();
 }
 
 uno::Sequence<OUString> SAL_CALL ScLinkTargetsObj::getElementNames()
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 36414ed178a3..49ec1b48010a 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -279,8 +279,7 @@ ScVbaApplication::getSelection()
     uno::Any any;
     any <<= false;
     xPropSet->setPropertyValue( aPropName, any );
-    uno::Reference< uno::XInterface > aSelection = ScUnoHelpFunctions::AnyToInterface(
-        xSelSupp->getSelection() );
+    uno::Reference<uno::XInterface> aSelection(xSelSupp->getSelection(), uno::UNO_QUERY);
     xPropSet->setPropertyValue( aPropName, aOldVal );
 
     if (!aSelection.is())


More information about the Libreoffice-commits mailing list