summaryrefslogtreecommitdiff
path: root/sfx2/source/view
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-07-21 19:39:26 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-07-29 18:44:33 +0200
commit25b200ff79c71c831bc7e6fe8b1ec0b5315e96d6 (patch)
treeb8e7cc15bfe82b677fb1bfc791b3f2f5a50fdc79 /sfx2/source/view
parentc762e3859973355b31f6676a8e697c5fd78c9970 (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/source/view')
-rw-r--r--sfx2/source/view/sfxbasecontroller.cxx19
-rw-r--r--sfx2/source/view/viewprn.cxx56
2 files changed, 34 insertions, 41 deletions
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;
}
}
}