[Libreoffice-commits] core.git: accessibility/source avmedia/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Mar 16 19:19:01 UTC 2019
accessibility/source/extended/textwindowaccessibility.cxx | 16 +++---------
accessibility/source/standard/vclxaccessiblelist.cxx | 16 ++++++------
accessibility/source/standard/vclxaccessibleradiobutton.cxx | 8 +-----
accessibility/source/standard/vclxaccessibletoolbox.cxx | 16 +++++-------
avmedia/source/gstreamer/gstplayer.cxx | 8 +++---
5 files changed, 26 insertions(+), 38 deletions(-)
New commits:
commit 0a4f7813c4deb26194eba1efe0ff2077460ab599
Author: Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sat Mar 16 11:19:05 2019 +0300
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Mar 16 20:18:40 2019 +0100
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 at collabora.co.uk>
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;
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
index 70cc690ab56c..78928cddcc45 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -227,10 +227,10 @@ void MissingPluginInstaller::detach(Player const * source) {
void MissingPluginInstaller::processQueue() {
assert(!queued_.empty());
assert(currentDetails_.empty());
- for (auto i = queued_.begin(); i != queued_.end(); ++i) {
- reported_.insert(i->first);
- currentDetails_.push_back(i->first);
- currentSources_.insert(i->second.begin(), i->second.end());
+ for (const auto& rEntry : queued_) {
+ reported_.insert(rEntry.first);
+ currentDetails_.push_back(rEntry.first);
+ currentSources_.insert(rEntry.second.begin(), rEntry.second.end());
}
queued_.clear();
}
More information about the Libreoffice-commits
mailing list