summaryrefslogtreecommitdiff
path: root/accessibility
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-03-16 11:19:05 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-03-16 20:18:40 +0100
commit0a4f7813c4deb26194eba1efe0ff2077460ab599 (patch)
tree050c44ed14caf70a6fa9384f7b8710ca0783ff6b /accessibility
parent10a48c737d347bcce765c8fbe009bc1dd0bb0c4d (diff)
Simplify containers iterations in accessibility, avmedia
Use range-based loop or replace with STL functions Change-Id: I47cabb02a2e52f2af8e87379fc44906d2a732d19 Reviewed-on: https://gerrit.libreoffice.org/69334 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'accessibility')
-rw-r--r--accessibility/source/extended/textwindowaccessibility.cxx16
-rw-r--r--accessibility/source/standard/vclxaccessiblelist.cxx16
-rw-r--r--accessibility/source/standard/vclxaccessibleradiobutton.cxx8
-rw-r--r--accessibility/source/standard/vclxaccessibletoolbox.cxx16
4 files changed, 22 insertions, 34 deletions
diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx
index b629710691c3..927895339a7e 100644
--- a/accessibility/source/extended/textwindowaccessibility.cxx
+++ b/accessibility/source/extended/textwindowaccessibility.cxx
@@ -34,6 +34,7 @@
#include <algorithm>
#include <memory>
+#include <numeric>
#include <vector>
namespace accessibility
@@ -775,20 +776,13 @@ Document::retrieveParagraphBounds(Paragraph const * pParagraph,
// and start at m_aVisibleBegin:
Paragraphs::iterator aPara(m_xParagraphs->begin()
+ pParagraph->getNumber());
+ auto lAddHeight = [](const sal_Int32& rSum, const ParagraphInfo& rParagraph) {
+ return rSum + rParagraph.getHeight(); };
::sal_Int32 nPos;
- Paragraphs::iterator aIt;
if (aPara < m_aVisibleBegin)
- {
- nPos = 0;
- aIt = m_xParagraphs->begin();
- }
+ nPos = std::accumulate(m_xParagraphs->begin(), aPara, sal_Int32(0), lAddHeight);
else
- {
- nPos = m_nViewOffset - m_nVisibleBeginOffset;
- aIt = m_aVisibleBegin;
- }
- for (; aIt != aPara; ++aIt)
- nPos += aIt->getHeight();
+ nPos = std::accumulate(m_aVisibleBegin, aPara, m_nViewOffset - m_nVisibleBeginOffset, lAddHeight);
Point aOrig(0, 0);
if (bAbsolute)
diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx
index 08f57db441e3..315b82975878 100644
--- a/accessibility/source/standard/vclxaccessiblelist.cxx
+++ b/accessibility/source/standard/vclxaccessiblelist.cxx
@@ -205,10 +205,9 @@ void VCLXAccessibleList::UpdateSelection_Impl_Acc(bool bHasDropDownList)
{
sal_Int32 i=0;
m_nCurSelectedPos = LISTBOX_ENTRY_NOTFOUND;
- for ( ListItems::iterator aIter = m_aAccessibleChildren.begin();
- aIter != m_aAccessibleChildren.end(); ++aIter,++i)
+ for ( auto& rChild : m_aAccessibleChildren )
{
- Reference< XAccessible > xHold = *aIter;
+ Reference< XAccessible > xHold = rChild;
if ( xHold.is() )
{
VCLXAccessibleListItem* pItem = static_cast< VCLXAccessibleListItem* >( xHold.get() );
@@ -219,7 +218,7 @@ void VCLXAccessibleList::UpdateSelection_Impl_Acc(bool bHasDropDownList)
if ( bNowSelected && !pItem->IsSelected() )
{
- xNewAcc = *aIter;
+ xNewAcc = rChild;
aNewValue <<= xNewAcc;
}
else if ( pItem->IsSelected() )
@@ -231,6 +230,7 @@ void VCLXAccessibleList::UpdateSelection_Impl_Acc(bool bHasDropDownList)
{ // it could happen that a child was not created before
checkEntrySelected(i,aNewValue,xNewAcc);
}
+ ++i;
}
const sal_Int32 nCount = m_pListBoxHelper->GetEntryCount();
if ( i < nCount ) // here we have to check the if any other listbox entry is selected
@@ -670,10 +670,9 @@ void VCLXAccessibleList::UpdateSelection_Impl(sal_Int32)
{
sal_Int32 i=0;
m_nCurSelectedPos = LISTBOX_ENTRY_NOTFOUND;
- for ( ListItems::iterator aIter = m_aAccessibleChildren.begin();
- aIter != m_aAccessibleChildren.end(); ++aIter,++i)
+ for ( auto& rChild : m_aAccessibleChildren )
{
- Reference< XAccessible > xHold = *aIter;
+ Reference< XAccessible > xHold = rChild;
if ( xHold.is() )
{
VCLXAccessibleListItem* pItem = static_cast< VCLXAccessibleListItem* >( xHold.get() );
@@ -684,7 +683,7 @@ void VCLXAccessibleList::UpdateSelection_Impl(sal_Int32)
if ( bNowSelected && !pItem->IsSelected() )
{
- xNewAcc = *aIter;
+ xNewAcc = rChild;
aNewValue <<= xNewAcc;
}
else if ( pItem->IsSelected() )
@@ -696,6 +695,7 @@ void VCLXAccessibleList::UpdateSelection_Impl(sal_Int32)
{ // it could happen that a child was not created before
checkEntrySelected(i,aNewValue,xNewAcc);
}
+ ++i;
}
const sal_Int32 nCount = m_pListBoxHelper->GetEntryCount();
if ( i < nCount ) // here we have to check the if any other listbox entry is selected
diff --git a/accessibility/source/standard/vclxaccessibleradiobutton.cxx b/accessibility/source/standard/vclxaccessibleradiobutton.cxx
index c970dd5c3ce9..eef7320de0ee 100644
--- a/accessibility/source/standard/vclxaccessibleradiobutton.cxx
+++ b/accessibility/source/standard/vclxaccessibleradiobutton.cxx
@@ -81,13 +81,9 @@ void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelati
std::vector< VclPtr<RadioButton> > aGroup(pRadioButton->GetRadioButtonGroup());
if (!aGroup.empty())
{
- sal_Int32 i = 0;
Sequence< Reference< XInterface > > aSequence( static_cast< sal_Int32 >( aGroup.size() ) );
- auto aEndItr = aGroup.end();
- for ( auto aItr = aGroup.begin(); aItr < aEndItr; ++aItr )
- {
- aSequence[i++] = (*aItr)->GetAccessible();
- }
+ std::transform(aGroup.begin(), aGroup.end(), aSequence.getArray(),
+ [](const VclPtr<RadioButton>& rxItem) { return rxItem->GetAccessible(); });
rRelationSet.AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, aSequence ) );
}
}
diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx b/accessibility/source/standard/vclxaccessibletoolbox.cxx
index 4a11f6e01ba2..7e20c261435d 100644
--- a/accessibility/source/standard/vclxaccessibletoolbox.cxx
+++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx
@@ -216,15 +216,14 @@ void VCLXAccessibleToolBox::UpdateFocus_Impl()
{
sal_uInt16 nHighlightItemId = pToolBox->GetHighlightItemId();
sal_uInt16 nFocusCount = 0;
- for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
- aIter != m_aAccessibleChildren.end(); ++aIter )
+ for ( const auto& [rPos, rxChild] : m_aAccessibleChildren )
{
- sal_uInt16 nItemId = pToolBox->GetItemId( aIter->first );
+ sal_uInt16 nItemId = pToolBox->GetItemId( rPos );
- if ( aIter->second.is() )
+ if ( rxChild.is() )
{
VCLXAccessibleToolBoxItem* pItem =
- static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
+ static_cast< VCLXAccessibleToolBoxItem* >( rxChild.get() );
if ( pItem->HasFocus() && nItemId != nHighlightItemId )
{
// reset the old focused item
@@ -270,13 +269,12 @@ void VCLXAccessibleToolBox::UpdateChecked_Impl( ToolBox::ImplToolItems::size_typ
sal_uInt16 nFocusId = pToolBox->GetItemId( _nPos );
VCLXAccessibleToolBoxItem* pFocusItem = nullptr;
- for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
- aIter != m_aAccessibleChildren.end(); ++aIter )
+ for ( const auto& [rPos, rxChild] : m_aAccessibleChildren )
{
- sal_uInt16 nItemId = pToolBox->GetItemId( aIter->first );
+ sal_uInt16 nItemId = pToolBox->GetItemId( rPos );
VCLXAccessibleToolBoxItem* pItem =
- static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
+ static_cast< VCLXAccessibleToolBoxItem* >( rxChild.get() );
pItem->SetChecked( pToolBox->IsItemChecked( nItemId ) );
if ( nItemId == nFocusId )
pFocusItem = pItem;