diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-07-27 20:15:17 +0300 |
---|---|---|
committer | Arkadiy Illarionov <qarkai@gmail.com> | 2019-07-29 18:45:04 +0200 |
commit | d458adeed0c34fae26fe7f3d6ecc9b75b431922f (patch) | |
tree | b594540ade488d97d14f93081161a3e77134db63 /sd/source/ui/unoidl | |
parent | c26f2fcf82d549a6475e9e55cdffde901190635b (diff) |
Simplify Sequence iterations in sd
Use range-based loops, STL and comphelper functions
Change-Id: If4b6d464fc393049dc8d7e5c3faf1cf66b6a369a
Reviewed-on: https://gerrit.libreoffice.org/76480
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'sd/source/ui/unoidl')
-rw-r--r-- | sd/source/ui/unoidl/SdUnoSlideView.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/unoidl/UnoDocumentSettings.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 21 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodule.cxx | 9 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unoobj.cxx | 45 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 48 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopback.cxx | 6 |
7 files changed, 61 insertions, 81 deletions
diff --git a/sd/source/ui/unoidl/SdUnoSlideView.cxx b/sd/source/ui/unoidl/SdUnoSlideView.cxx index a2758fb90718..8df0ab9f2542 100644 --- a/sd/source/ui/unoidl/SdUnoSlideView.cxx +++ b/sd/source/ui/unoidl/SdUnoSlideView.cxx @@ -58,10 +58,9 @@ sal_Bool SAL_CALL SdUnoSlideView::select (const Any& aSelection) rSelector.DeselectAllPages(); Sequence<Reference<drawing::XDrawPage> > xPages; aSelection >>= xPages; - const sal_uInt32 nCount = xPages.getLength(); - for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex) + for (const auto& rPage : xPages) { - Reference<beans::XPropertySet> xSet (xPages[nIndex], UNO_QUERY); + Reference<beans::XPropertySet> xSet (rPage, UNO_QUERY); if (xSet.is()) { try diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx index 2b426a632380..53ca87c54ab1 100644 --- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx +++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx @@ -310,15 +310,15 @@ uno::Sequence<beans::PropertyValue> { uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() ); int nRet = 0; - for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ ) + for( const auto& rConfigProp : aConfigProps ) { - XPropertyListType t = getTypeOfName( aConfigProps[i].Name ); + XPropertyListType t = getTypeOfName( rConfigProp.Name ); if (t == XPropertyListType::Unknown) - aRet[nRet++] = aConfigProps[i]; + aRet[nRet++] = rConfigProp; else { OUString aURL; - aConfigProps[i].Value >>= aURL; + rConfigProp.Value >>= aURL; LoadList( t, aURL, referer, xStorage ); } } diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index f414d6ec9246..c0f3bd5b1b76 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -368,7 +368,7 @@ uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes( ) { ::SolarMutexGuard aGuard; - if( maTypeSequence.getLength() == 0 ) + if( !maTypeSequence.hasElements() ) { uno::Sequence< uno::Type > aTypes( SfxBaseModel::getTypes() ); aTypes = comphelper::concatSequences(aTypes, @@ -1480,10 +1480,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SdXImpressDocument::getRenderer( throw lang::DisposedException(); bool bExportNotesPages = false; - for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty ) + for( const auto& rOption : rxOptions ) { - if ( rxOptions[ nProperty ].Name == "ExportNotesPages" ) - rxOptions[ nProperty].Value >>= bExportNotesPages; + if ( rOption.Name == "ExportNotesPages" ) + rOption.Value >>= bExportNotesPages; } uno::Sequence< beans::PropertyValue > aRenderer; if (mpDocShell) @@ -1883,13 +1883,13 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r PageKind ePageKind = PageKind::Standard; bool bExportNotesPages = false; - for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty ) + for( const auto& rOption : rxOptions ) { - if ( rxOptions[ nProperty ].Name == "RenderDevice" ) - rxOptions[ nProperty ].Value >>= xRenderDevice; - else if ( rxOptions[ nProperty ].Name == "ExportNotesPages" ) + if ( rOption.Name == "RenderDevice" ) + rOption.Value >>= xRenderDevice; + else if ( rOption.Name == "ExportNotesPages" ) { - rxOptions[ nProperty].Value >>= bExportNotesPages; + rOption.Value >>= bExportNotesPages; if ( bExportNotesPages ) ePageKind = PageKind::Notes; } @@ -2449,9 +2449,8 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs if (DrawViewShell* pViewShell = GetViewShell()) { DrawView* pDrawView = pViewShell->GetDrawView(); - for (sal_Int32 i = 0; i < rArguments.getLength(); ++i) + for (const beans::PropertyValue& rValue : rArguments) { - const beans::PropertyValue& rValue = rArguments[i]; if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>()) pDrawView->SetPageShadowVisible(rValue.Value.get<bool>()); else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>()) diff --git a/sd/source/ui/unoidl/unomodule.cxx b/sd/source/ui/unoidl/unomodule.cxx index 425f3d074d40..315d77d72309 100644 --- a/sd/source/ui/unoidl/unomodule.cxx +++ b/sd/source/ui/unoidl/unomodule.cxx @@ -83,12 +83,9 @@ uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL SdUnoModule::queryD sal_Int32 nCount = seqDescripts.getLength(); uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount ); - for( sal_Int32 i=0; i<nCount; ++i ) - { - lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL , - seqDescripts[i].FrameName , - seqDescripts[i].SearchFlags ); - } + std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(), + [this](const frame::DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> { + return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return lDispatcher; } diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index 4ee7abb1e749..2fd1f0fa9144 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -1129,7 +1129,6 @@ void SAL_CALL SdUnoEventsAccess::replaceByName( const OUString& aName, const uno throw lang::IllegalArgumentException(); FoundFlags nFound = FoundFlags::NONE; - const beans::PropertyValue* pProperties = aProperties.getConstArray(); OUString aStrEventType; presentation::ClickAction eClickAction = presentation::ClickAction_NONE; @@ -1142,85 +1141,83 @@ void SAL_CALL SdUnoEventsAccess::replaceByName( const OUString& aName, const uno OUString aStrLibrary; OUString aStrBookmark; - const sal_Int32 nCount = aProperties.getLength(); - sal_Int32 nIndex; - for( nIndex = 0; nIndex < nCount; nIndex++, pProperties++ ) + for( const beans::PropertyValue& rProperty : aProperties ) { - if( !( nFound & FoundFlags::EventType ) && pProperties->Name == gaStrEventType ) + if( !( nFound & FoundFlags::EventType ) && rProperty.Name == gaStrEventType ) { - if( pProperties->Value >>= aStrEventType ) + if( rProperty.Value >>= aStrEventType ) { nFound |= FoundFlags::EventType; continue; } } - else if( !( nFound & FoundFlags::ClickAction ) && pProperties->Name == gaStrClickAction ) + else if( !( nFound & FoundFlags::ClickAction ) && rProperty.Name == gaStrClickAction ) { - if( pProperties->Value >>= eClickAction ) + if( rProperty.Value >>= eClickAction ) { nFound |= FoundFlags::ClickAction; continue; } } - else if( !( nFound & FoundFlags::Macro ) && ( pProperties->Name == gaStrMacroName || pProperties->Name == gaStrScript ) ) + else if( !( nFound & FoundFlags::Macro ) && ( rProperty.Name == gaStrMacroName || rProperty.Name == gaStrScript ) ) { - if( pProperties->Value >>= aStrMacro ) + if( rProperty.Value >>= aStrMacro ) { nFound |= FoundFlags::Macro; continue; } } - else if( !( nFound & FoundFlags::Library ) && pProperties->Name == gaStrLibrary ) + else if( !( nFound & FoundFlags::Library ) && rProperty.Name == gaStrLibrary ) { - if( pProperties->Value >>= aStrLibrary ) + if( rProperty.Value >>= aStrLibrary ) { nFound |= FoundFlags::Library; continue; } } - else if( !( nFound & FoundFlags::Effect ) && pProperties->Name == gaStrEffect ) + else if( !( nFound & FoundFlags::Effect ) && rProperty.Name == gaStrEffect ) { - if( pProperties->Value >>= eEffect ) + if( rProperty.Value >>= eEffect ) { nFound |= FoundFlags::Effect; continue; } } - else if( !( nFound & FoundFlags::Bookmark ) && pProperties->Name == gaStrBookmark ) + else if( !( nFound & FoundFlags::Bookmark ) && rProperty.Name == gaStrBookmark ) { - if( pProperties->Value >>= aStrBookmark ) + if( rProperty.Value >>= aStrBookmark ) { nFound |= FoundFlags::Bookmark; continue; } } - else if( !( nFound & FoundFlags::Speed ) && pProperties->Name == gaStrSpeed ) + else if( !( nFound & FoundFlags::Speed ) && rProperty.Name == gaStrSpeed ) { - if( pProperties->Value >>= eSpeed ) + if( rProperty.Value >>= eSpeed ) { nFound |= FoundFlags::Speed; continue; } } - else if( !( nFound & FoundFlags::SoundUrl ) && pProperties->Name == gaStrSoundURL ) + else if( !( nFound & FoundFlags::SoundUrl ) && rProperty.Name == gaStrSoundURL ) { - if( pProperties->Value >>= aStrSoundURL ) + if( rProperty.Value >>= aStrSoundURL ) { nFound |= FoundFlags::SoundUrl; continue; } } - else if( !( nFound & FoundFlags::PlayFull ) && pProperties->Name == gaStrPlayFull ) + else if( !( nFound & FoundFlags::PlayFull ) && rProperty.Name == gaStrPlayFull ) { - if( pProperties->Value >>= bPlayFull ) + if( rProperty.Value >>= bPlayFull ) { nFound |= FoundFlags::PlayFull; continue; } } - else if( !( nFound & FoundFlags::Verb ) && pProperties->Name == gaStrVerb ) + else if( !( nFound & FoundFlags::Verb ) && rProperty.Name == gaStrVerb ) { - if( pProperties->Value >>= nVerb ) + if( rProperty.Value >>= nVerb ) { nFound |= FoundFlags::Verb; continue; diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index a5351af710dd..eaaef7cc7497 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -1328,24 +1328,22 @@ void SAL_CALL SdGenericDrawPage::setPropertyValues( const Sequence< OUString >& Sequence< Any > SAL_CALL SdGenericDrawPage::getPropertyValues( const Sequence< OUString >& aPropertyNames ) { - const OUString* pNames = aPropertyNames.getConstArray(); - sal_uInt32 nCount = aPropertyNames.getLength(); + sal_Int32 nCount = aPropertyNames.getLength(); Sequence< Any > aValues( nCount ); - Any* pValues = aValues.getArray(); - while( nCount-- ) - { - Any aValue; - try - { - aValue = getPropertyValue( *pNames++ ); - } - catch( beans::UnknownPropertyException& ) - { - // ignore for multi property set - // todo: optimize this! - } - *pValues++ = aValue; - } + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.begin(), + [this](const OUString& rName) -> Any { + Any aValue; + try + { + aValue = getPropertyValue(rName); + } + catch( beans::UnknownPropertyException& ) + { + // ignore for multi property set + // todo: optimize this! + } + return aValue; + }); return aValues; } @@ -2462,17 +2460,13 @@ void SdDrawPage::setBackground( const Any& rValue ) Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo() ); Sequence< beans::Property > aProperties( xDestSetInfo->getProperties() ); - sal_Int32 nCount = aProperties.getLength(); - beans::Property* pProp = aProperties.getArray(); - while( nCount-- ) + for( const beans::Property& rProp : aProperties ) { - const OUString aPropName( pProp->Name ); + const OUString aPropName( rProp.Name ); if( xSetInfo->hasPropertyByName( aPropName ) ) xDestSet->setPropertyValue( aPropName, xSet->getPropertyValue( aPropName ) ); - - pProp++; } pBackground->fillItemSet( static_cast<SdDrawDocument*>(&GetPage()->getSdrModelFromSdrPage()), aSet ); @@ -2834,16 +2828,12 @@ void SdMasterPage::setBackground( const Any& rValue ) Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo(), UNO_SET_THROW ); uno::Sequence< beans::Property> aProperties( xDestSetInfo->getProperties() ); - sal_Int32 nCount = aProperties.getLength(); - beans::Property* pProp = aProperties.getArray(); - while( nCount-- ) + for( const beans::Property& rProp : aProperties ) { - const OUString aPropName( pProp->Name ); + const OUString aPropName( rProp.Name ); if( xInputSetInfo->hasPropertyByName( aPropName ) ) xDestSet->setPropertyValue( aPropName, xInputSet->getPropertyValue( aPropName ) ); - - pProp++; } pBackground->fillItemSet( static_cast<SdDrawDocument*>(&SvxFmDrawPage::mpPage->getSdrModelFromSdrPage()), aSet ); diff --git a/sd/source/ui/unoidl/unopback.cxx b/sd/source/ui/unoidl/unopback.cxx index 459bdb42de71..1f379ed104e8 100644 --- a/sd/source/ui/unoidl/unopback.cxx +++ b/sd/source/ui/unoidl/unopback.cxx @@ -355,13 +355,11 @@ uno::Sequence< beans::PropertyState > SAL_CALL SdUnoPageBackground::getPropertyS SolarMutexGuard aGuard; sal_Int32 nCount = aPropertyName.getLength(); - const OUString* pNames = aPropertyName.getConstArray(); uno::Sequence< beans::PropertyState > aPropertyStateSequence( nCount ); - beans::PropertyState* pState = aPropertyStateSequence.getArray(); - while( nCount-- ) - *pState++ = getPropertyState( *pNames++ ); + std::transform(aPropertyName.begin(), aPropertyName.end(), aPropertyStateSequence.begin(), + [this](const OUString& rName) -> beans::PropertyState { return getPropertyState(rName); }); return aPropertyStateSequence; } |