Prepare for removal of non-const operator[] from Sequence in stoc

Change-Id: I2aabd9a1c764ae69a933bdb4df635ebb0c91f0cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124393
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2021-10-29 10:08:39 +03:00
parent 5b54ba7084
commit 1a5ddf061e
7 changed files with 27 additions and 25 deletions

View File

@@ -743,8 +743,9 @@ Sequence< Reference< XIdlClass > > InterfaceIdlClassImpl::getSuperclasses()
if (!_xSuperClasses.hasElements()) { if (!_xSuperClasses.hasElements()) {
typelib_InterfaceTypeDescription * pType = getTypeDescr(); typelib_InterfaceTypeDescription * pType = getTypeDescr();
_xSuperClasses.realloc(pType->nBaseTypes); _xSuperClasses.realloc(pType->nBaseTypes);
auto pSuperClasses = _xSuperClasses.getArray();
for (sal_Int32 i = 0; i < pType->nBaseTypes; ++i) { for (sal_Int32 i = 0; i < pType->nBaseTypes; ++i) {
_xSuperClasses[i] = getReflection()->forType( pSuperClasses[i] = getReflection()->forType(
&pType->ppBaseTypes[i]->aBase); &pType->ppBaseTypes[i]->aBase);
OSL_ASSERT(_xSuperClasses[i].is()); OSL_ASSERT(_xSuperClasses[i].is());
} }

View File

@@ -674,18 +674,18 @@ void delete_all_singleton_entries(
catch (registry::InvalidValueException &) catch (registry::InvalidValueException &)
{ {
} }
OUString const * p = registered_implnames.getConstArray(); auto aNonConstRange = asNonConstRange(registered_implnames);
sal_Int32 nOrigRegLength = registered_implnames.getLength(); sal_Int32 nOrigRegLength = registered_implnames.getLength();
sal_Int32 nNewLength = nOrigRegLength; sal_Int32 nNewLength = nOrigRegLength;
for ( sal_Int32 n = nOrigRegLength; n--; ) for ( sal_Int32 n = nOrigRegLength; n--; )
{ {
OUString const & registered_implname = p[ n ]; OUString const & registered_implname = registered_implnames[ n ];
for (auto const& impl_name : impl_names) for (auto const& impl_name : impl_names)
{ {
if (impl_name == registered_implname) if (impl_name == registered_implname)
{ {
registered_implnames[ n ] = p[ nNewLength -1 ]; aNonConstRange[ n ] = registered_implnames[ nNewLength -1 ];
--nNewLength; --nNewLength;
} }
} }
@@ -890,7 +890,7 @@ void insert_singletons(
{ {
// append and write back // append and write back
implnames.realloc( implnames.getLength() +1 ); implnames.realloc( implnames.getLength() +1 );
implnames[ implnames.getLength() -1 ] = implname; implnames.getArray()[ implnames.getLength() -1 ] = implname;
xRegisteredImplNames->setAsciiListValue( implnames ); xRegisteredImplNames->setAsciiListValue( implnames );
} }
} }

View File

@@ -136,7 +136,7 @@ const css::uno::Reference<XImplementationLoader> & JavaComponentLoader::getJavaL
// underlying JavaVM pointer: // underlying JavaVM pointer:
Sequence<sal_Int8> processID(17); Sequence<sal_Int8> processID(17);
rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8 *>(processID.getArray())); rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8 *>(processID.getArray()));
processID[16] = 1; processID.getArray()[16] = 1;
// We get a non-refcounted pointer to a jvmaccess::UnoVirtualMachine // We get a non-refcounted pointer to a jvmaccess::UnoVirtualMachine
// from the XJavaVM service (the pointer is guaranteed to be valid // from the XJavaVM service (the pointer is guaranteed to be valid

View File

@@ -81,10 +81,8 @@ bool InteractionRequest::RetryContinuation::isSelected() const
InteractionRequest::InteractionRequest(css::uno::Any const & rRequest): InteractionRequest::InteractionRequest(css::uno::Any const & rRequest):
m_aRequest(rRequest) m_aRequest(rRequest)
{ {
m_aContinuations.realloc(2);
m_xRetryContinuation = new RetryContinuation; m_xRetryContinuation = new RetryContinuation;
m_aContinuations[0] = new AbortContinuation; m_aContinuations = { new AbortContinuation, m_xRetryContinuation };
m_aContinuations[1] = m_xRetryContinuation.get();
} }
css::uno::Any SAL_CALL InteractionRequest::getRequest() css::uno::Any SAL_CALL InteractionRequest::getRequest()

View File

@@ -444,14 +444,14 @@ void FilePolicy::refresh()
Sequence< Any > perms( userPermissions[ userId ] ); Sequence< Any > perms( userPermissions[ userId ] );
sal_Int32 len = perms.getLength(); sal_Int32 len = perms.getLength();
perms.realloc( len +1 ); perms.realloc( len +1 );
perms[ len ] = perm; perms.getArray()[ len ] = perm;
userPermissions[ userId ] = perms; userPermissions[ userId ] = perms;
} }
else else
{ {
sal_Int32 len = defaultPermissions.getLength(); sal_Int32 len = defaultPermissions.getLength();
defaultPermissions.realloc( len +1 ); defaultPermissions.realloc( len +1 );
defaultPermissions[ len ] = perm; defaultPermissions.getArray()[ len ] = perm;
} }
token = reader.assureToken(); // next permissions token token = reader.assureToken(); // next permissions token

View File

@@ -641,9 +641,8 @@ Reference<XPropertySetInfo > OServiceManager::getPropertySetInfo()
check_undisposed(); check_undisposed();
if (! m_xPropertyInfo.is()) if (! m_xPropertyInfo.is())
{ {
Sequence< beans::Property > seq( 1 ); Sequence< beans::Property > seq{ beans::Property(
seq[ 0 ] = beans::Property( "DefaultContext", -1, cppu::UnoType<decltype(m_xContext)>::get(), 0 ) };
"DefaultContext", -1, cppu::UnoType<decltype(m_xContext)>::get(), 0 );
Reference< beans::XPropertySetInfo > xInfo( new PropertySetInfo_Impl( seq ) ); Reference< beans::XPropertySetInfo > xInfo( new PropertySetInfo_Impl( seq ) );
MutexGuard aGuard( m_mutex ); MutexGuard aGuard( m_mutex );
@@ -1422,12 +1421,11 @@ Reference<XPropertySetInfo > ORegistryServiceManager::getPropertySetInfo()
check_undisposed(); check_undisposed();
if (! m_xPropertyInfo.is()) if (! m_xPropertyInfo.is())
{ {
Sequence< beans::Property > seq( 2 ); Sequence< beans::Property > seq{
seq[ 0 ] = beans::Property( beans::Property("DefaultContext", -1, cppu::UnoType<decltype(m_xContext)>::get(), 0),
"DefaultContext", -1, cppu::UnoType<decltype(m_xContext)>::get(), 0 ); beans::Property("Registry", -1, cppu::UnoType<decltype(m_xRegistry)>::get(),
seq[ 1 ] = beans::Property( beans::PropertyAttribute::READONLY)
"Registry", -1, cppu::UnoType<decltype(m_xRegistry)>::get(), };
beans::PropertyAttribute::READONLY );
Reference< beans::XPropertySetInfo > xInfo( new PropertySetInfo_Impl( seq ) ); Reference< beans::XPropertySetInfo > xInfo( new PropertySetInfo_Impl( seq ) );
MutexGuard aGuard( m_mutex ); MutexGuard aGuard( m_mutex );

View File

@@ -305,8 +305,9 @@ css::uno::Sequence< sal_Int32 > Key::getLongListValue()
static_cast< OWeakObject * >(this)); static_cast< OWeakObject * >(this));
} }
css::uno::Sequence< sal_Int32 > value(static_cast< sal_Int32 >(n)); css::uno::Sequence< sal_Int32 > value(static_cast< sal_Int32 >(n));
auto aValueRange = asNonConstRange(value);
for (sal_uInt32 i = 0; i < n; ++i) { for (sal_uInt32 i = 0; i < n; ++i) {
value[static_cast< sal_Int32 >(i)] = list.getElement(i); aValueRange[static_cast< sal_Int32 >(i)] = list.getElement(i);
} }
return value; return value;
} }
@@ -446,11 +447,12 @@ css::uno::Sequence< OUString > Key::getAsciiListValue()
static_cast< OWeakObject * >(this)); static_cast< OWeakObject * >(this));
} }
css::uno::Sequence< OUString > value(static_cast< sal_Int32 >(n)); css::uno::Sequence< OUString > value(static_cast< sal_Int32 >(n));
auto aValueRange = asNonConstRange(value);
for (sal_uInt32 i = 0; i < n; ++i) { for (sal_uInt32 i = 0; i < n; ++i) {
char * el = list.getElement(i); char * el = list.getElement(i);
sal_Int32 size = rtl_str_getLength(el); sal_Int32 size = rtl_str_getLength(el);
if (!rtl_convertStringToUString( if (!rtl_convertStringToUString(
&value[static_cast< sal_Int32 >(i)].pData, el, size, &aValueRange[static_cast< sal_Int32 >(i)].pData, el, size,
RTL_TEXTENCODING_UTF8, RTL_TEXTENCODING_UTF8,
(RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
@@ -600,8 +602,9 @@ css::uno::Sequence< OUString > Key::getStringListValue()
static_cast< OWeakObject * >(this)); static_cast< OWeakObject * >(this));
} }
css::uno::Sequence< OUString > value(static_cast< sal_Int32 >(n)); css::uno::Sequence< OUString > value(static_cast< sal_Int32 >(n));
auto aValueRange = asNonConstRange(value);
for (sal_uInt32 i = 0; i < n; ++i) { for (sal_uInt32 i = 0; i < n; ++i) {
value[static_cast< sal_Int32 >(i)] = list.getElement(i); aValueRange[static_cast< sal_Int32 >(i)] = list.getElement(i);
} }
return value; return value;
} }
@@ -758,8 +761,9 @@ Key::openKeys()
} }
css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
keys(static_cast< sal_Int32 >(n)); keys(static_cast< sal_Int32 >(n));
auto aKeysRange = asNonConstRange(keys);
for (sal_uInt32 i = 0; i < n; ++i) { for (sal_uInt32 i = 0; i < n; ++i) {
keys[static_cast< sal_Int32 >(i)] = new Key( aKeysRange[static_cast< sal_Int32 >(i)] = new Key(
registry_, list.getElement(i)); registry_, list.getElement(i));
} }
return keys; return keys;
@@ -784,8 +788,9 @@ css::uno::Sequence< OUString > Key::getKeyNames()
static_cast< OWeakObject * >(this)); static_cast< OWeakObject * >(this));
} }
css::uno::Sequence< OUString > names(static_cast< sal_Int32 >(n)); css::uno::Sequence< OUString > names(static_cast< sal_Int32 >(n));
auto aNamesRange = asNonConstRange(names);
for (sal_uInt32 i = 0; i < n; ++i) { for (sal_uInt32 i = 0; i < n; ++i) {
names[static_cast< sal_Int32 >(i)] = list.getElement(i); aNamesRange[static_cast< sal_Int32 >(i)] = list.getElement(i);
} }
return names; return names;
} }