summaryrefslogtreecommitdiff
path: root/svx/source/accessibility
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-07-07 16:20:12 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-07-09 17:48:06 +0200
commit44a6335f49a64ac77207d3aa46c267503c65c5ff (patch)
tree8ed220967528dc6caa72fa9e753c0955f3de2433 /svx/source/accessibility
parent4a96a5d862ed46bbcb64d34b32720b5b1b3d7ca8 (diff)
Simplify Sequence iterations in svx
Use range-based loops, STL and comphelper functions Change-Id: If6d190cf72b8653c1c3fbe9a6a6e47f10f1a6765 Reviewed-on: https://gerrit.libreoffice.org/75255 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'svx/source/accessibility')
-rw-r--r--svx/source/accessibility/AccessibleControlShape.cxx8
-rw-r--r--svx/source/accessibility/AccessibleShape.cxx34
-rw-r--r--svx/source/accessibility/lookupcolorname.cxx6
3 files changed, 18 insertions, 30 deletions
diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx
index 09dd1fb887bb..8b7de6c3a3bd 100644
--- a/svx/source/accessibility/AccessibleControlShape.cxx
+++ b/svx/source/accessibility/AccessibleControlShape.cxx
@@ -809,13 +809,11 @@ void AccessibleControlShape::initializeComposedState()
aInnerStates = xInnerStates->getStates();
// look which one are to be propagated to the composed context
- const sal_Int16* pStates = aInnerStates.getConstArray();
- const sal_Int16* pStatesEnd = pStates + aInnerStates.getLength();
- for ( ; pStates != pStatesEnd; ++pStates )
+ for ( const sal_Int16 nState : aInnerStates )
{
- if ( isComposedState( *pStates ) && !pComposedStates->contains( *pStates ) )
+ if ( isComposedState( nState ) && !pComposedStates->contains( nState ) )
{
- pComposedStates->AddState( *pStates );
+ pComposedStates->AddState( nState );
}
}
}
diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx
index 5eb3bbfd5698..bac37417d92a 100644
--- a/svx/source/accessibility/AccessibleShape.cxx
+++ b/svx/source/accessibility/AccessibleShape.cxx
@@ -438,16 +438,11 @@ uno::Reference<XAccessibleStateSet> SAL_CALL
if (rState.is())
{
css::uno::Sequence<short> aStates = rState->getStates();
- int count = aStates.getLength();
- for( int iIndex = 0;iIndex < count;iIndex++ )
+ if (std::find(aStates.begin(), aStates.end(), AccessibleStateType::EDITABLE) != aStates.end())
{
- if( aStates[iIndex] == AccessibleStateType::EDITABLE )
- {
- pStateSet->AddState (AccessibleStateType::EDITABLE);
- pStateSet->AddState (AccessibleStateType::RESIZABLE);
- pStateSet->AddState (AccessibleStateType::MOVEABLE);
- break;
- }
+ pStateSet->AddState (AccessibleStateType::EDITABLE);
+ pStateSet->AddState (AccessibleStateType::RESIZABLE);
+ pStateSet->AddState (AccessibleStateType::MOVEABLE);
}
}
}
@@ -813,13 +808,7 @@ sal_Bool SAL_CALL AccessibleShape::isAccessibleChildSelected( sal_Int32 nChildIn
return false;
uno::Sequence<short> aStates = pRState->getStates();
- int nCount = aStates.getLength();
- for( int i = 0; i < nCount; i++ )
- {
- if(aStates[i] == AccessibleStateType::SELECTED)
- return true;
- }
- return false;
+ return std::find(aStates.begin(), aStates.end(), AccessibleStateType::SELECTED) != aStates.end();
}
}
@@ -928,16 +917,17 @@ uno::Sequence<uno::Type> SAL_CALL
// ... and merge them all into one list.
sal_Int32 nTypeCount (aTypeList.getLength()),
nComponentTypeCount (aComponentTypeList.getLength());
- int i;
aTypeList.realloc (nTypeCount + nComponentTypeCount + 3);
- for (i=0; i<nComponentTypeCount; i++)
- aTypeList[nTypeCount + i] = aComponentTypeList[i];
+ std::copy(aComponentTypeList.begin(), aComponentTypeList.end(),
+ std::next(aTypeList.begin(), nTypeCount));
+
+ int i = nTypeCount + nComponentTypeCount;
- aTypeList[nTypeCount + i++ ] = aLangEventListenerType;
- aTypeList[nTypeCount + i++ ] = aDocumentEventListenerType;
- aTypeList[nTypeCount + i ] = aUnoTunnelType;
+ aTypeList[ i++ ] = aLangEventListenerType;
+ aTypeList[ i++ ] = aDocumentEventListenerType;
+ aTypeList[ i ] = aUnoTunnelType;
return aTypeList;
}
diff --git a/svx/source/accessibility/lookupcolorname.cxx b/svx/source/accessibility/lookupcolorname.cxx
index d7e8b55db0a4..c33cb9b3be23 100644
--- a/svx/source/accessibility/lookupcolorname.cxx
+++ b/svx/source/accessibility/lookupcolorname.cxx
@@ -78,15 +78,15 @@ ColorNameMap::ColorNameMap() {
// Fill the map to convert from numerical color values to names.
if (xNA.is())
- for (long int i=0; i<aNames.getLength(); i++)
+ for (const auto& rName : aNames)
{
// Get the numerical value for the i-th color name.
try
{
- css::uno::Any aColor = xNA->getByName(aNames[i]);
+ css::uno::Any aColor = xNA->getByName(rName);
long nColor = 0;
aColor >>= nColor;
- map_[nColor] = aNames[i];
+ map_[nColor] = rName;
}
catch (css::uno::RuntimeException const&)
{