diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-05-02 13:26:52 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-05-02 16:20:38 +0200 |
commit | 96ab20756316b25b7f2343a15596bc5114ea5a68 (patch) | |
tree | f174a2f9753f7c3b6286283ca5c27040e75127d5 /sc | |
parent | 128145e227ef91fb2f23893e73d38ae72cf074e5 (diff) |
Deduplicate some code
Change-Id: Ia57947276a5d561f57bb3fe677451b77a80a1009
Reviewed-on: https://gerrit.libreoffice.org/71671
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/unoobj/dapiuno.cxx | 78 |
1 files changed, 24 insertions, 54 deletions
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 0f3fa929ef4a..44fbc9dcac93 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -1496,28 +1496,17 @@ static sal_Int32 lcl_GetFieldCount( const Reference<XDimensionsSupplier>& rSourc Reference<XNameAccess> xDimsName(rSource->getDimensions()); Reference<XIndexAccess> xIntDims(new ScNameToIndexAccess( xDimsName )); sal_Int32 nIntCount = xIntDims->getCount(); - if (rOrient.hasValue()) + for (sal_Int32 i = 0; i < nIntCount; ++i) { - // all fields of the specified orientation, including duplicated - Reference<XPropertySet> xDim; - for (sal_Int32 i = 0; i < nIntCount; ++i) - { - xDim.set(xIntDims->getByIndex(i), UNO_QUERY); - if (xDim.is() && (xDim->getPropertyValue(SC_UNO_DP_ORIENTATION) == rOrient)) - ++nRet; - } - } - else - { - // count all non-duplicated fields - - Reference<XPropertySet> xDim; - for (sal_Int32 i = 0; i < nIntCount; ++i) - { - xDim.set(xIntDims->getByIndex(i), UNO_QUERY); - if ( xDim.is() && !lcl_IsDuplicated( xDim ) ) - ++nRet; - } + Reference<XPropertySet> xDim(xIntDims->getByIndex(i), UNO_QUERY); + const bool bMatch = xDim + && (rOrient.hasValue() + // all fields of the specified orientation, including duplicated + ? (xDim->getPropertyValue(SC_UNO_DP_ORIENTATION) == rOrient) + // count all non-duplicated fields + : !lcl_IsDuplicated(xDim)); + if (bMatch) + ++nRet; } return nRet; @@ -1537,42 +1526,23 @@ static bool lcl_GetFieldDataByIndex( const Reference<XDimensionsSupplier>& rSour Reference<XIndexAccess> xIntDims(new ScNameToIndexAccess( xDimsName )); sal_Int32 nIntCount = xIntDims->getCount(); Reference<XPropertySet> xDim; - if (rOrient.hasValue()) - { - sal_Int32 i = 0; - while (i < nIntCount && !bOk) + for (sal_Int32 i = 0; i < nIntCount; ++i) + { + xDim.set(xIntDims->getByIndex(i), UNO_QUERY); + const bool bMatch = xDim + && (rOrient.hasValue() + ? (xDim->getPropertyValue(SC_UNO_DP_ORIENTATION) == rOrient) + : !lcl_IsDuplicated(xDim)); + if (bMatch) { - xDim.set(xIntDims->getByIndex(i), UNO_QUERY); - if (xDim.is() && (xDim->getPropertyValue(SC_UNO_DP_ORIENTATION) == rOrient)) + if (nPos == nIndex) { - if (nPos == nIndex) - { - bOk = true; - nDimIndex = i; - } - else - ++nPos; + bOk = true; + nDimIndex = i; + break; } - ++i; - } - } - else - { - sal_Int32 i = 0; - while (i < nIntCount && !bOk) - { - xDim.set(xIntDims->getByIndex(i), UNO_QUERY); - if ( xDim.is() && !lcl_IsDuplicated( xDim ) ) - { - if (nPos == nIndex) - { - bOk = true; - nDimIndex = i; - } - else - ++nPos; - } - ++i; + else + ++nPos; } } |