From 28239c40430ec4e613d9d936614c5c3853c332c4 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 2 Mar 2019 08:28:03 +0200 Subject: simplify UNO getTypes methods Change-Id: Ia8b07edec54527fb4904536fabb03a18e8452550 Reviewed-on: https://gerrit.libreoffice.org/68659 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../accessibility/AccessibleControlShape.cxx | 18 +---------------- .../accessibility/AccessibleGraphicShape.cxx | 12 +++-------- svx/source/accessibility/AccessibleOLEShape.cxx | 15 ++++---------- svx/source/form/fmdpage.cxx | 8 ++------ svx/source/table/cell.cxx | 13 +++++------- svx/source/unodraw/unomod.cxx | 23 ++++++---------------- svx/source/unodraw/unopool.cxx | 17 +++++++--------- svx/source/unogallery/unogalitem.cxx | 17 +++++++--------- svx/source/unogallery/unogaltheme.cxx | 16 +++++++-------- svx/source/unogallery/unogalthemeprovider.cxx | 16 +++++++-------- 10 files changed, 49 insertions(+), 106 deletions(-) (limited to 'svx') diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx index 6746592d9d18..91fc5b2ded68 100644 --- a/svx/source/accessibility/AccessibleControlShape.cxx +++ b/svx/source/accessibility/AccessibleControlShape.cxx @@ -403,24 +403,8 @@ Sequence< Type > SAL_CALL AccessibleControlShape::getTypes() if ( m_xControlContextTypeAccess.is() ) aAggregateTypes = m_xControlContextTypeAccess->getTypes(); - Sequence< Type > aAllTypes = comphelper::concatSequences( aShapeTypes, aOwnTypes, aAggregateTypes ); - // remove duplicates - Type* pBegin = aAllTypes.getArray(); - Type* pEnd = pBegin + aAllTypes.getLength(); - while ( pBegin != pEnd ) - { - Type aThisRoundType = *pBegin; - if ( ++pBegin != pEnd ) - { - pEnd = ::std::remove( pBegin, pEnd, aThisRoundType ); - // now all types between begin and (the old) end which equal aThisRoundType - // are moved behind the new end - } - } - aAllTypes.realloc( pEnd - aAllTypes.getArray() ); - - return aAllTypes; + return comphelper::combineSequences(comphelper::concatSequences( aShapeTypes, aOwnTypes), aAggregateTypes ); } void SAL_CALL AccessibleControlShape::notifyEvent( const AccessibleEventObject& _rEvent ) diff --git a/svx/source/accessibility/AccessibleGraphicShape.cxx b/svx/source/accessibility/AccessibleGraphicShape.cxx index fba25f4ad007..4169508d66e9 100644 --- a/svx/source/accessibility/AccessibleGraphicShape.cxx +++ b/svx/source/accessibility/AccessibleGraphicShape.cxx @@ -25,6 +25,7 @@ #include #include +#include #include using namespace ::accessibility; @@ -120,15 +121,8 @@ uno::Sequence SAL_CALL AccessibleGraphicShape::getTypes() { // Get list of types from the context base implementation... - uno::Sequence aTypeList (AccessibleShape::getTypes()); - // ...and add the additional type for the component. - long nTypeCount = aTypeList.getLength(); - aTypeList.realloc (nTypeCount + 1); - const uno::Type aImageType = - cppu::UnoType::get(); - aTypeList[nTypeCount] = aImageType; - - return aTypeList; + return comphelper::concatSequences(AccessibleShape::getTypes(), + uno::Sequence { cppu::UnoType::get() }); } diff --git a/svx/source/accessibility/AccessibleOLEShape.cxx b/svx/source/accessibility/AccessibleOLEShape.cxx index fc2df2c76a9f..e3412599a3df 100644 --- a/svx/source/accessibility/AccessibleOLEShape.cxx +++ b/svx/source/accessibility/AccessibleOLEShape.cxx @@ -23,6 +23,7 @@ #include #include +#include #include using namespace ::accessibility; @@ -119,19 +120,11 @@ css::uno::Sequence< OUString> SAL_CALL } // XTypeProvider -uno::Sequence SAL_CALL - AccessibleOLEShape::getTypes() +uno::Sequence SAL_CALL AccessibleOLEShape::getTypes() { // Get list of types from the context base implementation... - uno::Sequence aTypeList (AccessibleShape::getTypes()); - // ...and add the additional type for the component. - long nTypeCount = aTypeList.getLength(); - aTypeList.realloc (nTypeCount + 1); - const uno::Type aActionType = - cppu::UnoType::get(); - aTypeList[nTypeCount] = aActionType; - - return aTypeList; + return comphelper::concatSequences(AccessibleShape::getTypes(), + uno::Sequence { cppu::UnoType::get() } ); } // XAccessibleExtendedAttributes diff --git a/svx/source/form/fmdpage.cxx b/svx/source/form/fmdpage.cxx index 45ac667c50eb..d39a3ba8371d 100644 --- a/svx/source/form/fmdpage.cxx +++ b/svx/source/form/fmdpage.cxx @@ -58,12 +58,8 @@ Any SAL_CALL SvxFmDrawPage::queryAggregation( const css::uno::Type& _rType ) css::uno::Sequence< css::uno::Type > SAL_CALL SvxFmDrawPage::getTypes( ) { - css::uno::Sequence< css::uno::Type > aTypes(SvxDrawPage::getTypes()); - aTypes.realloc(aTypes.getLength() + 1); - css::uno::Type* pTypes = aTypes.getArray(); - - pTypes[aTypes.getLength()-1] = cppu::UnoType::get(); - return aTypes; + return comphelper::concatSequences(SvxDrawPage::getTypes(), + css::uno::Sequence { cppu::UnoType::get() }); } SdrObject *SvxFmDrawPage::CreateSdrObject_( const css::uno::Reference< css::drawing::XShape > & xDescr ) diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index da489f728846..c34723ab7b67 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -888,14 +889,10 @@ void SAL_CALL Cell::release() throw () Sequence< Type > SAL_CALL Cell::getTypes( ) { - Sequence< Type > aTypes( SvxUnoTextBase::getTypes() ); - - sal_Int32 nLen = aTypes.getLength(); - aTypes.realloc(nLen + 2); - aTypes[nLen++] = cppu::UnoType::get(); - aTypes[nLen++] = cppu::UnoType::get(); - - return aTypes; + return comphelper::concatSequences( SvxUnoTextBase::getTypes(), + Sequence { + cppu::UnoType::get(), + cppu::UnoType::get() }); } diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx index f6e60d5b022a..bbbf62c9b398 100644 --- a/svx/source/unodraw/unomod.cxx +++ b/svx/source/unodraw/unomod.cxx @@ -301,24 +301,13 @@ uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawingModel::getTypes( ) { if( maTypeSequence.getLength() == 0 ) { - const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() ); - const sal_Int32 nBaseTypes = aBaseTypes.getLength(); - const uno::Type* pBaseTypes = aBaseTypes.getConstArray(); - - const sal_Int32 nOwnTypes = 4; // !DANGER! Keep this updated! - - maTypeSequence.realloc( nBaseTypes + nOwnTypes ); - uno::Type* pTypes = maTypeSequence.getArray(); - - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - - for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) - *pTypes++ = *pBaseTypes++; + maTypeSequence = comphelper::concatSequences( SfxBaseModel::getTypes(), + uno::Sequence { + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get() }); } - return maTypeSequence; } diff --git a/svx/source/unodraw/unopool.cxx b/svx/source/unodraw/unopool.cxx index 9e78b7ea574d..d09758602172 100644 --- a/svx/source/unodraw/unopool.cxx +++ b/svx/source/unodraw/unopool.cxx @@ -358,16 +358,13 @@ void SAL_CALL SvxUnoDrawPool::release() throw ( ) uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawPool::getTypes() { - uno::Sequence< uno::Type > aTypes( 6 ); - uno::Type* pTypes = aTypes.getArray(); - - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - + static const uno::Sequence aTypes { + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get() }; return aTypes; } diff --git a/svx/source/unogallery/unogalitem.cxx b/svx/source/unogallery/unogalitem.cxx index 89a2b316c269..da2f64c9ae87 100644 --- a/svx/source/unogallery/unogalitem.cxx +++ b/svx/source/unogallery/unogalitem.cxx @@ -131,16 +131,13 @@ uno::Sequence< OUString > SAL_CALL GalleryItem::getSupportedServiceNames() uno::Sequence< uno::Type > SAL_CALL GalleryItem::getTypes() { - uno::Sequence< uno::Type > aTypes( 6 ); - uno::Type* pTypes = aTypes.getArray(); - - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - + static const uno::Sequence aTypes { + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get() }; return aTypes; } diff --git a/svx/source/unogallery/unogaltheme.cxx b/svx/source/unogallery/unogaltheme.cxx index dbdfb5a2a79b..7d81cfc3e309 100644 --- a/svx/source/unogallery/unogaltheme.cxx +++ b/svx/source/unogallery/unogaltheme.cxx @@ -83,15 +83,13 @@ uno::Sequence< OUString > SAL_CALL GalleryTheme::getSupportedServiceNames() uno::Sequence< uno::Type > SAL_CALL GalleryTheme::getTypes() { - uno::Sequence< uno::Type > aTypes( 5 ); - uno::Type* pTypes = aTypes.getArray(); - - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - + static const uno::Sequence aTypes { + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + }; return aTypes; } diff --git a/svx/source/unogallery/unogalthemeprovider.cxx b/svx/source/unogallery/unogalthemeprovider.cxx index 668ab6751ade..d044c347336a 100644 --- a/svx/source/unogallery/unogalthemeprovider.cxx +++ b/svx/source/unogallery/unogalthemeprovider.cxx @@ -103,15 +103,13 @@ uno::Sequence< OUString > SAL_CALL GalleryThemeProvider::getSupportedServiceName uno::Sequence< uno::Type > SAL_CALL GalleryThemeProvider::getTypes() { - uno::Sequence< uno::Type > aTypes( 6 ); - uno::Type* pTypes = aTypes.getArray(); - - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); - *pTypes++ = cppu::UnoType::get(); + static const uno::Sequence aTypes { + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get() }; return aTypes; } -- cgit