Kaydet (Commit) 2902cdc1 authored tarafından Matteo Casalin's avatar Matteo Casalin

Use more proper integer types and range-for loops

Change-Id: I6c1b6697e984dd39b70dace8568eda41b346e685
üst f6a42d64
...@@ -295,9 +295,8 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) ...@@ -295,9 +295,8 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt)
const SwPosition *pStart = rPaM.Start(), *pEnd = rPaM.End(); const SwPosition *pStart = rPaM.Start(), *pEnd = rPaM.End();
// Set index to the Selection's start // Set index to the Selection's start
for ( sal_uInt16 n = 0; n < GetSpzFrmFmts()->size(); ++n ) for ( const auto *pFmt : *GetSpzFrmFmts() )
{ {
const SwFrmFmt *const pFmt = (*GetSpzFrmFmts())[n];
SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
...@@ -496,7 +495,7 @@ bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) ...@@ -496,7 +495,7 @@ bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt)
if( !getIDocumentRedlineAccess().IsIgnoreRedline() && !getIDocumentRedlineAccess().GetRedlineTbl().empty() ) if( !getIDocumentRedlineAccess().IsIgnoreRedline() && !getIDocumentRedlineAccess().GetRedlineTbl().empty() )
getIDocumentRedlineAccess().DeleteRedline( *pTblNd, true, USHRT_MAX ); getIDocumentRedlineAccess().DeleteRedline( *pTblNd, true, USHRT_MAX );
sal_uInt16 nStart = 0; _FndLines::size_type nStart = 0;
if( pTblNd->GetTable().GetRowsToRepeat() > 0 && rOpt.eDirection == SRT_ROWS ) if( pTblNd->GetTable().GetRowsToRepeat() > 0 && rOpt.eDirection == SRT_ROWS )
{ {
// Uppermost selected Cell // Uppermost selected Cell
...@@ -561,9 +560,7 @@ bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) ...@@ -561,9 +560,7 @@ bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt)
SwSortBoxElements aSortList; SwSortBoxElements aSortList;
// When sorting, do not include the first row if the HeaderLine is repeated // When sorting, do not include the first row if the HeaderLine is repeated
sal_uInt16 i; for( sal_uInt16 i = static_cast<sal_uInt16>(nStart); i < nCount; ++i)
for( i = nStart; i < nCount; ++i)
{ {
SwSortBoxElement* pEle = new SwSortBoxElement( i ); SwSortBoxElement* pEle = new SwSortBoxElement( i );
aSortList.insert(pEle); aSortList.insert(pEle);
...@@ -571,7 +568,7 @@ bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) ...@@ -571,7 +568,7 @@ bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt)
// Move after Sorting // Move after Sorting
SwMovedBoxes aMovedList; SwMovedBoxes aMovedList;
i = 0; sal_uInt16 i = 0;
for (SwSortBoxElements::const_iterator it = aSortList.begin(); for (SwSortBoxElements::const_iterator it = aSortList.begin();
it != aSortList.end(); ++i, ++it) it != aSortList.end(); ++i, ++it)
{ {
...@@ -781,9 +778,9 @@ FlatFndBox::~FlatFndBox() ...@@ -781,9 +778,9 @@ FlatFndBox::~FlatFndBox()
bool FlatFndBox::CheckLineSymmetry(const _FndBox& rBox) bool FlatFndBox::CheckLineSymmetry(const _FndBox& rBox)
{ {
const _FndLines &rLines = rBox.GetLines(); const _FndLines &rLines = rBox.GetLines();
sal_uInt16 nBoxes(0); _FndBoxes::size_type nBoxes {0};
for(sal_uInt16 i=0; i < rLines.size(); ++i) for(_FndLines::size_type i=0; i < rLines.size(); ++i)
{ {
const _FndLine* pLn = &rLines[i]; const _FndLine* pLn = &rLines[i];
const _FndBoxes& rBoxes = pLn->GetBoxes(); const _FndBoxes& rBoxes = pLn->GetBoxes();
...@@ -803,9 +800,9 @@ bool FlatFndBox::CheckLineSymmetry(const _FndBox& rBox) ...@@ -803,9 +800,9 @@ bool FlatFndBox::CheckLineSymmetry(const _FndBox& rBox)
bool FlatFndBox::CheckBoxSymmetry(const _FndLine& rLn) bool FlatFndBox::CheckBoxSymmetry(const _FndLine& rLn)
{ {
const _FndBoxes &rBoxes = rLn.GetBoxes(); const _FndBoxes &rBoxes = rLn.GetBoxes();
sal_uInt16 nLines(0); _FndLines::size_type nLines {0};
for(sal_uInt16 i=0; i < rBoxes.size(); ++i) for(_FndBoxes::size_type i=0; i < rBoxes.size(); ++i)
{ {
_FndBox const*const pBox = &rBoxes[i]; _FndBox const*const pBox = &rBoxes[i];
const _FndLines& rLines = pBox->GetLines(); const _FndLines& rLines = pBox->GetLines();
...@@ -830,15 +827,14 @@ sal_uInt16 FlatFndBox::GetColCount(const _FndBox& rBox) ...@@ -830,15 +827,14 @@ sal_uInt16 FlatFndBox::GetColCount(const _FndBox& rBox)
return 1; return 1;
sal_uInt16 nSum = 0; sal_uInt16 nSum = 0;
for( sal_uInt16 i=0; i < rLines.size(); ++i ) for( const auto &rLine : rLines )
{ {
// The Boxes of a Line // The Boxes of a Line
sal_uInt16 nCount = 0; sal_uInt16 nCount = 0;
const _FndBoxes& rBoxes = rLines[i].GetBoxes(); const _FndBoxes& rBoxes = rLine.GetBoxes();
for( sal_uInt16 j=0; j < rBoxes.size(); ++j ) for( const auto &rB : rBoxes )
// Iterate recursively over the Lines // Iterate recursively over the Lines
nCount += (rBoxes[j].GetLines().size()) nCount += rB.GetLines().empty() ? 1 : GetColCount(rB);
? GetColCount(rBoxes[j]) : 1;
if( nSum < nCount ) if( nSum < nCount )
nSum = nCount; nSum = nCount;
...@@ -854,14 +850,14 @@ sal_uInt16 FlatFndBox::GetRowCount(const _FndBox& rBox) ...@@ -854,14 +850,14 @@ sal_uInt16 FlatFndBox::GetRowCount(const _FndBox& rBox)
return 1; return 1;
sal_uInt16 nLines = 0; sal_uInt16 nLines = 0;
for(sal_uInt16 i=0; i < rLines.size(); ++i) for(const auto &rLine : rLines )
{ // The Boxes of a Line { // The Boxes of a Line
const _FndBoxes& rBoxes = rLines[i].GetBoxes(); const _FndBoxes& rBoxes = rLine.GetBoxes();
sal_uInt16 nLn = 1; sal_uInt16 nLn = 1;
for(sal_uInt16 j=0; j < rBoxes.size(); ++j) for(const auto &rB : rBoxes)
if (rBoxes[j].GetLines().size()) if (rB.GetLines().size())
// Iterate recursively over the Lines // Iterate recursively over the Lines
nLn = std::max(GetRowCount(rBoxes[j]), nLn); nLn = std::max(GetRowCount(rB), nLn);
nLines = nLines + nLn; nLines = nLines + nLn;
} }
...@@ -876,17 +872,17 @@ void FlatFndBox::FillFlat(const _FndBox& rBox, bool bLastBox) ...@@ -876,17 +872,17 @@ void FlatFndBox::FillFlat(const _FndBox& rBox, bool bLastBox)
// Iterate over Lines // Iterate over Lines
sal_uInt16 nOldRow = nRow; sal_uInt16 nOldRow = nRow;
for( sal_uInt16 i=0; i < rLines.size(); ++i ) for( const auto &rLine : rLines )
{ {
// The Boxes of a Line // The Boxes of a Line
const _FndBoxes& rBoxes = rLines[i].GetBoxes(); const _FndBoxes& rBoxes = rLine.GetBoxes();
sal_uInt16 nOldCol = nCol; sal_uInt16 nOldCol = nCol;
for( sal_uInt16 j = 0; j < rBoxes.size(); ++j ) for( _FndBoxes::size_type j = 0; j < rBoxes.size(); ++j )
{ {
// Check the Box if it's an atomic one // Check the Box if it's an atomic one
const _FndBox *const pBox = &rBoxes[j]; const _FndBox *const pBox = &rBoxes[j];
if( !pBox->GetLines().size() ) if( pBox->GetLines().empty() )
{ {
// save it // save it
sal_uInt16 nOff = nRow * nCols + nCol; sal_uInt16 nOff = nRow * nCols + nCol;
...@@ -916,7 +912,7 @@ void FlatFndBox::FillFlat(const _FndBox& rBox, bool bLastBox) ...@@ -916,7 +912,7 @@ void FlatFndBox::FillFlat(const _FndBox& rBox, bool bLastBox)
else else
{ {
// Iterate recursively over the Lines of a Box // Iterate recursively over the Lines of a Box
FillFlat( *pBox, ( j == rBoxes.size()-1 ) ); FillFlat( *pBox, ( j+1 == rBoxes.size() ) );
} }
nCol++; nCol++;
} }
......
...@@ -341,7 +341,7 @@ void SwNumFmt::UpdateNumNodes( SwDoc* pDoc ) ...@@ -341,7 +341,7 @@ void SwNumFmt::UpdateNumNodes( SwDoc* pDoc )
{ {
bool bDocIsModified = pDoc->getIDocumentState().IsModified(); bool bDocIsModified = pDoc->getIDocumentState().IsModified();
bool bFnd = false; bool bFnd = false;
for( sal_uInt16 n = pDoc->GetNumRuleTbl().size(); !bFnd && n; ) for( SwNumRuleTbl::size_type n = pDoc->GetNumRuleTbl().size(); !bFnd && n; )
{ {
const SwNumRule* pRule = pDoc->GetNumRuleTbl()[ --n ]; const SwNumRule* pRule = pDoc->GetNumRuleTbl()[ --n ];
for( sal_uInt8 i = 0; i < MAXLEVEL; ++i ) for( sal_uInt8 i = 0; i < MAXLEVEL; ++i )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment