summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/com/sun/star/uno/Sequence.hxx3
-rw-r--r--include/comphelper/sequence.hxx10
-rw-r--r--include/oox/helper/containerhelper.hxx3
-rw-r--r--include/toolkit/helper/macros.hxx2
-rw-r--r--include/vbahelper/vbahelperinterface.hxx7
5 files changed, 12 insertions, 13 deletions
diff --git a/include/com/sun/star/uno/Sequence.hxx b/include/com/sun/star/uno/Sequence.hxx
index 5356872b1378..73e51a9bc7f5 100644
--- a/include/com/sun/star/uno/Sequence.hxx
+++ b/include/com/sun/star/uno/Sequence.hxx
@@ -295,8 +295,9 @@ template <class E> inline auto asNonConstRange(css::uno::Sequence<E>& s)
// These allow to pass it as range-expression to range-based for loops
E* begin() { return std::pair<E*, E*>::first; }
E* end() { return std::pair<E*, E*>::second; }
+ E& operator[](sal_Int32 i) { assert(i >= 0 && i < end() - begin()); return begin()[i]; }
};
- return SequenceRange(s.getArray(), s.getLength());
+ return SequenceRange(s.getLength() ? s.getArray() : nullptr, s.getLength());
};
/// @endcond
diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx
index ada6ee27b4ef..a42ef2d2f341 100644
--- a/include/comphelper/sequence.hxx
+++ b/include/comphelper/sequence.hxx
@@ -64,7 +64,8 @@ namespace comphelper
sal_Int32 n1 = left.getLength();
css::uno::Sequence<T> ret(n1 + right.getLength());
//TODO: check for overflow
- std::copy_n(left.getConstArray(), n1, ret.getArray());
+ auto pRet = ret.getArray();
+ std::copy_n(left.getConstArray(), n1, pRet);
sal_Int32 n2 = n1;
for (sal_Int32 i = 0; i != right.getLength(); ++i) {
bool found = false;
@@ -75,7 +76,7 @@ namespace comphelper
}
}
if (!found) {
- ret[n2++] = right[i];
+ pRet[n2++] = right[i];
}
}
ret.realloc(n2);
@@ -181,8 +182,9 @@ namespace comphelper
template < typename DstElementType, typename SrcType >
inline css::uno::Sequence< DstElementType > containerToSequence( const SrcType& i_Container )
{
- css::uno::Sequence< DstElementType > result( ::std::size(i_Container) );
- ::std::copy( ::std::begin(i_Container), ::std::end(i_Container), result.getArray() );
+ using ::std::size, ::std::begin, ::std::end;
+ css::uno::Sequence< DstElementType > result( size(i_Container) );
+ ::std::copy( begin(i_Container), end(i_Container), result.getArray() );
return result;
}
diff --git a/include/oox/helper/containerhelper.hxx b/include/oox/helper/containerhelper.hxx
index 256719c5334e..10af6995f52c 100644
--- a/include/oox/helper/containerhelper.hxx
+++ b/include/oox/helper/containerhelper.hxx
@@ -282,8 +282,9 @@ template< typename MatrixType >
if( !rMatrix.empty() )
{
aSeq.realloc( static_cast< sal_Int32 >( rMatrix.height() ) );
+ auto pSeq = aSeq.getArray();
for( size_t nRow = 0, nHeight = rMatrix.height(); nRow < nHeight; ++nRow )
- aSeq[ static_cast< sal_Int32 >( nRow ) ] =
+ pSeq[ static_cast< sal_Int32 >( nRow ) ] =
css::uno::Sequence< ValueType >( &rMatrix.row_front( nRow ), static_cast< sal_Int32 >( rMatrix.width() ) );
}
return aSeq;
diff --git a/include/toolkit/helper/macros.hxx b/include/toolkit/helper/macros.hxx
index cd121bc0998d..a04815ebaf20 100644
--- a/include/toolkit/helper/macros.hxx
+++ b/include/toolkit/helper/macros.hxx
@@ -149,7 +149,7 @@ IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_BODY( ClassName, InterfaceName, MethodNa
{ \
css::uno::Sequence< OUString > aNames = BaseClass::getSupportedServiceNames( ); \
aNames.realloc( aNames.getLength() + 1 ); \
- aNames[ aNames.getLength() - 1 ] = ServiceName; \
+ aNames.getArray()[ aNames.getLength() - 1 ] = ServiceName; \
return aNames; \
} \
diff --git a/include/vbahelper/vbahelperinterface.hxx b/include/vbahelper/vbahelperinterface.hxx
index 0bbf18992ec3..c7fb615b1f5a 100644
--- a/include/vbahelper/vbahelperinterface.hxx
+++ b/include/vbahelper/vbahelperinterface.hxx
@@ -132,12 +132,7 @@ OUString classname::getServiceImplName() \
} \
css::uno::Sequence< OUString > classname::getServiceNames() \
{ \
- static css::uno::Sequence< OUString > saServiceNames; \
- if( saServiceNames.getLength() == 0 ) \
- { \
- saServiceNames.realloc( 1 ); \
- saServiceNames[ 0 ] = servicename; \
- } \
+ static const css::uno::Sequence< OUString > saServiceNames { servicename }; \
return saServiceNames; \
}