diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-07-21 19:39:26 +0300 |
---|---|---|
committer | Arkadiy Illarionov <qarkai@gmail.com> | 2019-07-29 18:44:33 +0200 |
commit | 25b200ff79c71c831bc7e6fe8b1ec0b5315e96d6 (patch) | |
tree | b8e7cc15bfe82b677fb1bfc791b3f2f5a50fdc79 /sfx2 | |
parent | c762e3859973355b31f6676a8e697c5fd78c9970 (diff) |
Simplify Sequence iterations in sfx2
Use range-based loops, STL and comphelper functions
Change-Id: I6a0d18493db7a25e8b41925f2d45cb221b5065a7
Reviewed-on: https://gerrit.libreoffice.org/76074
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'sfx2')
49 files changed, 608 insertions, 847 deletions
diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index 5ad63a9869f4..323c87432d55 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/util/XFlushable.hpp> +#include <comphelper/sequence.hxx> #include <osl/file.hxx> #include <stdlib.h> @@ -335,10 +336,7 @@ void SfxApplication::GetOptions( SfxItemSet& rSet ) if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::EOption::SecureUrls)) { css::uno::Sequence< OUString > seqURLs = aSecurityOptions.GetSecureURLs(); - std::vector<OUString> aList; - sal_uInt32 nCount = seqURLs.getLength(); - for( sal_uInt32 nURL=0; nURL<nCount; ++nURL ) - aList.push_back(seqURLs[nURL]); + auto aList = comphelper::sequenceToContainer<std::vector<OUString>>(seqURLs); if( !rSet.Put( SfxStringListItem( rPool.GetWhich(SID_SECURE_URL), &aList ) ) ) bRet = false; diff --git a/sfx2/source/appl/appdispatchprovider.cxx b/sfx2/source/appl/appdispatchprovider.cxx index edab1b761f32..5c197bf92eaf 100644 --- a/sfx2/source/appl/appdispatchprovider.cxx +++ b/sfx2/source/appl/appdispatchprovider.cxx @@ -164,10 +164,9 @@ Sequence< Reference < XDispatch > > SAL_CALL SfxAppDispatchProvider::queryDispat { sal_Int32 nCount = seqDescriptor.getLength(); uno::Sequence< uno::Reference < frame::XDispatch > > lDispatcher(nCount); - for( sal_Int32 i=0; i<nCount; ++i ) - lDispatcher[i] = queryDispatch( seqDescriptor[i].FeatureURL, - seqDescriptor[i].FrameName, - seqDescriptor[i].SearchFlags ); + std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.begin(), + [this](const DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> { + return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return lDispatcher; } diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index e496b68c114f..1c778623b51f 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -44,6 +44,7 @@ #include <rtl/ustring.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/synchronousdispatch.hxx> @@ -250,7 +251,7 @@ ErrCode CheckPasswd_Impl pSet->ClearItem( SID_PASSWORD ); pSet->ClearItem( SID_ENCRYPTIONDATA ); - if ( aEncryptionData.getLength() > 0 ) + if ( aEncryptionData.hasElements() ) { pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) ); @@ -866,10 +867,10 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) // get registered protocol handlers from configuration Reference < XNameAccess > xAccess(officecfg::Office::ProtocolHandler::HandlerSet::get()); Sequence < OUString > aNames = xAccess->getElementNames(); - for ( sal_Int32 nName = 0; nName < aNames.getLength(); nName ++) + for ( const auto& rName : aNames ) { Reference < XPropertySet > xSet; - Any aRet = xAccess->getByName( aNames[nName] ); + Any aRet = xAccess->getByName( rName ); aRet >>= xSet; if ( xSet.is() ) { @@ -1033,15 +1034,12 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) // Any Referer (that was relevant in the above call to // SvtSecurityOptions::isSecureMacroUri) is no longer relevant, assuming // this "open" request is initiated directly by the user: - for (sal_Int32 i = 0; i != aArgs.getLength(); ++i) { - if (aArgs[i].Name == "Referer") { - ++i; - for (; i != aArgs.getLength(); ++i) { - aArgs[i - 1] = aArgs[i]; - } - aArgs.realloc(aArgs.getLength()-1); - break; - } + auto pArg = std::find_if(aArgs.begin(), aArgs.end(), + [](const PropertyValue& rArg) { return rArg.Name == "Referer"; }); + if (pArg != aArgs.end()) + { + auto nIndex = static_cast<sal_Int32>(std::distance(aArgs.begin(), pArg)); + comphelper::removeElementAt(aArgs, nIndex); } // TODO/LATER: either remove LinkItem or create an asynchronous process for it diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index fe24e15b8cc4..a6f66d604c1c 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -49,6 +49,7 @@ #include <comphelper/namedvaluecollection.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/sequence.hxx> #include <svtools/addresstemplate.hxx> #include <svtools/miscopt.hxx> @@ -875,11 +876,10 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) } const Sequence<OUString> aModeNodeNames( aModesNode.getNodeNames() ); - const sal_Int32 nCount( aModeNodeNames.getLength() ); - for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex ) + for ( const auto& rModeNodeName : aModeNodeNames ) { - const utl::OConfigurationNode aModeNode( aModesNode.openNode( aModeNodeNames[nReadIndex] ) ); + const utl::OConfigurationNode aModeNode( aModesNode.openNode( rModeNodeName ) ); if ( !aModeNode.isValid() ) continue; @@ -896,10 +896,9 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) // Backup visible toolbar list and hide all toolbars Sequence<Reference<XUIElement>> aUIElements = xLayoutManager->getElements(); - for ( sal_Int32 i = 0; i < aUIElements.getLength(); i++ ) + for ( const Reference< XUIElement >& xUIElement : aUIElements ) { - Reference< XUIElement > xUIElement( aUIElements[i] ); - Reference< XPropertySet > xPropertySet( aUIElements[i], UNO_QUERY ); + Reference< XPropertySet > xPropertySet( xUIElement, UNO_QUERY ); if ( xPropertySet.is() && xUIElement.is() ) { try @@ -969,13 +968,11 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) // Save settings if ( pViewFrame == SfxViewFrame::Current() ) { - css::uno::Sequence<OUString> aBackup( aBackupList.size() ); - for ( size_t i = 0; i < aBackupList.size(); ++i ) - aBackup[i] = aBackupList[i]; + css::uno::Sequence<OUString> aBackup( comphelper::containerToSequence(aBackupList) ); - for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex ) + for ( const auto& rModeNodeName : aModeNodeNames ) { - const utl::OConfigurationNode aModeNode( aModesNode.openNode( aModeNodeNames[nReadIndex] ) ); + const utl::OConfigurationNode aModeNode( aModesNode.openNode( rModeNodeName ) ); if ( !aModeNode.isValid() ) continue; diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 1528f231ca39..2954eb45a522 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -250,9 +250,8 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert #endif // complex property; collect sub items from the parameter set and reconstruct complex item sal_uInt16 nFound=0; - for ( sal_Int32 n=0; n<nCount; n++ ) + for ( const beans::PropertyValue& rPropValue : rArgs ) { - const beans::PropertyValue& rPropValue = pPropsVal[n]; sal_uInt16 nSub; for ( nSub=0; nSub<nSubCount; nSub++ ) { @@ -313,23 +312,20 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if ( nSubCount == 0 ) { // "simple" (base type) argument - for ( sal_Int32 n=0; n<nCount; n++ ) + auto aName = OUString( rArg.pName, strlen(rArg.pName), RTL_TEXTENCODING_UTF8 ); + auto pProp = std::find_if(rArgs.begin(), rArgs.end(), + [&aName](const beans::PropertyValue& rProp) { return rProp.Name == aName; }); + if (pProp != rArgs.end()) { - const beans::PropertyValue& rProp = pPropsVal[n]; - const OUString& rName = rProp.Name; - if ( rName == OUString( rArg.pName, strlen(rArg.pName), RTL_TEXTENCODING_UTF8 ) ) - { #ifdef DBG_UTIL - ++nFoundArgs; + ++nFoundArgs; #endif - if( pItem->PutValue( rProp.Value, 0 ) ) - // only use successfully converted items - rSet.Put( *pItem ); - else - { - SAL_WARN( "sfx", "Property not convertible: " << rArg.pName ); - } - break; + if( pItem->PutValue( pProp->Value, 0 ) ) + // only use successfully converted items + rSet.Put( *pItem ); + else + { + SAL_WARN( "sfx", "Property not convertible: " << rArg.pName ); } } } @@ -337,9 +333,8 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert { // complex argument, could be passed in one struct bool bAsWholeItem = false; - for ( sal_Int32 n=0; n<nCount; n++ ) + for ( const beans::PropertyValue& rProp : rArgs ) { - const beans::PropertyValue& rProp = pPropsVal[n]; const OUString& rName = rProp.Name; if ( rName == OUString(rArg.pName, strlen(rArg.pName), RTL_TEXTENCODING_UTF8) ) { @@ -363,9 +358,8 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert // only put item if at least one member was found and had the correct type // (is this a good idea?! Should we ask for *all* members?) bool bRet = false; - for ( sal_Int32 n=0; n<nCount; n++ ) + for ( const beans::PropertyValue& rProp : rArgs ) { - const beans::PropertyValue& rProp = pPropsVal[n]; for ( sal_uInt16 nSub=0; nSub<nSubCount; nSub++ ) { // search sub item by name @@ -408,9 +402,8 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert // f.e. "SaveAs" shouldn't support parameters not in the slot definition!) if ( nSlotId == SID_NEWWINDOW ) { - for ( sal_Int32 n=0; n<nCount; n++ ) + for ( const beans::PropertyValue& rProp : rArgs ) { - const beans::PropertyValue& rProp = pPropsVal[n]; const OUString& rName = rProp.Name; if ( rName == sFrame ) { @@ -429,12 +422,11 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert } else if ( bIsMediaDescriptor ) { - for ( sal_Int32 n=0; n<nCount; n++ ) + for ( const beans::PropertyValue& rProp : rArgs ) { #ifdef DBG_UTIL ++nFoundArgs; #endif - const beans::PropertyValue& rProp = pPropsVal[n]; const OUString& aName = rProp.Name; if ( aName == sModel ) rSet.Put( SfxUnoAnyItem( SID_DOCUMENT, rProp.Value ) ); @@ -865,17 +857,13 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert // transform parameter "OptionsPageURL" of slot "OptionsTreeDialog" if ( "OptionsTreeDialog" == OUString( pSlot->pUnoName, strlen(pSlot->pUnoName), RTL_TEXTENCODING_UTF8 ) ) { - for ( sal_Int32 n = 0; n < nCount; ++n ) + auto pProp = std::find_if(rArgs.begin(), rArgs.end(), + [](const PropertyValue& rProp) { return rProp.Name == "OptionsPageURL"; }); + if (pProp != rArgs.end()) { - const PropertyValue& rProp = pPropsVal[n]; - OUString sName( rProp.Name ); - if ( sName == "OptionsPageURL" ) - { - OUString sURL; - if ( rProp.Value >>= sURL ) - rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) ); - break; - } + OUString sURL; + if ( pProp->Value >>= sURL ) + rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) ); } } } diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx index cd5686e8154a..62838f4ae240 100644 --- a/sfx2/source/appl/childwin.cxx +++ b/sfx2/source/appl/childwin.cxx @@ -390,7 +390,7 @@ void SfxChildWindow::InitializeChildWinFactory_Impl(sal_uInt16 nId, SfxChildWinI css::uno::Sequence < css::beans::NamedValue > aSeq = xWinOpt->GetUserData(); OUString aTmp; - if ( aSeq.getLength() ) + if ( aSeq.hasElements() ) aSeq[0].Value >>= aTmp; OUString aWinData( aTmp ); diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx index fe4d1e463119..799fbb2ffdbb 100644 --- a/sfx2/source/appl/fileobj.cxx +++ b/sfx2/source/appl/fileobj.cxx @@ -225,11 +225,11 @@ static OUString impl_getFilter( const OUString& _rURL ) if ( !sType.isEmpty() ) { // Honor a selected/detected filter. - for (sal_Int32 i=0; i < aDescrList.getLength(); ++i) + for (const auto& rDescr : aDescrList) { - if (aDescrList[i].Name == "FilterName") + if (rDescr.Name == "FilterName") { - if (aDescrList[i].Value >>= sFilter) + if (rDescr.Value >>= sFilter) break; } } diff --git a/sfx2/source/appl/helpdispatch.cxx b/sfx2/source/appl/helpdispatch.cxx index 809078add4d0..a53c5e5ed622 100644 --- a/sfx2/source/appl/helpdispatch.cxx +++ b/sfx2/source/appl/helpdispatch.cxx @@ -57,14 +57,12 @@ void SAL_CALL HelpDispatch_Impl::dispatch( // search for a keyword (dispatch from the basic ide) bool bHasKeyword = false; OUString sKeyword; - const PropertyValue* pBegin = aArgs.getConstArray(); - const PropertyValue* pEnd = pBegin + aArgs.getLength(); - for ( ; pBegin != pEnd; ++pBegin ) + for ( const PropertyValue& rArg : aArgs ) { - if ( pBegin->Name == "HelpKeyword" ) + if ( rArg.Name == "HelpKeyword" ) { OUString sHelpKeyword; - if ( ( pBegin->Value >>= sHelpKeyword ) && !sHelpKeyword.isEmpty() ) + if ( ( rArg.Value >>= sHelpKeyword ) && !sHelpKeyword.isEmpty() ) { sKeyword = sHelpKeyword; bHasKeyword = !sKeyword.isEmpty(); diff --git a/sfx2/source/appl/helpinterceptor.cxx b/sfx2/source/appl/helpinterceptor.cxx index 0b6034a6c0da..90f95151da26 100644 --- a/sfx2/source/appl/helpinterceptor.cxx +++ b/sfx2/source/appl/helpinterceptor.cxx @@ -132,12 +132,9 @@ Sequence < Reference < XDispatch > > SAL_CALL HelpInterceptor_Impl::queryDispatc { Sequence< Reference< XDispatch > > aReturn( aDescripts.getLength() ); - Reference< XDispatch >* pReturn = aReturn.getArray(); - const DispatchDescriptor* pDescripts = aDescripts.getConstArray(); - for ( sal_Int32 i = 0; i < aDescripts.getLength(); ++i, ++pReturn, ++pDescripts ) - { - *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags ); - } + std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(), + [this](const DispatchDescriptor& rDescr) -> Reference<XDispatch> { + return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); }); return aReturn; } diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx index 970ff56b5083..1aeff343e275 100644 --- a/sfx2/source/appl/macroloader.cxx +++ b/sfx2/source/appl/macroloader.cxx @@ -53,7 +53,7 @@ using namespace ::com::sun::star::util; SfxMacroLoader::SfxMacroLoader(const css::uno::Sequence< css::uno::Any >& aArguments) { Reference < XFrame > xFrame; - if ( aArguments.getLength() ) + if ( aArguments.hasElements() ) { aArguments[0] >>= xFrame; m_xFrame = xFrame; @@ -114,10 +114,9 @@ uno::Sequence< uno::Reference<frame::XDispatch> > SAL_CALL { sal_Int32 nCount = seqDescriptor.getLength(); uno::Sequence< uno::Reference<frame::XDispatch> > lDispatcher(nCount); - for( sal_Int32 i=0; i<nCount; ++i ) - lDispatcher[i] = queryDispatch( seqDescriptor[i].FeatureURL, - seqDescriptor[i].FrameName, - seqDescriptor[i].SearchFlags ); + std::transform(seqDescriptor.begin(), seqDescriptor.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/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 6dbd7b82f6eb..a491d3ec02a2 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -656,10 +656,10 @@ void IndexTabPage_Impl::InitializeIndex() sal_uInt32 nRefListLen = aRefList.getLength(); - DBG_ASSERT( aAnchorList.getLength(), "*IndexTabPage_Impl::InitializeIndex(): AnchorList is empty!" ); + DBG_ASSERT( aAnchorList.hasElements(), "*IndexTabPage_Impl::InitializeIndex(): AnchorList is empty!" ); DBG_ASSERT( nRefListLen, "*IndexTabPage_Impl::InitializeIndex(): RefList is empty!" ); - if ( aAnchorList.getLength() && nRefListLen ) + if ( aAnchorList.hasElements() && nRefListLen ) { if ( aAnchorList[0].getLength() > 0 ) { @@ -1121,9 +1121,8 @@ static void GetBookmarkEntry_Impl OUString& rURL ) { - for ( int i = 0; i < aBookmarkEntry.getLength(); i++ ) + for ( const PropertyValue& aValue : aBookmarkEntry ) { - PropertyValue aValue = aBookmarkEntry[i]; if ( aValue.Name == HISTORY_PROPERTYNAME_URL ) aValue.Value >>= rURL; else if ( aValue.Name == HISTORY_PROPERTYNAME_TITLE ) @@ -1279,10 +1278,9 @@ BookmarksTabPage_Impl::BookmarksTabPage_Impl(vcl::Window* pParent, SfxHelpIndexW OUString aTitle; OUString aURL; - sal_uInt32 i, nCount = aBookmarkSeq.getLength(); - for ( i = 0; i < nCount; ++i ) + for ( auto& rBookmark : aBookmarkSeq ) { - GetBookmarkEntry_Impl( aBookmarkSeq[i], aTitle, aURL ); + GetBookmarkEntry_Impl( rBookmark, aTitle, aURL ); AddBookmarks( aTitle, aURL ); } } diff --git a/sfx2/source/appl/preventduplicateinteraction.cxx b/sfx2/source/appl/preventduplicateinteraction.cxx index 3f34743891d3..8c9796491b8f 100644 --- a/sfx2/source/appl/preventduplicateinteraction.cxx +++ b/sfx2/source/appl/preventduplicateinteraction.cxx @@ -104,11 +104,9 @@ void SAL_CALL PreventDuplicateInteraction::handle(const css::uno::Reference< css else { const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations(); - sal_Int32 c = lContinuations.getLength(); - sal_Int32 i = 0; - for (i=0; i<c; ++i) + for (const auto& rContinuation : lContinuations) { - css::uno::Reference< css::task::XInteractionAbort > xAbort(lContinuations[i], css::uno::UNO_QUERY); + css::uno::Reference< css::task::XInteractionAbort > xAbort(rContinuation, css::uno::UNO_QUERY); if (xAbort.is()) { xAbort->select(); @@ -151,11 +149,9 @@ sal_Bool SAL_CALL PreventDuplicateInteraction::handleInteractionRequest( const c else { const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations(); - sal_Int32 c = lContinuations.getLength(); - sal_Int32 i = 0; - for (i=0; i<c; ++i) + for (const auto& rContinuation : lContinuations) { - css::uno::Reference< css::task::XInteractionAbort > xAbort(lContinuations[i], css::uno::UNO_QUERY); + css::uno::Reference< css::task::XInteractionAbort > xAbort(rContinuation, css::uno::UNO_QUERY); if (xAbort.is()) { xAbort->select(); diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index d6fac42bd6de..409edaf57e16 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -481,14 +481,10 @@ OUString SfxHelp::GetHelpModuleName_Impl(const OUString& rHelpID) ModuleManager::create(::comphelper::getProcessComponentContext()) ); Sequence< PropertyValue > lProps; xModuleManager->getByName( aModuleIdentifier ) >>= lProps; - for ( sal_Int32 i = 0; i < lProps.getLength(); ++i ) - { - if ( lProps[i].Name == "ooSetupFactoryShortName" ) - { - lProps[i].Value >>= aFactoryShortName; - break; - } - } + auto pProp = std::find_if(lProps.begin(), lProps.end(), + [](const PropertyValue& rProp) { return rProp.Name == "ooSetupFactoryShortName"; }); + if (pProp != lProps.end()) + pProp->Value >>= aFactoryShortName; } catch (const Exception&) { diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index f8772610617d..b5970c7ac874 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -434,11 +434,11 @@ ErrCode SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, std: uno::Sequence< beans::PropertyValue > lDescriptor = aDescriptor.getAsConstPropertyValueList(); sTypeName = xDetection->queryTypeByDescriptor(lDescriptor, true); // lDescriptor is used as In/Out param ... don't use aDescriptor.getAsConstPropertyValueList() directly! - for (sal_Int32 i = 0; i < lDescriptor.getLength(); ++i) + for (const auto& rProp : lDescriptor) { - if (lDescriptor[i].Name == "FilterName") + if (rProp.Name == "FilterName") // Type detection picked a preferred filter for this format. - aFilterName = lDescriptor[i].Value.get<OUString>(); + aFilterName = rProp.Value.get<OUString>(); } } // no stream exists => try flat detection without preselection as fallback @@ -926,49 +926,47 @@ void SfxFilterContainer::ReadSingleFilter_Impl( bool bEnabled = true ; // first get directly available properties - sal_Int32 nFilterPropertyCount = lFilterProperties.getLength(); - sal_Int32 nFilterProperty = 0 ; - for( nFilterProperty=0; nFilterProperty<nFilterPropertyCount; ++nFilterProperty ) + for( const auto& rFilterProperty : lFilterProperties ) { - if ( lFilterProperties[nFilterProperty].Name == "FileFormatVersion" ) + if ( rFilterProperty.Name == "FileFormatVersion" ) { - lFilterProperties[nFilterProperty].Value >>= nFormatVersion; + rFilterProperty.Value >>= nFormatVersion; } - else if ( lFilterProperties[nFilterProperty].Name == "TemplateName" ) + else if ( rFilterProperty.Name == "TemplateName" ) { - lFilterProperties[nFilterProperty].Value >>= sDefaultTemplate; + rFilterProperty.Value >>= sDefaultTemplate; } - else if ( lFilterProperties[nFilterProperty].Name == "Flags" ) + else if ( rFilterProperty.Name == "Flags" ) { sal_Int32 nTmp(0); - lFilterProperties[nFilterProperty].Value >>= nTmp; + rFilterProperty.Value >>= nTmp; assert((nTmp & ~o3tl::typed_flags<SfxFilterFlags>::mask) == 0); nFlags = static_cast<SfxFilterFlags>(nTmp); } - else if ( lFilterProperties[nFilterProperty].Name == "UIName" ) + else if ( rFilterProperty.Name == "UIName" ) { - lFilterProperties[nFilterProperty].Value >>= sUIName; + rFilterProperty.Value >>= sUIName; } - else if ( lFilterProperties[nFilterProperty].Name == "UserData" ) + else if ( rFilterProperty.Name == "UserData" ) { uno::Sequence< OUString > lUserData; - lFilterProperties[nFilterProperty].Value >>= lUserData; + rFilterProperty.Value >>= lUserData; sUserData = implc_convertStringlistToString( lUserData, ',', OUString() ); } - else if ( lFilterProperties[nFilterProperty].Name == "DocumentService" ) + else if ( rFilterProperty.Name == "DocumentService" ) { - lFilterProperties[nFilterProperty].Value >>= sServiceName; + rFilterProperty.Value >>= sServiceName; } - else if (lFilterProperties[nFilterProperty].Name == "ExportExtension") + else if (rFilterProperty.Name == "ExportExtension") { // Extension preferred by the filter. This takes precedence // over those that are given in the file format type. - lFilterProperties[nFilterProperty].Value >>= sExtension; + rFilterProperty.Value >>= sExtension; sExtension = "*." + sExtension; } - else if ( lFilterProperties[nFilterProperty].Name == "Type" ) + else if ( rFilterProperty.Name == "Type" ) { - lFilterProperties[nFilterProperty].Value >>= sType; + rFilterProperty.Value >>= sType; // Try to get filter .. but look for any exceptions! // May be filter was deleted by another thread ... try @@ -984,39 +982,37 @@ void SfxFilterContainer::ReadSingleFilter_Impl( if( aResult >>= lTypeProperties ) { // get indirect available properties then (types) - sal_Int32 nTypePropertyCount = lTypeProperties.getLength(); - sal_Int32 nTypeProperty = 0 ; - for( nTypeProperty=0; nTypeProperty<nTypePropertyCount; ++nTypeProperty ) + for( const auto& rTypeProperty : lTypeProperties ) { - if ( lTypeProperties[nTypeProperty].Name == "ClipboardFormat" ) + if ( rTypeProperty.Name == "ClipboardFormat" ) { - lTypeProperties[nTypeProperty].Value >>= sHumanName; + rTypeProperty.Value >>= sHumanName; } - else if ( lTypeProperties[nTypeProperty].Name == "MediaType" ) + else if ( rTypeProperty.Name == "MediaType" ) { - lTypeProperties[nTypeProperty].Value >>= sMimeType; + rTypeProperty.Value >>= sMimeType; } - else if ( lTypeProperties[nTypeProperty].Name == "Extensions" ) + else if ( rTypeProperty.Name == "Extensions" ) { if (sExtension.isEmpty()) { uno::Sequence< OUString > lExtensions; - lTypeProperties[nTypeProperty].Value >>= lExtensions; + rTypeProperty.Value >>= lExtensions; sExtension = implc_convertStringlistToString( lExtensions, ';', "*." ); } } - else if ( lTypeProperties[nTypeProperty].Name == "URLPattern" ) + else if ( rTypeProperty.Name == "URLPattern" ) { uno::Sequence< OUString > lPattern; - lTypeProperties[nTypeProperty].Value >>= lPattern; + rTypeProperty.Value >>= lPattern; sPattern = implc_convertStringlistToString( lPattern, ';', OUString() ); } } } } - else if ( lFilterProperties[nFilterProperty].Name == "Enabled" ) + else if ( rFilterProperty.Name == "Enabled" ) { - lFilterProperties[nFilterProperty].Value >>= bEnabled; + rFilterProperty.Value >>= bEnabled; } } @@ -1109,7 +1105,7 @@ void SfxFilterContainer::ReadFilters_Impl( bool bUpdate ) { // select right query to get right set of filters for search module uno::Sequence< OUString > lFilterNames = xFilterCFG->getElementNames(); - if ( lFilterNames.getLength() ) + if ( lFilterNames.hasElements() ) { // If list of filters already exist ... // ReadExternalFilters must work in update mode. @@ -1126,13 +1122,10 @@ void SfxFilterContainer::ReadFilters_Impl( bool bUpdate ) } // get all properties of filters ... put it into the filter container - sal_Int32 nFilterCount = lFilterNames.getLength(); - sal_Int32 nFilter=0; - for( nFilter=0; nFilter<nFilterCount; ++nFilter ) + for( const OUString& sFilterName : lFilterNames ) { // Try to get filter .. but look for any exceptions! // May be filter was deleted by another thread ... - OUString sFilterName = lFilterNames[nFilter]; ReadSingleFilter_Impl( sFilterName, xTypeCFG, xFilterCFG, bUpdate ); } } diff --git a/sfx2/source/bastyp/frmhtmlw.cxx b/sfx2/source/bastyp/frmhtmlw.cxx index d074138ce56a..0cff220f48ae 100644 --- a/sfx2/source/bastyp/frmhtmlw.cxx +++ b/sfx2/source/bastyp/frmhtmlw.cxx @@ -212,11 +212,11 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, const OUString& rBaseURL, xUserDefinedProps->getPropertySetInfo(); DBG_ASSERT(xPropInfo.is(), "UserDefinedProperties Info is null"); uno::Sequence<beans::Property> props = xPropInfo->getProperties(); - for (sal_Int32 i = 0; i < props.getLength(); ++i) + for (const auto& rProp : props) { try { - OUString name = props[i].Name; + OUString name = rProp.Name; uno::Any aStr = xConverter->convertToSimpleType( xUserDefinedProps->getPropertyValue(name), uno::TypeClass_STRING); diff --git a/sfx2/source/control/charmapcontrol.cxx b/sfx2/source/control/charmapcontrol.cxx index 6534a9b1efc6..c28a5d75108c 100644 --- a/sfx2/source/control/charmapcontrol.cxx +++ b/sfx2/source/control/charmapcontrol.cxx @@ -106,17 +106,11 @@ void SfxCharmapCtrl::getFavCharacterList() { //retrieve recent character list css::uno::Sequence< OUString > rFavCharList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() ); - for (int i = 0; i < rFavCharList.getLength(); ++i) - { - maFavCharList.push_back(rFavCharList[i]); - } + std::copy(rFavCharList.begin(), rFavCharList.end(), std::back_inserter(maFavCharList)); //retrieve recent character font list css::uno::Sequence< OUString > rFavCharFontList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() ); - for (int i = 0; i < rFavCharFontList.getLength(); ++i) - { - maFavCharFontList.push_back(rFavCharFontList[i]); - } + std::copy(rFavCharFontList.begin(), rFavCharFontList.end(), std::back_inserter(maFavCharFontList)); } @@ -146,17 +140,11 @@ void SfxCharmapCtrl::getRecentCharacterList() { //retrieve recent character list css::uno::Sequence< OUString > rRecentCharList( officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() ); - for (int i = 0; i < rRecentCharList.getLength(); ++i) - { - maRecentCharList.push_back(rRecentCharList[i]); - } + std::copy(rRecentCharList.begin(), rRecentCharList.end(), std::back_inserter(maRecentCharList)); //retrieve recent character font list css::uno::Sequence< OUString > rRecentCharFontList( officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() ); - for (int i = 0; i < rRecentCharFontList.getLength(); ++i) - { - maRecentCharFontList.push_back(rRecentCharFontList[i]); - } + std::copy(rRecentCharFontList.begin(), rRecentCharFontList.end(), std::back_inserter(maRecentCharFontList)); } diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx index 51674e4e808d..46314a428ab2 100644 --- a/sfx2/source/control/recentdocsview.cxx +++ b/sfx2/source/control/recentdocsview.cxx @@ -240,14 +240,14 @@ void RecentDocsView::Reload() OUString aTitle; BitmapEx aThumbnail; - for ( int j = 0; j < rRecentEntry.getLength(); j++ ) + for ( const auto& rProp : rRecentEntry ) { - Any a = rRecentEntry[j].Value; + Any a = rProp.Value; - if (rRecentEntry[j].Name == "URL") + if (rProp.Name == "URL") a >>= aURL; //fdo#74834: only load thumbnail if the corresponding option is not disabled in the configuration - else if (rRecentEntry[j].Name == "Thumbnail" && officecfg::Office::Common::History::RecentDocsThumbnail::get()) + else if (rProp.Name == "Thumbnail" && officecfg::Office::Common::History::RecentDocsThumbnail::get()) { OUString aBase64; a >>= aBase64; diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index 52c59572daa7..abdb828d7721 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -602,19 +602,20 @@ void SfxShell::VerbExec(SfxRequest& rReq) bool bReadOnly = pViewShell->GetObjectShell()->IsReadOnly(); css::uno::Sequence < css::embed::VerbDescriptor > aList = pViewShell->GetVerbs(); - for (sal_Int32 n=0, nVerb=0; n<aList.getLength(); n++) + sal_Int32 nVerb = 0; + for (const auto& rVerb : aList) { // check for ReadOnly verbs - if ( bReadOnly && !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) ) + if ( bReadOnly && !(rVerb.VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) ) continue; // check for verbs that shouldn't appear in the menu - if ( !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) ) + if ( !(rVerb.VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) ) continue; if (nId == SID_VERB_START + nVerb++) { - pViewShell->DoVerb(aList[n].VerbID); + pViewShell->DoVerb(rVerb.VerbID); rReq.Done(); return; } diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 982811f93fc4..500bacca768d 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -438,14 +438,8 @@ bool TemplateLocalView::IsDefaultTemplate(const OUString& rPath) SvtModuleOptions aModOpt; const css::uno::Sequence<OUString> &aServiceNames = aModOpt.GetAllServiceNames(); - for( sal_Int32 i=0, nCount = aServiceNames.getLength(); i < nCount; ++i ) - { - const OUString defaultPath = SfxObjectFactory::GetStandardTemplate( aServiceNames[i] ); - if(defaultPath.match(rPath)) - return true; - } - - return false; + return std::any_of(aServiceNames.begin(), aServiceNames.end(), [&rPath](const OUString& rName) { + return SfxObjectFactory::GetStandardTemplate(rName).match(rPath); }); } BitmapEx TemplateLocalView::getDefaultThumbnail( const OUString& rPath ) @@ -1301,14 +1295,8 @@ bool SfxTemplateLocalView::IsDefaultTemplate(const OUString& rPath) SvtModuleOptions aModOpt; const css::uno::Sequence<OUString> &aServiceNames = aModOpt.GetAllServiceNames(); - for( sal_Int32 i=0, nCount = aServiceNames.getLength(); i < nCount; ++i ) - { - const OUString defaultPath = SfxObjectFactory::GetStandardTemplate( aServiceNames[i] ); - if(defaultPath.match(rPath)) - return true; - } - - return false; + return std::any_of(aServiceNames.begin(), aServiceNames.end(), [&rPath](const OUString& rName) { + return SfxObjectFactory::GetStandardTemplate(rName).match(rPath); }); } void SfxTemplateLocalView::RemoveDefaultTemplateIcon(const OUString& rPath) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index e4e1b8d5f691..a321248cdc9b 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -667,9 +667,8 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, { sal_uInt32 nIndex( lNewArgs.getLength() ); - lNewArgs.realloc( lNewArgs.getLength()+aAddArgs.size() ); - for ( sal_uInt32 i = 0; i < nAddArgs; i++ ) - lNewArgs[nIndex++] = aAddArgs[i]; + lNewArgs.realloc( nIndex + nAddArgs ); + std::copy(aAddArgs.begin(), aAddArgs.end(), std::next(lNewArgs.begin(), nIndex)); } // Overwrite possible detected synchron argument, if real listener exists (currently no other way) diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index ccb5f05962f1..22df8b24937a 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -711,8 +711,9 @@ css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL Bac sal_Int32 nCount = seqDescripts.getLength(); css::uno::Sequence < css::uno::Reference < 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 css::frame::DispatchDescriptor& rDesc) -> css::uno::Reference<XDispatch> { + return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, rDesc.SearchFlags); }); return lDispatcher; } diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 70669200b5a8..5c8d83be5398 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -236,19 +236,17 @@ SfxDocumentInfoItem::SfxDocumentInfoItem( const OUString& rFile, { Reference < beans::XPropertySet > xSet( xContainer, UNO_QUERY ); const Sequence< beans::Property > lProps = xSet->getPropertySetInfo()->getProperties(); - const beans::Property* pProps = lProps.getConstArray(); - sal_Int32 nCount = lProps.getLength(); - for ( sal_Int32 i = 0; i < nCount; ++i ) + for ( const beans::Property& rProp : lProps ) { // "fix" property? => not a custom property => ignore it! - if (!(pProps[i].Attributes & css::beans::PropertyAttribute::REMOVABLE)) + if (!(rProp.Attributes & css::beans::PropertyAttribute::REMOVABLE)) { SAL_WARN( "sfx.dialog", "non-removable user-defined property?"); continue; } - uno::Any aValue = xSet->getPropertyValue(pProps[i].Name); - std::unique_ptr<CustomProperty> pProp(new CustomProperty( pProps[i].Name, aValue )); + uno::Any aValue = xSet->getPropertyValue(rProp.Name); + std::unique_ptr<CustomProperty> pProp(new CustomProperty( rProp.Name, aValue )); m_aCustomProperties.push_back( std::move(pProp) ); } } @@ -392,13 +390,11 @@ void SfxDocumentInfoItem::UpdateDocumentInfo( Reference < beans::XPropertySet > xSet( xContainer, UNO_QUERY ); Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo(); const Sequence< beans::Property > lProps = xSetInfo->getProperties(); - const beans::Property* pProps = lProps.getConstArray(); - sal_Int32 nCount = lProps.getLength(); - for ( sal_Int32 j = 0; j < nCount; ++j ) + for ( const beans::Property& rProp : lProps ) { - if (pProps[j].Attributes & css::beans::PropertyAttribute::REMOVABLE) + if (rProp.Attributes & css::beans::PropertyAttribute::REMOVABLE) { - xContainer->removeProperty( pProps[j].Name ); + xContainer->removeProperty( rProp.Name ); } } @@ -854,7 +850,7 @@ void SfxDocumentPage::ImplCheckPasswordState() else break; - if (!aEncryptionData.getLength()) + if (!aEncryptionData.hasElements()) break; m_xChangePassBtn->set_sensitive(true); return; @@ -1033,17 +1029,17 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet ) if ( rInfoItem.isCmisDocument( ) ) { uno::Sequence< document::CmisProperty > aCmisProps = rInfoItem.GetCmisProperties(); - for ( sal_Int32 i = 0; i < aCmisProps.getLength(); i++ ) + for ( const auto& rCmisProp : aCmisProps ) { - if ( aCmisProps[i].Id == "cmis:contentStreamLength" && + if ( rCmisProp.Id == "cmis:contentStreamLength" && aSizeText == m_aUnknownSize ) { Sequence< sal_Int64 > seqValue; - aCmisProps[i].Value >>= seqValue; + rCmisProp.Value >>= seqValue; SvNumberFormatter aNumberFormatter( ::comphelper::getProcessComponentContext(), Application::GetSettings().GetLanguageTag().getLanguageType() ); sal_uInt32 nIndex = aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM ); - if ( seqValue.getLength( ) > 0 ) + if ( seqValue.hasElements() ) { OUString sValue; aNumberFormatter.GetInputLineString( seqValue[0], nIndex, sValue ); @@ -1053,24 +1049,24 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet ) util::DateTime uDT; OUString emptyDate = ConvertDateTime_Impl( "", uDT, rLocaleWrapper ); - if ( aCmisProps[i].Id == "cmis:creationDate" && + if ( rCmisProp.Id == "cmis:creationDate" && (m_xCreateValFt->get_label() == emptyDate || m_xCreateValFt->get_label().isEmpty())) { Sequence< util::DateTime > seqValue; - aCmisProps[i].Value >>= seqValue; - if ( seqValue.getLength( ) > 0 ) + rCmisProp.Value >>= seqValue; + if ( seqValue.hasElements() ) { m_xCreateValFt->set_label( ConvertDateTime_Impl( "", seqValue[0], rLocaleWrapper ) ); } } - if ( aCmisProps[i].Id == "cmis:lastModificationDate" && + if ( rCmisProp.Id == "cmis:lastModificationDate" && (m_xChangeValFt->get_label() == emptyDate || m_xChangeValFt->get_label().isEmpty())) { Sequence< util::DateTime > seqValue; - aCmisProps[i].Value >>= seqValue; - if ( seqValue.getLength( ) > 0 ) + rCmisProp.Value >>= seqValue; + if ( seqValue.hasElements() ) { m_xChangeValFt->set_label( ConvertDateTime_Impl( "", seqValue[0], rLocaleWrapper ) ); } @@ -1882,12 +1878,11 @@ IMPL_LINK_NOARG(SfxCustomPropertiesPage, AddHdl, weld::Button&, void) // each time SfxDocumentInfoItem destructor is called SfxDocumentInfoItem pInfo; Sequence< beans::PropertyValue > aPropertySeq = m_xPropertiesCtrl->GetCustomProperties(); - sal_Int32 i = 0, nCount = aPropertySeq.getLength(); - for ( ; i < nCount; ++i ) + for ( const auto& rProperty : aPropertySeq ) { - if ( !aPropertySeq[i].Name.isEmpty() ) + if ( !rProperty.Name.isEmpty() ) { - pInfo.AddCustomProperty( aPropertySeq[i].Name, aPropertySeq[i].Value ); + pInfo.AddCustomProperty( rProperty.Name, rProperty.Value ); } } @@ -1924,11 +1919,10 @@ bool SfxCustomPropertiesPage::FillItemSet( SfxItemSet* rSet ) pInfo->ClearCustomProperties(); Sequence< beans::PropertyValue > aPropertySeq = m_xPropertiesCtrl->GetCustomProperties(); - sal_Int32 i = 0, nCount = aPropertySeq.getLength(); - for ( ; i < nCount; ++i ) + for ( const auto& rProperty : aPropertySeq ) { - if ( !aPropertySeq[i].Name.isEmpty() ) - pInfo->AddCustomProperty( aPropertySeq[i].Name, aPropertySeq[i].Value ); + if ( !rProperty.Name.isEmpty() ) + pInfo->AddCustomProperty( rProperty.Name, rProperty.Value ); } } @@ -2053,11 +2047,10 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName, Sequence< sal_Int64 > seqValue; rAny >>= seqValue; sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM ); - sal_Int32 nNumValue = seqValue.getLength( ); - for ( sal_Int32 i = 0; i < nNumValue; ++i ) + for ( const auto& rValue : seqValue ) { OUString sValue; - m_aNumberFormatter.GetInputLineString( seqValue[i], nIndex, sValue ); + m_aNumberFormatter.GetInputLineString( rValue, nIndex, sValue ); std::unique_ptr<CmisValue> pValue(new CmisValue(m_xBox.get(), sValue)); pValue->m_xValueEdit->set_editable(bUpdatable); pNewLine->m_aValues.push_back( std::move(pValue) ); @@ -2068,11 +2061,10 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName, Sequence< double > seqValue; rAny >>= seqValue; sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM ); - sal_Int32 nNumValue = seqValue.getLength( ); - for ( sal_Int32 i = 0; i < nNumValue; ++i ) + for ( const auto& rValue : seqValue ) { OUString sValue; - m_aNumberFormatter.GetInputLineString( seqValue[i], nIndex, sValue ); + m_aNumberFormatter.GetInputLineString( rValue, nIndex, sValue ); std::unique_ptr<CmisValue> pValue(new CmisValue(m_xBox.get(), sValue)); pValue->m_xValueEdit->set_editable(bUpdatable); pNewLine->m_aValues.push_back( std::move(pValue) ); @@ -2083,10 +2075,9 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName, { Sequence<sal_Bool> seqValue; rAny >>= seqValue; - sal_Int32 nNumValue = seqValue.getLength( ); - for ( sal_Int32 i = 0; i < nNumValue; ++i ) + for ( const auto& rValue : seqValue ) { - std::unique_ptr<CmisYesNo> pYesNo(new CmisYesNo(m_xBox.get(), seqValue[i])); + std::unique_ptr<CmisYesNo> pYesNo(new CmisYesNo(m_xBox.get(), rValue)); pYesNo->m_xYesButton->set_sensitive( bUpdatable ); pYesNo->m_xNoButton->set_sensitive( bUpdatable ); pNewLine->m_aYesNos.push_back( std::move(pYesNo) ); @@ -2096,10 +2087,9 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName, { Sequence< OUString > seqValue; rAny >>= seqValue; - sal_Int32 nNumValue = seqValue.getLength( ); - for ( sal_Int32 i = 0; i < nNumValue; ++i ) + for ( const auto& rValue : seqValue ) { - std::unique_ptr<CmisValue> pValue(new CmisValue(m_xBox.get(), seqValue[i])); + std::unique_ptr<CmisValue> pValue(new CmisValue(m_xBox.get(), rValue)); pValue->m_xValueEdit->set_editable(bUpdatable); pNewLine->m_aValues.push_back( std::move(pValue) ); } @@ -2108,10 +2098,9 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName, { Sequence< util::DateTime > seqValue; rAny >>= seqValue; - sal_Int32 nNumValue = seqValue.getLength( ); - for ( sal_Int32 i = 0; i < nNumValue; ++i ) + for ( const auto& rValue : seqValue ) { - std::unique_ptr<CmisDateTime> pDateTime(new CmisDateTime(m_xBox.get(), seqValue[i])); + std::unique_ptr<CmisDateTime> pDateTime(new CmisDateTime(m_xBox.get(), rValue)); pDateTime->m_xDateField->set_sensitive(bUpdatable); pDateTime->m_xTimeField->set_sensitive(bUpdatable); pNewLine->m_aDateTimes.push_back( std::move(pDateTime) ); @@ -2305,10 +2294,10 @@ bool SfxCmisPropertiesPage::FillItemSet( SfxItemSet* rSet ) aOldProps[i].Value >>= oldValue; // We only edit hours and minutes // don't compare NanoSeconds and Seconds - for ( sal_Int32 ii = 0; ii < oldValue.getLength( ); ++ii ) + for ( auto& rDateTime : oldValue ) { - oldValue[ii].NanoSeconds = 0; - oldValue[ii].Seconds = 0; + rDateTime.NanoSeconds = 0; + rDateTime.Seconds = 0; } Sequence< util::DateTime > newValue; aNewProps[i].Value >>= newValue; @@ -2340,17 +2329,17 @@ void SfxCmisPropertiesPage::Reset( const SfxItemSet* rItemSet ) m_xPropertiesCtrl->ClearAllLines(); const SfxDocumentInfoItem& rInfoItem = rItemSet->Get(SID_DOCINFO); uno::Sequence< document::CmisProperty > aCmisProps = rInfoItem.GetCmisProperties(); - for ( sal_Int32 i = 0; i < aCmisProps.getLength(); i++ ) + for ( auto& rCmisProp : aCmisProps ) { - m_xPropertiesCtrl->AddLine(aCmisProps[i].Id, - aCmisProps[i].Name, - aCmisProps[i].Type, - aCmisProps[i].Updatable, - aCmisProps[i].Required, - aCmisProps[i].MultiValued, - aCmisProps[i].OpenChoice, - aCmisProps[i].Choices, - aCmisProps[i].Value); + m_xPropertiesCtrl->AddLine(rCmisProp.Id, + rCmisProp.Name, + rCmisProp.Type, + rCmisProp.Updatable, + rCmisProp.Required, + rCmisProp.MultiValued, + rCmisProp.OpenChoice, + rCmisProp.Choices, + rCmisProp.Value); } } diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx index 4dbce1831f91..d38a361b5a2a 100644 --- a/sfx2/source/dialog/dockwin.cxx +++ b/sfx2/source/dialog/dockwin.cxx @@ -102,11 +102,11 @@ static bool lcl_getWindowState( const uno::Reference< container::XNameAccess >& a = xWindowStateMgr->getByName( rResourceURL ); if ( a >>= aWindowState ) { - for ( sal_Int32 n = 0; n < aWindowState.getLength(); n++ ) + for ( const auto& rProp : aWindowState ) { - if ( aWindowState[n].Name == "UIName" ) + if ( rProp.Name == "UIName" ) { - aWindowState[n].Value >>= rWindowState.sTitle; + rProp.Value >>= rWindowState.sTitle; } } } diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 5f2699d0f525..198043cac4a9 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -410,12 +410,11 @@ bool FileDialogHelper_Impl::CheckFilterOptionsCapability( const std::shared_ptr< if ( aAny >>= aProps ) { OUString aServiceName; - sal_Int32 nPropertyCount = aProps.getLength(); - for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty ) + for( const auto& rProp : aProps ) { - if( aProps[nProperty].Name == "UIComponent" ) + if( rProp.Name == "UIComponent" ) { - aProps[nProperty].Value >>= aServiceName; + rProp.Value >>= aServiceName; if( !aServiceName.isEmpty() ) bResult = true; } @@ -508,13 +507,7 @@ void FileDialogHelper_Impl::updateSelectionBox() if ( xCtrlInfo.is() ) { Sequence< OUString > aCtrlList = xCtrlInfo->getSupportedControls(); - sal_uInt32 nCount = aCtrlList.getLength(); - for ( sal_uInt32 nCtrl = 0; nCtrl < nCount; ++nCtrl ) - if ( aCtrlList[ nCtrl ] == "SelectionBox" ) - { - bSelectionBoxFound = true; - break; - } + bSelectionBoxFound = comphelper::findValue(aCtrlList, "SelectionBox") != -1; } if ( bSelectionBoxFound ) @@ -632,8 +625,8 @@ void FileDialogHelper_Impl::updateVersions() aEntries.realloc( xVersions.getLength() + 1 ); aEntries[0] = SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ); - for ( sal_Int32 i=0; i<xVersions.getLength(); i++ ) - aEntries[ i + 1 ] = xVersions[i].Identifier; + std::transform(xVersions.begin(), xVersions.end(), std::next(aEntries.begin()), + [](const util::RevisionTag& rVersion) -> OUString { return rVersion.Identifier; }); } catch( const uno::Exception& ) { @@ -651,9 +644,7 @@ void FileDialogHelper_Impl::updateVersions() } catch( const IllegalArgumentException& ){} - sal_Int32 nCount = aEntries.getLength(); - - if ( !nCount ) + if ( !aEntries.hasElements() ) return; try @@ -1361,9 +1352,7 @@ void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterfac if (xPickNew.is()) { Sequence< OUString > lFiles = xPickNew->getSelectedFiles(); - ::sal_Int32 nFiles = lFiles.getLength(); - for(sal_Int32 i = 0; i < nFiles; ++i) - rpURLList.push_back(lFiles[i]); + comphelper::sequenceToContainer(rpURLList, lFiles); } // b) the olde way ... non optional. @@ -2724,7 +2713,7 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, uno::Sequence< sal_Int8 > aUniqueID = ::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 ); uno::Sequence< sal_Int8 > aEncryptionKey = ::comphelper::DocPasswordHelper::GenerateStd97Key( pPasswordRequest->getPassword(), aUniqueID ); - if ( aEncryptionKey.getLength() ) + if ( aEncryptionKey.hasElements() ) { ::comphelper::SequenceAsHashMap aHashData; aHashData[ OUString( "STD97EncryptionKey" ) ] <<= aEncryptionKey; @@ -2758,7 +2747,7 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, else { uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = ::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( pPasswordRequest->getPasswordToModify() ); - if ( aModifyPasswordInfo.getLength() ) + if ( aModifyPasswordInfo.hasElements() ) pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( aModifyPasswordInfo ) ) ); } } diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx index 0701c5c62f77..a59d7c8159c6 100644 --- a/sfx2/source/dialog/filtergrouping.cxx +++ b/sfx2/source/dialog/filtergrouping.cxx @@ -225,17 +225,12 @@ namespace sfx2 _rGlobalClasses.clear(); _rGlobalClassNames.clear(); - // get the list describing the order of all global classes Sequence< OUString > aGlobalClasses; _rFilterClassification.getNodeValue( "GlobalFilters/Order" ) >>= aGlobalClasses; - const OUString* pNames = aGlobalClasses.getConstArray(); - const OUString* pNamesEnd = pNames + aGlobalClasses.getLength(); - // copy the logical names - _rGlobalClassNames.resize( aGlobalClasses.getLength() ); - ::std::copy( pNames, pNamesEnd, _rGlobalClassNames.begin() ); + comphelper::sequenceToContainer(_rGlobalClassNames, aGlobalClasses); // Global classes are presented in an own group, so their order matters (while the order of the // "local classes" doesn't). @@ -243,8 +238,8 @@ namespace sfx2 // are returned from the configuration - it is completely undefined, and we need a _defined_ order. FilterClassReferrer aClassReferrer; ::std::for_each( - pNames, - pNamesEnd, + aGlobalClasses.begin(), + aGlobalClasses.end(), CreateEmptyClassRememberPos( _rGlobalClasses, aClassReferrer ) ); // now _rGlobalClasses contains a dummy entry for each global class, diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx index f8933256e539..31ee48bf6e0b 100644 --- a/sfx2/source/dialog/mailmodel.cxx +++ b/sfx2/source/dialog/mailmodel.cxx @@ -146,13 +146,12 @@ SfxMailModel::SaveResult SfxMailModel::ShowFilterOptionsDialog( if ( aAny >>= aProps ) { - sal_Int32 nPropertyCount = aProps.getLength(); - for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty ) + for( const auto& rProp : aProps ) { - if( aProps[nProperty].Name == "UIComponent" ) + if( rProp.Name == "UIComponent" ) { OUString aServiceName; - aProps[nProperty].Value >>= aServiceName; + rProp.Value >>= aServiceName; if( !aServiceName.isEmpty() ) { uno::Reference< ui::dialogs::XExecutableDialog > xFilterDialog( @@ -191,16 +190,14 @@ SfxMailModel::SaveResult SfxMailModel::ShowFilterOptionsDialog( uno::Sequence< beans::PropertyValue > aPropsFromDialog = xFilterProperties->getPropertyValues(); //add them to the args - for ( sal_Int32 nInd = 0; nInd < aPropsFromDialog.getLength(); nInd++ ) + auto pProp = std::find_if(aPropsFromDialog.begin(), aPropsFromDialog.end(), + [](const beans::PropertyValue& rDialogProp) { return rDialogProp.Name == "FilterData"; }); + if (pProp != aPropsFromDialog.end()) { - if( aPropsFromDialog[ nInd ].Name == "FilterData" ) - { - //found the filterdata, add to the storing argument - rArgs.realloc( ++rNumArgs ); - rArgs[rNumArgs-1].Name = aPropsFromDialog[ nInd ].Name; - rArgs[rNumArgs-1].Value = aPropsFromDialog[ nInd ].Value; - break; - } + //found the filterdata, add to the storing argument + rArgs.realloc( ++rNumArgs ); + rArgs[rNumArgs-1].Name = pProp->Name; + rArgs[rNumArgs-1].Value = pProp->Value; } eRet = SAVE_SUCCESSFULL; } diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx index 743ecd6158e3..6dfc4329c769 100644 --- a/sfx2/source/dialog/versdlg.cxx +++ b/sfx2/source/dialog/versdlg.cxx @@ -80,28 +80,28 @@ public: SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < util::RevisionTag >& rInfo ) { - for ( sal_Int32 n=0; n<rInfo.getLength(); n++ ) + for ( const auto& rItem : rInfo ) { std::unique_ptr<SfxVersionInfo> pInfo(new SfxVersionInfo); - pInfo->aName = rInfo[n].Identifier; - pInfo->aComment = rInfo[n].Comment; - pInfo->aAuthor = rInfo[n].Author; + pInfo->aName = rItem.Identifier; + pInfo->aComment = rItem.Comment; + pInfo->aAuthor = rItem.Author; - pInfo->aCreationDate = DateTime( rInfo[n].TimeStamp ); + pInfo->aCreationDate = DateTime( rItem.TimeStamp ); aTableList.push_back( std::move(pInfo) ); } } SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < document::CmisVersion >& rInfo ) { - for ( sal_Int32 n=0; n<rInfo.getLength(); n++ ) + for ( const auto& rItem : rInfo ) { std::unique_ptr<SfxVersionInfo> pInfo(new SfxVersionInfo); - pInfo->aName = rInfo[n].Id; - pInfo->aComment = rInfo[n].Comment; - pInfo->aAuthor = rInfo[n].Author; + pInfo->aName = rItem.Id; + pInfo->aComment = rItem.Comment; + pInfo->aAuthor = rItem.Author; - pInfo->aCreationDate = DateTime( rInfo[n].TimeStamp ); + pInfo->aCreationDate = DateTime( rItem.TimeStamp ); aTableList.push_back( std::move(pInfo) ); } } diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index 14c5d98ca5d2..35952895e99c 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -329,10 +329,10 @@ addFile(struct DocumentMetadataAccess_Impl const & i_rImpl, getURI<rdf::URIs::RDF_TYPE>(i_rImpl.m_xContext), i_xType.get()); if (i_pTypes) { - for (sal_Int32 i = 0; i < i_pTypes->getLength(); ++i) { + for (const auto& rType : *i_pTypes) { i_rImpl.m_xManifest->addStatement(xURI.get(), getURI<rdf::URIs::RDF_TYPE>(i_rImpl.m_xContext), - (*i_pTypes)[i].get()); + rType.get()); } } } catch (const uno::RuntimeException &) { @@ -956,12 +956,11 @@ DocumentMetadataAccess::addMetadataFile(const OUString & i_rFileName, "DocumentMetadataAccess::addMetadataFile:" "invalid FileName: reserved", *this, 0); } - for (sal_Int32 i = 0; i < i_rTypes.getLength(); ++i) { - if (!i_rTypes[i].is()) { - throw lang::IllegalArgumentException( - "DocumentMetadataAccess::addMetadataFile: " - "null type", *this, 2); - } + if (std::any_of(i_rTypes.begin(), i_rTypes.end(), + [](const uno::Reference< rdf::XURI >& rType) { return !rType.is(); })) { + throw lang::IllegalArgumentException( + "DocumentMetadataAccess::addMetadataFile: " + "null type", *this, 2); } const uno::Reference<rdf::XURI> xGraphName( @@ -998,12 +997,11 @@ DocumentMetadataAccess::importMetadataFile(::sal_Int16 i_Format, "DocumentMetadataAccess::importMetadataFile:" "invalid FileName: reserved", *this, 0); } - for (sal_Int32 i = 0; i < i_rTypes.getLength(); ++i) { - if (!i_rTypes[i].is()) { - throw lang::IllegalArgumentException( - "DocumentMetadataAccess::importMetadataFile: null type", - *this, 5); - } + if (std::any_of(i_rTypes.begin(), i_rTypes.end(), + [](const uno::Reference< rdf::XURI >& rType) { return !rType.is(); })) { + throw lang::IllegalArgumentException( + "DocumentMetadataAccess::importMetadataFile: null type", + *this, 5); } const uno::Reference<rdf::XURI> xGraphName( @@ -1232,8 +1230,7 @@ void SAL_CALL DocumentMetadataAccess::storeMetadataToStorage( const uno::Sequence<uno::Reference<rdf::XURI> > graphs( m_pImpl->m_xRepository->getGraphNames()); const sal_Int32 len( baseURI.getLength() ); - for (sal_Int32 i = 0; i < graphs.getLength(); ++i) { - const uno::Reference<rdf::XURI> xName(graphs[i]); + for (const uno::Reference<rdf::XURI>& xName : graphs) { const OUString name(xName->getStringValue()); if (!name.match(baseURI)) { SAL_WARN("sfx", "storeMetadataToStorage: graph not in document: " << name); diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 7d2ed6faf10b..a9d248a2738c 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -571,18 +571,18 @@ SfxDocumentMetaData::getURLProperties( css::uno::Reference< css::beans::XPropertyBag> xPropArg = css::beans::PropertyBag::createDefault( m_xContext ); try { css::uno::Any baseUri; - for (sal_Int32 i = 0; i < i_rMedium.getLength(); ++i) { - if (i_rMedium[i].Name == "DocumentBaseURL") { - baseUri = i_rMedium[i].Value; - } else if (i_rMedium[i].Name == "URL") { + for (const auto& rProp : i_rMedium) { + if (rProp.Name == "DocumentBaseURL") { + baseUri = rProp.Value; + } else if (rProp.Name == "URL") { if (!baseUri.hasValue()) { - baseUri = i_rMedium[i].Value; + baseUri = rProp.Value; } - } else if (i_rMedium[i].Name == "HierarchicalDocumentName") { + } else if (rProp.Name == "HierarchicalDocumentName") { xPropArg->addProperty( "StreamRelPath", css::beans::PropertyAttribute::MAYBEVOID, - i_rMedium[i].Value); + rProp.Value); } } if (baseUri.hasValue()) { @@ -1621,12 +1621,12 @@ SfxDocumentMetaData::setDocumentStatistics( osl::MutexGuard g(m_aMutex); checkInit(); std::vector<std::pair<const char *, OUString> > attributes; - for (sal_Int32 i = 0; i < the_value.getLength(); ++i) { - const OUString name = the_value[i].Name; + for (const auto& rValue : the_value) { + const OUString name = rValue.Name; // inefficiently search for matching attribute for (size_t j = 0; s_stdStats[j] != nullptr; ++j) { if (name.equalsAscii(s_stdStats[j])) { - const css::uno::Any any = the_value[i].Value; + const css::uno::Any any = rValue.Value; sal_Int32 val = 0; if (any >>= val) { attributes.emplace_back(s_stdStatAttrs[j], diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx index 313065b3cab5..43514b1bc68e 100644 --- a/sfx2/source/doc/docfac.cxx +++ b/sfx2/source/doc/docfac.cxx @@ -176,9 +176,9 @@ void SfxObjectFactory::SetSystemTemplate( const OUString& rServiceName, const OU OUString aActualFilterTypeName; uno::Sequence< beans::PropertyValue > aActuralFilterData; xFilterFactory->getByName( aActualFilter ) >>= aActuralFilterData; - for ( sal_Int32 nInd = 0; nInd < aActuralFilterData.getLength(); nInd++ ) - if ( aActuralFilterData[nInd].Name == "Type" ) - aActuralFilterData[nInd].Value >>= aActualFilterTypeName; + for ( const auto& rProp : aActuralFilterData ) + if ( rProp.Name == "Type" ) + rProp.Value >>= aActualFilterTypeName; ::comphelper::SequenceAsHashMap aProps1( xTypeDetection->getByName( aActualFilterTypeName ) ); uno::Sequence< OUString > aAllExt = aProps1.getUnpackedValueOrDefault("Extensions", uno::Sequence< OUString >() ); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 96ff6618739c..f2782b99de40 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -83,6 +83,7 @@ #include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/interaction.hxx> +#include <comphelper/sequence.hxx> #include <comphelper/simplefileaccessinteraction.hxx> #include <framework/interaction.hxx> #include <unotools/streamhelper.hxx> @@ -1639,7 +1640,7 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( bool bCreateTempIfNo ) if ( pVersion && pVersion->GetValue() ) { // Read all available versions - if ( pImpl->aVersions.getLength() ) + if ( pImpl->aVersions.hasElements() ) { // Search for the version fits the comment // The versions are numbered starting with 1, versions with @@ -3457,7 +3458,7 @@ css::uno::Reference< css::io::XInputStream > const & SfxMedium::GetInputStream( const uno::Sequence < util::RevisionTag >& SfxMedium::GetVersionList( bool _bNoReload ) { // if the medium has no name, then this medium should represent a new document and can have no version info - if ( ( !_bNoReload || !pImpl->m_bVersionsAlreadyLoaded ) && !pImpl->aVersions.getLength() && + if ( ( !_bNoReload || !pImpl->m_bVersionsAlreadyLoaded ) && !pImpl->aVersions.hasElements() && ( !pImpl->m_aName.isEmpty() || !pImpl->m_aLogicName.isEmpty() ) && GetStorage().is() ) { uno::Reference < document::XDocumentRevisionListPersistence > xReader = @@ -3500,9 +3501,9 @@ void SfxMedium::AddVersion_Impl( util::RevisionTag& rRevision ) // To determine a unique name for the stream std::vector<sal_uInt32> aLongs; sal_Int32 nLength = pImpl->aVersions.getLength(); - for ( sal_Int32 m=0; m<nLength; m++ ) + for ( const auto& rVersion : pImpl->aVersions ) { - sal_uInt32 nVer = static_cast<sal_uInt32>( pImpl->aVersions[m].Identifier.copy(7).toInt32()); + sal_uInt32 nVer = static_cast<sal_uInt32>( rVersion.Identifier.copy(7).toInt32()); size_t n; for ( n=0; n<aLongs.size(); ++n ) if ( nVer<aLongs[n] ) @@ -3524,25 +3525,21 @@ void SfxMedium::AddVersion_Impl( util::RevisionTag& rRevision ) void SfxMedium::RemoveVersion_Impl( const OUString& rName ) { - if ( !pImpl->aVersions.getLength() ) + if ( !pImpl->aVersions.hasElements() ) return; - sal_Int32 nLength = pImpl->aVersions.getLength(); - for ( sal_Int32 n=0; n<nLength; n++ ) + auto pVersion = std::find_if(pImpl->aVersions.begin(), pImpl->aVersions.end(), + [&rName](const auto& rVersion) { return rVersion.Identifier == rName; }); + if (pVersion != pImpl->aVersions.end()) { - if ( pImpl->aVersions[n].Identifier == rName ) - { - for ( sal_Int32 m=n; m<nLength-1; m++ ) - pImpl->aVersions[m] = pImpl->aVersions[m+1]; - pImpl->aVersions.realloc(nLength-1); - return; - } + auto nIndex = static_cast<sal_Int32>(std::distance(pImpl->aVersions.begin(), pVersion)); + comphelper::removeElementAt(pImpl->aVersions, nIndex); } } bool SfxMedium::TransferVersionList_Impl( SfxMedium const & rMedium ) { - if ( rMedium.pImpl->aVersions.getLength() ) + if ( rMedium.pImpl->aVersions.hasElements() ) { pImpl->aVersions = rMedium.pImpl->aVersions; return true; @@ -3556,7 +3553,7 @@ void SfxMedium::SaveVersionList_Impl() if ( !GetStorage().is() ) return; - if ( !pImpl->aVersions.getLength() ) + if ( !pImpl->aVersions.hasElements() ) return; uno::Reference < document::XDocumentRevisionListPersistence > xWriter = diff --git a/sfx2/source/doc/docinf.cxx b/sfx2/source/doc/docinf.cxx index b58dfd81bca1..71dbff9a64ed 100644 --- a/sfx2/source/doc/docinf.cxx +++ b/sfx2/source/doc/docinf.cxx @@ -274,14 +274,14 @@ bool SaveOlePropertySet( xUserDefinedProps->getPropertySetInfo(); DBG_ASSERT(xPropInfo.is(), "UserDefinedProperties Info is null"); uno::Sequence<beans::Property> props = xPropInfo->getProperties(); - for (sal_Int32 i = 0; i < props.getLength(); ++i) + for (const auto& rProp : props) { try { // skip transient properties - if (~props[i].Attributes & beans::PropertyAttribute::TRANSIENT) + if (~rProp.Attributes & beans::PropertyAttribute::TRANSIENT) { - const OUString name = props[i].Name; + const OUString name = rProp.Name; const sal_Int32 nPropId = rCustomSect.GetFreePropertyId(); if (rCustomSect.SetAnyValue( nPropId, xUserDefinedProps->getPropertyValue(name))) { diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx index aa9c4c6b3a33..b24806a1b460 100644 --- a/sfx2/source/doc/docinsert.cxx +++ b/sfx2/source/doc/docinsert.cxx @@ -175,11 +175,11 @@ static void impl_FillURLList( sfx2::FileDialogHelper const * _pFileDlg, std::vec { _rpURLList.clear(); - for ( sal_Int32 i = 0; i < aPathSeq.getLength(); ++i ) - { - INetURLObject aPathObj( aPathSeq[i] ); - _rpURLList.push_back(aPathObj.GetMainURL(INetURLObject::DecodeMechanism::NONE)); - } + std::transform(aPathSeq.begin(), aPathSeq.end(), std::back_inserter(_rpURLList), + [](const OUString& rPath) -> OUString { + INetURLObject aPathObj( rPath ); + return aPathObj.GetMainURL(INetURLObject::DecodeMechanism::NONE); + }); } } diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx index 41b25170b8a3..cef89b0d0aa2 100644 --- a/sfx2/source/doc/docmacromode.cxx +++ b/sfx2/source/doc/docmacromode.cxx @@ -311,23 +311,18 @@ namespace sfx2 const OUString aStdLibName( "Standard" ); const OUString aVBAProject( "VBAProject" ); Sequence< OUString > aElements = xContainer->getElementNames(); - if ( aElements.hasElements() ) + for( const OUString& aElement : aElements ) { - sal_Int32 nElements = aElements.getLength(); - for( sal_Int32 i = 0; i < nElements; ++i ) + if( aElement == aStdLibName || aElement == aVBAProject ) { - const OUString aElement = aElements[i]; - if( aElement == aStdLibName || aElement == aVBAProject ) - { - Reference < XNameAccess > xLib; - Any aAny = xContainer->getByName( aElement ); - aAny >>= xLib; - if ( xLib.is() && xLib->hasElements() ) - return true; - } - else + Reference < XNameAccess > xLib; + Any aAny = xContainer->getByName( aElement ); + aAny >>= xLib; + if ( xLib.is() && xLib->hasElements() ) return true; } + else + return true; } } } diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 435041fd1189..7c980be3b77f 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -553,22 +553,20 @@ void SfxDocTplService_Impl::getDirList() "vnd.sun.star.expand:" ); sal_Int32 nIdx{ 0 }; - for (sal_Int32 i = 0; i < nCount; ++i) + for (auto& rTemplateDir : maTemplateDirs) { aURL.SetSmartProtocol( INetProtocol::File ); aURL.SetURL( aDirs.getToken( 0, C_DELIM, nIdx ) ); - maTemplateDirs[i] = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + rTemplateDir = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); if ( xExpander.is() ) { - const sal_Int32 nIndex{ maTemplateDirs[i].indexOf( aPrefix ) }; + const sal_Int32 nIndex{ rTemplateDir.indexOf( aPrefix ) }; if (nIndex<0) continue; - maTemplateDirs[i] = maTemplateDirs[i].replaceAt(nIndex, - aPrefix.getLength(), - OUString()); - maTemplateDirs[i] = xExpander->expandMacros( maTemplateDirs[i] ); + rTemplateDir = rTemplateDir.replaceAt(nIndex, aPrefix.getLength(), OUString()); + rTemplateDir = xExpander->expandMacros( rTemplateDir ); } } @@ -581,13 +579,12 @@ void SfxDocTplService_Impl::getDirList() Any aAny = xPathSettings->getPropertyValue( "Template_internal" ); aAny >>= maInternalTemplateDirs; - nCount = maInternalTemplateDirs.getLength(); - for (sal_Int32 i = 0; i < nCount; ++i) + for (auto& rInternalTemplateDir : maInternalTemplateDirs) { //expand vnd.sun.star.expand: and remove "..." from them //to normalize into the expected url patterns - maRelocator.makeRelocatableURL(maInternalTemplateDirs[i]); - maRelocator.makeAbsoluteURL(maInternalTemplateDirs[i]); + maRelocator.makeRelocatableURL(rInternalTemplateDir); + maRelocator.makeAbsoluteURL(rInternalTemplateDir); } // Store the template dir list @@ -994,9 +991,9 @@ bool SfxDocTplService_Impl::setProperty( Content& rContent, Sequence< OUString > aValues; if ( rPropValue >>= aValues ) { - for ( sal_Int32 n = 0; n < aValues.getLength(); n++ ) + for ( auto& rValue : aValues ) { - maRelocator.makeRelocatableURL( aValues[ n ] ); + maRelocator.makeRelocatableURL( rValue ); } aPropValue <<= aValues; } @@ -1053,9 +1050,9 @@ bool SfxDocTplService_Impl::getProperty(Content& rContent, const OUString& rProp Sequence< OUString > aValues; if ( rPropValue >>= aValues ) { - for ( sal_Int32 n = 0; n < aValues.getLength(); n++ ) + for ( auto& rValue : aValues ) { - maRelocator.makeAbsoluteURL( aValues[ n ] ); + maRelocator.makeAbsoluteURL( rValue ); } rPropValue <<= aValues; } @@ -1769,9 +1766,9 @@ bool SfxDocTplService_Impl::storeTemplate( const OUString& rGroupName, uno::Sequence< beans::PropertyValue > aFilterData; xFilterFactory->getByName( aFilterName ) >>= aFilterData; OUString aTypeName; - for ( sal_Int32 nInd = 0; nInd < aFilterData.getLength(); nInd++ ) - if ( aFilterData[nInd].Name == "Type" ) - aFilterData[nInd].Value >>= aTypeName; + for ( const auto& rProp : aFilterData ) + if ( rProp.Name == "Type" ) + rProp.Value >>= aTypeName; if ( aTypeName.isEmpty() ) throw uno::RuntimeException(); @@ -2005,25 +2002,16 @@ bool SfxDocTplService_Impl::addTemplate( const OUString& rGroupName, bool SfxDocTplService_Impl::isInternalTemplateDir(const OUString& rURL) const { - const sal_Int32 nDirs = maInternalTemplateDirs.getLength(); - const OUString* pDirs = maInternalTemplateDirs.getConstArray(); - for (sal_Int32 i = 0; i < nDirs; ++i, ++pDirs) - { - if (::utl::UCBContentHelper::IsSubPath(*pDirs, rURL)) - return true; - } - return false; + return std::any_of(maInternalTemplateDirs.begin(), maInternalTemplateDirs.end(), + [&rURL](const OUString& rDir) { return ::utl::UCBContentHelper::IsSubPath(rDir, rURL); }); } OUString SfxDocTplService_Impl::findParentTemplateDir(const OUString& rURL) const { - const sal_Int32 nDirs = maTemplateDirs.getLength(); - const OUString* pDirs = maTemplateDirs.getConstArray(); - for (sal_Int32 i = 0; i < nDirs; ++i, ++pDirs) - { - if (::utl::UCBContentHelper::IsSubPath(*pDirs, rURL)) - return *pDirs; - } + const OUString* pDirs = std::find_if(maTemplateDirs.begin(), maTemplateDirs.end(), + [&rURL](const OUString& rDir) { return ::utl::UCBContentHelper::IsSubPath(rDir, rURL); }); + if (pDirs != maTemplateDirs.end()) + return *pDirs; return OUString(); } diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index dedb5a83d72f..8dec12dda161 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -568,54 +568,49 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName ) uno::Any aAny = m_pOwner->GetFilterConfiguration()->getByName( aFilterName ); if ( aAny >>= aProps ) { - const sal_Int32 nPropertyCount = aProps.getLength(); - for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty ) + auto pProp = std::find_if(aProps.begin(), aProps.end(), + [](const beans::PropertyValue& rProp) { return rProp.Name == "UIComponent"; }); + if (pProp != aProps.end()) { - if( aProps[nProperty].Name == "UIComponent" ) + OUString aServiceName; + pProp->Value >>= aServiceName; + if( !aServiceName.isEmpty() ) { - OUString aServiceName; - aProps[nProperty].Value >>= aServiceName; - if( !aServiceName.isEmpty() ) + uno::Sequence<uno::Any> aDialogArgs(comphelper::InitAnyPropertySequence( { - uno::Sequence<uno::Any> aDialogArgs(comphelper::InitAnyPropertySequence( - { - {"ParentWindow", uno::Any(SfxStoringHelper::GetModelXWindow(m_xModel))}, - })); + {"ParentWindow", uno::Any(SfxStoringHelper::GetModelXWindow(m_xModel))}, + })); + + uno::Reference< ui::dialogs::XExecutableDialog > xFilterDialog( + comphelper::getProcessServiceFactory()->createInstanceWithArguments(aServiceName, aDialogArgs), uno::UNO_QUERY ); + uno::Reference< beans::XPropertyAccess > xFilterProperties( xFilterDialog, uno::UNO_QUERY ); + + if( xFilterDialog.is() && xFilterProperties.is() ) + { + bDialogUsed = true; - uno::Reference< ui::dialogs::XExecutableDialog > xFilterDialog( - comphelper::getProcessServiceFactory()->createInstanceWithArguments(aServiceName, aDialogArgs), uno::UNO_QUERY ); - uno::Reference< beans::XPropertyAccess > xFilterProperties( xFilterDialog, uno::UNO_QUERY ); + uno::Reference< document::XExporter > xExporter( xFilterDialog, uno::UNO_QUERY ); + if( xExporter.is() ) + xExporter->setSourceDocument( GetModel() ); - if( xFilterDialog.is() && xFilterProperties.is() ) + uno::Sequence< beans::PropertyValue > aPropsForDialog; + GetMediaDescr() >> aPropsForDialog; + xFilterProperties->setPropertyValues( aPropsForDialog ); + + if( !xFilterDialog->execute() ) { - bDialogUsed = true; - - uno::Reference< document::XExporter > xExporter( xFilterDialog, uno::UNO_QUERY ); - if( xExporter.is() ) - xExporter->setSourceDocument( GetModel() ); - - uno::Sequence< beans::PropertyValue > aPropsForDialog; - GetMediaDescr() >> aPropsForDialog; - xFilterProperties->setPropertyValues( aPropsForDialog ); - - if( !xFilterDialog->execute() ) - { - throw task::ErrorCodeIOException( - ("ModelData_Impl::ExecuteFilterDialog_Impl:" - " ERRCODE_IO_ABORT"), - uno::Reference< uno::XInterface >(), - sal_uInt32(ERRCODE_IO_ABORT)); - } - - uno::Sequence< beans::PropertyValue > aPropsFromDialog = - xFilterProperties->getPropertyValues(); - const sal_Int32 nPropsLen {aPropsFromDialog.getLength()}; - for ( sal_Int32 nInd = 0; nInd < nPropsLen; ++nInd ) - GetMediaDescr()[aPropsFromDialog[nInd].Name] = aPropsFromDialog[nInd].Value; + throw task::ErrorCodeIOException( + ("ModelData_Impl::ExecuteFilterDialog_Impl:" + " ERRCODE_IO_ABORT"), + uno::Reference< uno::XInterface >(), + sal_uInt32(ERRCODE_IO_ABORT)); } - } - break; + uno::Sequence< beans::PropertyValue > aPropsFromDialog = + xFilterProperties->getPropertyValues(); + for ( const auto& rProp : aPropsFromDialog ) + GetMediaDescr()[rProp.Name] = rProp.Value; + } } } } @@ -1740,23 +1735,21 @@ void SfxStoringHelper::SetDocInfoState( uno::Reference< beans::XPropertyContainer > xContainer( xSet, uno::UNO_QUERY ); uno::Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo(); uno::Sequence< beans::Property > lProps = xSetInfo->getProperties(); - const beans::Property* pProps = lProps.getConstArray(); - const sal_Int32 nPropLen = lProps.getLength(); - for (sal_Int32 i=0; i<nPropLen; ++i) + for (const beans::Property& rProp : lProps) { - uno::Any aValue = xPropSet->getPropertyValue( pProps[i].Name ); - if ( pProps[i].Attributes & css::beans::PropertyAttribute::REMOVABLE ) + uno::Any aValue = xPropSet->getPropertyValue( rProp.Name ); + if ( rProp.Attributes & css::beans::PropertyAttribute::REMOVABLE ) { try { // QUESTION: DefaultValue?! - xContainer->addProperty( pProps[i].Name, pProps[i].Attributes, aValue ); + xContainer->addProperty( rProp.Name, rProp.Attributes, aValue ); } catch (beans::PropertyExistException const&) {} try { // it is possible that the propertysets from XML and binary files differ; we shouldn't break then - xSet->setPropertyValue( pProps[i].Name, aValue ); + xSet->setPropertyValue( rProp.Name, aValue ); } catch ( const uno::Exception& ) {} } diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 5ecfad4faf8e..d4b30edfa5b2 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -259,9 +259,9 @@ bool SfxObjectShell::IsModified() if (pImpl->mpObjectContainer) { uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames(); - for ( sal_Int32 n=0; n<aNames.getLength(); n++ ) + for ( const auto& rName : aNames ) { - uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aNames[n] ); + uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( rName ); OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!" ); if ( xObj.is() ) { @@ -1802,10 +1802,9 @@ bool SfxObjectShell_Impl::hasTrustedScriptingSignature( bool bAllowUIToAddAuthor if ( nScriptingSignatureState == SignatureState::OK || nScriptingSignatureState == SignatureState::NOTVALIDATED ) { - for ( sal_Int32 nInd = 0; !bResult && nInd < aInfo.getLength(); nInd++ ) - { - bResult = xSigner->isAuthorTrusted( aInfo[nInd].Signer ); - } + bResult = std::any_of(aInfo.begin(), aInfo.end(), + [&xSigner](const security::DocumentSignatureInformation& rInfo) { + return xSigner->isAuthorTrusted( rInfo.Signer ); }); if ( !bResult && bAllowUIToAddAuthor ) { diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 517d30a7c950..69e106319b16 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1134,17 +1134,17 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) // Loop over the CMIS Properties to find cmis:isVersionSeriesCheckedOut bool bIsGoogleFile = false; bool bCheckedOut = false; - for ( sal_Int32 i = 0; i < aCmisProperties.getLength(); ++i ) + for ( const auto& rCmisProperty : aCmisProperties ) { - if ( aCmisProperties[i].Id == "cmis:isVersionSeriesCheckedOut" ) + if ( rCmisProperty.Id == "cmis:isVersionSeriesCheckedOut" ) { uno::Sequence< sal_Bool > bTmp; - aCmisProperties[i].Value >>= bTmp; + rCmisProperty.Value >>= bTmp; bCheckedOut = bTmp[0]; } // using title to know if it's a Google Drive file // maybe there's a safer way. - if ( aCmisProperties[i].Name == "title" ) + if ( rCmisProperty.Name == "title" ) bIsGoogleFile = true; } bShow = !bCheckedOut && !bIsGoogleFile; @@ -1168,17 +1168,14 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) if ( xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( ) ) { // Loop over the CMIS Properties to find cmis:isVersionSeriesCheckedOut - bool bFoundCheckedout = false; bool bCheckedOut = false; - for ( sal_Int32 i = 0; i < aCmisProperties.getLength() && !bFoundCheckedout; ++i ) + auto pProp = std::find_if(aCmisProperties.begin(), aCmisProperties.end(), + [](const document::CmisProperty& rProp) { return rProp.Id == "cmis:isVersionSeriesCheckedOut"; }); + if (pProp != aCmisProperties.end()) { - if ( aCmisProperties[i].Id == "cmis:isVersionSeriesCheckedOut" ) - { - bFoundCheckedout = true; - uno::Sequence< sal_Bool > bTmp; - aCmisProperties[i].Value >>= bTmp; - bCheckedOut = bTmp[0]; - } + uno::Sequence< sal_Bool > bTmp; + pProp->Value >>= bTmp; + bCheckedOut = bTmp[0]; } bShow = bCheckedOut; } @@ -1516,25 +1513,24 @@ SignatureState SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequen { bool bCertValid = true; SignatureState nResult = SignatureState::NOSIGNATURES; - int nInfos = aInfos.getLength(); bool bCompleteSignature = true; - if( nInfos ) + if( aInfos.hasElements() ) { nResult = SignatureState::OK; - for ( int n = 0; n < nInfos; n++ ) + for ( const auto& rInfo : aInfos ) { if ( bCertValid ) { - sal_Int32 nCertStat = aInfos[n].CertificateStatus; + sal_Int32 nCertStat = rInfo.CertificateStatus; bCertValid = nCertStat == security::CertificateValidity::VALID; } - if ( !aInfos[n].SignatureIsValid ) + if ( !rInfo.SignatureIsValid ) { nResult = SignatureState::BROKEN; break; // we know enough } - bCompleteSignature &= !aInfos[n].PartialDocumentSignature; + bCompleteSignature &= !rInfo.PartialDocumentSignature; } } diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 86ca3b03375f..9375989e35e3 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -537,11 +537,11 @@ bool SfxObjectShell::ImportFromGeneratedStream_Impl( pMedium->GetItemSet()->Put( aSet ); pMedium->CanDisposeStorage_Impl( false ); uno::Reference<text::XTextRange> xInsertTextRange; - for (sal_Int32 i = 0; i < rMediaDescr.getLength(); ++i) + for (const auto& rProp : rMediaDescr) { - if (rMediaDescr[i].Name == "TextInsertModeRange") + if (rProp.Name == "TextInsertModeRange") { - rMediaDescr[i].Value >>= xInsertTextRange; + rProp.Value >>= xInsertTextRange; } } @@ -884,56 +884,54 @@ ErrCode SfxObjectShell::HandleFilter( SfxMedium* pMedium, SfxObjectShell const * Any aAny = xFilterCFG->getByName( pFilter->GetName() ); if ( aAny >>= aProps ) { - sal_Int32 nPropertyCount = aProps.getLength(); - for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty ) - if( aProps[nProperty].Name == "UIComponent" ) + auto pProp = std::find_if(aProps.begin(), aProps.end(), + [](const PropertyValue& rProp) { return rProp.Name == "UIComponent"; }); + if (pProp != aProps.end()) + { + OUString aServiceName; + pProp->Value >>= aServiceName; + if( !aServiceName.isEmpty() ) { - OUString aServiceName; - aProps[nProperty].Value >>= aServiceName; - if( !aServiceName.isEmpty() ) + css::uno::Reference< XInteractionHandler > rHandler = pMedium->GetInteractionHandler(); + if( rHandler.is() ) { - css::uno::Reference< XInteractionHandler > rHandler = pMedium->GetInteractionHandler(); - if( rHandler.is() ) + // we need some properties in the media descriptor, so we have to make sure that they are in + Any aStreamAny; + aStreamAny <<= pMedium->GetInputStream(); + if ( pSet->GetItemState( SID_INPUTSTREAM ) < SfxItemState::SET ) + pSet->Put( SfxUnoAnyItem( SID_INPUTSTREAM, aStreamAny ) ); + if ( pSet->GetItemState( SID_FILE_NAME ) < SfxItemState::SET ) + pSet->Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) ); + if ( pSet->GetItemState( SID_FILTER_NAME ) < SfxItemState::SET ) + pSet->Put( SfxStringItem( SID_FILTER_NAME, pFilter->GetName() ) ); + + Sequence< PropertyValue > rProperties; + TransformItems( SID_OPENDOC, *pSet, rProperties ); + RequestFilterOptions* pFORequest = new RequestFilterOptions( pDoc->GetModel(), rProperties ); + + css::uno::Reference< XInteractionRequest > rRequest( pFORequest ); + rHandler->handle( rRequest ); + + if ( !pFORequest->isAbort() ) { - // we need some properties in the media descriptor, so we have to make sure that they are in - Any aStreamAny; - aStreamAny <<= pMedium->GetInputStream(); - if ( pSet->GetItemState( SID_INPUTSTREAM ) < SfxItemState::SET ) - pSet->Put( SfxUnoAnyItem( SID_INPUTSTREAM, aStreamAny ) ); - if ( pSet->GetItemState( SID_FILE_NAME ) < SfxItemState::SET ) - pSet->Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) ); - if ( pSet->GetItemState( SID_FILTER_NAME ) < SfxItemState::SET ) - pSet->Put( SfxStringItem( SID_FILTER_NAME, pFilter->GetName() ) ); - - Sequence< PropertyValue > rProperties; - TransformItems( SID_OPENDOC, *pSet, rProperties ); - RequestFilterOptions* pFORequest = new RequestFilterOptions( pDoc->GetModel(), rProperties ); - - css::uno::Reference< XInteractionRequest > rRequest( pFORequest ); - rHandler->handle( rRequest ); - - if ( !pFORequest->isAbort() ) - { - SfxAllItemSet aNewParams( pDoc->GetPool() ); - TransformParameters( SID_OPENDOC, - pFORequest->getFilterOptions(), - aNewParams ); - - const SfxStringItem* pFilterOptions = aNewParams.GetItem<SfxStringItem>(SID_FILE_FILTEROPTIONS, false); - if ( pFilterOptions ) - pSet->Put( *pFilterOptions ); - - const SfxUnoAnyItem* pFilterData = aNewParams.GetItem<SfxUnoAnyItem>(SID_FILTER_DATA, false); - if ( pFilterData ) - pSet->Put( *pFilterData ); - } - else - bAbort = true; + SfxAllItemSet aNewParams( pDoc->GetPool() ); + TransformParameters( SID_OPENDOC, + pFORequest->getFilterOptions(), + aNewParams ); + + const SfxStringItem* pFilterOptions = aNewParams.GetItem<SfxStringItem>(SID_FILE_FILTEROPTIONS, false); + if ( pFilterOptions ) + pSet->Put( *pFilterOptions ); + + const SfxUnoAnyItem* pFilterData = aNewParams.GetItem<SfxUnoAnyItem>(SID_FILTER_DATA, false); + if ( pFilterData ) + pSet->Put( *pFilterData ); } + else + bAbort = true; } - - break; } + } } if( bAbort ) @@ -1447,10 +1445,10 @@ bool SfxObjectShell::SaveTo_Impl if ( !xNewVerStor.is() || !xOldVerStor.is() ) throw uno::RuntimeException(); - for ( sal_Int32 n=0; n<aVersions.getLength(); n++ ) + for ( const auto& rVersion : aVersions ) { - if ( xOldVerStor->hasByName( aVersions[n].Identifier ) ) - xOldVerStor->copyElementTo( aVersions[n].Identifier, xNewVerStor, aVersions[n].Identifier ); + if ( xOldVerStor->hasByName( rVersion.Identifier ) ) + xOldVerStor->copyElementTo( rVersion.Identifier, xNewVerStor, rVersion.Identifier ); } uno::Reference< embed::XTransactedObject > xTransact( xNewVerStor, uno::UNO_QUERY ); @@ -2137,16 +2135,10 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, } OUString aFilterImplName; - sal_Int32 nFilterProps = aProps.getLength(); - for ( sal_Int32 nFilterProp = 0; nFilterProp<nFilterProps; nFilterProp++ ) - { - const beans::PropertyValue& rFilterProp = aProps[nFilterProp]; - if (rFilterProp.Name == "FilterService") - { - rFilterProp.Value >>= aFilterImplName; - break; - } - } + auto pProp = std::find_if(aProps.begin(), aProps.end(), + [](const beans::PropertyValue& rFilterProp) { return rFilterProp.Name == "FilterService"; }); + if (pProp != aProps.end()) + pProp->Value >>= aFilterImplName; uno::Reference< document::XFilter > xLoader; if ( !aFilterImplName.isEmpty() ) @@ -2180,10 +2172,9 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, bool bHasInputStream = false; bool bHasBaseURL = false; - sal_Int32 i; sal_Int32 nEnd = lDescriptor.getLength(); - for ( i = 0; i < nEnd; i++ ) + for ( sal_Int32 i = 0; i < nEnd; i++ ) { pNewValue[i] = pOldValue[i]; if ( pOldValue [i].Name == sInputStream ) @@ -2219,9 +2210,9 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, // modified flag, so needs to reset the flag to false after loading bool bRtn = xLoader->filter( aArgs ); uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames(); - for ( sal_Int32 n = 0; n < aNames.getLength(); ++n ) + for ( const auto& rName : aNames ) { - uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aNames[n] ); + uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( rName ); OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!" ); if ( xObj.is() ) { @@ -2314,16 +2305,10 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) xFilters->getByName( aFilterName ) >>= aProps; OUString aFilterImplName; - sal_Int32 nFilterProps = aProps.getLength(); - for ( sal_Int32 nFilterProp = 0; nFilterProp<nFilterProps; nFilterProp++ ) - { - const beans::PropertyValue& rFilterProp = aProps[nFilterProp]; - if (rFilterProp.Name == "FilterService") - { - rFilterProp.Value >>= aFilterImplName; - break; - } - } + auto pProp = std::find_if(aProps.begin(), aProps.end(), + [](const beans::PropertyValue& rFilterProp) { return rFilterProp.Name == "FilterService"; }); + if (pProp != aProps.end()) + pProp->Value >>= aFilterImplName; if ( !aFilterImplName.isEmpty() ) { @@ -2361,10 +2346,9 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) bool bHasBaseURL = false; bool bHasFilterName = false; bool bIsRedactMode = false; - sal_Int32 i; sal_Int32 nEnd = aOldArgs.getLength(); - for ( i = 0; i < nEnd; i++ ) + for ( sal_Int32 i = 0; i < nEnd; i++ ) { pNewValue[i] = pOldValue[i]; if ( pOldValue[i].Name == "FileName" ) @@ -3137,9 +3121,9 @@ bool SfxObjectShell::SaveCompletedChildren() if ( pImpl->mpObjectContainer ) { uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames(); - for ( sal_Int32 n=0; n<aNames.getLength(); n++ ) + for ( const auto& rName : aNames ) { - uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aNames[n] ); + uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( rName ); OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!" ); if ( xObj.is() ) { @@ -3244,9 +3228,9 @@ static bool StoragesOfUnknownMediaTypeAreCopied_Impl( const uno::Reference< embe try { uno::Sequence< OUString > aSubElements = xSource->getElementNames(); - for ( sal_Int32 nInd = 0; nInd < aSubElements.getLength(); nInd++ ) + for ( const auto& rSubElement : aSubElements ) { - if ( xSource->isStorageElement( aSubElements[nInd] ) ) + if ( xSource->isStorageElement( rSubElement ) ) { OUString aMediaType; const OUString aMediaTypePropName( "MediaType" ); @@ -3256,7 +3240,7 @@ static bool StoragesOfUnknownMediaTypeAreCopied_Impl( const uno::Reference< embe { uno::Reference< embed::XOptimizedStorage > xOptStorage( xSource, uno::UNO_QUERY_THROW ); bGotMediaType = - ( xOptStorage->getElementPropertyValue( aSubElements[nInd], aMediaTypePropName ) >>= aMediaType ); + ( xOptStorage->getElementPropertyValue( rSubElement, aMediaTypePropName ) >>= aMediaType ); } catch( uno::Exception& ) {} @@ -3265,14 +3249,14 @@ static bool StoragesOfUnknownMediaTypeAreCopied_Impl( const uno::Reference< embe { uno::Reference< embed::XStorage > xSubStorage; try { - xSubStorage = xSource->openStorageElement( aSubElements[nInd], embed::ElementModes::READ ); + xSubStorage = xSource->openStorageElement( rSubElement, embed::ElementModes::READ ); } catch( uno::Exception& ) {} if ( !xSubStorage.is() ) { xSubStorage = ::comphelper::OStorageHelper::GetTemporaryStorage(); - xSource->copyStorageElementLastCommitTo( aSubElements[nInd], xSubStorage ); + xSource->copyStorageElementLastCommitTo( rSubElement, xSubStorage ); } uno::Reference< beans::XPropertySet > xProps( xSubStorage, uno::UNO_QUERY_THROW ); @@ -3310,7 +3294,7 @@ static bool StoragesOfUnknownMediaTypeAreCopied_Impl( const uno::Reference< embe default: { - if ( !xTarget->hasByName( aSubElements[nInd] ) ) + if ( !xTarget->hasByName( rSubElement ) ) return false; } } diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index aad076b642a9..bd26b76d46c3 100644 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -333,24 +333,18 @@ void SfxPrintHelper::impl_setPrinter(const uno::Sequence< beans::PropertyValue > // new Printer-Name available? nChangeFlags = SfxPrinterChangeFlags::NONE; sal_Int32 lDummy = 0; - for ( int n = 0; n < rPrinter.getLength(); ++n ) + auto pProp = std::find_if(rPrinter.begin(), rPrinter.end(), + [](const beans::PropertyValue &rProp) { return rProp.Name == "Name"; }); + if (pProp != rPrinter.end()) { - // get Property-Value from printer description - const beans::PropertyValue &rProp = rPrinter.getConstArray()[n]; + OUString aPrinterName; + if ( ! ( pProp->Value >>= aPrinterName ) ) + throw css::lang::IllegalArgumentException(); - // Name-Property? - if ( rProp.Name == "Name" ) + if ( aPrinterName != pPrinter->GetName() ) { - OUString aPrinterName; - if ( ! ( rProp.Value >>= aPrinterName ) ) - throw css::lang::IllegalArgumentException(); - - if ( aPrinterName != pPrinter->GetName() ) - { - pPrinter = VclPtr<SfxPrinter>::Create( pPrinter->GetOptions().Clone(), aPrinterName ); - nChangeFlags = SfxPrinterChangeFlags::PRINTER; - } - break; + pPrinter = VclPtr<SfxPrinter>::Create( pPrinter->GetOptions().Clone(), aPrinterName ); + nChangeFlags = SfxPrinterChangeFlags::PRINTER; } } @@ -358,11 +352,9 @@ void SfxPrintHelper::impl_setPrinter(const uno::Sequence< beans::PropertyValue > view::PaperFormat nPaperFormat = view::PaperFormat_USER; // other properties - for ( int i = 0; i < rPrinter.getLength(); ++i ) + for ( const beans::PropertyValue &rProp : rPrinter ) { // get Property-Value from printer description - const beans::PropertyValue &rProp = rPrinter.getConstArray()[i]; - // PaperOrientation-Property? if ( rProp.Name == "PaperOrientation" ) { @@ -611,11 +603,9 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& sal_Int32 nProps = 0; bool bWaitUntilEnd = false; sal_Int16 nDuplexMode = css::view::DuplexMode::UNKNOWN; - for ( int n = 0; n < rOptions.getLength(); ++n ) + for ( const beans::PropertyValue &rProp : rOptions ) { // get Property-Value from options - const beans::PropertyValue &rProp = rOptions.getConstArray()[n]; - // FileName-Property? if ( rProp.Name == "FileName" ) { diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index db831f784dbb..3d0dc17836b6 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -401,20 +401,20 @@ SfxOwnFramesLocker::SfxOwnFramesLocker( SfxObjectShell const * pObjectShell ) SfxOwnFramesLocker::~SfxOwnFramesLocker() { - for ( sal_Int32 nInd = 0; nInd < m_aLockedFrames.getLength(); nInd++ ) + for ( auto& rFrame : m_aLockedFrames ) { try { - if ( m_aLockedFrames[nInd].is() ) + if ( rFrame.is() ) { // get vcl window related to the frame and unlock it - vcl::Window* pWindow = GetVCLWindow( m_aLockedFrames[nInd] ); + vcl::Window* pWindow = GetVCLWindow( rFrame ); if ( !pWindow ) throw RuntimeException(); pWindow->Enable(); - m_aLockedFrames[nInd].clear(); + rFrame.clear(); } } catch( Exception& ) @@ -969,8 +969,6 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs() TransformParameters( SID_OPENDOC, m_pData->m_seqArguments, aSet ); TransformItems( SID_OPENDOC, aSet, seqArgsOld ); - sal_Int32 nOrgLength = m_pData->m_seqArguments.getLength(); - sal_Int32 nOldLength = seqArgsOld.getLength(); sal_Int32 nNewLength = seqArgsNew.getLength(); // "WinExtent" property should be updated always. @@ -1016,26 +1014,20 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs() Sequence< beans::PropertyValue > aFinalCache; sal_Int32 nFinalLength = 0; - for ( sal_Int32 nOrg = 0; nOrg < nOrgLength; nOrg++ ) + for ( const auto& rOrg : m_pData->m_seqArguments ) { - sal_Int32 nOldInd = 0; - while ( nOldInd < nOldLength ) - { - if ( m_pData->m_seqArguments[nOrg].Name == seqArgsOld[nOldInd].Name ) - break; - nOldInd++; - } - - if ( nOldInd == nOldLength ) + auto bNew = std::none_of(seqArgsOld.begin(), seqArgsOld.end(), + [&rOrg](const beans::PropertyValue& rOld){ return rOld.Name == rOrg.Name; }); + if ( bNew ) { // the entity with this name should be new for seqArgsNew // since it is not supported by transformer seqArgsNew.realloc( ++nNewLength ); - seqArgsNew[ nNewLength - 1 ] = m_pData->m_seqArguments[nOrg]; + seqArgsNew[ nNewLength - 1 ] = rOrg; aFinalCache.realloc( ++nFinalLength ); - aFinalCache[ nFinalLength - 1 ] = m_pData->m_seqArguments[nOrg]; + aFinalCache[ nFinalLength - 1 ] = rOrg; } } @@ -1058,22 +1050,22 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs) "Medium could not be retrieved, unable to execute setArgs"); } - for (int i = 0; i < aArgs.getLength(); i++) + for (const auto& rArg : aArgs) { OUString sValue; - aArgs[i].Value >>= sValue; + rArg.Value >>= sValue; - if (aArgs[i].Name == "SuggestedSaveAsName") + if (rArg.Name == "SuggestedSaveAsName") { pMedium->GetItemSet()->Put(SfxStringItem(SID_SUGGESTEDSAVEASNAME, sValue)); } - else if (aArgs[i].Name == "SuggestedSaveAsDir") + else if (rArg.Name == "SuggestedSaveAsDir") { pMedium->GetItemSet()->Put(SfxStringItem(SID_SUGGESTEDSAVEASDIR, sValue)); } else { - throw lang::IllegalArgumentException("Setting property not supported: " + aArgs[i].Name, + throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name, comphelper::getProcessComponentContext(), 0); } } @@ -1518,28 +1510,28 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue > bool bCheckIn = false; bool bOnMainThread = false; - for ( sal_Int32 nInd = 0; nInd < aSeqArgs.getLength(); nInd++ ) + for ( const auto& rArg : aSeqArgs ) { // check that only acceptable parameters are provided here - if ( aSeqArgs[nInd].Name != "VersionComment" && aSeqArgs[nInd].Name != "Author" - && aSeqArgs[nInd].Name != "DontTerminateEdit" - && aSeqArgs[nInd].Name != "InteractionHandler" && aSeqArgs[nInd].Name != "StatusIndicator" - && aSeqArgs[nInd].Name != "VersionMajor" - && aSeqArgs[nInd].Name != "FailOnWarning" - && aSeqArgs[nInd].Name != "CheckIn" - && aSeqArgs[nInd].Name != "NoFileSync" - && aSeqArgs[nInd].Name != "OnMainThread" ) + if ( rArg.Name != "VersionComment" && rArg.Name != "Author" + && rArg.Name != "DontTerminateEdit" + && rArg.Name != "InteractionHandler" && rArg.Name != "StatusIndicator" + && rArg.Name != "VersionMajor" + && rArg.Name != "FailOnWarning" + && rArg.Name != "CheckIn" + && rArg.Name != "NoFileSync" + && rArg.Name != "OnMainThread" ) { - const OUString aMessage( "Unexpected MediaDescriptor parameter: " + aSeqArgs[nInd].Name ); + const OUString aMessage( "Unexpected MediaDescriptor parameter: " + rArg.Name ); throw lang::IllegalArgumentException( aMessage, Reference< XInterface >(), 1 ); } - else if ( aSeqArgs[nInd].Name == "CheckIn" ) + else if ( rArg.Name == "CheckIn" ) { - aSeqArgs[nInd].Value >>= bCheckIn; + rArg.Value >>= bCheckIn; } - else if (aSeqArgs[nInd].Name == "OnMainThread") + else if (rArg.Name == "OnMainThread") { - aSeqArgs[nInd].Value >>= bOnMainThread; + rArg.Value >>= bOnMainThread; } } @@ -1551,16 +1543,8 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue > nSlotId = SID_CHECKIN; sal_Int32 nLength = aSeqArgs.getLength( ); aArgs = Sequence< beans::PropertyValue >( nLength - 1 ); - sal_Int32 nNewI = 0; - for ( sal_Int32 i = 0; i < nLength; ++i ) - { - beans::PropertyValue aProp = aSeqArgs[i]; - if ( aProp.Name != "CheckIn" ) - { - aArgs[nNewI] = aProp; - ++nNewI; - } - } + std::copy_if(aSeqArgs.begin(), aSeqArgs.end(), aArgs.begin(), + [](const beans::PropertyValue& rProp) { return rProp.Name != "CheckIn"; }); } std::unique_ptr<SfxAllItemSet> pParams(new SfxAllItemSet( SfxGetpApp()->GetPool() )); @@ -1621,7 +1605,6 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue > "SfxBaseModel::storeSelf: " + nErrCode.toHexString(), Reference< XInterface >(), sal_uInt32(nErrCode)); } - } @@ -2691,21 +2674,15 @@ SfxMedium* SfxBaseModel::handleLoadError( ErrCode nError, SfxMedium* pMedium ) static void addTitle_Impl( Sequence < beans::PropertyValue >& rSeq, const OUString& rTitle ) { - sal_Int32 nCount = rSeq.getLength(); - sal_Int32 nArg; - - for ( nArg = 0; nArg < nCount; nArg++ ) + auto pProp = std::find_if(rSeq.begin(), rSeq.end(), + [](const beans::PropertyValue& rProp) { return rProp.Name == "Title"; }); + if (pProp != rSeq.end()) { - beans::PropertyValue& rProp = rSeq[nArg]; - if ( rProp.Name == "Title" ) - { - rProp.Value <<= rTitle; - break; - } + pProp->Value <<= rTitle; } - - if ( nArg == nCount ) + else { + sal_Int32 nCount = rSeq.getLength(); rSeq.realloc( nCount+1 ); rSeq[nCount].Name = "Title"; rSeq[nCount].Value <<= rTitle; @@ -3334,12 +3311,12 @@ Sequence< OUString > SAL_CALL SfxBaseModel::getDocumentSubStoragesNames() { Sequence< OUString > aTemp = xStorage->getElementNames(); sal_Int32 nResultSize = 0; - for ( sal_Int32 n = 0; n < aTemp.getLength(); n++ ) + for ( const auto& rName : aTemp ) { - if ( xStorage->isStorageElement( aTemp[n] ) ) + if ( xStorage->isStorageElement( rName ) ) { aResult.realloc( ++nResultSize ); - aResult[ nResultSize - 1 ] = aTemp[n]; + aResult[ nResultSize - 1 ] = rName; } } @@ -3412,14 +3389,12 @@ static void GetCommandFromSequence( OUString& rCommand, sal_Int32& nIndex, const { nIndex = -1; - for ( sal_Int32 i = 0; i < rSeqPropValue.getLength(); i++ ) + auto pPropValue = std::find_if(rSeqPropValue.begin(), rSeqPropValue.end(), + [](const beans::PropertyValue& rPropValue) { return rPropValue.Name == "Command"; }); + if (pPropValue != rSeqPropValue.end()) { - if ( rSeqPropValue[i].Name == "Command" ) - { - rSeqPropValue[i].Value >>= rCommand; - nIndex = i; - return; - } + pPropValue->Value >>= rCommand; + nIndex = static_cast<sal_Int32>(std::distance(rSeqPropValue.begin(), pPropValue)); } } diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 909a43ed30e5..ee00f17da016 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -912,14 +912,14 @@ void SfxTemplateManagerDlg::OnTemplateImportCategory(const OUString& sCategory) OUString aTemplateList; - for (size_t i = 0, n = aFiles.getLength(); i < n; ++i) + for (const auto& rFile : aFiles) { - if(!mxLocalView->copyFrom(pContItem,aFiles[i])) + if(!mxLocalView->copyFrom(pContItem, rFile)) { if (aTemplateList.isEmpty()) - aTemplateList = aFiles[i]; + aTemplateList = rFile; else - aTemplateList = aTemplateList + "\n" + aFiles[i]; + aTemplateList = aTemplateList + "\n" + rFile; } } @@ -1261,12 +1261,12 @@ static std::vector<OUString> lcl_getAllFactoryURLs () std::vector<OUString> aList; const css::uno::Sequence<OUString> &aServiceNames = aModOpt.GetAllServiceNames(); - for( sal_Int32 i=0, nCount = aServiceNames.getLength(); i < nCount; ++i ) + for( const auto& rServiceName : aServiceNames ) { - if ( ! SfxObjectFactory::GetStandardTemplate( aServiceNames[i] ).isEmpty() ) + if ( ! SfxObjectFactory::GetStandardTemplate( rServiceName ).isEmpty() ) { SvtModuleOptions::EFactory eFac = SvtModuleOptions::EFactory::WRITER; - SvtModuleOptions::ClassifyFactoryByName( aServiceNames[i], eFac ); + SvtModuleOptions::ClassifyFactoryByName( rServiceName, eFac ); aList.push_back(aModOpt.GetFactoryEmptyDocumentURL(eFac)); } } diff --git a/sfx2/source/doc/zoomitem.cxx b/sfx2/source/doc/zoomitem.cxx index aed98ad5c648..474ea51f68c6 100644 --- a/sfx2/source/doc/zoomitem.cxx +++ b/sfx2/source/doc/zoomitem.cxx @@ -108,21 +108,21 @@ bool SvxZoomItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) sal_Int16 nTypeTmp( 0 ); bool bAllConverted( true ); sal_Int16 nConvertedCount( 0 ); - for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ ) + for ( const auto& rProp : aSeq ) { - if ( aSeq[i].Name == ZOOM_PARAM_VALUE ) + if ( rProp.Name == ZOOM_PARAM_VALUE ) { - bAllConverted &= ( aSeq[i].Value >>= nValueTmp ); + bAllConverted &= ( rProp.Value >>= nValueTmp ); ++nConvertedCount; } - else if ( aSeq[i].Name == ZOOM_PARAM_VALUESET ) + else if ( rProp.Name == ZOOM_PARAM_VALUESET ) { - bAllConverted &= ( aSeq[i].Value >>= nValueSetTmp ); + bAllConverted &= ( rProp.Value >>= nValueSetTmp ); ++nConvertedCount; } - else if ( aSeq[i].Name == ZOOM_PARAM_TYPE ) + else if ( rProp.Name == ZOOM_PARAM_TYPE ) { - bAllConverted &= ( aSeq[i].Value >>= nTypeTmp ); + bAllConverted &= ( rProp.Value >>= nTypeTmp ); ++nConvertedCount; } } diff --git a/sfx2/source/inet/inettbc.cxx b/sfx2/source/inet/inettbc.cxx index 1afd5df14b5c..68d862eeced6 100644 --- a/sfx2/source/inet/inettbc.cxx +++ b/sfx2/source/inet/inettbc.cxx @@ -206,16 +206,15 @@ void SfxURLToolBoxControl_Impl::StateChanged pURLBox->Clear(); css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > lList = SvtHistoryOptions().GetList(ePICKLIST); - for (sal_Int32 i=0; i<lList.getLength(); ++i) + for (const css::uno::Sequence< css::beans::PropertyValue >& lProps : lList) { - css::uno::Sequence< css::beans::PropertyValue > lProps = lList[i]; - for (sal_Int32 p=0; p<lProps.getLength(); ++p) + for (const auto& rProp : lProps) { - if (lProps[p].Name != HISTORY_PROPERTYNAME_URL) + if (rProp.Name != HISTORY_PROPERTYNAME_URL) continue; OUString sURL; - if (!(lProps[p].Value>>=sURL) || sURL.isEmpty()) + if (!(rProp.Value>>=sURL) || sURL.isEmpty()) continue; INetURLObject aURL ( sURL ); diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 73ca5614935e..c31e0d9f43d6 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -57,28 +57,27 @@ static void NotebookbarAddonValues( { css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> aExtension = aAddonsItems.GetAddonsNotebookBarPart(nIdx); - for (int nSecIdx = 0; nSecIdx < aExtension.getLength(); nSecIdx++) + for (const css::uno::Sequence<css::beans::PropertyValue>& rExtensionVal : aExtension) { - css::uno::Sequence<css::beans::PropertyValue> pExtensionVal = aExtension[nSecIdx]; Image aImage; bool isBigImage = true; - for (int nRes = 0; nRes < pExtensionVal.getLength(); nRes++) + for (const auto& rProp : rExtensionVal) { OUString sImage; - if (pExtensionVal[nRes].Name == MERGE_NOTEBOOKBAR_IMAGEID) + if (rProp.Name == MERGE_NOTEBOOKBAR_IMAGEID) { - pExtensionVal[nRes].Value >>= sImage; + rProp.Value >>= sImage; aImage = framework::AddonsOptions().GetImageFromURL(sImage, isBigImage); } } if(!aImage) { - for (int nRes = 0; nRes < pExtensionVal.getLength(); nRes++) + for (const auto& rProp : rExtensionVal) { OUString sImage; - if (pExtensionVal[nRes].Name == MERGE_NOTEBOOKBAR_URL) + if (rProp.Name == MERGE_NOTEBOOKBAR_URL) { - pExtensionVal[nRes].Value >>= sImage; + rProp.Value >>= sImage; aImage = framework::AddonsOptions().GetImageFromURL(sImage, isBigImage); } } @@ -199,11 +198,10 @@ static const utl::OConfigurationNode lcl_getCurrentImplConfigNode(const Referenc const utl::OConfigurationNode aImplsNode = rNotebookbarNode.openNode("Applications/" + lcl_getAppName( eApp) + "/Modes"); const Sequence<OUString> aModeNodeNames( aImplsNode.getNodeNames() ); - const sal_Int32 nCount( aModeNodeNames.getLength() ); - for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex ) + for ( const auto& rModeNodeName : aModeNodeNames ) { - const utl::OConfigurationNode aImplNode( aImplsNode.openNode( aModeNodeNames[nReadIndex] ) ); + const utl::OConfigurationNode aImplNode( aImplsNode.openNode( rModeNodeName ) ); if ( !aImplNode.isValid() ) continue; @@ -295,11 +293,10 @@ bool SfxNotebookBar::IsActive() const utl::OConfigurationNode aModesNode = aAppNode.openNode("Modes"); const Sequence<OUString> aModeNodeNames( aModesNode.getNodeNames() ); - const sal_Int32 nCount( aModeNodeNames.getLength() ); - for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex ) + for ( const auto& rModeNodeName : aModeNodeNames ) { - const utl::OConfigurationNode aModeNode( aModesNode.openNode( aModeNodeNames[nReadIndex] ) ); + const utl::OConfigurationNode aModeNode( aModesNode.openNode( rModeNodeName ) ); if ( !aModeNode.isValid() ) continue; diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index 4e619d954c93..99ff4c0d80e3 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -36,6 +36,7 @@ #include <unotools/securityoptions.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/namedvaluecollection.hxx> +#include <comphelper/sequence.hxx> #include <eventsupplier.hxx> #include <sfx2/app.hxx> @@ -56,49 +57,46 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUString & aName, const uno:: ::osl::MutexGuard aGuard( maMutex ); // find the event in the list and replace the data - long nCount = maEventNames.getLength(); - for ( long i=0; i<nCount; i++ ) + auto nIndex = comphelper::findValue(maEventNames, aName); + if (nIndex != -1) { - if ( maEventNames[i] == aName ) + // check for correct type of the element + if ( !::comphelper::NamedValueCollection::canExtractFrom( rElement ) ) + throw lang::IllegalArgumentException(); + ::comphelper::NamedValueCollection const aEventDescriptor( rElement ); + + // create Configuration at first, creation might call this method also and that would overwrite everything + // we might have stored before! + if ( mpObjShell && !mpObjShell->IsLoading() ) + mpObjShell->SetModified(); + + ::comphelper::NamedValueCollection aNormalizedDescriptor; + NormalizeMacro( aEventDescriptor, aNormalizedDescriptor, mpObjShell ); + + OUString sType; + if ( ( aNormalizedDescriptor.size() == 1 ) + && !aNormalizedDescriptor.has( PROP_EVENT_TYPE ) //TODO + && ( aNormalizedDescriptor.get( PROP_EVENT_TYPE ) >>= sType ) + && ( sType.isEmpty() ) + ) { - // check for correct type of the element - if ( !::comphelper::NamedValueCollection::canExtractFrom( rElement ) ) - throw lang::IllegalArgumentException(); - ::comphelper::NamedValueCollection const aEventDescriptor( rElement ); - - // create Configuration at first, creation might call this method also and that would overwrite everything - // we might have stored before! - if ( mpObjShell && !mpObjShell->IsLoading() ) - mpObjShell->SetModified(); - - ::comphelper::NamedValueCollection aNormalizedDescriptor; - NormalizeMacro( aEventDescriptor, aNormalizedDescriptor, mpObjShell ); - - OUString sType; - if ( ( aNormalizedDescriptor.size() == 1 ) - && !aNormalizedDescriptor.has( PROP_EVENT_TYPE ) //TODO - && ( aNormalizedDescriptor.get( PROP_EVENT_TYPE ) >>= sType ) - && ( sType.isEmpty() ) - ) - { - // An empty event type means no binding. Therefore reset data - // to reflect that state. - // (that's for compatibility only. Nowadays, the Tools/Customize dialog should - // set an empty sequence to indicate the request for resetting the assignment.) - OSL_ENSURE( false, "legacy event assignment format detected" ); - aNormalizedDescriptor.clear(); - } + // An empty event type means no binding. Therefore reset data + // to reflect that state. + // (that's for compatibility only. Nowadays, the Tools/Customize dialog should + // set an empty sequence to indicate the request for resetting the assignment.) + OSL_ENSURE( false, "legacy event assignment format detected" ); + aNormalizedDescriptor.clear(); + } - if ( !aNormalizedDescriptor.empty() ) - { - maEventData[i] <<= aNormalizedDescriptor.getPropertyValues(); - } - else - { - maEventData[i].clear(); - } - return; + if ( !aNormalizedDescriptor.empty() ) + { + maEventData[nIndex] <<= aNormalizedDescriptor.getPropertyValues(); } + else + { + maEventData[nIndex].clear(); + } + return; } throw container::NoSuchElementException(); @@ -113,13 +111,9 @@ uno::Any SAL_CALL SfxEvents_Impl::getByName( const OUString& aName ) // find the event in the list and return the data - long nCount = maEventNames.getLength(); - - for ( long i=0; i<nCount; i++ ) - { - if ( maEventNames[i] == aName ) - return maEventData[i]; - } + auto nIndex = comphelper::findValue(maEventNames, aName); + if (nIndex != -1) + return maEventData[nIndex]; throw container::NoSuchElementException(); } @@ -137,15 +131,7 @@ sal_Bool SAL_CALL SfxEvents_Impl::hasByName( const OUString& aName ) // find the event in the list and return the data - long nCount = maEventNames.getLength(); - - for ( long i=0; i<nCount; i++ ) - { - if ( maEventNames[i] == aName ) - return true; - } - - return false; + return comphelper::findValue(maEventNames, aName) != -1; } @@ -176,26 +162,22 @@ void SfxEvents_Impl::Execute( uno::Any const & aEventData, const document::Docum OUString aLibrary; OUString aMacroName; - sal_Int32 nCount = aProperties.getLength(); - - if ( !nCount ) + if ( !aProperties.hasElements() ) return; - sal_Int32 nIndex = 0; - while ( nIndex < nCount ) + for ( const auto& rProp : aProperties ) { - if ( aProperties[ nIndex ].Name == PROP_EVENT_TYPE ) - aProperties[ nIndex ].Value >>= aType; - else if ( aProperties[ nIndex ].Name == PROP_SCRIPT ) - aProperties[ nIndex ].Value >>= aScript; - else if ( aProperties[ nIndex ].Name == PROP_LIBRARY ) - aProperties[ nIndex ].Value >>= aLibrary; - else if ( aProperties[ nIndex ].Name == PROP_MACRO_NAME ) - aProperties[ nIndex ].Value >>= aMacroName; + if ( rProp.Name == PROP_EVENT_TYPE ) + rProp.Value >>= aType; + else if ( rProp.Name == PROP_SCRIPT ) + rProp.Value >>= aScript; + else if ( rProp.Name == PROP_LIBRARY ) + rProp.Value >>= aLibrary; + else if ( rProp.Name == PROP_MACRO_NAME ) + rProp.Value >>= aMacroName; else { OSL_FAIL("Unknown property value!"); } - nIndex += 1; } if (aType == STAR_BASIC && !aScript.isEmpty()) @@ -271,20 +253,8 @@ void SAL_CALL SfxEvents_Impl::notifyEvent( const document::EventObject& aEvent ) // get the event name, find the corresponding data, execute the data - OUString aName = aEvent.EventName; - long nCount = maEventNames.getLength(); - long nIndex = 0; - bool bFound = false; - - while ( !bFound && ( nIndex < nCount ) ) - { - if ( maEventNames[nIndex] == aName ) - bFound = true; - else - nIndex += 1; - } - - if ( !bFound ) + auto nIndex = comphelper::findValue(maEventNames, aEvent.EventName); + if ( nIndex == -1 ) return; uno::Any aEventData = maEventData[ nIndex ]; @@ -345,26 +315,22 @@ std::unique_ptr<SvxMacro> SfxEvents_Impl::ConvertToMacro( const uno::Any& rEleme OUString aLibrary; OUString aMacroName; - long nCount = aProperties.getLength(); - long nIndex = 0; - - if ( !nCount ) + if ( !aProperties.hasElements() ) return pMacro; - while ( nIndex < nCount ) + for ( const auto& rProp : aProperties ) { - if ( aProperties[ nIndex ].Name == PROP_EVENT_TYPE ) - aProperties[ nIndex ].Value >>= aType; - else if ( aProperties[ nIndex ].Name == PROP_SCRIPT ) - aProperties[ nIndex ].Value >>= aScriptURL; - else if ( aProperties[ nIndex ].Name == PROP_LIBRARY ) - aProperties[ nIndex ].Value >>= aLibrary; - else if ( aProperties[ nIndex ].Name == PROP_MACRO_NAME ) - aProperties[ nIndex ].Value >>= aMacroName; + if ( rProp.Name == PROP_EVENT_TYPE ) + rProp.Value >>= aType; + else if ( rProp.Name == PROP_SCRIPT ) + rProp.Value >>= aScriptURL; + else if ( rProp.Name == PROP_LIBRARY ) + rProp.Value >>= aLibrary; + else if ( rProp.Name == PROP_MACRO_NAME ) + rProp.Value >>= aMacroName; else { OSL_FAIL("Unknown property value!"); } - nIndex += 1; } // Get the type diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx index 1dfcd370794c..9c6f7f1f442a 100644 --- a/sfx2/source/sidebar/ResourceManager.cxx +++ b/sfx2/source/sidebar/ResourceManager.cxx @@ -255,11 +255,9 @@ void ResourceManager::ReadDeckList() return; const Sequence<OUString> aDeckNodeNames (aDeckRootNode.getNodeNames()); - const sal_Int32 nCount(aDeckNodeNames.getLength()); maDecks.clear(); - for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex) + for (const OUString& aDeckName : aDeckNodeNames) { - const OUString aDeckName = aDeckNodeNames[nReadIndex]; if (comphelper::LibreOfficeKit::isActive()) { // Hide these decks in LOK as they aren't fully functional. @@ -285,7 +283,7 @@ void ResourceManager::ReadDeckList() rDeckDescriptor.mnOrderIndex = getInt32(aDeckNode, "OrderIndex"); rDeckDescriptor.mbExperimental = getBool(aDeckNode, "IsExperimental"); - rDeckDescriptor.msNodeName = aDeckNodeNames[nReadIndex]; + rDeckDescriptor.msNodeName = aDeckName; ReadContextList( aDeckNode, @@ -424,11 +422,10 @@ void ResourceManager::ReadPanelList() return; const Sequence<OUString> aPanelNodeNames (aPanelRootNode.getNodeNames()); - const sal_Int32 nCount (aPanelNodeNames.getLength()); maPanels.clear(); - for (sal_Int32 nReadIndex(0); nReadIndex<nCount; ++nReadIndex) + for (const auto& rPanelNodeName : aPanelNodeNames) { - const utl::OConfigurationNode aPanelNode (aPanelRootNode.openNode(aPanelNodeNames[nReadIndex])); + const utl::OConfigurationNode aPanelNode (aPanelRootNode.openNode(rPanelNodeName)); if (!aPanelNode.isValid()) continue; @@ -448,7 +445,7 @@ void ResourceManager::ReadPanelList() rPanelDescriptor.mbExperimental = getBool(aPanelNode, "IsExperimental"); const OUString sDefaultMenuCommand(getString(aPanelNode, "DefaultMenuCommand")); - rPanelDescriptor.msNodeName = aPanelNodeNames[nReadIndex]; + rPanelDescriptor.msNodeName = rPanelNodeName; ReadContextList(aPanelNode, rPanelDescriptor.maContextList, sDefaultMenuCommand); } @@ -484,16 +481,11 @@ void ResourceManager::ReadContextList ( { const Any aValue = rParentNode.getNodeValue("ContextList"); Sequence<OUString> aValues; - sal_Int32 nCount; - if (aValue >>= aValues) - nCount = aValues.getLength(); - else - nCount = 0; + if (!(aValue >>= aValues)) + return; - for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex) + for (const OUString& sValue : aValues) { - const OUString sValue (aValues[nIndex]); - sal_Int32 nCharacterIndex (0); const OUString sApplicationName (sValue.getToken(0, ',', nCharacterIndex).trim()); if (nCharacterIndex < 0) @@ -742,12 +734,8 @@ void ResourceManager::GetToolPanelNodeNames ( const utl::OConfigurationTreeRoot& aRoot) { Sequence<OUString> aChildNodeNames (aRoot.getNodeNames()); - const sal_Int32 nCount (aChildNodeNames.getLength()); - for (sal_Int32 nIndex(0); nIndex<nCount; ++nIndex) - { - if (aChildNodeNames[nIndex].startsWith( "private:resource/toolpanel/" )) - rMatchingNames.push_back(aChildNodeNames[nIndex]); - } + std::copy_if(aChildNodeNames.begin(), aChildNodeNames.end(), std::back_inserter(rMatchingNames), + [](const OUString& rChildNodeName) { return rChildNodeName.startsWith( "private:resource/toolpanel/" ); }); } bool ResourceManager::IsDeckEnabled ( diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 7819b96488c1..c5503a3c2aa5 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -478,7 +478,7 @@ Sequence< PropertyValue > SAL_CALL SfxBaseController::getCreationArguments() void SfxBaseController::SetCreationArguments_Impl( const Sequence< PropertyValue >& i_rCreationArgs ) { - OSL_ENSURE( m_pData->m_aCreationArgs.getLength() == 0, "SfxBaseController::SetCreationArguments_Impl: not intended to be called twice!" ); + OSL_ENSURE( !m_pData->m_aCreationArgs.hasElements(), "SfxBaseController::SetCreationArguments_Impl: not intended to be called twice!" ); m_pData->m_aCreationArgs = i_rCreationArgs; } @@ -837,12 +837,9 @@ uno::Sequence< Reference< frame::XDispatch > > SAL_CALL SfxBaseController::query sal_Int32 nCount = seqDescripts.getLength(); uno::Sequence< 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& rDesc) -> Reference< frame::XDispatch > { + return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, rDesc.SearchFlags); }); return lDispatcher; } @@ -1380,16 +1377,16 @@ void SfxBaseController::ShowInfoBars( ) // and find if it is a Google Drive file. bool bIsGoogleFile = false; bool bCheckedOut = false; - for ( sal_Int32 i = 0; i < aCmisProperties.getLength(); ++i ) + for ( const auto& rCmisProp : aCmisProperties ) { - if ( aCmisProperties[i].Id == "cmis:isVersionSeriesCheckedOut" ) { + if ( rCmisProp.Id == "cmis:isVersionSeriesCheckedOut" ) { uno::Sequence< sal_Bool > bTmp; - aCmisProperties[i].Value >>= bTmp; + rCmisProp.Value >>= bTmp; bCheckedOut = bTmp[0]; } // if it is a Google Drive file, we don't need the checkout bar, // still need the checkout feature for the version dialog. - if ( aCmisProperties[i].Name == "title" ) + if ( rCmisProp.Name == "title" ) bIsGoogleFile = true; } diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 243136eef9bc..4590d32743e6 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -129,8 +129,8 @@ SfxPrinterController::SfxPrinterController( const VclPtr<Printer>& i_rPrinter, // initialize extra ui options if( mxRenderable.is() ) { - for (sal_Int32 nProp=0; nProp < rProps.getLength(); ++nProp) - setValue( rProps[nProp].Name, rProps[nProp].Value ); + for (const auto& rProp : rProps) + setValue( rProp.Name, rProp.Value ); Sequence< beans::PropertyValue > aRenderOptions( 3 ); aRenderOptions[0].Name = "ExtraPrintUIOptions"; @@ -141,18 +141,17 @@ SfxPrinterController::SfxPrinterController( const VclPtr<Printer>& i_rPrinter, try { Sequence< beans::PropertyValue > aRenderParms( mxRenderable->getRenderer( 0 , getSelectionObject(), aRenderOptions ) ); - int nProps = aRenderParms.getLength(); - for( int i = 0; i < nProps; i++ ) + for( const auto& rRenderParm : aRenderParms ) { - if ( aRenderParms[i].Name == "ExtraPrintUIOptions" ) + if ( rRenderParm.Name == "ExtraPrintUIOptions" ) { Sequence< beans::PropertyValue > aUIProps; - aRenderParms[i].Value >>= aUIProps; + rRenderParm.Value >>= aUIProps; setUIOptions( aUIProps ); } - else if( aRenderParms[i].Name == "NUp" ) + else if( rRenderParm.Name == "NUp" ) { - setValue( aRenderParms[i].Name, aRenderParms[i].Value ); + setValue( rRenderParm.Name, rRenderParm.Value ); } } } @@ -590,16 +589,13 @@ void SfxViewShell::StartPrint( const uno::Sequence < beans::PropertyValue >& rPr Any aViewProp( makeAny( xController ) ); VclPtr<Printer> aPrt; - const beans::PropertyValue* pVal = rProps.getConstArray(); - for( sal_Int32 i = 0; i < rProps.getLength(); i++ ) + const beans::PropertyValue* pVal = std::find_if(rProps.begin(), rProps.end(), + [](const beans::PropertyValue& rVal) { return rVal.Name == "PrinterName"; }); + if (pVal != rProps.end()) { - if ( pVal[i].Name == "PrinterName" ) - { - OUString aPrinterName; - pVal[i].Value >>= aPrinterName; - aPrt.reset( VclPtr<Printer>::Create( aPrinterName ) ); - break; - } + OUString aPrinterName; + pVal->Value >>= aPrinterName; + aPrt.reset( VclPtr<Printer>::Create( aPrinterName ) ); } std::shared_ptr<vcl::PrinterController> xNewController(std::make_shared<SfxPrinterController>( @@ -709,29 +705,29 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) // the TransformItems function overwrite aProps TransformItems( nId, *rReq.GetArgs(), aProps, GetInterface()->GetSlot(nId) ); - for ( sal_Int32 nProp=0; nProp < aProps.getLength(); ++nProp ) + for ( auto& rProp : aProps ) { - if ( aProps[nProp].Name == "Copies" ) + if ( rProp.Name == "Copies" ) { - aProps[nProp]. Name = "CopyCount"; + rProp.Name = "CopyCount"; } - else if ( aProps[nProp].Name == "RangeText" ) + else if ( rProp.Name == "RangeText" ) { - aProps[nProp]. Name = "Pages"; + rProp.Name = "Pages"; } - else if ( aProps[nProp].Name == "Asynchron" ) + else if ( rProp.Name == "Asynchron" ) { - aProps[nProp]. Name = "Wait"; + rProp.Name = "Wait"; bool bAsynchron = false; - aProps[nProp].Value >>= bAsynchron; - aProps[nProp].Value <<= !bAsynchron; + rProp.Value >>= bAsynchron; + rProp.Value <<= !bAsynchron; } - else if ( aProps[nProp].Name == "Silent" ) + else if ( rProp.Name == "Silent" ) { - aProps[nProp]. Name = "MonitorVisible"; + rProp.Name = "MonitorVisible"; bool bPrintSilent = false; - aProps[nProp].Value >>= bPrintSilent; - aProps[nProp].Value <<= !bPrintSilent; + rProp.Value >>= bPrintSilent; + rProp.Value <<= !bPrintSilent; } } } |