[Libreoffice-commits] core.git: accessibility/inc accessibility/source

Arnaud Versini arnaud.versini at gmail.com
Sat Jan 7 13:22:28 UTC 2017


 accessibility/inc/helper/characterattributeshelper.hxx    |    1 
 accessibility/source/helper/characterattributeshelper.cxx |   36 ++------------
 2 files changed, 7 insertions(+), 30 deletions(-)

New commits:
commit c1f4d4ddf27814b1d86b7d35dcf70a28aa217885
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Mon Dec 19 11:18:28 2016 +0100

    accessibility: simplify CharacterAttributesHelper.
    
    Change-Id: I62063745e704c941fdce306228ebbe3522c3b438
    Reviewed-on: https://gerrit.libreoffice.org/32738
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/accessibility/inc/helper/characterattributeshelper.hxx b/accessibility/inc/helper/characterattributeshelper.hxx
index 6b679a9..bbffd80 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 4e33d1b..e4896fa 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);
 }
 


More information about the Libreoffice-commits mailing list