diff options
author | Arnaud Versini <arnaud.versini@gmail.com> | 2016-12-19 11:18:28 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-07 13:22:04 +0000 |
commit | c1f4d4ddf27814b1d86b7d35dcf70a28aa217885 (patch) | |
tree | 5077ebbb34a69d15f0f87df5c7702b8c1cf09a7d /accessibility | |
parent | f2d9e2984155fa383adb33a52fec69be70a84cb7 (diff) |
accessibility: simplify CharacterAttributesHelper.
Change-Id: I62063745e704c941fdce306228ebbe3522c3b438
Reviewed-on: https://gerrit.libreoffice.org/32738
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'accessibility')
-rw-r--r-- | accessibility/inc/helper/characterattributeshelper.hxx | 1 | ||||
-rw-r--r-- | accessibility/source/helper/characterattributeshelper.cxx | 36 |
2 files changed, 7 insertions, 30 deletions
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); } |