Use comphelper::containerToSequence()

Change-Id: I18d6ef04ff00f971a4c54ba259733c07501c6c1a
This commit is contained in:
Noel Grandin 2015-12-03 10:28:31 +02:00
parent d40d756f40
commit 7f8c4b8445
5 changed files with 57 additions and 61 deletions

View file

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

View file

@ -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;
}
}
else
{
aValues = GetCharacterAttributes();
AttributeMap::iterator aFound = m_aAttributeMap.find( aRequestedAttributes[i] );
if ( aFound != m_aAttributeMap.end() )
aAttributeMap.insert( *aFound );
}
return aValues;
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);
}

View file

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

View file

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

View file

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