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>
This commit is contained in:
Arnaud Versini
2016-12-19 11:18:28 +01:00
committed by Noel Grandin
parent f2d9e29841
commit c1f4d4ddf2
2 changed files with 7 additions and 30 deletions

View File

@@ -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 );

View File

@@ -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);
}