Skip to content

Commit ccdb98c

Browse files
committed
Drop some uses of css::uno::Sequence::getConstArray
where it was obsoleted by commits 2484de6 (Remove non-const Sequence::begin()/end() in internal code, 2021-10-15) and fb3c04b (Drop non-const Sequence::operator[] in internal code 2021-11-05). Change-Id: I64683093afc48ddf2307dc1dee2302cf0b3cbecc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167110 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins
1 parent d4f07d4 commit ccdb98c

File tree

8 files changed

+53
-72
lines changed

8 files changed

+53
-72
lines changed

canvas/inc/verifyinput.hxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,8 @@ namespace canvas
360360
const css::uno::Reference< css::uno::XInterface >& xIf,
361361
::sal_Int16 nArgPos )
362362
{
363-
const SequenceContent* pCurr = rSequence.getConstArray();
364-
const SequenceContent* pEnd = pCurr + rSequence.getLength();
365-
while( pCurr != pEnd )
366-
verifyInput( *pCurr++, pStr, xIf, nArgPos );
363+
for (auto& element : rSequence)
364+
verifyInput(element, pStr, xIf, nArgPos);
367365
}
368366

369367
/// Catch-all, to handle cases that DON'T need input checking (i.e. the Integer geometry ones)

canvas/source/directx/dx_config.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace dxcanvas
4848
uno::Sequence< uno::Any > aProps( GetProperties( { "DeviceDenylist" } ));
4949
uno::Sequence< sal_Int32 > aValues;
5050

51-
if( aProps.getLength() > 0 &&
51+
if (aProps.hasElements() &&
5252
(aProps[0] >>= aValues) )
5353
{
5454
const sal_Int32* pValues = aValues.getConstArray();

canvas/source/directx/dx_surfacebitmap.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ namespace dxcanvas
542542
if(FAILED(mpSurface->LockRect(&aLockedRect,nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
543543
throw uno::RuntimeException("failed to lock directx surface to surface memory");
544544

545-
sal_uInt8 const *pSrc = reinterpret_cast<sal_uInt8 const *>(data.getConstArray());
545+
auto* pSrc = data.getConstArray();
546546
sal_uInt8 *pDst = (static_cast<BYTE *>(aLockedRect.pBits)+(rect.Y1*aLockedRect.Pitch))+rect.X1;
547547
sal_uInt32 nSegmentSizeInBytes = nWidth<<4;
548548
for(sal_uInt32 y=0; y<nHeight; ++y)

editeng/source/accessibility/AccessibleEditableTextPara.cxx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,14 @@ namespace accessibility
796796

797797
struct IndexCompare
798798
{
799-
const PropertyValue* pValues;
800-
explicit IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {}
799+
const uno::Sequence<beans::PropertyValue>& m_rValues;
800+
explicit IndexCompare(const uno::Sequence<beans::PropertyValue>& rValues)
801+
: m_rValues(rValues)
802+
{
803+
}
801804
bool operator() ( sal_Int32 a, sal_Int32 b ) const
802805
{
803-
return pValues[a].Name < pValues[b].Name;
806+
return m_rValues[a].Name < m_rValues[b].Name;
804807
}
805808
};
806809

@@ -1228,19 +1231,13 @@ namespace accessibility
12281231
//sort property values
12291232
// build sorted index array
12301233
sal_Int32 nLength = aRes.getLength();
1231-
const beans::PropertyValue* pPairs = aRes.getConstArray();
1232-
std::unique_ptr<sal_Int32[]> pIndices(new sal_Int32[nLength]);
1233-
sal_Int32 i = 0;
1234-
for( i = 0; i < nLength; i++ )
1235-
pIndices[i] = i;
1236-
std::sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) );
1234+
std::vector<sal_Int32> indices(nLength);
1235+
std::iota(indices.begin(), indices.end(), 0);
1236+
std::sort(indices.begin(), indices.end(), IndexCompare(aRes));
12371237
// create sorted sequences according to index array
12381238
uno::Sequence<beans::PropertyValue> aNewValues( nLength );
1239-
beans::PropertyValue* pNewValues = aNewValues.getArray();
1240-
for( i = 0; i < nLength; i++ )
1241-
{
1242-
pNewValues[i] = pPairs[pIndices[i]];
1243-
}
1239+
std::transform(indices.begin(), indices.end(), aNewValues.getArray(),
1240+
[&aRes](sal_Int32 index) { return aRes[index]; });
12441241

12451242
return aNewValues;
12461243
}

editeng/source/accessibility/AccessibleStaticTextBase.cxx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -903,13 +903,9 @@ namespace accessibility
903903

904904
for ( const auto& rDefAttr : aDefAttrVec )
905905
{
906-
const beans::PropertyValue* pItr = aSeq.getConstArray();
907-
const beans::PropertyValue* pEnd = pItr + aSeq.getLength();
908-
const beans::PropertyValue* pFind = std::find_if( pItr, pEnd, PropertyValueEqualFunctor(rDefAttr) );
909-
if ( pFind != pEnd )
910-
{
911-
aIntersectionVec.push_back( *pFind );
912-
}
906+
auto it = std::find_if(aSeq.begin(), aSeq.end(), PropertyValueEqualFunctor(rDefAttr));
907+
if (it != aSeq.end())
908+
aIntersectionVec.push_back(*it);
913909
}
914910

915911
aDefAttrVec.swap( aIntersectionVec );
@@ -937,16 +933,13 @@ namespace accessibility
937933
uno::Sequence< beans::PropertyValue > aIntersectionSeq = getDefaultAttributes( RequestedAttributes );
938934
PropertyValueVector aDiffVec;
939935

940-
const beans::PropertyValue* pDefAttr = aDefAttrSeq.getConstArray();
941-
const sal_Int32 nLength = aDefAttrSeq.getLength();
942-
for ( sal_Int32 i = 0; i < nLength; ++i )
936+
for (auto& defAttr : aDefAttrSeq)
943937
{
944-
const beans::PropertyValue* pItr = aIntersectionSeq.getConstArray();
945-
const beans::PropertyValue* pEnd = pItr + aIntersectionSeq.getLength();
946-
bool bNone = std::none_of( pItr, pEnd, PropertyValueEqualFunctor( pDefAttr[i] ) );
947-
if ( bNone && pDefAttr[i].Handle != 0)
938+
bool bNone = std::none_of(aIntersectionSeq.begin(), aIntersectionSeq.end(),
939+
PropertyValueEqualFunctor(defAttr));
940+
if (bNone && defAttr.Handle != 0)
948941
{
949-
aDiffVec.push_back( pDefAttr[i] );
942+
aDiffVec.push_back(defAttr);
950943
}
951944
}
952945

scripting/source/dlgprov/dlgevtatt.cxx

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -281,37 +281,33 @@ namespace dlgprov
281281
// We know that we have to do with instances of XControl.
282282
// Otherwise this is not the right implementation for
283283
// XScriptEventsAttacher and we have to give up.
284-
Reference< XControl > xControl( rObject, UNO_QUERY );
285-
Reference< XControlContainer > xControlContainer( xControl, UNO_QUERY );
286-
Reference< XDialog > xDialog( xControl, UNO_QUERY );
287-
if ( !xControl.is() )
288-
throw IllegalArgumentException();
289-
290-
// get XEventsSupplier from control model
291-
Reference< XControlModel > xControlModel = xControl->getModel();
292-
Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY );
293-
attachEventsToControl( xControl, xEventsSupplier, Helper );
294-
if ( mbUseFakeVBAEvents )
295-
{
296-
xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) );
297-
Any newHelper(xControl );
298-
attachEventsToControl( xControl, xEventsSupplier, newHelper );
299-
}
300-
if ( xControlContainer.is() && !xDialog.is() )
301-
{
302-
Sequence< Reference< XControl > > aControls = xControlContainer->getControls();
303-
sal_Int32 nControlCount = aControls.getLength();
304-
305-
Sequence< Reference< XInterface > > aObjects( nControlCount );
306-
Reference< XInterface >* pObjects2 = aObjects.getArray();
307-
const Reference< XControl >* pControls = aControls.getConstArray();
284+
nestedAttachEvents(rObject.query<XControl>(), Helper, sDialogCodeName);
285+
}
286+
}
308287

309-
for ( sal_Int32 i2 = 0; i2 < nControlCount; ++i2 )
310-
{
311-
pObjects2[i2].set( pControls[i2], UNO_QUERY );
312-
}
313-
nestedAttachEvents( aObjects, Helper, sDialogCodeName );
314-
}
288+
void DialogEventsAttacherImpl::nestedAttachEvents(
289+
const css::uno::Reference<css::awt::XControl>& xControl, const css::uno::Any& Helper,
290+
OUString& sDialogCodeName)
291+
{
292+
if (!xControl.is())
293+
throw IllegalArgumentException();
294+
Reference<XControlContainer> xControlContainer(xControl, UNO_QUERY);
295+
Reference<XDialog> xDialog(xControl, UNO_QUERY);
296+
297+
// get XEventsSupplier from control model
298+
Reference<XControlModel> xControlModel = xControl->getModel();
299+
Reference<XScriptEventsSupplier> xEventsSupplier(xControlModel, UNO_QUERY);
300+
attachEventsToControl(xControl, xEventsSupplier, Helper);
301+
if (mbUseFakeVBAEvents)
302+
{
303+
xEventsSupplier.set(getFakeVbaEventsSupplier(xControl, sDialogCodeName));
304+
Any newHelper(xControl);
305+
attachEventsToControl(xControl, xEventsSupplier, newHelper);
306+
}
307+
if (xControlContainer.is() && !xDialog.is())
308+
{
309+
for (auto& xChildControl : xControlContainer->getControls())
310+
nestedAttachEvents(xChildControl, Helper, sDialogCodeName);
315311
}
316312
}
317313

@@ -527,8 +523,7 @@ namespace dlgprov
527523
{
528524
OUString aMethodName = aScriptEvent.ScriptCode.copy( strlen("vnd.sun.star.UNO:") );
529525

530-
const Any* pArguments = aScriptEvent.Arguments.getConstArray();
531-
Any aEventObject = pArguments[0];
526+
Any aEventObject = aScriptEvent.Arguments[0];
532527

533528
bool bHandled = false;
534529
if( m_xHandler.is() )

scripting/source/dlgprov/dlgevtatt.hxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ namespace dlgprov
5454
css::uno::Reference< css::script::XScriptListener > const & getScriptListenerForKey( const OUString& sScriptName );
5555
css::uno::Reference< css::script::XScriptEventsSupplier > getFakeVbaEventsSupplier( const css::uno::Reference< css::awt::XControl>& xControl, OUString const & sCodeName );
5656
void nestedAttachEvents( const css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >& Objects, const css::uno::Any& Helper, OUString& sDialogCodeName );
57+
void nestedAttachEvents( const css::uno::Reference< css::awt::XControl >& xControl, const css::uno::Any& Helper, OUString& sDialogCodeName );
5758
void attachEventsToControl( const css::uno::Reference< css::awt::XControl>& xControl, const css::uno::Reference< css::script::XScriptEventsSupplier >& events, const css::uno::Any& Helper );
5859
public:
5960
DialogEventsAttacherImpl( const css::uno::Reference< css::uno::XComponentContext >& rxContext,

scripting/source/dlgprov/dlgprov.cxx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,12 @@ namespace dlgprov
440440
return;
441441

442442
Sequence< Reference< XControl > > aControls = xControlContainer->getControls();
443-
const Reference< XControl >* pControls = aControls.getConstArray();
444443
sal_Int32 nControlCount = aControls.getLength();
445444

446445
Sequence< Reference< XInterface > > aObjects( nControlCount + 1 );
447446
Reference< XInterface >* pObjects = aObjects.getArray();
448-
for ( sal_Int32 i = 0; i < nControlCount; ++i )
449-
{
450-
pObjects[i].set( pControls[i], UNO_QUERY );
451-
}
447+
std::transform(aControls.begin(), aControls.end(), pObjects,
448+
[](auto& xControl) { return xControl.template query<XInterface>(); });
452449

453450
// also add the dialog control itself to the sequence
454451
pObjects[nControlCount].set( rxControl, UNO_QUERY );

0 commit comments

Comments
 (0)