summaryrefslogtreecommitdiff
path: root/oox/source/ole
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2018-03-31 12:17:55 +0200
committerJulien Nabet <serval2412@yahoo.fr>2018-03-31 13:25:28 +0200
commit0d06d1d16775fde3b0b34f3374907e07cbba763d (patch)
treebd74c0df75afe158c8ae9a67dd1c41d2cd2239eb /oox/source/ole
parent67c04cecc86f4a2e11da3b1fd982940a526cb6cb (diff)
Use for-range loops in oox (part2)
Change-Id: I7cbeb67a1adcdb9b0003e22b61789a882fc336c9 Reviewed-on: https://gerrit.libreoffice.org/52182 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'oox/source/ole')
-rw-r--r--oox/source/ole/axbinaryreader.cxx16
-rw-r--r--oox/source/ole/axbinarywriter.cxx16
-rw-r--r--oox/source/ole/axcontrol.cxx8
-rw-r--r--oox/source/ole/vbacontrol.cxx35
-rw-r--r--oox/source/ole/vbaproject.cxx18
5 files changed, 53 insertions, 40 deletions
diff --git a/oox/source/ole/axbinaryreader.cxx b/oox/source/ole/axbinaryreader.cxx
index 14ed7f382d9d..e478677f9aeb 100644
--- a/oox/source/ole/axbinaryreader.cxx
+++ b/oox/source/ole/axbinaryreader.cxx
@@ -249,9 +249,11 @@ bool AxBinaryPropertyReader::finalizeImport()
maInStrm.align( 4 );
if( ensureValid( mnPropFlags == 0 ) && !maLargeProps.empty() )
{
- for( ComplexPropVector::iterator aIt = maLargeProps.begin(), aEnd = maLargeProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
+ for (auto const& largeProp : maLargeProps)
{
- ensureValid( (*aIt)->readProperty( maInStrm ) );
+ if (!ensureValid())
+ break;
+ ensureValid( largeProp->readProperty( maInStrm ) );
maInStrm.align( 4 );
}
}
@@ -259,8 +261,14 @@ bool AxBinaryPropertyReader::finalizeImport()
// read stream properties (no stream alignment between properties!)
if( ensureValid() && !maStreamProps.empty() )
- for( ComplexPropVector::iterator aIt = maStreamProps.begin(), aEnd = maStreamProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
- ensureValid( (*aIt)->readProperty( maInStrm ) );
+ {
+ for (auto const& streamProp : maStreamProps)
+ {
+ if (!ensureValid())
+ break;
+ ensureValid( streamProp->readProperty( maInStrm ) );
+ }
+ }
return mbValid;
}
diff --git a/oox/source/ole/axbinarywriter.cxx b/oox/source/ole/axbinarywriter.cxx
index a0e4b83f23ce..b532527923ab 100644
--- a/oox/source/ole/axbinarywriter.cxx
+++ b/oox/source/ole/axbinarywriter.cxx
@@ -157,9 +157,11 @@ void AxBinaryPropertyWriter::finalizeExport()
maOutStrm.align( 4 );
if( !maLargeProps.empty() )
{
- for( ComplexPropVector::iterator aIt = maLargeProps.begin(), aEnd = maLargeProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
+ for (auto const& largeProp : maLargeProps)
{
- (*aIt)->writeProperty( maOutStrm );
+ if (!ensureValid())
+ break;
+ largeProp->writeProperty( maOutStrm );
maOutStrm.align( 4 );
}
}
@@ -168,8 +170,14 @@ void AxBinaryPropertyWriter::finalizeExport()
// write stream properties (no stream alignment between properties!)
if( !maStreamProps.empty() )
- for( ComplexPropVector::iterator aIt = maStreamProps.begin(), aEnd = maStreamProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
- (*aIt)->writeProperty( maOutStrm );
+ {
+ for (auto const& streamProp : maStreamProps)
+ {
+ if (!ensureValid())
+ break;
+ streamProp->writeProperty( maOutStrm );
+ }
+ }
sal_Int64 nPos = maOutStrm.tell();
maOutStrm.seek( mnPropFlagsStart - sizeof( mnBlockSize ) );
diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx
index ea6f461bbdcf..c8be2ca7c7bc 100644
--- a/oox/source/ole/axcontrol.cxx
+++ b/oox/source/ole/axcontrol.cxx
@@ -2589,15 +2589,15 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
{
msListData.realloc( listValues.size() );
sal_Int32 index = 0;
- for( std::vector< OUString >::iterator it = listValues.begin(); it != listValues.end(); ++it, ++index )
- msListData[ index ] = *it;
+ for (auto const& listValue : listValues)
+ msListData[ index++ ] = listValue;
}
if ( !selectedIndices.empty() )
{
msIndices.realloc( selectedIndices.size() );
sal_Int32 index = 0;
- for( std::vector< sal_Int16 >::iterator it = selectedIndices.begin(); it != selectedIndices.end(); ++it, ++index )
- msIndices[ index ] = *it;
+ for (auto const& selectedIndice : selectedIndices)
+ msIndices[ index++ ] = selectedIndice;
}
return true;
}
diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx
index 51e1b04223c8..36b9278c079d 100644
--- a/oox/source/ole/vbacontrol.cxx
+++ b/oox/source/ole/vbacontrol.cxx
@@ -424,13 +424,11 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla
}
typedef std::unordered_map< sal_uInt32, std::shared_ptr< VbaFormControl > > IdToPageMap;
IdToPageMap idToPage;
- VbaFormControlVector::iterator it = maControls.begin();
- VbaFormControlVector::iterator it_end = maControls.end();
AxArrayString sCaptions;
- for ( ; it != it_end; ++it )
+ for (auto const& control : maControls)
{
- auto& elem = (*it)->mxCtrlModel;
+ auto& elem = control->mxCtrlModel;
if (!elem)
{
SAL_WARN("oox", "empty control model");
@@ -438,9 +436,9 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla
}
if (elem->getControlType() == API_CONTROL_PAGE)
{
- VbaSiteModelRef xPageSiteRef = (*it)->mxSiteModel;
+ VbaSiteModelRef xPageSiteRef = control->mxSiteModel;
if ( xPageSiteRef.get() )
- idToPage[ xPageSiteRef->getId() ] = (*it);
+ idToPage[ xPageSiteRef->getId() ] = control;
}
else
{
@@ -599,9 +597,9 @@ void VbaFormControl::finalizeEmbeddedControls()
VbaControlNamesSet aControlNames;
VbaControlNameInserter aInserter( aControlNames );
maControls.forEach( aInserter );
- for( VbaFormControlVector::iterator aIt = maControls.begin(), aEnd = maControls.end(); aIt != aEnd; ++aIt )
- if( (*aIt)->mxCtrlModel.get() && ((*aIt)->mxCtrlModel->getControlType() == API_CONTROL_GROUPBOX) )
- (*aIt)->maControls.forEach( aInserter );
+ for (auto const& control : maControls)
+ if( control->mxCtrlModel.get() && (control->mxCtrlModel->getControlType() == API_CONTROL_GROUPBOX) )
+ control->maControls.forEach( aInserter );
/* Reprocess the sorted list and collect all option button controls that
are part of the same option group (determined by group name). All
@@ -618,10 +616,9 @@ void VbaFormControl::finalizeEmbeddedControls()
typedef VbaFormControlVectorMap::mapped_type VbaFormControlVectorRef;
bool bLastWasOptionButton = false;
- for( VbaFormControlVector::iterator aIt = maControls.begin(), aEnd = maControls.end(); aIt != aEnd; ++aIt )
+ for (auto const& control : maControls)
{
- VbaFormControlRef xControl = *aIt;
- const ControlModelBase* pCtrlModel = xControl->mxCtrlModel.get();
+ const ControlModelBase* pCtrlModel = control->mxCtrlModel.get();
if( const AxOptionButtonModel* pOptButtonModel = dynamic_cast< const AxOptionButtonModel* >( pCtrlModel ) )
{
@@ -647,7 +644,7 @@ void VbaFormControl::finalizeEmbeddedControls()
/* Append the option button to the control group (which is now
referred by the vector aControlGroups and by the map
aOptionGroups). */
- rxOptionGroup->push_back( xControl );
+ rxOptionGroup->push_back(control);
bLastWasOptionButton = true;
}
else
@@ -660,7 +657,7 @@ void VbaFormControl::finalizeEmbeddedControls()
}
// append the control to the last control group
VbaFormControlVector& rLastGroup = *aControlGroups.back();
- rLastGroup.push_back( xControl );
+ rLastGroup.push_back(control);
bLastWasOptionButton = false;
// if control is a group box, move all its children to this control
@@ -668,11 +665,11 @@ void VbaFormControl::finalizeEmbeddedControls()
{
/* Move all embedded controls of the group box relative to the
position of the group box. */
- xControl->moveEmbeddedToAbsoluteParent();
+ control->moveEmbeddedToAbsoluteParent();
/* Insert all children of the group box into the last control
group (following the group box). */
- rLastGroup.insert( rLastGroup.end(), xControl->maControls.begin(), xControl->maControls.end() );
- xControl->maControls.clear();
+ rLastGroup.insert( rLastGroup.end(), control->maControls.begin(), control->maControls.end() );
+ control->maControls.clear();
// check if last control of the group box is an option button
bLastWasOptionButton = dynamic_cast< const AxOptionButtonModel* >( rLastGroup.back()->mxCtrlModel.get() ) != nullptr;
}
@@ -681,8 +678,8 @@ void VbaFormControl::finalizeEmbeddedControls()
// flatten the vector of vectors of form controls to a single vector
maControls.clear();
- for( VbaFormControlVectorVector::iterator aIt = aControlGroups.begin(), aEnd = aControlGroups.end(); aIt != aEnd; ++aIt )
- maControls.insert( maControls.end(), (*aIt)->begin(), (*aIt)->end() );
+ for (auto const& controlGroup : aControlGroups)
+ maControls.insert( maControls.end(), controlGroup->begin(), controlGroup->end() );
}
void VbaFormControl::moveRelative( const AxPairData& rDistance )
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index 6a00b0cb3f57..5a779944e0e6 100644
--- a/oox/source/ole/vbaproject.cxx
+++ b/oox/source/ole/vbaproject.cxx
@@ -431,12 +431,12 @@ void VbaProject::importModulesAndForms( StorageBase& rVbaPrjStrg, const GraphicH
// create empty dummy modules
VbaModuleMap aDummyModules;
- for( DummyModuleMap::iterator aIt = maDummyModules.begin(), aEnd = maDummyModules.end(); aIt != aEnd; ++aIt )
+ for (auto const& dummyModule : maDummyModules)
{
- OSL_ENSURE( !maModules.has( aIt->first ) && !aDummyModules.has( aIt->first ), "VbaProject::importVba - multiple modules with the same name" );
- VbaModuleMap::mapped_type& rxModule = aDummyModules[ aIt->first ];
- rxModule.reset( new VbaModule( mxContext, mxDocModel, aIt->first, eTextEnc, bExecutable ) );
- rxModule->setType( aIt->second );
+ OSL_ENSURE( !maModules.has( dummyModule.first ) && !aDummyModules.has( dummyModule.first ), "VbaProject::importVba - multiple modules with the same name" );
+ VbaModuleMap::mapped_type& rxModule = aDummyModules[ dummyModule.first ];
+ rxModule.reset( new VbaModule( mxContext, mxDocModel, dummyModule.first, eTextEnc, bExecutable ) );
+ rxModule->setType( dummyModule.second );
}
/* Now it is time to load the source code. All modules will be inserted
@@ -483,16 +483,16 @@ void VbaProject::importModulesAndForms( StorageBase& rVbaPrjStrg, const GraphicH
storages that misses to mention a module for an existing form. */
::std::vector< OUString > aElements;
rVbaPrjStrg.getElementNames( aElements );
- for( ::std::vector< OUString >::iterator aIt = aElements.begin(), aEnd = aElements.end(); aIt != aEnd; ++aIt )
+ for (auto const& elem : aElements)
{
// try to open the element as storage
- if( *aIt != "VBA" )
+ if( elem != "VBA" )
{
- StorageRef xSubStrg = rVbaPrjStrg.openSubStorage( *aIt, false );
+ StorageRef xSubStrg = rVbaPrjStrg.openSubStorage( elem, false );
if( xSubStrg.get() ) try
{
// resolve module name from storage name (which equals the module stream name)
- VbaModule* pModule = maModulesByStrm.get( *aIt ).get();
+ VbaModule* pModule = maModulesByStrm.get( elem ).get();
OSL_ENSURE( pModule && (pModule->getType() == ModuleType::FORM),
"VbaProject::importVba - form substorage without form module" );
OUString aModuleName;