summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2015-03-01 19:10:46 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2015-04-05 11:25:11 +0200
commitbf5577fb086b0e6779dc4a6b5a0acc19e960b326 (patch)
tree7e06a77027ac5596b4b9980a16bf2f2c240ac02d
parent98cd6327e00e075170f8f9df4893b724a6e857d7 (diff)
Filled vector already provides nuber of items
But taking advantages of range-for loops is even better Change-Id: I79c6721ca63482c0ed40dad828ba736eeae92b6c
-rw-r--r--sw/inc/section.hxx2
-rw-r--r--sw/source/core/doc/doctxm.cxx5
-rw-r--r--sw/source/core/docnode/section.cxx3
-rw-r--r--sw/source/ui/dialog/uiregionsw.cxx31
4 files changed, 20 insertions, 21 deletions
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index 70b212827e58..a3080ab19ec9 100644
--- a/sw/inc/section.hxx
+++ b/sw/inc/section.hxx
@@ -314,7 +314,7 @@ public:
// All sections that are derived from this one:
// - sorted according to name or position or unsorted
// - all of them or only those that are in the normal Nodes-array.
- sal_uInt16 GetChildSections( SwSections& rArr,
+ void GetChildSections( SwSections& rArr,
SectionSort eSort = SORTSECT_NOT,
bool bAllSections = true ) const;
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index 613310607cf9..5b2002bdcfae 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -562,10 +562,9 @@ bool SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes )
if( !bDelNodes )
{
SwSections aArr( 0 );
- sal_uInt16 nCnt = pFmt->GetChildSections( aArr, SORTSECT_NOT, false );
- for( sal_uInt16 n = 0; n < nCnt; ++n )
+ pFmt->GetChildSections( aArr, SORTSECT_NOT, false );
+ for( const auto pSect : aArr )
{
- SwSection* pSect = aArr[ n ];
if( TOX_HEADER_SECTION == pSect->GetType() )
{
DelSectionFmt( pSect->GetFmt(), bDelNodes );
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index 48b2a214689b..70bb3b89302c 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -896,7 +896,7 @@ static bool lcl_SectionCmpNm( const SwSection *pFSect, const SwSection *pSSect)
}
// get all Sections that have been derived from this one
-sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr,
+void SwSectionFmt::GetChildSections( SwSections& rArr,
SectionSort eSort,
bool bAllSections ) const
{
@@ -929,7 +929,6 @@ sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr,
case SORTSECT_NOT: break;
}
}
- return rArr.size();
}
// See whether the Section is within the Nodes or the UndoNodes array
diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx
index 9210d30effe9..8f4c71211e6b 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -71,14 +71,14 @@ static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox );
static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames, const SwSectionFmt* pNewFmt )
{
- const SwSectionFmt* pFmt;
if( !pNewFmt )
{
const sal_uInt16 nCount = rSh.GetSectionFmtCount();
for(sal_uInt16 i=0;i<nCount;i++)
{
SectionType eTmpType;
- if( !(pFmt = &rSh.GetSectionFmt(i))->GetParent() &&
+ const SwSectionFmt* pFmt = &rSh.GetSectionFmt(i);
+ if( !pFmt->GetParent() &&
pFmt->IsInNodesArr() &&
(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType )
@@ -94,12 +94,14 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva
else
{
SwSections aTmpArr;
- const sal_uInt16 nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS);
- if( nCnt )
+ pNewFmt->GetChildSections(aTmpArr, SORTSECT_POS);
+ if( !aTmpArr.empty() )
{
SectionType eTmpType;
- for( sal_uInt16 n = 0; n < nCnt; ++n )
- if( (pFmt = aTmpArr[n]->GetFmt())->IsInNodesArr()&&
+ for( const auto pSect : aTmpArr )
+ {
+ const SwSectionFmt* pFmt = pSect->GetFmt();
+ if( pFmt->IsInNodesArr()&&
(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType )
{
@@ -109,6 +111,7 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva
rSubRegions.InsertEntry(sString);
lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt );
}
+ }
}
}
}
@@ -438,7 +441,6 @@ bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox)
// recursively look for child-sections
void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pEntry )
{
- SwSection* pSect = 0;
SvTreeListEntry* pSelEntry = 0;
if (!pFmt)
{
@@ -451,8 +453,8 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE
(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType )
{
- SectRepr* pSectRepr = new SectRepr( n,
- *(pSect=pFmt->GetSection()) );
+ SwSection *pSect = pFmt->GetSection();
+ SectRepr* pSectRepr = new SectRepr( n, *pSect );
Image aImg = BuildBitmap( pSect->IsProtect(),pSect->IsHidden());
pEntry = m_pTree->InsertEntry(pSect->GetSectionName(), aImg, aImg);
pEntry->SetUserData(pSectRepr);
@@ -468,18 +470,17 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE
{
SwSections aTmpArr;
SvTreeListEntry* pNEntry;
- const sal_uInt16 nCnt = pFmt->GetChildSections(aTmpArr,SORTSECT_POS);
- if( nCnt )
+ pFmt->GetChildSections(aTmpArr, SORTSECT_POS);
+ if( !aTmpArr.empty() )
{
- for( sal_uInt16 n = 0; n < nCnt; ++n )
+ for( const auto pSect : aTmpArr )
{
SectionType eTmpType;
- pFmt = aTmpArr[n]->GetFmt();
+ pFmt = pSect->GetFmt();
if( pFmt->IsInNodesArr() &&
(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType )
{
- pSect=aTmpArr[n];
SectRepr* pSectRepr=new SectRepr(
FindArrPos( pSect->GetFmt() ), *pSect );
Image aImage = BuildBitmap( pSect->IsProtect(),
@@ -487,7 +488,7 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE
pNEntry = m_pTree->InsertEntry(
pSect->GetSectionName(), aImage, aImage, pEntry);
pNEntry->SetUserData(pSectRepr);
- RecurseList( aTmpArr[n]->GetFmt(), pNEntry );
+ RecurseList( pSect->GetFmt(), pNEntry );
if( pNEntry->HasChildren())
m_pTree->Expand(pNEntry);
if (pCurrSect==pSect)