[Libreoffice-commits] core.git: sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Jan 21 07:05:03 UTC 2019
sc/source/filter/xcl97/XclExpChangeTrack.cxx | 57 +--
sc/source/filter/xcl97/xcl97rec.cxx | 47 +--
sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx | 9
sc/source/filter/xml/XMLColumnRowGroupExport.cxx | 37 --
sc/source/filter/xml/XMLDDELinksContext.cxx | 13
sc/source/filter/xml/XMLExportDataPilot.cxx | 10
sc/source/filter/xml/XMLExportIterator.cxx | 50 +--
sc/source/filter/xml/XMLStylesExportHelper.cxx | 51 +--
sc/source/filter/xml/XMLStylesImportHelper.cxx | 35 --
sc/source/filter/xml/pivotsource.cxx | 5
sc/source/filter/xml/sheetdata.cxx | 70 +---
sc/source/filter/xml/xmlcelli.cxx | 71 +---
sc/source/filter/xml/xmldpimp.cxx | 14
sc/source/filter/xml/xmldrani.cxx | 9
sc/source/filter/xml/xmlexprt.cxx | 252 ++++++-----------
sc/source/filter/xml/xmlimprt.cxx | 36 --
sc/source/filter/xml/xmlstyle.cxx | 42 +-
sc/source/filter/xml/xmlstyli.cxx | 56 +--
18 files changed, 339 insertions(+), 525 deletions(-)
New commits:
commit 63ab0873f2a64a66212f6d0e8aa73575416e0a54
Author: Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sat Jan 19 14:41:58 2019 +0300
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Jan 21 08:04:38 2019 +0100
Simplify containers iterations in sc/source/filter/x*
Use range-based loop or replace with STL functions.
Change-Id: Ide655aa3633f548ac38c71b452b0ecfc91ee9128
Reviewed-on: https://gerrit.libreoffice.org/66636
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index 0354f8649d72..5affec70ed40 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -18,6 +18,7 @@
*/
#include <memory>
+#include <numeric>
#include <stdio.h>
#include <sot/storage.hxx>
#include <XclExpChangeTrack.hxx>
@@ -139,11 +140,10 @@ XclExpUserBViewList::XclExpUserBViewList( const ScChangeTrack& rChangeTrack )
bool bValidGUID = false;
const std::set<OUString>& rStrColl = rChangeTrack.GetUserCollection();
aViews.reserve(rStrColl.size());
- std::set<OUString>::const_iterator it = rStrColl.begin(), itEnd = rStrColl.end();
- for (; it != itEnd; ++it)
+ for (const auto& rStr : rStrColl)
{
lcl_GenerateGUID( aGUID, bValidGUID );
- aViews.emplace_back( *it, aGUID );
+ aViews.emplace_back( rStr, aGUID );
}
}
@@ -481,10 +481,9 @@ void XclExpXmlChTrHeader::SaveXml( XclExpXmlStream& rStrm )
pRevLogStrm->write(">");
- auto it = maActions.begin(), itEnd = maActions.end();
- for (; it != itEnd; ++it)
+ for (const auto& rxAction : maActions)
{
- (*it)->SaveXml(rStrm);
+ rxAction->SaveXml(rStrm);
}
pRevLogStrm->write("</")->writeId(XML_revisions)->write(">");
@@ -702,13 +701,12 @@ void XclExpChTrAction::AddDependentContents(
const ScChangeTrack& rChangeTrack )
{
ScChangeActionMap aActionMap;
- ScChangeActionMap::iterator itChangeAction;
rChangeTrack.GetDependents( const_cast<ScChangeAction*>(&rAction), aActionMap );
- for( itChangeAction = aActionMap.begin(); itChangeAction != aActionMap.end(); ++itChangeAction )
- if( itChangeAction->second->GetType() == SC_CAT_CONTENT )
+ for( const auto& rEntry : aActionMap )
+ if( rEntry.second->GetType() == SC_CAT_CONTENT )
SetAddAction( new XclExpChTrCellContent(
- *static_cast<const ScChangeActionContent*>(itChangeAction->second), rRoot, rIdBuffer ) );
+ *static_cast<const ScChangeActionContent*>(rEntry.second), rRoot, rIdBuffer ) );
}
void XclExpChTrAction::SetIndex( sal_uInt32& rIndex )
@@ -779,22 +777,22 @@ void XclExpChTrData::WriteFormula( XclExpStream& rStrm, const XclExpChTrTabIdBuf
OSL_ENSURE( mxTokArr && !mxTokArr->Empty(), "XclExpChTrData::Write - no formula" );
rStrm << *mxTokArr;
- for( XclExpRefLog::const_iterator aIt = maRefLog.begin(), aEnd = maRefLog.end(); aIt != aEnd; ++aIt )
+ for( const auto& rLogEntry : maRefLog )
{
- if( aIt->mpUrl && aIt->mpFirstTab )
+ if( rLogEntry.mpUrl && rLogEntry.mpFirstTab )
{
- rStrm << *aIt->mpUrl << sal_uInt8(0x01) << *aIt->mpFirstTab << sal_uInt8(0x02);
+ rStrm << *rLogEntry.mpUrl << sal_uInt8(0x01) << *rLogEntry.mpFirstTab << sal_uInt8(0x02);
}
else
{
- bool bSingleTab = aIt->mnFirstXclTab == aIt->mnLastXclTab;
+ bool bSingleTab = rLogEntry.mnFirstXclTab == rLogEntry.mnLastXclTab;
rStrm.SetSliceSize( bSingleTab ? 6 : 8 );
rStrm << sal_uInt8(0x01) << sal_uInt8(0x02) << sal_uInt8(0x00);
- rStrm << rTabIdBuffer.GetId( aIt->mnFirstXclTab );
+ rStrm << rTabIdBuffer.GetId( rLogEntry.mnFirstXclTab );
if( bSingleTab )
rStrm << sal_uInt8(0x02);
else
- rStrm << sal_uInt8(0x00) << rTabIdBuffer.GetId( aIt->mnLastXclTab );
+ rStrm << sal_uInt8(0x00) << rTabIdBuffer.GetId( rLogEntry.mnLastXclTab );
}
}
rStrm.SetSliceSize( 0 );
@@ -928,15 +926,14 @@ void XclExpChTrCellContent::GetCellData(
rpData->mxTokArr = GetFormulaCompiler().CreateFormula(
EXC_FMLATYPE_CELL, *pTokenArray, &pFmlCell->aPos, &rRefLog );
rpData->nType = EXC_CHTR_TYPE_FORMULA;
- std::size_t nSize = rpData->mxTokArr->GetSize() + 3;
-
- for( XclExpRefLog::const_iterator aIt = rRefLog.begin(), aEnd = rRefLog.end(); aIt != aEnd; ++aIt )
- {
- if( aIt->mpUrl && aIt->mpFirstTab )
- nSize += aIt->mpUrl->GetSize() + aIt->mpFirstTab->GetSize() + 2;
- else
- nSize += (aIt->mnFirstXclTab == aIt->mnLastXclTab) ? 6 : 8;
- }
+ std::size_t nSize = std::accumulate(rRefLog.begin(), rRefLog.end(),
+ static_cast<std::size_t>(rpData->mxTokArr->GetSize() + 3),
+ [](const std::size_t& rSum, const XclExpRefLogEntry& rLogEntry) {
+ if( rLogEntry.mpUrl && rLogEntry.mpFirstTab )
+ return rSum + rLogEntry.mpUrl->GetSize() + rLogEntry.mpFirstTab->GetSize() + 2;
+ else
+ return rSum + ((rLogEntry.mnFirstXclTab == rLogEntry.mnLastXclTab) ? 6 : 8);
+ });
rpData->nSize = ::std::min< std::size_t >( nSize, 0xFFFF );
rXclLength1 = 0x00000052;
rXclLength2 = 0x0018;
@@ -1624,9 +1621,8 @@ void XclExpChangeTrack::Write()
{
XclExpStream aXclStrm( *xSvStrm, GetRoot(), EXC_MAXRECSIZE_BIFF8 + 8 );
- RecListType::iterator pIter;
- for(pIter = maRecList.begin(); pIter != maRecList.end(); ++pIter)
- (*pIter)->Save(aXclStrm);
+ for(const auto& rxRec : maRecList)
+ rxRec->Save(aXclStrm);
xSvStrm->Commit();
}
@@ -1670,9 +1666,8 @@ void XclExpChangeTrack::WriteXml( XclExpXmlStream& rWorkbookStrm )
// contents of XclExpChangeTrack::WriteUserNamesStream()).
rWorkbookStrm.PushStream( pRevisionHeaders );
- RecListType::iterator pIter;
- for (pIter = maRecList.begin(); pIter != maRecList.end(); ++pIter)
- (*pIter)->SaveXml(rWorkbookStrm);
+ for (const auto& rxRec : maRecList)
+ rxRec->SaveXml(rWorkbookStrm);
rWorkbookStrm.PopStream();
}
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index 88d65fa9fc9e..6623f44d0791 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -162,8 +162,8 @@ void XclExpObjList::Save( XclExpStream& rStrm )
//! Escher must be written, even if there are no objects
pMsodrawingPerSheet->Save( rStrm );
- for ( auto pIter = maObjs.begin(); pIter != maObjs.end(); ++pIter )
- (*pIter)->Save( rStrm );
+ for ( const auto& rxObj : maObjs )
+ rxObj->Save( rStrm );
if( pSolverContainer )
pSolverContainer->Save( rStrm );
@@ -184,13 +184,8 @@ bool IsVmlObject( const XclObj *rObj )
sal_Int32 GetVmlObjectCount( XclExpObjList& rList )
{
- sal_Int32 nNumVml = 0;
-
- for ( auto pIter = rList.begin(); pIter != rList.end(); ++pIter )
- if( IsVmlObject( pIter->get() ) )
- ++nNumVml;
-
- return nNumVml;
+ return static_cast<sal_Int32>(std::count_if(rList.begin(), rList.end(),
+ [](const std::unique_ptr<XclObj>& rxObj) { return IsVmlObject( rxObj.get() ); }));
}
bool IsValidObject( const XclObj& rObj )
@@ -238,12 +233,12 @@ void SaveDrawingMLObjects( XclExpObjList& rList, XclExpXmlStream& rStrm, sal_Int
{
std::vector<XclObj*> aList;
aList.reserve(rList.size());
- for (auto it = rList.begin(), itEnd = rList.end(); it != itEnd; ++it)
+ for (const auto& rxObj : rList)
{
- if (IsVmlObject(it->get()) || !IsValidObject(**it))
+ if (IsVmlObject(rxObj.get()) || !IsValidObject(*rxObj))
continue;
- aList.push_back(it->get());
+ aList.push_back(rxObj.get());
}
if (aList.empty())
@@ -270,8 +265,8 @@ void SaveDrawingMLObjects( XclExpObjList& rList, XclExpXmlStream& rStrm, sal_Int
FSNS( XML_xmlns, XML_r ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(),
FSEND );
- for (auto it = aList.begin(), itEnd = aList.end(); it != itEnd; ++it)
- (*it)->SaveXml(rStrm);
+ for (const auto& rpObj : aList)
+ rpObj->SaveXml(rStrm);
pDrawing->endElement( FSNS( XML_xdr, XML_wsDr ) );
@@ -305,11 +300,11 @@ void SaveVmlObjects( XclExpObjList& rList, XclExpXmlStream& rStrm, sal_Int32& nV
FSNS( XML_xmlns, XML_w10 ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(vmlWord))).getStr(),
FSEND );
- for ( auto pIter = rList.begin(); pIter != rList.end(); ++pIter )
+ for ( const auto& rxObj : rList )
{
- if( !IsVmlObject( pIter->get() ) )
+ if( !IsVmlObject( rxObj.get() ) )
continue;
- (*pIter)->SaveXml( rStrm );
+ rxObj->SaveXml( rStrm );
}
pVmlDrawing->endElement( XML_xml );
@@ -879,8 +874,8 @@ void XclTxo::Save( XclExpStream& rStrm )
// CONTINUE for formatting runs
rStrm.StartRecord( EXC_ID_CONT, 8 * mpString->GetFormatsCount() );
const XclFormatRunVec& rFormats = mpString->GetFormats();
- for( XclFormatRunVec::const_iterator aIt = rFormats.begin(), aEnd = rFormats.end(); aIt != aEnd; ++aIt )
- rStrm << aIt->mnChar << aIt->mnFontIdx << sal_uInt32( 0 );
+ for( const auto& rFormat : rFormats )
+ rStrm << rFormat.mnChar << rFormat.mnFontIdx << sal_uInt32( 0 );
rStrm.EndRecord();
}
}
@@ -1444,11 +1439,10 @@ void ExcEScenario::SaveCont( XclExpStream& rStrm )
if( sComment.Len() )
rStrm << sComment;
- std::vector<ExcEScenarioCell>::iterator pIter;
- for( pIter = aCells.begin(); pIter != aCells.end(); ++pIter )
- pIter->WriteAddress( rStrm ); // pos of cell
- for( pIter = aCells.begin(); pIter != aCells.end(); ++pIter )
- pIter->WriteText( rStrm ); // string content
+ for( const auto& rCell : aCells )
+ rCell.WriteAddress( rStrm ); // pos of cell
+ for( const auto& rCell : aCells )
+ rCell.WriteText( rStrm ); // string content
rStrm.SetSliceSize( 2 );
rStrm.WriteZeroBytes( 2 * count ); // date format
}
@@ -1475,9 +1469,8 @@ void ExcEScenario::SaveXml( XclExpXmlStream& rStrm )
XML_comment, XESTRING_TO_PSZ( sComment ),
FSEND );
- std::vector<ExcEScenarioCell>::iterator pIter;
- for( pIter = aCells.begin(); pIter != aCells.end(); ++pIter )
- pIter->SaveXml( rStrm );
+ for( const auto& rCell : aCells )
+ rCell.SaveXml( rStrm );
rWorkbook->endElement( XML_scenario );
}
diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
index 12d611c081cc..c371fd3129a4 100644
--- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
@@ -799,13 +799,12 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc)
aItr = aActions.erase(aItr);
}
- aItr = aActions.begin();
- while (aItr != aActions.end())
+ for (const auto& rxAction : aActions)
{
- OSL_ENSURE((*aItr)->nActionType == SC_CAT_CONTENT, "wrong action type");
- SetNewCell(static_cast<ScMyContentAction*>(aItr->get()));
- aItr = aActions.erase(aItr);
+ OSL_ENSURE(rxAction->nActionType == SC_CAT_CONTENT, "wrong action type");
+ SetNewCell(static_cast<ScMyContentAction*>(rxAction.get()));
}
+ aActions.clear();
if (aProtect.getLength())
pTrack->SetProtection(aProtect);
else if (pDoc->GetChangeTrack() && pDoc->GetChangeTrack()->IsProtected())
diff --git a/sc/source/filter/xml/XMLColumnRowGroupExport.cxx b/sc/source/filter/xml/XMLColumnRowGroupExport.cxx
index 6ccf3cac4bc0..74e9e6a576f1 100644
--- a/sc/source/filter/xml/XMLColumnRowGroupExport.cxx
+++ b/sc/source/filter/xml/XMLColumnRowGroupExport.cxx
@@ -74,25 +74,13 @@ bool ScMyOpenCloseColumnRowGroup::IsGroupStart(const sal_Int32 nField)
bool bGroupStart(false);
if (!aTableStart.empty())
{
- ScMyColumnRowGroupVec::iterator aItr(aTableStart.begin());
- sal_Int32 nItrField = aItr->nField;
- if ( nItrField < nField )
- {
- // when used to find repeated rows at the beginning of a group,
- // aTableStart may contain entries before nField. They must be skipped here
- // (they will be used for OpenGroups later in the right order).
-
- ScMyColumnRowGroupVec::iterator aEnd(aTableStart.end());
- while ( aItr != aEnd && nItrField < nField )
- {
- ++aItr;
- if ( aItr != aEnd )
- nItrField = aItr->nField;
- }
- }
+ // when used to find repeated rows at the beginning of a group,
+ // aTableStart may contain entries before nField. They must be skipped here
+ // (they will be used for OpenGroups later in the right order).
- if (nItrField == nField)
- bGroupStart = true;
+ ScMyColumnRowGroupVec::iterator aItr = std::find_if_not(aTableStart.begin(), aTableStart.end(),
+ [&nField](const ScMyColumnRowGroup& rGroup) { return rGroup.nField < nField; });
+ bGroupStart = (aItr != aTableStart.end()) && (aItr->nField == nField);
}
return bGroupStart;
}
@@ -123,13 +111,7 @@ void ScMyOpenCloseColumnRowGroup::OpenGroups(const sal_Int32 nField)
bool ScMyOpenCloseColumnRowGroup::IsGroupEnd(const sal_Int32 nField)
{
- bool bGroupEnd(false);
- if (!aTableEnd.empty())
- {
- if (*(aTableEnd.begin()) == nField)
- bGroupEnd = true;
- }
- return bGroupEnd;
+ return (!aTableEnd.empty()) && (aTableEnd.front() == nField);
}
void ScMyOpenCloseColumnRowGroup::CloseGroups(const sal_Int32 nField)
@@ -151,12 +133,11 @@ void ScMyOpenCloseColumnRowGroup::CloseGroups(const sal_Int32 nField)
sal_Int32 ScMyOpenCloseColumnRowGroup::GetLast()
{
sal_Int32 maximum(-1);
- ScMyFieldGroupVec::iterator i(aTableEnd.begin());
- while (i != aTableEnd.end())
+ if (!aTableEnd.empty())
{
+ ScMyFieldGroupVec::iterator i(std::max_element(aTableEnd.begin(), aTableEnd.end()));
if (*i > maximum)
maximum = *i;
- ++i;
}
return maximum;
}
diff --git a/sc/source/filter/xml/XMLDDELinksContext.cxx b/sc/source/filter/xml/XMLDDELinksContext.cxx
index ae3c7bb46a8d..7ddf26f920ef 100644
--- a/sc/source/filter/xml/XMLDDELinksContext.cxx
+++ b/sc/source/filter/xml/XMLDDELinksContext.cxx
@@ -151,11 +151,9 @@ void SAL_CALL ScXMLDDELinkContext::endFastElement( sal_Int32 /*nElement*/ )
sal_Int32 nCol(0);
sal_Int32 nRow(-1);
sal_Int32 nIndex(0);
- ScDDELinkCells::iterator aItr(aDDELinkTable.begin());
- ScDDELinkCells::iterator aEndItr(aDDELinkTable.end());
svl::SharedStringPool& rPool = pDoc->GetSharedStringPool();
- while (aItr != aEndItr)
+ for (const auto& rDDELinkCell : aDDELinkTable)
{
if (nIndex % nColumns == 0)
{
@@ -167,15 +165,14 @@ void SAL_CALL ScXMLDDELinkContext::endFastElement( sal_Int32 /*nElement*/ )
SCSIZE nScCol( static_cast< SCSIZE >( nCol ) );
SCSIZE nScRow( static_cast< SCSIZE >( nRow ) );
- if( aItr->bEmpty )
+ if( rDDELinkCell.bEmpty )
pMatrix->PutEmpty( nScCol, nScRow );
- else if( aItr->bString )
- pMatrix->PutString(rPool.intern(aItr->sValue), nScCol, nScRow);
+ else if( rDDELinkCell.bString )
+ pMatrix->PutString(rPool.intern(rDDELinkCell.sValue), nScCol, nScRow);
else
- pMatrix->PutDouble( aItr->fValue, nScCol, nScRow );
+ pMatrix->PutDouble( rDDELinkCell.fValue, nScCol, nScRow );
++nIndex;
- ++aItr;
}
GetScImport().GetDocument()->SetDdeLinkResultMatrix( static_cast< sal_uInt16 >( nPosition ), pMatrix );
diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index 633cdc2d5eba..42cf6b501990 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -460,22 +460,22 @@ void ScXMLExportDataPilot::WriteMembers(const ScDPSaveDimension* pDim)
{
SvXMLElementExport aElemDPMs(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBERS, true, true);
rExport.CheckAttrList();
- for (ScDPSaveDimension::MemberList::const_iterator i=rMembers.begin(); i != rMembers.end() ; ++i)
+ for (const auto& rpMember : rMembers)
{
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, (*i)->GetName());
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, rpMember->GetName());
if (rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012)
{
// Export display names only for ODF 1.2 extended or later.
- const boost::optional<OUString> & pLayoutName = (*i)->GetLayoutName();
+ const boost::optional<OUString> & pLayoutName = rpMember->GetLayoutName();
if (pLayoutName)
rExport.AddAttribute(XML_NAMESPACE_TABLE_EXT, XML_DISPLAY_NAME, *pLayoutName);
}
OUStringBuffer sBuffer;
- ::sax::Converter::convertBool(sBuffer, (*i)->GetIsVisible());
+ ::sax::Converter::convertBool(sBuffer, rpMember->GetIsVisible());
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, sBuffer.makeStringAndClear());
- ::sax::Converter::convertBool(sBuffer, (*i)->GetShowDetails());
+ ::sax::Converter::convertBool(sBuffer, rpMember->GetShowDetails());
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_DETAILS, sBuffer.makeStringAndClear());
SvXMLElementExport aElemDPM(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_MEMBER, true, true);
rExport.CheckAttrList();
diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index b428f4803afb..24993493b3fc 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -95,9 +95,9 @@ void ScMyShapesContainer::SetCellData( ScMyCell& rMyCell )
void ScMyShapesContainer::SkipTable(SCTAB nSkip)
{
- ScMyShapeList::iterator aItr = aShapeList.begin();
- while( ( aItr != aShapeList.end() ) && ( aItr->aAddress.Tab() == nSkip ) )
- aItr = aShapeList.erase(aItr);
+ ScMyShapeList::iterator aItr = std::find_if_not(aShapeList.begin(), aShapeList.end(),
+ [&nSkip](const ScMyShape& rShape) { return rShape.aAddress.Tab() == nSkip; });
+ aShapeList.erase(aShapeList.begin(), aItr);
}
void ScMyShapesContainer::Sort()
@@ -137,18 +137,16 @@ bool ScMyNoteShapesContainer::GetFirstAddress( ScAddress& rCellAddress )
void ScMyNoteShapesContainer::SetCellData( ScMyCell& rMyCell )
{
- ScMyNoteShapeList::iterator aItr = aNoteShapeList.begin();
- while( (aItr != aNoteShapeList.end()) && (aItr->aPos == rMyCell.maCellAddress) )
- {
- aItr = aNoteShapeList.erase(aItr);
- }
+ ScMyNoteShapeList::iterator aItr = std::find_if_not(aNoteShapeList.begin(), aNoteShapeList.end(),
+ [&rMyCell](const ScMyNoteShape& rNoteShape) { return rNoteShape.aPos == rMyCell.maCellAddress; });
+ aNoteShapeList.erase(aNoteShapeList.begin(), aItr);
}
void ScMyNoteShapesContainer::SkipTable(SCTAB nSkip)
{
- ScMyNoteShapeList::iterator aItr = aNoteShapeList.begin();
- while( (aItr != aNoteShapeList.end() ) && ( aItr->aPos.Tab() == nSkip ) )
- aItr = aNoteShapeList.erase(aItr);
+ ScMyNoteShapeList::iterator aItr = std::find_if_not(aNoteShapeList.begin(), aNoteShapeList.end(),
+ [&nSkip](const ScMyNoteShape& rNoteShape) { return rNoteShape.aPos.Tab() == nSkip; });
+ aNoteShapeList.erase(aNoteShapeList.begin(), aItr);
}
void ScMyNoteShapesContainer::Sort()
@@ -231,9 +229,9 @@ void ScMyMergedRangesContainer::SetCellData( ScMyCell& rMyCell )
void ScMyMergedRangesContainer::SkipTable(SCTAB nSkip)
{
- ScMyMergedRangeList::iterator aItr = aRangeList.begin();
- while( ( aItr != aRangeList.end() ) && ( aItr->aCellRange.aStart.Tab() == nSkip ) )
- aItr = aRangeList.erase(aItr);
+ ScMyMergedRangeList::iterator aItr = std::find_if_not(aRangeList.begin(), aRangeList.end(),
+ [&nSkip](const ScMyMergedRange& rRange) { return rRange.aCellRange.aStart.Tab() == nSkip; });
+ aRangeList.erase(aRangeList.begin(), aItr);
}
void ScMyMergedRangesContainer::Sort()
@@ -303,9 +301,9 @@ void ScMyAreaLinksContainer::SetCellData( ScMyCell& rMyCell )
void ScMyAreaLinksContainer::SkipTable(SCTAB nSkip)
{
- ScMyAreaLinkList::iterator aItr = aAreaLinkList.begin();
- while( ( aItr != aAreaLinkList.end() ) && ( aItr->aDestRange.aStart.Tab() == nSkip ) )
- aItr = aAreaLinkList.erase(aItr);
+ ScMyAreaLinkList::iterator aItr = std::find_if_not(aAreaLinkList.begin(), aAreaLinkList.end(),
+ [&nSkip](const ScMyAreaLink& rAreaLink) { return rAreaLink.aDestRange.aStart.Tab() == nSkip; });
+ aAreaLinkList.erase(aAreaLinkList.begin(), aItr);
}
void ScMyAreaLinksContainer::Sort()
@@ -366,9 +364,9 @@ void ScMyEmptyDatabaseRangesContainer::SetCellData( ScMyCell& rMyCell )
void ScMyEmptyDatabaseRangesContainer::SkipTable(SCTAB nSkip)
{
- ScMyEmptyDatabaseRangeList::iterator aItr = aDatabaseList.begin();
- while( ( aItr != aDatabaseList.end() ) && ( aItr->aStart.Tab() == nSkip ) )
- aItr = aDatabaseList.erase(aItr);
+ ScMyEmptyDatabaseRangeList::iterator aItr = std::find_if_not(aDatabaseList.begin(), aDatabaseList.end(),
+ [&nSkip](const ScRange& rDatabase) { return rDatabase.aStart.Tab() == nSkip; });
+ aDatabaseList.erase(aDatabaseList.begin(), aItr);
}
void ScMyEmptyDatabaseRangesContainer::Sort()
@@ -448,9 +446,9 @@ void ScMyDetectiveObjContainer::SetCellData( ScMyCell& rMyCell )
void ScMyDetectiveObjContainer::SkipTable(SCTAB nSkip)
{
- ScMyDetectiveObjList::iterator aItr = aDetectiveObjList.begin();
- while( ( aItr != aDetectiveObjList.end() ) && ( aItr->aPosition.Tab() == nSkip ) )
- aItr = aDetectiveObjList.erase(aItr);
+ ScMyDetectiveObjList::iterator aItr = std::find_if_not(aDetectiveObjList.begin(), aDetectiveObjList.end(),
+ [&nSkip](const ScMyDetectiveObj& rDetectiveObj) { return rDetectiveObj.aPosition.Tab() == nSkip; });
+ aDetectiveObjList.erase(aDetectiveObjList.begin(), aItr);
}
void ScMyDetectiveObjContainer::Sort()
@@ -507,9 +505,9 @@ void ScMyDetectiveOpContainer::SetCellData( ScMyCell& rMyCell )
void ScMyDetectiveOpContainer::SkipTable(SCTAB nSkip)
{
- ScMyDetectiveOpList::iterator aItr = aDetectiveOpList.begin();
- while( (aItr != aDetectiveOpList.end()) && (aItr->aPosition.Tab() == nSkip) )
- aItr = aDetectiveOpList.erase(aItr);
+ ScMyDetectiveOpList::iterator aItr = std::find_if_not(aDetectiveOpList.begin(), aDetectiveOpList.end(),
+ [&nSkip](const ScMyDetectiveOp& rDetectiveOp) { return rDetectiveOp.aPosition.Tab() == nSkip; });
+ aDetectiveOpList.erase(aDetectiveOpList.begin(), aItr);
}
void ScMyDetectiveOpContainer::Sort()
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx
index 770cfbc518cc..fc351c62a302 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx
@@ -339,22 +339,20 @@ void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
if (!aValidationVec.empty())
{
SvXMLElementExport aElemVs(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATIONS, true, true);
- ScMyValidationVec::iterator aItr(aValidationVec.begin());
- ScMyValidationVec::iterator aEndItr(aValidationVec.end());
- while (aItr != aEndItr)
+ for (const auto& rValidation : aValidationVec)
{
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sName);
- OUString sCondition(GetCondition(rExport, *aItr));
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, rValidation.sName);
+ OUString sCondition(GetCondition(rExport, rValidation));
if (!sCondition.isEmpty())
{
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION, sCondition);
- if (aItr->bIgnoreBlanks)
+ if (rValidation.bIgnoreBlanks)
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_TRUE);
else
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_FALSE);
- if (aItr->aValidationType == sheet::ValidationType_LIST)
+ if (rValidation.aValidationType == sheet::ValidationType_LIST)
{
- switch (aItr->nShowList)
+ switch (rValidation.nShowList)
{
case sheet::TableValidationVisibility::INVISIBLE:
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_NO);
@@ -370,39 +368,39 @@ void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
}
}
}
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, GetBaseCellAddress(rExport.GetDocument(), aItr->aBaseCell));
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, GetBaseCellAddress(rExport.GetDocument(), rValidation.aBaseCell));
SvXMLElementExport aElemV(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, true, true);
- if (aItr->bShowImputMessage || !aItr->sImputMessage.isEmpty() || !aItr->sImputTitle.isEmpty())
+ if (rValidation.bShowImputMessage || !rValidation.sImputMessage.isEmpty() || !rValidation.sImputTitle.isEmpty())
{
- WriteMessage(rExport, aItr->sImputTitle, aItr->sImputMessage, aItr->bShowImputMessage, true);
+ WriteMessage(rExport, rValidation.sImputTitle, rValidation.sImputMessage, rValidation.bShowImputMessage, true);
}
- if (aItr->bShowErrorMessage || !aItr->sErrorMessage.isEmpty() || !aItr->sErrorTitle.isEmpty())
+ if (rValidation.bShowErrorMessage || !rValidation.sErrorMessage.isEmpty() || !rValidation.sErrorTitle.isEmpty())
{
- switch (aItr->aAlertStyle)
+ switch (rValidation.aAlertStyle)
{
case sheet::ValidationAlertStyle_INFO :
{
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_INFORMATION);
- WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, false);
+ WriteMessage(rExport, rValidation.sErrorTitle, rValidation.sErrorMessage, rValidation.bShowErrorMessage, false);
}
break;
case sheet::ValidationAlertStyle_WARNING :
{
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_WARNING);
- WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, false);
+ WriteMessage(rExport, rValidation.sErrorTitle, rValidation.sErrorMessage, rValidation.bShowErrorMessage, false);
}
break;
case sheet::ValidationAlertStyle_STOP :
{
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_STOP);
- WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, false);
+ WriteMessage(rExport, rValidation.sErrorTitle, rValidation.sErrorMessage, rValidation.bShowErrorMessage, false);
}
break;
case sheet::ValidationAlertStyle_MACRO :
{
{
//rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sErrorTitle);
- if (aItr->bShowErrorMessage)
+ if (rValidation.bShowErrorMessage)
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_TRUE);
else
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_FALSE);
@@ -412,13 +410,13 @@ void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
// #i47525# for a script URL the type and the property name for the URL
// are both "Script", for a simple macro name the type is "StarBasic"
// and the property name is "MacroName".
- bool bScriptURL = SfxApplication::IsXScriptURL( aItr->sErrorTitle );
+ bool bScriptURL = SfxApplication::IsXScriptURL( rValidation.sErrorTitle );
const OUString sScript("Script");
uno::Sequence<beans::PropertyValue> aSeq( comphelper::InitPropertySequence({
{ "EventType", uno::Any(bScriptURL ? sScript : OUString("StarBasic")) },
{ "Library", uno::Any(OUString()) },
- { bScriptURL ? sScript : OUString("MacroName"), uno::Any(aItr->sErrorTitle) }
+ { bScriptURL ? sScript : OUString("MacroName"), uno::Any(rValidation.sErrorTitle) }
}));
// 2) export the sequence
rExport.GetEventExport().ExportSingleEvent( aSeq, "OnError");
@@ -431,7 +429,6 @@ void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
}
}
}
- ++aItr;
}
}
}
@@ -643,17 +640,13 @@ bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange)
sal_Int32 ScRowFormatRanges::GetMaxRows() const
{
- ScMyRowFormatRangesList::const_iterator aItr(aRowFormatRanges.begin());
- ScMyRowFormatRangesList::const_iterator aEndItr(aRowFormatRanges.end());
sal_Int32 nMaxRows = MAXROW + 1;
- if (aItr != aEndItr)
+ if (!aRowFormatRanges.empty())
{
- while (aItr != aEndItr)
- {
- if ((*aItr).nRepeatRows < nMaxRows)
- nMaxRows = (*aItr).nRepeatRows;
- ++aItr;
- }
+ auto aItr = std::min_element(aRowFormatRanges.begin(), aRowFormatRanges.end(),
+ [](const ScMyRowFormatRange& a, const ScMyRowFormatRange& b) { return a.nRepeatRows < b.nRepeatRows; });
+ if ((*aItr).nRepeatRows < nMaxRows)
+ nMaxRows = (*aItr).nRepeatRows;
}
else
{
diff --git a/sc/source/filter/xml/XMLStylesImportHelper.cxx b/sc/source/filter/xml/XMLStylesImportHelper.cxx
index c4739ad68138..ed0f8f749c57 100644
--- a/sc/source/filter/xml/XMLStylesImportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesImportHelper.cxx
@@ -149,12 +149,9 @@ void ScMyStyleRanges::InsertCol(const sal_Int32 nCol, const sal_Int32 nTab)
if (pCurrencyList)
{
- ScMyCurrencyStylesSet::iterator aItr(pCurrencyList->begin());
- ScMyCurrencyStylesSet::iterator aEndItr(pCurrencyList->end());
- while (aItr != aEndItr)
+ for (auto& rCurrency : *pCurrencyList)
{
- aItr->mpRanges->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
- ++aItr;
+ rCurrency.mpRanges->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
}
}
}
@@ -163,9 +160,8 @@ void ScMyStyleRanges::SetStylesToRanges(const list<ScRange>& rRanges,
const OUString* pStyleName, const sal_Int16 nCellType,
const OUString* pCurrency, ScXMLImport& rImport)
{
- list<ScRange>::const_iterator itr = rRanges.begin(), itrEnd = rRanges.end();
- for (; itr != itrEnd; ++itr)
- rImport.SetStyleToRange(*itr, pStyleName, nCellType, pCurrency);
+ for (const auto& rRange : rRanges)
+ rImport.SetStyleToRange(rRange, pStyleName, nCellType, pCurrency);
}
void ScMyStyleRanges::SetStylesToRanges(const OUString* pStyleName, ScXMLImport& rImport)
@@ -221,14 +217,11 @@ void ScMyStyleRanges::SetStylesToRanges(const OUString* pStyleName, ScXMLImport&
}
if (pCurrencyList)
{
- ScMyCurrencyStylesSet::iterator aItr(pCurrencyList->begin());
- ScMyCurrencyStylesSet::iterator aEndItr(pCurrencyList->end());
- while (aItr != aEndItr)
+ for (const auto& rCurrency : *pCurrencyList)
{
list<ScRange> aList;
- aItr->mpRanges->getRangeList(aList);
- SetStylesToRanges(aList, pStyleName, util::NumberFormat::CURRENCY, &aItr->sCurrency, rImport);
- ++aItr;
+ rCurrency.mpRanges->getRangeList(aList);
+ SetStylesToRanges(aList, pStyleName, util::NumberFormat::CURRENCY, &rCurrency.sCurrency, rImport);
}
}
}
@@ -428,12 +421,9 @@ void ScMyStylesImportHelper::AddCell(const ScAddress& rAddress)
void ScMyStylesImportHelper::InsertCol(const sal_Int32 nCol, const sal_Int32 nTab)
{
ScXMLImport::MutexGuard aGuard(rImport);
- ScMyStylesSet::iterator aItr(aCellStyles.begin());
- ScMyStylesSet::iterator aEndItr(aCellStyles.end());
- while (aItr != aEndItr)
+ for (auto& rCellStyle : aCellStyles)
{
- aItr->xRanges->InsertCol(nCol, nTab);
- ++aItr;
+ rCellStyle.xRanges->InsertCol(nCol, nTab);
}
}
@@ -448,12 +438,9 @@ void ScMyStylesImportHelper::EndTable()
void ScMyStylesImportHelper::SetStylesToRanges()
{
- ScMyStylesSet::iterator aItr(aCellStyles.begin());
- ScMyStylesSet::iterator aEndItr(aCellStyles.end());
- while (aItr != aEndItr)
+ for (auto& rCellStyle : aCellStyles)
{
- aItr->xRanges->SetStylesToRanges(&aItr->sStyleName, rImport);
- ++aItr;
+ rCellStyle.xRanges->SetStylesToRanges(&rCellStyle.sStyleName, rImport);
}
aColDefaultStyles.clear();
aCellStyles.clear();
diff --git a/sc/source/filter/xml/pivotsource.cxx b/sc/source/filter/xml/pivotsource.cxx
index 8ae4d40b52aa..ff856fc5e3a6 100644
--- a/sc/source/filter/xml/pivotsource.cxx
+++ b/sc/source/filter/xml/pivotsource.cxx
@@ -67,11 +67,8 @@ struct SelectedPageProcessor
if (!pSaveData)
return;
- PivotTableSources::SelectedPagesType::const_iterator it = rItem.maSelectedPages.begin(), itEnd = rItem.maSelectedPages.end();
- for (; it != itEnd; ++it)
+ for (const auto& [rDimName, rSelected] : rItem.maSelectedPages)
{
- const OUString& rDimName = it->first;
- const OUString& rSelected = it->second;
ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(rDimName);
if (!pDim)
continue;
diff --git a/sc/source/filter/xml/sheetdata.cxx b/sc/source/filter/xml/sheetdata.cxx
index 68d0ada52ca5..7c61c8cfe880 100644
--- a/sc/source/filter/xml/sheetdata.cxx
+++ b/sc/source/filter/xml/sheetdata.cxx
@@ -173,11 +173,9 @@ void ScSheetSaveData::StoreInitialNamespaces( const SvXMLNamespaceMap& rNamespac
// so only a unordered_map of the prefixes is needed.
const NameSpaceHash& rNameHash = rNamespaces.GetAllEntries();
- NameSpaceHash::const_iterator aIter = rNameHash.begin(), aEnd = rNameHash.end();
- while (aIter != aEnd)
+ for (const auto& rEntry : rNameHash)
{
- maInitialPrefixes.insert( aIter->first );
- ++aIter;
+ maInitialPrefixes.insert( rEntry.first );
}
}
@@ -186,70 +184,52 @@ void ScSheetSaveData::StoreLoadedNamespaces( const SvXMLNamespaceMap& rNamespace
// store the loaded namespaces, so the prefixes in copied stream fragments remain valid
const NameSpaceHash& rNameHash = rNamespaces.GetAllEntries();
- NameSpaceHash::const_iterator aIter = rNameHash.begin(), aEnd = rNameHash.end();
- while (aIter != aEnd)
+ for (const auto& [rName, rxEntry] : rNameHash)
{
// ignore the initial namespaces
- if ( maInitialPrefixes.find( aIter->first ) == maInitialPrefixes.end() )
+ if ( maInitialPrefixes.find( rName ) == maInitialPrefixes.end() )
{
- const NameSpaceEntry& rEntry = *(aIter->second);
- maLoadedNamespaces.emplace_back( rEntry.sPrefix, rEntry.sName, rEntry.nKey );
+ maLoadedNamespaces.emplace_back( rxEntry->sPrefix, rxEntry->sName, rxEntry->nKey );
}
- ++aIter;
}
}
static bool lcl_NameInHash( const NameSpaceHash& rNameHash, const OUString& rName )
{
- NameSpaceHash::const_iterator aIter = rNameHash.begin(), aEnd = rNameHash.end();
- while (aIter != aEnd)
- {
- if ( aIter->second->sName == rName )
- return true;
-
- ++aIter;
- }
- return false; // not found
+ return std::any_of(rNameHash.begin(), rNameHash.end(),
+ [&rName](const NameSpaceHash::value_type& rEntry) { return rEntry.second->sName == rName; });
}
bool ScSheetSaveData::AddLoadedNamespaces( SvXMLNamespaceMap& rNamespaces ) const
{
// Add the loaded namespaces to the name space map.
- // first loop: only look for conflicts
+ // look for conflicts
// (if the loaded namespaces were added first, this might not be necessary)
const NameSpaceHash& rNameHash = rNamespaces.GetAllEntries();
- std::vector<ScLoadedNamespaceEntry>::const_iterator aIter = maLoadedNamespaces.begin();
- std::vector<ScLoadedNamespaceEntry>::const_iterator aEnd = maLoadedNamespaces.end();
- while (aIter != aEnd)
- {
- NameSpaceHash::const_iterator aHashIter = rNameHash.find( aIter->maPrefix );
- if ( aHashIter == rNameHash.end() )
- {
- if ( lcl_NameInHash( rNameHash, aIter->maName ) )
- {
- // a second prefix for the same name would confuse SvXMLNamespaceMap lookup,
- // so this is also considered a conflict
- return false;
- }
- }
- else if ( aHashIter->second->sName != aIter->maName )
- {
+ auto bConflict = std::any_of(maLoadedNamespaces.begin(), maLoadedNamespaces.end(),
+ [&rNameHash](const ScLoadedNamespaceEntry& rLoadedNamespace) {
+ NameSpaceHash::const_iterator aHashIter = rNameHash.find( rLoadedNamespace.maPrefix );
+
// same prefix, but different name: loaded namespaces can't be used
- return false;
- }
- ++aIter;
- }
+ bool bNameConflict = (aHashIter != rNameHash.end()) && (aHashIter->second->sName != rLoadedNamespace.maName);
+
+ // a second prefix for the same name would confuse SvXMLNamespaceMap lookup,
+ // so this is also considered a conflict
+ bool bPrefixConflict = (aHashIter == rNameHash.end()) && lcl_NameInHash(rNameHash, rLoadedNamespace.maName);
+
+ return bNameConflict || bPrefixConflict;
+ });
+ if (bConflict)
+ return false;
// only if there were no conflicts, add the entries that aren't in the map already
// (the key is needed if the same namespace is added later within an element)
- aIter = maLoadedNamespaces.begin();
- while (aIter != aEnd)
+ for (const auto& rLoadedNamespace : maLoadedNamespaces)
{
- NameSpaceHash::const_iterator aHashIter = rNameHash.find( aIter->maPrefix );
+ NameSpaceHash::const_iterator aHashIter = rNameHash.find( rLoadedNamespace.maPrefix );
if ( aHashIter == rNameHash.end() )
- rNamespaces.Add( aIter->maPrefix, aIter->maName, aIter->mnKey );
- ++aIter;
+ rNamespaces.Add( rLoadedNamespace.maPrefix, rLoadedNamespace.maName, rLoadedNamespace.mnKey );
}
return true; // success
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index aded39006850..1300b5b38afa 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -376,13 +376,12 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
std::unique_ptr<SfxPoolItem> pPoolItem;
sal_uInt16 nLastItemID = EE_CHAR_END + 1;
- std::vector<XMLPropertyState>::const_iterator it = rProps.begin(), itEnd = rProps.end();
- for (; it != itEnd; ++it)
+ for (const auto& rProp : rProps)
{
- if (it->mnIndex == -1 || it->mnIndex >= nEntryCount)
+ if (rProp.mnIndex == -1 || rProp.mnIndex >= nEntryCount)
continue;
- const OUString& rName = xMapper->GetEntryAPIName(it->mnIndex);
+ const OUString& rName = xMapper->GetEntryAPIName(rProp.mnIndex);
const ScXMLEditAttributeMap::Entry* pEntry = rEditAttrMap.getEntryByAPIName(rName);
if (!pEntry)
continue;
@@ -404,7 +403,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxFontItem(pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_WEIGHT:
@@ -414,7 +413,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxWeightItem(WEIGHT_NORMAL, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_FONTHEIGHT:
@@ -424,7 +423,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxFontHeightItem(240, 100, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_ITALIC:
@@ -434,7 +433,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxPostureItem(ITALIC_NONE, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_UNDERLINE:
@@ -442,7 +441,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxUnderlineItem(LINESTYLE_NONE, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_OVERLINE:
@@ -450,7 +449,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxOverlineItem(LINESTYLE_NONE, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_COLOR:
@@ -458,7 +457,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxColorItem(pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_WLM:
@@ -466,7 +465,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxWordLineModeItem(false, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_STRIKEOUT:
@@ -474,7 +473,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxCrossedOutItem(STRIKEOUT_NONE, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_RELIEF:
@@ -482,7 +481,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxCharReliefItem(FontRelief::NONE, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_OUTLINE:
@@ -490,7 +489,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxContourItem(false, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_SHADOW:
@@ -498,7 +497,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxShadowedItem(false, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_KERNING:
@@ -506,7 +505,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxKerningItem(0, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_PAIRKERNING:
@@ -514,7 +513,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxAutoKernItem(false, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_FONTWIDTH:
@@ -522,7 +521,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxCharScaleWidthItem(100, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_ESCAPEMENT:
@@ -530,7 +529,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxEscapementItem(pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_EMPHASISMARK:
@@ -538,7 +537,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxEmphasisMarkItem(FontEmphasisMark::NONE, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
case EE_CHAR_LANGUAGE:
@@ -548,7 +547,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
if (!pPoolItem)
pPoolItem.reset(new SvxLanguageItem(LANGUAGE_DONTKNOW, pEntry->mnItemID));
- pPoolItem->PutValue(it->maValue, pEntry->mnFlag);
+ pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
}
break;
default:
@@ -940,12 +939,9 @@ void ScXMLTableRowCellContext::SetAnnotation(const ScAddress& rPos)
ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rXMLImport.GetModel())->GetSheetSaveData();
pSheetData->HandleNoteStyles( mxAnnotationData->maStyleName, mxAnnotationData->maTextStyle, rPos );
- std::vector<ScXMLAnnotationStyleEntry>::const_iterator aIter = mxAnnotationData->maContentStyles.begin();
- std::vector<ScXMLAnnotationStyleEntry>::const_iterator aEnd = mxAnnotationData->maContentStyles.end();
- while (aIter != aEnd)
+ for (const auto& rContentStyle : mxAnnotationData->maContentStyles)
{
- pSheetData->AddNoteContentStyle( aIter->mnFamily, aIter->maName, rPos, aIter->maSelection );
- ++aIter;
+ pSheetData->AddNoteContentStyle( rContentStyle.mnFamily, rContentStyle.maName, rPos, rContentStyle.maSelection );
}
}
@@ -957,18 +953,15 @@ void ScXMLTableRowCellContext::SetDetectiveObj( const ScAddress& rPosition )
LockSolarMutex();
ScDetectiveFunc aDetFunc( rXMLImport.GetDocument(), rPosition.Tab() );
uno::Reference<container::XIndexAccess> xShapesIndex (rXMLImport.GetTables().GetCurrentXShapes(), uno::UNO_QUERY); // make draw page
- ScMyImpDetectiveObjVec::iterator aItr(pDetectiveObjVec->begin());
- ScMyImpDetectiveObjVec::iterator aEndItr(pDetectiveObjVec->end());
- while(aItr != aEndItr)
+ for(const auto& rDetectiveObj : *pDetectiveObjVec)
{
- aDetFunc.InsertObject( aItr->eObjType, rPosition, aItr->aSourceRange, aItr->bHasError );
+ aDetFunc.InsertObject( rDetectiveObj.eObjType, rPosition, rDetectiveObj.aSourceRange, rDetectiveObj.bHasError );
if (xShapesIndex.is())
{
sal_Int32 nShapes = xShapesIndex->getCount();
uno::Reference < drawing::XShape > xShape;
rXMLImport.GetShapeImport()->shapeWithZIndexAdded(xShape, nShapes);
}
- ++aItr;
}
}
}
@@ -1105,17 +1098,11 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
else
{
// This text either has format runs, has field(s), or consists of multiple lines.
- {
- ParaFormatsType::const_iterator it = maFormats.begin(), itEnd = maFormats.end();
- for (; it != itEnd; ++it)
- mpEditEngine->QuickSetAttribs((*it)->maItemSet, (*it)->maSelection);
- }
+ for (const auto& rxFormat : maFormats)
+ mpEditEngine->QuickSetAttribs(rxFormat->maItemSet, rxFormat->maSelection);
- {
- FieldsType::const_iterator it = maFields.begin(), itEnd = maFields.end();
- for (; it != itEnd; ++it)
- mpEditEngine->QuickInsertField(SvxFieldItem(*(*it)->mpData, EE_FEATURE_FIELD), (*it)->maSelection);
- }
+ for (const auto& rxField : maFields)
+ mpEditEngine->QuickInsertField(SvxFieldItem(*rxField->mpData, EE_FEATURE_FIELD), rxField->maSelection);
// This edit engine uses the SfxItemPool instance returned
// from pDoc->GetEditPool() to create the text object, which
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index cefdc779a85f..5a5dc443857b 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -946,19 +946,13 @@ void SAL_CALL ScXMLDataPilotFieldContext::endFastElement( sal_Int32 /*nElement*/
aGroupDim.SetDateInfo(aInfo, nGroupPart);
else
{
- ::std::vector<ScXMLDataPilotGroup>::const_iterator aItr(aGroups.begin());
- ::std::vector<ScXMLDataPilotGroup>::const_iterator aEndItr(aGroups.end());
- while (aItr != aEndItr)
+ for (const auto& rGroup : aGroups)
{
- ScDPSaveGroupItem aItem(aItr->aName);
- ::std::vector<OUString>::const_iterator aMembersItr(aItr->aMembers.begin());
- ::std::vector<OUString>::const_iterator aMembersEndItr(aItr->aMembers.end());
- while (aMembersItr != aMembersEndItr)
+ ScDPSaveGroupItem aItem(rGroup.aName);
+ for (const auto& rMember : rGroup.aMembers)
{
- aItem.AddElement(*aMembersItr);
- ++aMembersItr;
+ aItem.AddElement(rMember);
}
- ++aItr;
aGroupDim.AddGroupItem(aItem);
}
}
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index ddd0596e0520..7439bdc41256 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -331,15 +331,15 @@ std::unique_ptr<ScDBData> ScXMLDatabaseRangeContext::ConvertToDBData(const OUStr
aParam.bCaseSens = bSubTotalsIsCaseSensitive;
aParam.bDoSort = bSubTotalsSortGroups;
aParam.bAscending = bSubTotalsAscending;
- std::vector <ScSubTotalRule>::iterator itr = aSubTotalRules.begin(), itrEnd = aSubTotalRules.end();
- for (size_t nPos = 0; itr != itrEnd; ++itr, ++nPos)
+ size_t nPos = 0;
+ for (const auto& rSubTotalRule : aSubTotalRules)
{
if (nPos >= MAXSUBTOTAL)
break;
- const uno::Sequence<sheet::SubTotalColumn>& rColumns = itr->aSubTotalColumns;
+ const uno::Sequence<sheet::SubTotalColumn>& rColumns = rSubTotalRule.aSubTotalColumns;
sal_Int32 nColCount = rColumns.getLength();
- sal_Int16 nGroupColumn = itr->nSubTotalRuleGroupFieldNumber;
+ sal_Int16 nGroupColumn = rSubTotalRule.nSubTotalRuleGroupFieldNumber;
aParam.bGroupActive[nPos] = true;
aParam.nField[nPos] = static_cast<SCCOL>(nGroupColumn);
@@ -362,6 +362,7 @@ std::unique_ptr<ScDBData> ScXMLDatabaseRangeContext::ConvertToDBData(const OUStr
aParam.pSubTotals[nPos] = nullptr;
aParam.pFunctions[nPos] = nullptr;
}
+ ++nPos;
}
pData->SetSubTotalParam(aParam);
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index cb59fca9c129..e15f71a4ec91 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -590,13 +590,10 @@ void ScXMLExport::CollectShapesAutoStyles(SCTAB nTableCount)
ScMyTableShapes* pTableShapes(pSharedData->GetTableShapes());
if (pTableShapes)
{
- ScMyTableXShapes::iterator aItr((*pTableShapes)[nTable].begin());
- ScMyTableXShapes::iterator aEndItr((*pTableShapes)[nTable].end());
- while (aItr != aEndItr)
+ for (const auto& rxShape : (*pTableShapes)[nTable])
{
- GetShapeExport()->collectShapeAutoStyles(*aItr);
+ GetShapeExport()->collectShapeAutoStyles(rxShape);
IncrementProgressBar(false);
- ++aItr;
}
}
if (pShapeList)
@@ -612,11 +609,10 @@ void ScXMLExport::CollectShapesAutoStyles(SCTAB nTableCount)
if (pSharedData->GetNoteShapes())
{
const ScMyNoteShapeList& rNoteShapes = pSharedData->GetNoteShapes()->GetNotes();
- for (ScMyNoteShapeList::const_iterator aNoteShapeItr = rNoteShapes.begin(), aNoteShapeEndItr = rNoteShapes.end();
- aNoteShapeItr != aNoteShapeEndItr; ++aNoteShapeItr)
+ for (const auto& rNoteShape : rNoteShapes)
{
- if ( aNoteShapeItr->aPos.Tab() == nTable )
- GetShapeExport()->collectShapeAutoStyles(aNoteShapeItr->xShape);
+ if ( rNoteShape.aPos.Tab() == nTable )
+ GetShapeExport()->collectShapeAutoStyles(rNoteShape.xShape);
}
}
}
@@ -888,10 +884,9 @@ void ScXMLExport::ExportExternalRefCacheStyles()
vector<sal_uInt32> aNumFmts;
pRefMgr->getAllCachedNumberFormats(aNumFmts);
const OUString aDefaultStyle = OUString("Default").intern();
- for (vector<sal_uInt32>::const_iterator itr = aNumFmts.begin(), itrEnd = aNumFmts.end();
- itr != itrEnd; ++itr)
+ for (const auto& rNumFmt : aNumFmts)
{
- sal_Int32 nNumFmt = static_cast<sal_Int32>(*itr);
+ sal_Int32 nNumFmt = static_cast<sal_Int32>(rNumFmt);
addDataStyle(nNumFmt);
@@ -949,10 +944,8 @@ const SvxFieldData* toXMLPropertyStates(
const SvxFieldData* pField = nullptr;
sal_Int32 nEntryCount = xMapper->GetEntryCount();
rPropStates.reserve(rSecAttrs.size());
- std::vector<const SfxPoolItem*>::const_iterator it = rSecAttrs.begin(), itEnd = rSecAttrs.end();
- for (; it != itEnd; ++it)
+ for (const SfxPoolItem* p : rSecAttrs)
{
- const SfxPoolItem* p = *it;
if (p->Which() == EE_FEATURE_FIELD)
{
pField = static_cast<const SvxFieldItem*>(p)->GetField();
@@ -1256,10 +1249,9 @@ void ScXMLExport::ExportCellTextAutoStyles(sal_Int32 nTable)
if (aAttrs.empty())
continue;
- std::vector<editeng::Section>::const_iterator itSec = aAttrs.begin(), itSecEnd = aAttrs.end();
- for (; itSec != itSecEnd; ++itSec)
+ for (const auto& rSec : aAttrs)
{
- const std::vector<const SfxPoolItem*>& rSecAttrs = itSec->maAttributes;
+ const std::vector<const SfxPoolItem*>& rSecAttrs = rSec.maAttributes;
if (rSecAttrs.empty())
// No formats applied to this section. Skip it.
continue;
@@ -2154,16 +2146,12 @@ void ScXMLExport::AddStyleFromColumn(const uno::Reference<beans::XPropertySet>&
std::vector<XMLPropertyState> aPropStates(xColumnStylesExportPropertySetMapper->Filter(xColumnProperties));
if(!aPropStates.empty())
{
- std::vector< XMLPropertyState >::iterator aItr(aPropStates.begin());
- std::vector< XMLPropertyState >::iterator aEndItr(aPropStates.end());
- while (aItr != aEndItr)
+ auto aItr = std::find_if(aPropStates.begin(), aPropStates.end(),
+ [this](const XMLPropertyState& rPropState) {
+ return xColumnStylesPropertySetMapper->GetEntryContextId(rPropState.mnIndex) == CTF_SC_ISVISIBLE; });
+ if (aItr != aPropStates.end())
{
- if (xColumnStylesPropertySetMapper->GetEntryContextId(aItr->mnIndex) == CTF_SC_ISVISIBLE)
- {
- aItr->maValue >>= rIsVisible;
- break;
- }
- ++aItr;
+ aItr->maValue >>= rIsVisible;
}
OUString sParent;
@@ -2275,11 +2263,9 @@ void ScXMLExport::collectAutoStyles()
// stored cell styles
const std::vector<ScCellStyleEntry>& rCellEntries = pSheetData->GetCellStyles();
- std::vector<ScCellStyleEntry>::const_iterator aCellIter = rCellEntries.begin();
- std::vector<ScCellStyleEntry>::const_iterator aCellEnd = rCellEntries.end();
- while (aCellIter != aCellEnd)
+ for (const auto& rCellEntry : rCellEntries)
{
- ScAddress aPos = aCellIter->maCellPos;
+ ScAddress aPos = rCellEntry.maCellPos;
sal_Int32 nTable = aPos.Tab();
bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
if (bCopySheet)
@@ -2288,18 +2274,15 @@ void ScXMLExport::collectAutoStyles()
uno::Reference <beans::XPropertySet> xProperties(
xTable->getCellByPosition( aPos.Col(), aPos.Row() ), uno::UNO_QUERY );
- AddStyleFromCells(xProperties, xTable, nTable, &aCellIter->maName);
+ AddStyleFromCells(xProperties, xTable, nTable, &rCellEntry.maName);
}
- ++aCellIter;
}
// stored column styles
const std::vector<ScCellStyleEntry>& rColumnEntries = pSheetData->GetColumnStyles();
- std::vector<ScCellStyleEntry>::const_iterator aColumnIter = rColumnEntries.begin();
- std::vector<ScCellStyleEntry>::const_iterator aColumnEnd = rColumnEntries.end();
- while (aColumnIter != aColumnEnd)
+ for (const auto& rColumnEntry : rColumnEntries)
{
- ScAddress aPos = aColumnIter->maCellPos;
+ ScAddress aPos = rColumnEntry.maCellPos;
sal_Int32 nTable = aPos.Tab();
bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
if (bCopySheet)
@@ -2310,18 +2293,15 @@ void ScXMLExport::collectAutoStyles()
sal_Int32 nIndex(-1);
bool bIsVisible(true);
- AddStyleFromColumn( xColumnProperties, &aColumnIter->maName, nIndex, bIsVisible );
+ AddStyleFromColumn( xColumnProperties, &rColumnEntry.maName, nIndex, bIsVisible );
}
- ++aColumnIter;
}
// stored row styles
const std::vector<ScCellStyleEntry>& rRowEntries = pSheetData->GetRowStyles();
- std::vector<ScCellStyleEntry>::const_iterator aRowIter = rRowEntries.begin();
- std::vector<ScCellStyleEntry>::const_iterator aRowEnd = rRowEntries.end();
- while (aRowIter != aRowEnd)
+ for (const auto& rRowEntry : rRowEntries)
{
- ScAddress aPos = aRowIter->maCellPos;
+ ScAddress aPos = rRowEntry.maCellPos;
sal_Int32 nTable = aPos.Tab();
bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
if (bCopySheet)
@@ -2331,18 +2311,15 @@ void ScXMLExport::collectAutoStyles()
uno::Reference<beans::XPropertySet> xRowProperties(xTableRows->getByIndex( aPos.Row() ), uno::UNO_QUERY);
sal_Int32 nIndex(-1);
- AddStyleFromRow( xRowProperties, &aRowIter->maName, nIndex );
+ AddStyleFromRow( xRowProperties, &rRowEntry.maName, nIndex );
}
- ++aRowIter;
}
// stored table styles
const std::vector<ScCellStyleEntry>& rTableEntries = pSheetData->GetTableStyles();
- std::vector<ScCellStyleEntry>::const_iterator aTableIter = rTableEntries.begin();
- std::vector<ScCellStyleEntry>::const_iterator aTableEnd = rTableEntries.end();
- while (aTableIter != aTableEnd)
+ for (const auto& rTableEntry : rTableEntries)
{
- ScAddress aPos = aTableIter->maCellPos;
+ ScAddress aPos = rTableEntry.maCellPos;
sal_Int32 nTable = aPos.Tab();
bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
if (bCopySheet)
@@ -2352,12 +2329,11 @@ void ScXMLExport::collectAutoStyles()
if (xTableProperties.is())
{
std::vector<XMLPropertyState> aPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties));
- OUString sName( aTableIter->maName );
+ OUString sName( rTableEntry.maName );
GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TABLE_TABLE, OUString(), aPropStates);
GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_TABLE, sName);
}
}
- ++aTableIter;
}
// stored styles for notes
@@ -2366,11 +2342,9 @@ void ScXMLExport::collectAutoStyles()
GetShapeExport(); // make sure the graphics styles family is added
const std::vector<ScNoteStyleEntry>& rNoteEntries = pSheetData->GetNoteStyles();
- std::vector<ScNoteStyleEntry>::const_iterator aNoteIter = rNoteEntries.begin();
- std::vector<ScNoteStyleEntry>::const_iterator aNoteEnd = rNoteEntries.end();
- while (aNoteIter != aNoteEnd)
+ for (const auto& rNoteEntry : rNoteEntries)
{
- ScAddress aPos = aNoteIter->maCellPos;
+ ScAddress aPos = rNoteEntry.maCellPos;
SCTAB nTable = aPos.Tab();
bool bCopySheet = pDoc->IsStreamValid( nTable );
if (bCopySheet)
@@ -2386,25 +2360,24 @@ void ScXMLExport::collectAutoStyles()
uno::Reference<beans::XPropertySet> xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY );
if (xShapeProperties.is())
{
- if ( !aNoteIter->maStyleName.isEmpty() )
+ if ( !rNoteEntry.maStyleName.isEmpty() )
{
std::vector<XMLPropertyState> aPropStates(xShapeMapper->Filter(xShapeProperties));
- OUString sName( aNoteIter->maStyleName );
+ OUString sName( rNoteEntry.maStyleName );
GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_SD_GRAPHICS_ID, OUString(), aPropStates);
GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_SD_GRAPHICS_ID, sName);
}
- if ( !aNoteIter->maTextStyle.isEmpty() )
+ if ( !rNoteEntry.maTextStyle.isEmpty() )
{
std::vector<XMLPropertyState> aPropStates(
GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(xShapeProperties));
- OUString sName( aNoteIter->maTextStyle );
+ OUString sName( rNoteEntry.maTextStyle );
GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, OUString(), aPropStates);
GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName);
}
}
}
}
- ++aNoteIter;
}
// note paragraph styles
@@ -2412,11 +2385,9 @@ void ScXMLExport::collectAutoStyles()
rtl::Reference<SvXMLExportPropertyMapper> xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper();
const std::vector<ScTextStyleEntry>& rNoteParaEntries = pSheetData->GetNoteParaStyles();
- std::vector<ScTextStyleEntry>::const_iterator aNoteParaIter = rNoteParaEntries.begin();
- std::vector<ScTextStyleEntry>::const_iterator aNoteParaEnd = rNoteParaEntries.end();
- while (aNoteParaIter != aNoteParaEnd)
+ for (const auto& rNoteParaEntry : rNoteParaEntries)
{
- ScAddress aPos = aNoteParaIter->maCellPos;
+ ScAddress aPos = rNoteParaEntry.maCellPos;
SCTAB nTable = aPos.Tab();
bool bCopySheet = pDoc->IsStreamValid( nTable );
if (bCopySheet)
@@ -2428,17 +2399,16 @@ void ScXMLExport::collectAutoStyles()
const std::shared_ptr< SdrCaptionObj >& pDrawObj = pNote->GetOrCreateCaption( aPos );
uno::Reference<container::XEnumerationAccess> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xParaProp(
- lcl_GetEnumerated( xCellText, aNoteParaIter->maSelection.nStartPara ), uno::UNO_QUERY );
+ lcl_GetEnumerated( xCellText, rNoteParaEntry.maSelection.nStartPara ), uno::UNO_QUERY );
if ( xParaProp.is() )
{
std::vector<XMLPropertyState> aPropStates(xParaPropMapper->Filter(xParaProp));
- OUString sName( aNoteParaIter->maName );
+ OUString sName( rNoteParaEntry.maName );
GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, OUString(), aPropStates);
GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName);
}
}
}
- ++aNoteParaIter;
}
// note text styles
@@ -2446,11 +2416,9 @@ void ScXMLExport::collectAutoStyles()
rtl::Reference<SvXMLExportPropertyMapper> xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this );
const std::vector<ScTextStyleEntry>& rNoteTextEntries = pSheetData->GetNoteTextStyles();
- std::vector<ScTextStyleEntry>::const_iterator aNoteTextIter = rNoteTextEntries.begin();
- std::vector<ScTextStyleEntry>::const_iterator aNoteTextEnd = rNoteTextEntries.end();
- while (aNoteTextIter != aNoteTextEnd)
+ for (const auto& rNoteTextEntry : rNoteTextEntries)
{
- ScAddress aPos = aNoteTextIter->maCellPos;
+ ScAddress aPos = rNoteTextEntry.maCellPos;
SCTAB nTable = aPos.Tab();
bool bCopySheet = pDoc->IsStreamValid( nTable );
if (bCopySheet)
@@ -2465,26 +2433,23 @@ void ScXMLExport::collectAutoStyles()
ScDrawTextCursor* pCursor = ScDrawTextCursor::getImplementation( xCursorProp );
if (pCursor)
{
- pCursor->SetSelection( aNoteTextIter->maSelection );
+ pCursor->SetSelection( rNoteTextEntry.maSelection );
std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(xCursorProp));
- OUString sName( aNoteTextIter->maName );
+ OUString sName( rNoteTextEntry.maName );
GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, OUString(), aPropStates);
GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName);
}
}
}
- ++aNoteTextIter;
}
// stored text styles
const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->GetTextStyles();
- std::vector<ScTextStyleEntry>::const_iterator aTextIter = rTextEntries.begin();
- std::vector<ScTextStyleEntry>::const_iterator aTextEnd = rTextEntries.end();
- while (aTextIter != aTextEnd)
+ for (const auto& rTextEntry : rTextEntries)
{
- ScAddress aPos = aTextIter->maCellPos;
+ ScAddress aPos = rTextEntry.maCellPos;
sal_Int32 nTable = aPos.Tab();
bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
if (bCopySheet)
@@ -2498,15 +2463,14 @@ void ScXMLExport::collectAutoStyles()
ScCellTextCursor* pCursor = ScCellTextCursor::getImplementation( xCursorProp );
if (pCursor)
{
- pCursor->SetSelection( aTextIter->maSelection );
+ pCursor->SetSelection( rTextEntry.maSelection );
std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(xCursorProp));
- OUString sName( aTextIter->maName );
+ OUString sName( rTextEntry.maName );
GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, OUString(), aPropStates);
GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName);
}
}
- ++aTextIter;
}
}
@@ -3518,33 +3482,30 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell)
else
aPoint.X = aRect.Left();
aPoint.Y = aRect.Top();
- ScMyShapeList::const_iterator aItr = rMyCell.aShapeList.begin();
- ScMyShapeList::const_iterator aEndItr(rMyCell.aShapeList.end());
- while (aItr != aEndItr)
+ for (const auto& rShape : rMyCell.aShapeList)
{
- if (aItr->xShape.is())
+ if (rShape.xShape.is())
{
if (bNegativePage)
- aPoint.X = 2 * aItr->xShape->getPosition().X + aItr->xShape->getSize().Width - aPoint.X;
+ aPoint.X = 2 * rShape.xShape->getPosition().X + rShape.xShape->getSize().Width - aPoint.X;
// We only write the end address if we want the shape to resize with the cell
- if ( aItr->bResizeWithCell &&
- aItr->xShape->getShapeType() != "com.sun.star.drawing.CaptionShape" )
+ if ( rShape.bResizeWithCell &&
+ rShape.xShape->getShapeType() != "com.sun.star.drawing.CaptionShape" )
{
OUString sEndAddress;
- ScRangeStringConverter::GetStringFromAddress(sEndAddress, aItr->aEndAddress, pDoc, FormulaGrammar::CONV_OOO);
+ ScRangeStringConverter::GetStringFromAddress(sEndAddress, rShape.aEndAddress, pDoc, FormulaGrammar::CONV_OOO);
AddAttribute(XML_NAMESPACE_TABLE, XML_END_CELL_ADDRESS, sEndAddress);
OUStringBuffer sBuffer;
GetMM100UnitConverter().convertMeasureToXML(
- sBuffer, aItr->nEndX);
+ sBuffer, rShape.nEndX);
AddAttribute(XML_NAMESPACE_TABLE, XML_END_X, sBuffer.makeStringAndClear());
GetMM100UnitConverter().convertMeasureToXML(
- sBuffer, aItr->nEndY);
+ sBuffer, rShape.nEndY);
AddAttribute(XML_NAMESPACE_TABLE, XML_END_Y, sBuffer.makeStringAndClear());
}
- ExportShape(aItr->xShape, &aPoint);
+ ExportShape(rShape.xShape, &aPoint);
}
- ++aItr;
}
}
}
@@ -3556,25 +3517,23 @@ void ScXMLExport::WriteTableShapes()
{
OSL_ENSURE(pTableShapes->size() > static_cast<size_t>(nCurrentTable), "wrong Table");
SvXMLElementExport aShapesElem(*this, XML_NAMESPACE_TABLE, XML_SHAPES, true, false);
- ScMyTableXShapes::iterator aItr((*pTableShapes)[nCurrentTable].begin());
- ScMyTableXShapes::iterator aEndItr((*pTableShapes)[nCurrentTable].end());
- while (aItr != aEndItr)
+ for (const auto& rxShape : (*pTableShapes)[nCurrentTable])
{
- if (aItr->is())
+ if (rxShape.is())
{
if (pDoc->IsNegativePage(static_cast<SCTAB>(nCurrentTable)))
{
- awt::Point aPoint((*aItr)->getPosition());
- awt::Size aSize((*aItr)->getSize());
+ awt::Point aPoint(rxShape->getPosition());
+ awt::Size aSize(rxShape->getSize());
aPoint.X += aPoint.X + aSize.Width;
aPoint.Y = 0;
- ExportShape(*aItr, &aPoint);
+ ExportShape(rxShape, &aPoint);
}
else
- ExportShape(*aItr, nullptr);
+ ExportShape(rxShape, nullptr);
}
- aItr = (*pTableShapes)[nCurrentTable].erase(aItr);
}
+ (*pTableShapes)[nCurrentTable].clear();
}
}
@@ -3693,37 +3652,31 @@ void ScXMLExport::WriteDetective( const ScMyCell& rMyCell )
{
SvXMLElementExport aDetElem( *this, XML_NAMESPACE_TABLE, XML_DETECTIVE, true, true );
OUString sString;
- ScMyDetectiveObjVec::const_iterator aObjItr(rObjVec.begin());
- ScMyDetectiveObjVec::const_iterator aEndObjItr(rObjVec.end());
- while(aObjItr != aEndObjItr)
+ for(const auto& rObj : rObjVec)
{
- if (aObjItr->eObjType != SC_DETOBJ_CIRCLE)
+ if (rObj.eObjType != SC_DETOBJ_CIRCLE)
{
- if( (aObjItr->eObjType == SC_DETOBJ_ARROW) || (aObjItr->eObjType == SC_DETOBJ_TOOTHERTAB))
+ if( (rObj.eObjType == SC_DETOBJ_ARROW) || (rObj.eObjType == SC_DETOBJ_TOOTHERTAB))
{
- ScRangeStringConverter::GetStringFromRange( sString, aObjItr->aSourceRange, pDoc, FormulaGrammar::CONV_OOO );
+ ScRangeStringConverter::GetStringFromRange( sString, rObj.aSourceRange, pDoc, FormulaGrammar::CONV_OOO );
AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sString );
}
- ScXMLConverter::GetStringFromDetObjType( sString, aObjItr->eObjType );
+ ScXMLConverter::GetStringFromDetObjType( sString, rObj.eObjType );
AddAttribute( XML_NAMESPACE_TABLE, XML_DIRECTION, sString );
- if( aObjItr->bHasError )
+ if( rObj.bHasError )
AddAttribute( XML_NAMESPACE_TABLE, XML_CONTAINS_ERROR, XML_TRUE );
}
else
AddAttribute( XML_NAMESPACE_TABLE, XML_MARKED_INVALID, XML_TRUE );
SvXMLElementExport aRangeElem( *this, XML_NAMESPACE_TABLE, XML_HIGHLIGHTED_RANGE, true, true );
- ++aObjItr;
}
- ScMyDetectiveOpVec::const_iterator aOpItr(rOpVec.begin());
- ScMyDetectiveOpVec::const_iterator aEndOpItr(rOpVec.end());
- while(aOpItr != aEndOpItr)
+ for(const auto& rOp : rOpVec)
{
OUString sOpString;
- ScXMLConverter::GetStringFromDetOpType( sOpString, aOpItr->eOpType );
+ ScXMLConverter::GetStringFromDetOpType( sOpString, rOp.eOpType );
AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, sOpString );
- AddAttribute( XML_NAMESPACE_TABLE, XML_INDEX, OUString::number(aOpItr->nIndex) );
+ AddAttribute( XML_NAMESPACE_TABLE, XML_INDEX, OUString::number(rOp.nIndex) );
SvXMLElementExport aRangeElem( *this, XML_NAMESPACE_TABLE, XML_OPERATION, true, true );
- ++aOpItr;
}
}
}
@@ -4419,27 +4372,27 @@ void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
{
//write a global or local ScRangeName
SvXMLElementExport aElemNEs(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, true, true);
- for (ScRangeName::iterator it = pRangeName->begin(); it != pRangeName->end(); ++it)
+ for (const auto& rxEntry : *pRangeName)
{
- AddAttribute(sAttrName, it->second->GetName());
+ AddAttribute(sAttrName, rxEntry.second->GetName());
OUString sBaseCellAddress;
- it->second->ValidateTabRefs();
- ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, it->second->GetPos(), pDoc,
+ rxEntry.second->ValidateTabRefs();
+ ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, rxEntry.second->GetPos(), pDoc,
FormulaGrammar::CONV_OOO, ' ', false, ScRefFlags::ADDR_ABS_3D);
AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, sBaseCellAddress);
OUString sSymbol;
- it->second->GetSymbol(sSymbol, pDoc->GetStorageGrammar());
+ rxEntry.second->GetSymbol(sSymbol, pDoc->GetStorageGrammar());
OUString sTempSymbol(sSymbol);
ScRange aRange;
- if (it->second->IsReference(aRange))
+ if (rxEntry.second->IsReference(aRange))
{
OUString sContent(sTempSymbol.copy(1, sTempSymbol.getLength() -2 ));
AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sContent);
- sal_Int32 nRangeType = it->second->GetUnoType();
+ sal_Int32 nRangeType = rxEntry.second->GetUnoType();
OUStringBuffer sBufferRangeType;
if ((nRangeType & sheet::NamedRangeFlag::COLUMN_HEADER) == sheet::NamedRangeFlag::COLUMN_HEADER)
sBufferRangeType.append(GetXMLToken(XML_REPEAT_COLUMN));
@@ -4551,18 +4504,17 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
SvXMLElementExport aElementCondFormats(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMATS, true, true);
- for(ScConditionalFormatList::const_iterator itr = pCondFormatList->begin();
- itr != pCondFormatList->end(); ++itr)
+ for(const auto& rxCondFormat : *pCondFormatList)
{
OUString sRanges;
- const ScRangeList& rRangeList = (*itr)->GetRange();
+ const ScRangeList& rRangeList = rxCondFormat->GetRange();
ScRangeStringConverter::GetStringFromRangeList( sRanges, &rRangeList, pDoc, formula::FormulaGrammar::CONV_OOO );
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TARGET_RANGE_ADDRESS, sRanges);
SvXMLElementExport aElementCondFormat(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMAT, true, true);
- size_t nEntries = (*itr)->size();
+ size_t nEntries = rxCondFormat->size();
for(size_t i = 0; i < nEntries; ++i)
{
- const ScFormatEntry* pFormatEntry = (*itr)->GetEntry(i);
+ const ScFormatEntry* pFormatEntry = rxCondFormat->GetEntry(i);
if(pFormatEntry->GetType()==ScFormatEntry::Type::Condition)
{
const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry);
@@ -4695,20 +4647,19 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
{
SvXMLElementExport aElementColorScale(*this, XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE, true, true);
const ScColorScaleFormat& rColorScale = static_cast<const ScColorScaleFormat&>(*pFormatEntry);
- for(ScColorScaleEntries::const_iterator it = rColorScale.begin();
- it != rColorScale.end(); ++it)
+ for(const auto& rxItem : rColorScale)
{
- if(it[0]->GetType() == COLORSCALE_FORMULA)
+ if(rxItem->GetType() == COLORSCALE_FORMULA)
{
- OUString sFormula = it[0]->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
+ OUString sFormula = rxItem->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
}
else
- AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, OUString::number(it[0]->GetValue()));
+ AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, OUString::number(rxItem->GetValue()));
- AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*it[0]));
+ AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*rxItem));
OUStringBuffer aBuffer;
- ::sax::Converter::convertColor(aBuffer, it[0]->GetColor());
+ ::sax::Converter::convertColor(aBuffer, rxItem->GetColor());
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLOR, aBuffer.makeStringAndClear());
SvXMLElementExport aElementColorScaleEntry(*this, XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE_ENTRY, true, true);
}
@@ -4800,12 +4751,10 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
if (rIconSet.GetIconSetData()->mbCustom)
{
- for (std::vector<std::pair<ScIconSetType, sal_Int32> >::const_iterator
- it = rIconSet.GetIconSetData()->maCustomVector.begin();
- it != rIconSet.GetIconSetData()->maCustomVector.end(); ++it)
+ for (const auto& [rType, rIndex] : rIconSet.GetIconSetData()->maCustomVector)
{
- AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET_NAME, OUString::createFromAscii(ScIconSetFormat::getIconSetName(it->first)));
- AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET_INDEX, OUString::number(it->second));
+ AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET_NAME, OUString::createFromAscii(ScIconSetFormat::getIconSetName(rType)));
+ AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET_INDEX, OUString::number(rIndex));
SvXMLElementExport aCustomIcon(*this, XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET, true, true);
}
@@ -4859,14 +4808,13 @@ void ScXMLExport::WriteExternalRefCaches()
if (aTabNames.empty())
continue;
- for (vector<OUString>::const_iterator itr = aTabNames.begin(), itrEnd = aTabNames.end();
- itr != itrEnd; ++itr)
+ for (const auto& rTabName : aTabNames)
{
- ScExternalRefCache::TableTypeRef pTable = pRefMgr->getCacheTable(nFileId, *itr, false);
+ ScExternalRefCache::TableTypeRef pTable = pRefMgr->getCacheTable(nFileId, rTabName, false);
if (!pTable.get() || !pTable->isReferenced())
continue;
- AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, "'" + *pUrl + "'#" + *itr);
+ AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, "'" + *pUrl + "'#" + rTabName);
AddAttribute(XML_NAMESPACE_TABLE, XML_PRINT, GetXMLToken(XML_FALSE));
AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, sExternalRefTabStyleName);
SvXMLElementExport aElemTable(*this, XML_NAMESPACE_TABLE, XML_TABLE, true, true);
@@ -4881,7 +4829,7 @@ void ScXMLExport::WriteExternalRefCaches()
aRelUrl = GetRelativeReference(pExtFileData->maRelativeName);
AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aRelUrl);
- AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_NAME, *itr);
+ AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_NAME, rTabName);
if (!pExtFileData->maFilterName.isEmpty())
AddAttribute(XML_NAMESPACE_TABLE, XML_FILTER_NAME, pExtFileData->maFilterName);
if (!pExtFileData->maFilterOptions.isEmpty())
@@ -4895,10 +4843,8 @@ void ScXMLExport::WriteExternalRefCaches()
SCCOL nMaxColsUsed = 1; // assume that there is at least one cell somewhere..
vector<SCROW> aRows;
pTable->getAllRows(aRows);
- for (vector<SCROW>::const_iterator itrRow = aRows.begin(), itrRowEnd = aRows.end();
- itrRow != itrRowEnd; ++itrRow)
+ for (SCROW nRow : aRows)
{
- SCROW nRow = *itrRow;
vector<SCCOL> aCols;
pTable->getAllCols(nRow, aCols);
if (!aCols.empty())
@@ -4920,10 +4866,8 @@ void ScXMLExport::WriteExternalRefCaches()
// Write cache content for this table.
SCROW nLastRow = 0;
bool bFirstRow = true;
- for (vector<SCROW>::const_iterator itrRow = aRows.begin(), itrRowEnd = aRows.end();
- itrRow != itrRowEnd; ++itrRow)
+ for (SCROW nRow : aRows)
{
- SCROW nRow = *itrRow;
if (bFirstRow)
{
if (nRow > 0)
@@ -4965,10 +4909,8 @@ void ScXMLExport::WriteExternalRefCaches()
pTable->getAllCols(nRow, aCols);
SCCOL nLastCol = 0;
bool bFirstCol = true;
- for (vector<SCCOL>::const_iterator itrCol = aCols.begin(), itrColEnd = aCols.end();
- itrCol != itrColEnd; ++itrCol)
+ for (SCCOL nCol : aCols)
{
- SCCOL nCol = *itrCol;
if (bFirstCol)
{
if (nCol > 0)
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index a572e5f8e459..a1923a93415d 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -891,24 +891,15 @@ bool ScXMLImport::GetValidation(const OUString& sName, ScMyImportValidation& aVa
{
if (pValidations)
{
- bool bFound(false);
- ScMyImportValidations::iterator aItr(pValidations->begin());
- ScMyImportValidations::iterator aEndItr(pValidations->end());
- while(aItr != aEndItr && !bFound)
+ auto aItr = std::find_if(pValidations->begin(), pValidations->end(),
+ [&sName](const ScMyImportValidation& rValidation) { return rValidation.sName == sName; });
+ if (aItr != pValidations->end())
{
- if (aItr->sName == sName)
- {
- // source position must be set as string,
- // so sBaseCellAddress no longer has to be converted here
-
- bFound = true;
- }
- else
- ++aItr;
- }
- if (bFound)
+ // source position must be set as string,
+ // so sBaseCellAddress no longer has to be converted here
aValidation = *aItr;
- return bFound;
+ return true;
+ }
}
return false;
}
@@ -1593,24 +1584,23 @@ void ScXMLImport::SetLabelRanges()
table::CellRangeAddress aLabelRange;
table::CellRangeAddress aDataRange;
- ScMyLabelRanges::iterator aItr = pMyLabelRanges->begin();
- while (aItr != pMyLabelRanges->end())
+ for (const auto& rxLabelRange : *pMyLabelRanges)
{
sal_Int32 nOffset1(0);
sal_Int32 nOffset2(0);
FormulaGrammar::AddressConvention eConv = FormulaGrammar::CONV_OOO;
- if (ScRangeStringConverter::GetRangeFromString( aLabelRange, (*aItr)->sLabelRangeStr, GetDocument(), eConv, nOffset1 ) &&
- ScRangeStringConverter::GetRangeFromString( aDataRange, (*aItr)->sDataRangeStr, GetDocument(), eConv, nOffset2 ))
+ if (ScRangeStringConverter::GetRangeFromString( aLabelRange, rxLabelRange->sLabelRangeStr, GetDocument(), eConv, nOffset1 ) &&
+ ScRangeStringConverter::GetRangeFromString( aDataRange, rxLabelRange->sDataRangeStr, GetDocument(), eConv, nOffset2 ))
{
- if ( (*aItr)->bColumnOrientation )
+ if ( rxLabelRange->bColumnOrientation )
xColRanges->addNew( aLabelRange, aDataRange );
else
xRowRanges->addNew( aLabelRange, aDataRange );
}
-
- aItr = pMyLabelRanges->erase(aItr);
}
+
+ pMyLabelRanges->clear();
}
}
}
diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx
index d92d30049f28..4f80c8a0c022 100644
--- a/sc/source/filter/xml/xmlstyle.cxx
+++ b/sc/source/filter/xml/xmlstyle.cxx
@@ -230,11 +230,9 @@ void ScXMLCellExportPropertyMapper::ContextFilter(
XMLPropertyState* pParaAdjust = nullptr;
XMLPropertyState* pParaAdjustLast = nullptr;
- ::std::vector< XMLPropertyState >::iterator aEndIter(rProperties.end());
- for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
- aIter != aEndIter; ++aIter )
+ for( auto& rProperty : rProperties )
{
- XMLPropertyState* propertyState = &(*aIter);
+ XMLPropertyState* propertyState = &rProperty;
if (propertyState->mnIndex != -1)
{
switch( getPropertySetMapper()->GetEntryContextId( propertyState->mnIndex ) )
@@ -615,25 +613,23 @@ void ScXMLAutoStylePoolP::exportStyleAttributes(
SvXMLAutoStylePoolP::exportStyleAttributes( rAttrList, nFamily, rProperties, rPropExp, rUnitConverter, rNamespaceMap );
if (nFamily == XML_STYLE_FAMILY_TABLE_CELL)
{
- ::std::vector< XMLPropertyState >::const_iterator i(rProperties.begin());
- ::std::vector< XMLPropertyState >::const_iterator endi(rProperties.end());
- for(; i != endi; ++i)
+ for(const auto& rProperty : rProperties)
{
rtl::Reference< XMLPropertySetMapper > aPropMapper(rScXMLExport.GetCellStylesPropertySetMapper());
- sal_Int16 nContextID(aPropMapper->GetEntryContextId(i->mnIndex));
+ sal_Int16 nContextID(aPropMapper->GetEntryContextId(rProperty.mnIndex));
switch (nContextID)
{
case CTF_SC_NUMBERFORMAT :
{
sal_Int32 nNumberFormat = 0;
- if (i->maValue >>= nNumberFormat)
+ if (rProperty.maValue >>= nNumberFormat)
{
OUString sAttrValue(rScXMLExport.getDataStyleName(nNumberFormat));
if (!sAttrValue.isEmpty())
{
GetExport().AddAttribute(
- aPropMapper->GetEntryNameSpace(i->mnIndex),
- aPropMapper->GetEntryXMLName(i->mnIndex),
+ aPropMapper->GetEntryNameSpace(rProperty.mnIndex),
+ aPropMapper->GetEntryXMLName(rProperty.mnIndex),
sAttrValue );
}
}
@@ -644,22 +640,20 @@ void ScXMLAutoStylePoolP::exportStyleAttributes(
}
else if (nFamily == XML_STYLE_FAMILY_TABLE_TABLE)
{
- ::std::vector< XMLPropertyState >::const_iterator i(rProperties.begin());
- ::std::vector< XMLPropertyState >::const_iterator endi(rProperties.end());
- for(; i != endi; ++i)
+ for(const auto& rProperty : rProperties)
{
rtl::Reference< XMLPropertySetMapper > aPropMapper(rScXMLExport.GetTableStylesPropertySetMapper());
- sal_Int16 nContextID(aPropMapper->GetEntryContextId(i->mnIndex));
+ sal_Int16 nContextID(aPropMapper->GetEntryContextId(rProperty.mnIndex));
switch (nContextID)
{
case CTF_SC_MASTERPAGENAME :
{
OUString sName;
- if (i->maValue >>= sName)
+ if (rProperty.maValue >>= sName)
{
GetExport().AddAttribute(
- aPropMapper->GetEntryNameSpace(i->mnIndex),
- aPropMapper->GetEntryXMLName(i->mnIndex),
+ aPropMapper->GetEntryNameSpace(rProperty.mnIndex),
+ aPropMapper->GetEntryXMLName(rProperty.mnIndex),
GetExport().EncodeStyleName( sName ));
}
}
@@ -681,19 +675,17 @@ void ScXMLAutoStylePoolP::exportStyleContent(
SvXMLAutoStylePoolP::exportStyleContent( rHandler, nFamily, rProperties, rPropExp, rUnitConverter, rNamespaceMap );
if (nFamily == XML_STYLE_FAMILY_TABLE_CELL)
{
- ::std::vector< XMLPropertyState >::const_iterator i(rProperties.begin());
- ::std::vector< XMLPropertyState >::const_iterator endi(rProperties.end());
- for(; i != endi; ++i)
+ for(const auto& rProperty : rProperties)
{
- if (i->mnIndex != -1)
+ if (rProperty.mnIndex != -1)
{
- sal_Int16 nContextID = rScXMLExport.GetCellStylesPropertySetMapper()->GetEntryContextId(i->mnIndex);
+ sal_Int16 nContextID = rScXMLExport.GetCellStylesPropertySetMapper()->GetEntryContextId(rProperty.mnIndex);
switch (nContextID)
{
case CTF_SC_MAP :
{
- uno::Reference<container::XIndexAccess> xIndex( i->maValue, uno::UNO_QUERY );
- if ( xIndex.is() )
+ uno::Reference<container::XIndexAccess> xIndex( rProperty.maValue, uno::UNO_QUERY );
+ if ( xIndex.is() )
{
sal_Int32 nConditionCount(xIndex->getCount());
for (sal_Int32 nCondition = 0; nCondition < nConditionCount; ++nCondition)
diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx
index 1fd83894a6d2..3d4d83db74f4 100644
--- a/sc/source/filter/xml/xmlstyli.cxx
+++ b/sc/source/filter/xml/xmlstyli.cxx
@@ -92,11 +92,9 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >&
XMLPropertyState* pOldDiagBorderWidths[2] = { nullptr }; // old attribute names without "s"
XMLPropertyState* pDiagBorderWidths[2] = { nullptr };
- ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end());
- for (::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
- aIter != endproperty; ++aIter)
+ for (auto& rProperty : rProperties)
{
- XMLPropertyState*property = &(*aIter);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list