summaryrefslogtreecommitdiff
path: root/accessibility
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-12-03 10:28:31 +0200
committerNoel Grandin <noel@peralex.com>2015-12-03 13:57:22 +0200
commit7f8c4b8445b578ec26256efd6f96e5a5b8d81f2e (patch)
tree1e9c14c05df034f622160222eaa6cf073a1aad7e /accessibility
parentd40d756f4079a228035b5db346da50fe7aed0bd2 (diff)
Use comphelper::containerToSequence()
Change-Id: I18d6ef04ff00f971a4c54ba259733c07501c6c1a
Diffstat (limited to 'accessibility')
-rw-r--r--accessibility/inc/accessibility/helper/characterattributeshelper.hxx2
-rw-r--r--accessibility/source/helper/characterattributeshelper.cxx65
2 files changed, 31 insertions, 36 deletions
diff --git a/accessibility/inc/accessibility/helper/characterattributeshelper.hxx b/accessibility/inc/accessibility/helper/characterattributeshelper.hxx
index 7ed84cbd9b4e..3ed820b127e4 100644
--- a/accessibility/inc/accessibility/helper/characterattributeshelper.hxx
+++ b/accessibility/inc/accessibility/helper/characterattributeshelper.hxx
@@ -43,7 +43,7 @@ public:
CharacterAttributesHelper( const vcl::Font& rFont, sal_Int32 nBackColor, sal_Int32 nColor );
~CharacterAttributesHelper();
- css::uno::Sequence< css::beans::PropertyValue > GetCharacterAttributes();
+ 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 cf8cf794c2d5..3f82d708959e 100644
--- a/accessibility/source/helper/characterattributeshelper.cxx
+++ b/accessibility/source/helper/characterattributeshelper.cxx
@@ -19,6 +19,7 @@
#include <accessibility/helper/characterattributeshelper.hxx>
#include <tools/gen.hxx>
+#include <comphelper/sequence.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
@@ -48,57 +49,51 @@ CharacterAttributesHelper::~CharacterAttributesHelper()
}
-Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes()
+std::vector< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes()
{
- Sequence< PropertyValue > aValues( m_aAttributeMap.size() );
- PropertyValue* pValues = aValues.getArray();
+ std::vector< PropertyValue > aValues( m_aAttributeMap.size() );
- for ( AttributeMap::iterator aIt = m_aAttributeMap.begin(); aIt != m_aAttributeMap.end(); ++aIt, ++pValues )
+ int i = 0;
+ for ( AttributeMap::iterator aIt = m_aAttributeMap.begin(); aIt != m_aAttributeMap.end(); ++aIt, ++i )
{
- pValues->Name = aIt->first;
- pValues->Handle = (sal_Int32) -1;
- pValues->Value = aIt->second;
- pValues->State = PropertyState_DIRECT_VALUE;
+ aValues[i].Name = aIt->first;
+ aValues[i].Handle = (sal_Int32) -1;
+ aValues[i].Value = aIt->second;
+ aValues[i].State = PropertyState_DIRECT_VALUE;
}
return aValues;
}
-Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes( const Sequence< OUString >& aRequestedAttributes )
+Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes( const css::uno::Sequence< OUString >& aRequestedAttributes )
{
- Sequence< PropertyValue > aValues;
+ if ( aRequestedAttributes.getLength() == 0 )
+ return comphelper::containerToSequence(GetCharacterAttributes());
+
+ std::vector< PropertyValue > aValues;
sal_Int32 nLength = aRequestedAttributes.getLength();
- if ( nLength != 0 )
+ AttributeMap aAttributeMap;
+
+ for ( sal_Int32 i = 0; i < nLength; ++i )
{
- const OUString* pNames = aRequestedAttributes.getConstArray();
- AttributeMap aAttributeMap;
-
- for ( sal_Int32 i = 0; i < nLength; ++i )
- {
- AttributeMap::iterator aFound = m_aAttributeMap.find( pNames[i] );
- if ( aFound != m_aAttributeMap.end() )
- aAttributeMap.insert( *aFound );
- }
-
- aValues.realloc( aAttributeMap.size() );
- PropertyValue* pValues = aValues.getArray();
-
- for ( AttributeMap::iterator aIt = aAttributeMap.begin(); aIt != aAttributeMap.end(); ++aIt, ++pValues )
- {
- pValues->Name = aIt->first;
- pValues->Handle = (sal_Int32) -1;
- pValues->Value = aIt->second;
- pValues->State = PropertyState_DIRECT_VALUE;
- }
+ AttributeMap::iterator aFound = m_aAttributeMap.find( aRequestedAttributes[i] );
+ if ( aFound != m_aAttributeMap.end() )
+ aAttributeMap.insert( *aFound );
}
- else
+
+ aValues.reserve( aAttributeMap.size() );
+
+ int i = 0;
+ for ( AttributeMap::iterator aIt = aAttributeMap.begin(); aIt != aAttributeMap.end(); ++aIt, ++i )
{
- aValues = GetCharacterAttributes();
+ aValues[i].Name = aIt->first;
+ aValues[i].Handle = (sal_Int32) -1;
+ aValues[i].Value = aIt->second;
+ aValues[i].State = PropertyState_DIRECT_VALUE;
}
-
- return aValues;
+ return comphelper::containerToSequence(aValues);
}