From c1f4d4ddf27814b1d86b7d35dcf70a28aa217885 Mon Sep 17 00:00:00 2001 From: Arnaud Versini Date: Mon, 19 Dec 2016 11:18:28 +0100 Subject: accessibility: simplify CharacterAttributesHelper. Change-Id: I62063745e704c941fdce306228ebbe3522c3b438 Reviewed-on: https://gerrit.libreoffice.org/32738 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../inc/helper/characterattributeshelper.hxx | 1 - .../source/helper/characterattributeshelper.cxx | 36 +++++----------------- 2 files changed, 7 insertions(+), 30 deletions(-) (limited to 'accessibility') diff --git a/accessibility/inc/helper/characterattributeshelper.hxx b/accessibility/inc/helper/characterattributeshelper.hxx index 6b679a9d5b6a..bbffd80c5058 100644 --- a/accessibility/inc/helper/characterattributeshelper.hxx +++ b/accessibility/inc/helper/characterattributeshelper.hxx @@ -41,7 +41,6 @@ private: public: CharacterAttributesHelper( const vcl::Font& rFont, sal_Int32 nBackColor, sal_Int32 nColor ); - ~CharacterAttributesHelper(); std::vector< css::beans::PropertyValue > GetCharacterAttributes(); css::uno::Sequence< css::beans::PropertyValue > GetCharacterAttributes( const css::uno::Sequence< OUString >& aRequestedAttributes ); diff --git a/accessibility/source/helper/characterattributeshelper.cxx b/accessibility/source/helper/characterattributeshelper.cxx index 4e33d1bc184a..e4896fad9868 100644 --- a/accessibility/source/helper/characterattributeshelper.cxx +++ b/accessibility/source/helper/characterattributeshelper.cxx @@ -43,23 +43,14 @@ CharacterAttributesHelper::CharacterAttributesHelper( const vcl::Font& rFont, sa } -CharacterAttributesHelper::~CharacterAttributesHelper() -{ - m_aAttributeMap.clear(); -} - - std::vector< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes() { - std::vector< PropertyValue > aValues( m_aAttributeMap.size() ); + std::vector< PropertyValue > aValues; + aValues.reserve( m_aAttributeMap.size() ); - int i = 0; - for ( AttributeMap::iterator aIt = m_aAttributeMap.begin(); aIt != m_aAttributeMap.end(); ++aIt, ++i ) + for ( const auto& aIt : m_aAttributeMap) { - aValues[i].Name = aIt->first; - aValues[i].Handle = (sal_Int32) -1; - aValues[i].Value = aIt->second; - aValues[i].State = PropertyState_DIRECT_VALUE; + aValues.emplace_back(aIt.first, (sal_Int32) -1, aIt.second, PropertyState_DIRECT_VALUE); } return aValues; @@ -72,27 +63,14 @@ Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes( con return comphelper::containerToSequence(GetCharacterAttributes()); std::vector< PropertyValue > aValues; - sal_Int32 nLength = aRequestedAttributes.getLength(); - AttributeMap aAttributeMap; - - for ( sal_Int32 i = 0; i < nLength; ++i ) + for ( const auto& aRequestedAttribute: aRequestedAttributes) { - AttributeMap::iterator aFound = m_aAttributeMap.find( aRequestedAttributes[i] ); + AttributeMap::iterator aFound = m_aAttributeMap.find( aRequestedAttribute ); if ( aFound != m_aAttributeMap.end() ) - aAttributeMap.insert( *aFound ); + aValues.emplace_back(aFound->first, (sal_Int32) -1, aFound->second, PropertyState_DIRECT_VALUE); } - aValues.reserve( aAttributeMap.size() ); - - int i = 0; - for ( AttributeMap::iterator aIt = aAttributeMap.begin(); aIt != aAttributeMap.end(); ++aIt, ++i ) - { - aValues[i].Name = aIt->first; - aValues[i].Handle = (sal_Int32) -1; - aValues[i].Value = aIt->second; - aValues[i].State = PropertyState_DIRECT_VALUE; - } return comphelper::containerToSequence(aValues); } -- cgit