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

Filled vector already provides nuber of items

But taking advantages of range-for loops is even better

Change-Id: I79c6721ca63482c0ed40dad828ba736eeae92b6c
üst 98cd6327
...@@ -314,7 +314,7 @@ public: ...@@ -314,7 +314,7 @@ public:
// All sections that are derived from this one: // All sections that are derived from this one:
// - sorted according to name or position or unsorted // - sorted according to name or position or unsorted
// - all of them or only those that are in the normal Nodes-array. // - 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, SectionSort eSort = SORTSECT_NOT,
bool bAllSections = true ) const; bool bAllSections = true ) const;
......
...@@ -562,10 +562,9 @@ bool SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes ) ...@@ -562,10 +562,9 @@ bool SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes )
if( !bDelNodes ) if( !bDelNodes )
{ {
SwSections aArr( 0 ); SwSections aArr( 0 );
sal_uInt16 nCnt = pFmt->GetChildSections( aArr, SORTSECT_NOT, false ); pFmt->GetChildSections( aArr, SORTSECT_NOT, false );
for( sal_uInt16 n = 0; n < nCnt; ++n ) for( const auto pSect : aArr )
{ {
SwSection* pSect = aArr[ n ];
if( TOX_HEADER_SECTION == pSect->GetType() ) if( TOX_HEADER_SECTION == pSect->GetType() )
{ {
DelSectionFmt( pSect->GetFmt(), bDelNodes ); DelSectionFmt( pSect->GetFmt(), bDelNodes );
......
...@@ -896,7 +896,7 @@ static bool lcl_SectionCmpNm( const SwSection *pFSect, const SwSection *pSSect) ...@@ -896,7 +896,7 @@ static bool lcl_SectionCmpNm( const SwSection *pFSect, const SwSection *pSSect)
} }
// get all Sections that have been derived from this one // get all Sections that have been derived from this one
sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr, void SwSectionFmt::GetChildSections( SwSections& rArr,
SectionSort eSort, SectionSort eSort,
bool bAllSections ) const bool bAllSections ) const
{ {
...@@ -929,7 +929,6 @@ sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr, ...@@ -929,7 +929,6 @@ sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr,
case SORTSECT_NOT: break; case SORTSECT_NOT: break;
} }
} }
return rArr.size();
} }
// See whether the Section is within the Nodes or the UndoNodes array // See whether the Section is within the Nodes or the UndoNodes array
......
...@@ -71,14 +71,14 @@ static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox ); ...@@ -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 ) static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames, const SwSectionFmt* pNewFmt )
{ {
const SwSectionFmt* pFmt;
if( !pNewFmt ) if( !pNewFmt )
{ {
const sal_uInt16 nCount = rSh.GetSectionFmtCount(); const sal_uInt16 nCount = rSh.GetSectionFmtCount();
for(sal_uInt16 i=0;i<nCount;i++) for(sal_uInt16 i=0;i<nCount;i++)
{ {
SectionType eTmpType; SectionType eTmpType;
if( !(pFmt = &rSh.GetSectionFmt(i))->GetParent() && const SwSectionFmt* pFmt = &rSh.GetSectionFmt(i);
if( !pFmt->GetParent() &&
pFmt->IsInNodesArr() && pFmt->IsInNodesArr() &&
(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType ) && TOX_HEADER_SECTION != eTmpType )
...@@ -94,12 +94,14 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva ...@@ -94,12 +94,14 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva
else else
{ {
SwSections aTmpArr; SwSections aTmpArr;
const sal_uInt16 nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS); pNewFmt->GetChildSections(aTmpArr, SORTSECT_POS);
if( nCnt ) if( !aTmpArr.empty() )
{ {
SectionType eTmpType; SectionType eTmpType;
for( sal_uInt16 n = 0; n < nCnt; ++n ) for( const auto pSect : aTmpArr )
if( (pFmt = aTmpArr[n]->GetFmt())->IsInNodesArr()&& {
const SwSectionFmt* pFmt = pSect->GetFmt();
if( pFmt->IsInNodesArr()&&
(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType ) && TOX_HEADER_SECTION != eTmpType )
{ {
...@@ -109,6 +111,7 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva ...@@ -109,6 +111,7 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva
rSubRegions.InsertEntry(sString); rSubRegions.InsertEntry(sString);
lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt ); lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt );
} }
}
} }
} }
} }
...@@ -438,7 +441,6 @@ bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox) ...@@ -438,7 +441,6 @@ bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox)
// recursively look for child-sections // recursively look for child-sections
void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pEntry ) void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pEntry )
{ {
SwSection* pSect = 0;
SvTreeListEntry* pSelEntry = 0; SvTreeListEntry* pSelEntry = 0;
if (!pFmt) if (!pFmt)
{ {
...@@ -451,8 +453,8 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE ...@@ -451,8 +453,8 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE
(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType ) && TOX_HEADER_SECTION != eTmpType )
{ {
SectRepr* pSectRepr = new SectRepr( n, SwSection *pSect = pFmt->GetSection();
*(pSect=pFmt->GetSection()) ); SectRepr* pSectRepr = new SectRepr( n, *pSect );
Image aImg = BuildBitmap( pSect->IsProtect(),pSect->IsHidden()); Image aImg = BuildBitmap( pSect->IsProtect(),pSect->IsHidden());
pEntry = m_pTree->InsertEntry(pSect->GetSectionName(), aImg, aImg); pEntry = m_pTree->InsertEntry(pSect->GetSectionName(), aImg, aImg);
pEntry->SetUserData(pSectRepr); pEntry->SetUserData(pSectRepr);
...@@ -468,18 +470,17 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE ...@@ -468,18 +470,17 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE
{ {
SwSections aTmpArr; SwSections aTmpArr;
SvTreeListEntry* pNEntry; SvTreeListEntry* pNEntry;
const sal_uInt16 nCnt = pFmt->GetChildSections(aTmpArr,SORTSECT_POS); pFmt->GetChildSections(aTmpArr, SORTSECT_POS);
if( nCnt ) if( !aTmpArr.empty() )
{ {
for( sal_uInt16 n = 0; n < nCnt; ++n ) for( const auto pSect : aTmpArr )
{ {
SectionType eTmpType; SectionType eTmpType;
pFmt = aTmpArr[n]->GetFmt(); pFmt = pSect->GetFmt();
if( pFmt->IsInNodesArr() && if( pFmt->IsInNodesArr() &&
(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType ) && TOX_HEADER_SECTION != eTmpType )
{ {
pSect=aTmpArr[n];
SectRepr* pSectRepr=new SectRepr( SectRepr* pSectRepr=new SectRepr(
FindArrPos( pSect->GetFmt() ), *pSect ); FindArrPos( pSect->GetFmt() ), *pSect );
Image aImage = BuildBitmap( pSect->IsProtect(), Image aImage = BuildBitmap( pSect->IsProtect(),
...@@ -487,7 +488,7 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE ...@@ -487,7 +488,7 @@ void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pE
pNEntry = m_pTree->InsertEntry( pNEntry = m_pTree->InsertEntry(
pSect->GetSectionName(), aImage, aImage, pEntry); pSect->GetSectionName(), aImage, aImage, pEntry);
pNEntry->SetUserData(pSectRepr); pNEntry->SetUserData(pSectRepr);
RecurseList( aTmpArr[n]->GetFmt(), pNEntry ); RecurseList( pSect->GetFmt(), pNEntry );
if( pNEntry->HasChildren()) if( pNEntry->HasChildren())
m_pTree->Expand(pNEntry); m_pTree->Expand(pNEntry);
if (pCurrSect==pSect) if (pCurrSect==pSect)
......
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