diff options
author | Noel Grandin <noel@peralex.com> | 2015-12-03 10:28:31 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-12-03 13:57:22 +0200 |
commit | 7f8c4b8445b578ec26256efd6f96e5a5b8d81f2e (patch) | |
tree | 1e9c14c05df034f622160222eaa6cf073a1aad7e | |
parent | d40d756f4079a228035b5db346da50fe7aed0bd2 (diff) |
Use comphelper::containerToSequence()
Change-Id: I18d6ef04ff00f971a4c54ba259733c07501c6c1a
5 files changed, 56 insertions, 60 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); } diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx index 13cf03c9cc0a..982efe88233f 100644 --- a/canvas/source/vcl/textlayout.cxx +++ b/canvas/source/vcl/textlayout.cxx @@ -122,7 +122,7 @@ namespace vclcanvas ::std::unique_ptr< long []> aOffsets(new long[maLogicalAdvancements.getLength()]); setupTextOffsets(aOffsets.get(), maLogicalAdvancements, aViewState, aRenderState); - uno::Sequence< uno::Reference< rendering::XPolyPolygon2D> > aOutlineSequence; + std::vector< uno::Reference< rendering::XPolyPolygon2D> > aOutlineSequence; ::basegfx::B2DPolyPolygonVector aOutlines; if (pVDev->GetTextOutlines( aOutlines, @@ -134,7 +134,7 @@ namespace vclcanvas 0, aOffsets.get())) { - aOutlineSequence.realloc(aOutlines.size()); + aOutlineSequence.reserve(aOutlines.size()); sal_Int32 nIndex (0); for (::basegfx::B2DPolyPolygonVector::const_iterator iOutline(aOutlines.begin()), @@ -148,7 +148,7 @@ namespace vclcanvas } } - return aOutlineSequence; + return comphelper::containerToSequence(aOutlineSequence); } uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException, std::exception) diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 4f68d0b65632..6511a2893e84 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -72,21 +72,23 @@ static const char lcl_aCompleteRange[] = "all"; typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > > lcl_tSequenceMap; -Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq ) +std::vector< OUString > lcl_AnyToStringSequence( const std::vector< uno::Any >& aAnySeq ) { - Sequence< OUString > aResult; - aResult.realloc( aAnySeq.getLength() ); - transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), - aResult.getArray(), CommonFunctors::AnyToString() ); + std::vector< OUString > aResult; + aResult.resize( aAnySeq.size() ); + int i = 0; + for (const uno::Any& aAny : aAnySeq) + aResult[i++] = CommonFunctors::AnyToString()(aAny); return aResult; } -Sequence< uno::Any > lcl_StringToAnySequence( const Sequence< OUString >& aStringSeq ) +std::vector< uno::Any > lcl_StringToAnyVector( const css::uno::Sequence< OUString >& aStringSeq ) { - Sequence< uno::Any > aResult; - aResult.realloc( aStringSeq.getLength() ); - transform( aStringSeq.getConstArray(), aStringSeq.getConstArray() + aStringSeq.getLength(), - aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + std::vector< uno::Any > aResult; + aResult.resize( aStringSeq.getLength() ); + int i = 0; + for (const OUString& aStr : aStringSeq) + aResult[i++] = CommonFunctors::makeAny<OUString>()(aStr); return aResult; } @@ -151,9 +153,9 @@ struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2:: if( xLabel.is() ) { if( m_bDataInColumns ) - m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) ); + m_rInternalData.setComplexColumnLabel( nNewIndex, lcl_StringToAnyVector( xLabel->getTextualData() ) ); else - m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) ); + m_rInternalData.setComplexRowLabel( nNewIndex, lcl_StringToAnyVector( xLabel->getTextualData() ) ); if( m_bConnectToModel ) { Reference< chart2::data::XDataSequence > xNewLabel( @@ -1324,15 +1326,15 @@ vector< vector< Type > > lcl_convertSequenceSequenceToVectorVector( const Sequen return aRet; } -Sequence< Sequence< OUString > > lcl_convertComplexAnyVectorToStringSequence( const vector< vector< uno::Any > >& rIn ) +std::vector< Sequence< OUString > > lcl_convertComplexAnyVectorToStringSequence( const vector< vector< uno::Any > >& rIn ) { - Sequence< Sequence< OUString > > aRet; + std::vector< Sequence< OUString > > aRet; sal_Int32 nOuterCount = rIn.size(); if( nOuterCount ) { - aRet.realloc(nOuterCount); + aRet.resize(nOuterCount); for( sal_Int32 nN=0; nN<nOuterCount; nN++) - aRet[nN]= lcl_AnyToStringSequence( comphelper::containerToSequence( rIn[nN] ) ); + aRet[nN] = comphelper::containerToSequence(lcl_AnyToStringSequence( rIn[nN] )); } return aRet; } @@ -1342,7 +1344,7 @@ vector< vector< uno::Any > > lcl_convertComplexStringSequenceToAnyVector( const vector< vector< uno::Any > > aRet; sal_Int32 nOuterCount = rIn.getLength(); for( sal_Int32 nN=0; nN<nOuterCount; nN++) - aRet.push_back( ContainerHelper::SequenceToVector( lcl_StringToAnySequence( rIn[nN] ) ) ); + aRet.push_back( lcl_StringToAnyVector( rIn[nN] ) ); return aRet; } @@ -1440,7 +1442,7 @@ void SAL_CALL InternalDataProvider::setAnyColumnDescriptions( const Sequence< Se // ____ XComplexDescriptionAccess ____ Sequence< Sequence< OUString > > SAL_CALL InternalDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException, std::exception) { - return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexRowLabels() ); + return comphelper::containerToSequence(lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexRowLabels() )); } void SAL_CALL InternalDataProvider::setComplexRowDescriptions( const Sequence< Sequence< OUString > >& aRowDescriptions ) throw (uno::RuntimeException, std::exception) { @@ -1448,7 +1450,7 @@ void SAL_CALL InternalDataProvider::setComplexRowDescriptions( const Sequence< S } Sequence< Sequence< OUString > > SAL_CALL InternalDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException, std::exception) { - return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexColumnLabels() ); + return comphelper::containerToSequence(lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexColumnLabels() )); } void SAL_CALL InternalDataProvider::setComplexColumnDescriptions( const Sequence< Sequence< OUString > >& aColumnDescriptions ) throw (uno::RuntimeException, std::exception) { diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx index c2b063f8f0e3..3abd1f85fdee 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx @@ -429,8 +429,7 @@ void OAppDetailPageHelper::describeCurrentSelectionForType( const ElementType _e pEntry = pList->NextSelected(pEntry); } - _out_rSelectedObjects.realloc( aSelected.size() ); - ::std::copy( aSelected.begin(), aSelected.end(), _out_rSelectedObjects.getArray() ); + _out_rSelectedObjects = comphelper::containerToSequence( aSelected ); } void OAppDetailPageHelper::selectElements(const Sequence< OUString>& _aNames) |