tdf#145538 Use range based for loops in tblafmt.cxx and ndtbl1.cxx

Replace index basedloops with range based loops where safe.
No functional change intended.

Change-Id: I9b6ed9a03d4a35d809f3049c371efa7d1f43e060
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202787
Reviewed-by: Dmitriy Usov <du@thesec.net>
Tested-by: Jenkins
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
This commit is contained in:
RashmiVid
2026-03-31 17:35:47 +02:00
committed by Ilmari Lauhakangas
parent 59f7c0491a
commit 9f2e368e76
2 changed files with 16 additions and 18 deletions
+9 -9
View File
@@ -854,10 +854,10 @@ void SwCellStyleTable::RemoveBoxFormat(const OUString& sName)
UIName SwCellStyleTable::GetBoxFormatName(const SwBoxAutoFormat& rBoxFormat) const
{
for (size_t i = 0; i < m_aCellStyles.size(); ++i)
for (const auto& rCellStyle : m_aCellStyles)
{
if (m_aCellStyles[i].second.get() == &rBoxFormat)
return m_aCellStyles[i].first;
if (rCellStyle.second.get() == &rBoxFormat)
return rCellStyle.first;
}
// box format not found
@@ -866,10 +866,10 @@ UIName SwCellStyleTable::GetBoxFormatName(const SwBoxAutoFormat& rBoxFormat) con
SwBoxAutoFormat* SwCellStyleTable::GetBoxFormat(const UIName& sName) const
{
for (size_t i = 0; i < m_aCellStyles.size(); ++i)
for (const auto& rCellStyle : m_aCellStyles)
{
if (m_aCellStyles[i].first == sName)
return m_aCellStyles[i].second.get();
if (rCellStyle.first == sName)
return rCellStyle.second.get();
}
return nullptr;
@@ -882,11 +882,11 @@ void SwCellStyleTable::ChangeBoxFormatName(std::u16string_view sFromName, const
SAL_INFO("sw.core", "SwCellStyleTable::ChangeBoxName, box with given name already exists");
return;
}
for (size_t i = 0; i < m_aCellStyles.size(); ++i)
for (auto& rCellStyle : m_aCellStyles)
{
if (m_aCellStyles[i].first == sFromName)
if (rCellStyle.first == sFromName)
{
m_aCellStyles[i].first = sToName;
rCellStyle.first = sToName;
// changed successfully
return;
}
+7 -9
View File
@@ -1288,10 +1288,8 @@ void SwDoc::SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew )
std::vector<std::unique_ptr<SwTableFormatCmp>> aFormatCmp;
aFormatCmp.reserve(std::max<size_t>(255, aBoxes.size()));
for (size_t i = 0; i < aBoxes.size(); ++i)
for (auto pBox : aBoxes)
{
SwTableBox *pBox = aBoxes[i];
SwFrameFormat *pNewFormat = SwTableFormatCmp::FindNewFormat( aFormatCmp, pBox->GetFrameFormat(), 0 );
if ( nullptr != pNewFormat )
pBox->ChgFrameFormat( static_cast<SwTableBoxFormat*>(pNewFormat) );
@@ -1330,14 +1328,14 @@ bool SwDoc::GetBoxAttr( const SwCursor& rCursor, std::unique_ptr<SfxPoolItem>& r
bRet = true;
bool bOneFound = false;
const sal_uInt16 nWhich = rToFill->Which();
for (size_t i = 0; i < aBoxes.size(); ++i)
for (auto pBox : aBoxes)
{
switch ( nWhich )
{
case RES_BACKGROUND:
{
std::unique_ptr<SvxBrushItem> xBack =
aBoxes[i]->GetFrameFormat()->makeBackgroundBrushItem();
pBox->GetFrameFormat()->makeBackgroundBrushItem();
if( !bOneFound )
{
rToFill = std::move(xBack);
@@ -1351,7 +1349,7 @@ bool SwDoc::GetBoxAttr( const SwCursor& rCursor, std::unique_ptr<SfxPoolItem>& r
case RES_FRAMEDIR:
{
const SvxFrameDirectionItem& rDir =
aBoxes[i]->GetFrameFormat()->GetFrameDir();
pBox->GetFrameFormat()->GetFrameDir();
if( !bOneFound )
{
rToFill.reset(rDir.Clone());
@@ -1364,7 +1362,7 @@ bool SwDoc::GetBoxAttr( const SwCursor& rCursor, std::unique_ptr<SfxPoolItem>& r
case RES_VERT_ORIENT:
{
const SwFormatVertOrient& rOrient =
aBoxes[i]->GetFrameFormat()->GetVertOrient();
pBox->GetFrameFormat()->GetVertOrient();
if( !bOneFound )
{
rToFill.reset(rOrient.Clone());
@@ -1399,10 +1397,10 @@ sal_uInt16 SwDoc::GetBoxAlign( const SwCursor& rCursor )
SwSelBoxes aBoxes;
if( pTableNd && ::lcl_GetBoxSel( rCursor, aBoxes ))
{
for (size_t i = 0; i < aBoxes.size(); ++i)
for (auto pBox : aBoxes)
{
const SwFormatVertOrient &rOri =
aBoxes[i]->GetFrameFormat()->GetVertOrient();
pBox->GetFrameFormat()->GetVertOrient();
if( USHRT_MAX == nAlign )
nAlign = o3tl::narrowing<sal_uInt16>(rOri.GetVertOrient());
else if( rOri.GetVertOrient() != nAlign )