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

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Thu May 2 08:44:34 UTC 2019


 sc/source/core/data/dpobject.cxx |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit dd670d89951876c32fdfdcb26a93ced1c6d42998
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu May 2 08:54:40 2019 +0200
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu May 2 10:43:49 2019 +0200

    Use range-based for here instead of ScNameToIndexAccess
    
    Change-Id: Ida1351dda42f2dc0ddb50dbcbd55564d64280c15
    Reviewed-on: https://gerrit.libreoffice.org/71655
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 8357f5961f94..57c1b7723c71 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -262,23 +262,23 @@ static sheet::DataPilotFieldOrientation lcl_GetDataGetOrientation( const uno::Re
     sheet::DataPilotFieldOrientation nRet = sheet::DataPilotFieldOrientation_HIDDEN;
     if ( xSource.is() )
     {
-        uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
-        uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName );
-        long nIntCount = xIntDims->getCount();
-        bool bFound = false;
-        for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++)
+        uno::Reference<container::XNameAccess> xDimNames = xSource->getDimensions();
+        for (const OUString& rDimName: xDimNames->getElementNames())
         {
-            uno::Reference<beans::XPropertySet> xDimProp(xIntDims->getByIndex(nIntDim),
+            uno::Reference<beans::XPropertySet> xDimProp(xDimNames->getByName(rDimName),
                                                          uno::UNO_QUERY);
             if ( xDimProp.is() )
             {
-                bFound = ScUnoHelpFunctions::GetBoolProperty( xDimProp,
+                const bool bFound = ScUnoHelpFunctions::GetBoolProperty( xDimProp,
                     SC_UNO_DP_ISDATALAYOUT );
                 //TODO: error checking -- is "IsDataLayoutDimension" property required??
                 if (bFound)
+                {
                     nRet = ScUnoHelpFunctions::GetEnumProperty(
                             xDimProp, SC_UNO_DP_ORIENTATION,
                             sheet::DataPilotFieldOrientation_HIDDEN );
+                    break;
+                }
             }
         }
     }


More information about the Libreoffice-commits mailing list