diff options
author | Noel Grandin <noel@peralex.com> | 2012-05-16 10:18:27 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-05-25 00:17:03 +0200 |
commit | f2e528072ef2bfec30795b1ba05905b39f5dc893 (patch) | |
tree | fd93193027e84cf7724e5447ae13a9828bb02cb0 /sw | |
parent | Convert SV_DECL_PTRARR(SwSortKeys) to std::vector (diff) | |
download | core-f2e528072ef2bfec30795b1ba05905b39f5dc893.tar.gz core-f2e528072ef2bfec30795b1ba05905b39f5dc893.zip |
Convert SV_DECL_PTRARR(SwSections) to std::vector
Change-Id: Ie41c43dc0cb5b64240122e76df20ff1a57f8532a
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/section.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/docnode/section.cxx | 64 | ||||
-rw-r--r-- | sw/source/core/unocore/unoidx.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unosect.cxx | 8 |
4 files changed, 32 insertions, 45 deletions
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 89bb7423705c..eccf256dfaee 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -41,6 +41,7 @@ #include <sfx2/Metadatable.hxx> #include <frmfmt.hxx> +#include <vector> namespace com { namespace sun { namespace star { @@ -59,7 +60,7 @@ class SwTOXBase; SV_DECL_REF( SwServerObject ) #endif -SV_DECL_PTRARR( SwSections, SwSection*, 0 ) +typedef std::vector<SwSection*> SwSections; enum SectionType { CONTENT_SECTION, TOX_HEADER_SECTION, diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index d4fc3db8fd35..156952a60014 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -66,6 +66,7 @@ #include <unosection.hxx> #include <switerator.hxx> #include <svl/smplhint.hxx> +#include <algorithm> using namespace ::com::sun::star; @@ -104,7 +105,6 @@ TYPEINIT1(SwSection,SwClient ); typedef SwSection* SwSectionPtr; -SV_IMPL_PTRARR( SwSections, SwSection*) SV_IMPL_PTRARR(SwSectionFmts,SwSectionFmt*) @@ -902,30 +902,24 @@ sal_Bool SwSectionFmt::GetInfo( SfxPoolItem& rInfo ) const return SwModify::GetInfo( rInfo ); } -extern "C" { - - int SAL_CALL lcl_SectionCmpPos( const void *pFirst, const void *pSecond) - { - const SwSectionFmt* pFSectFmt = (*(SwSectionPtr*)pFirst)->GetFmt(); - const SwSectionFmt* pSSectFmt = (*(SwSectionPtr*)pSecond)->GetFmt(); - OSL_ENSURE( pFSectFmt && pSSectFmt && - pFSectFmt->GetCntnt(sal_False).GetCntntIdx() && - pSSectFmt->GetCntnt(sal_False).GetCntntIdx(), - "ungueltige Sections" ); - return (int)((long)pFSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex()) - - pSSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex(); - } +static bool lcl_SectionCmpPos( const SwSection *pFirst, const SwSection *pSecond) +{ + const SwSectionFmt* pFSectFmt = pFirst->GetFmt(); + const SwSectionFmt* pSSectFmt = pSecond->GetFmt(); + OSL_ENSURE( pFSectFmt && pSSectFmt && + pFSectFmt->GetCntnt(sal_False).GetCntntIdx() && + pSSectFmt->GetCntnt(sal_False).GetCntntIdx(), + "ungueltige Sections" ); + return pFSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex() < + pSSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex(); +} - int SAL_CALL lcl_SectionCmpNm( const void *pFirst, const void *pSecond) - { - const SwSectionPtr pFSect = *(SwSectionPtr*)pFirst; - const SwSectionPtr pSSect = *(SwSectionPtr*)pSecond; - OSL_ENSURE( pFSect && pSSect, "ungueltige Sections" ); - StringCompare const eCmp = - pFSect->GetSectionName().CompareTo( pSSect->GetSectionName() ); - return eCmp == COMPARE_EQUAL ? 0 - : eCmp == COMPARE_LESS ? 1 : -1; - } +static bool lcl_SectionCmpNm( const SwSection *pFSect, const SwSection *pSSect) +{ + OSL_ENSURE( pFSect && pSSect, "ungueltige Sections" ); + StringCompare const eCmp = + pFSect->GetSectionName().CompareTo( pSSect->GetSectionName() ); + return eCmp == COMPARE_LESS; } // alle Sections, die von dieser abgeleitet sind @@ -933,7 +927,7 @@ sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr, SectionSort eSort, sal_Bool bAllSections ) const { - rArr.Remove( 0, rArr.Count() ); + rArr.clear(); if( GetDepends() ) { @@ -944,33 +938,25 @@ sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr, ( 0 != ( pIdx = pLast->GetCntnt(sal_False). GetCntntIdx()) && &pIdx->GetNodes() == &GetDoc()->GetNodes() )) { - const SwSection* Dummy = pLast->GetSection(); - rArr.C40_INSERT( SwSection, - Dummy, - rArr.Count() ); + SwSection* pDummy = pLast->GetSection(); + rArr.push_back( pDummy ); } // noch eine Sortierung erwuenscht ? - if( 1 < rArr.Count() ) + if( 1 < rArr.size() ) switch( eSort ) { case SORTSECT_NAME: - qsort( (void*)rArr.GetData(), - rArr.Count(), - sizeof( SwSectionPtr ), - lcl_SectionCmpNm ); + std::sort( rArr.begin(), rArr.end(), lcl_SectionCmpNm ); break; case SORTSECT_POS: - qsort( (void*)rArr.GetData(), - rArr.Count(), - sizeof( SwSectionPtr ), - lcl_SectionCmpPos ); + std::sort( rArr.begin(), rArr.end(), lcl_SectionCmpPos ); break; case SORTSECT_NOT: break; } } - return rArr.Count(); + return rArr.size(); } // erfrage, ob sich die Section im Nodes-Array oder UndoNodes-Array diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 1382a034abc3..a0ee7b30da91 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -930,7 +930,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, SwSections aSectArr; pSectionFmt->GetChildSections(aSectArr, SORTSECT_NOT, sal_False); - for(sal_uInt16 i = 0; i < aSectArr.Count(); i++) + for(sal_uInt16 i = 0; i < aSectArr.size(); i++) { SwSection* pSect = aSectArr[i]; if(pSect->GetType() == TOX_HEADER_SECTION) diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index bfb786f0707d..4dc90b8099b3 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -255,11 +255,11 @@ SwXTextSection::getChildSections() throw (uno::RuntimeException) SwSections aChildren; rSectionFmt.GetChildSections(aChildren, SORTSECT_NOT, sal_False); - uno::Sequence<uno::Reference<text::XTextSection> > aSeq(aChildren.Count()); + uno::Sequence<uno::Reference<text::XTextSection> > aSeq(aChildren.size()); uno::Reference< text::XTextSection > * pArray = aSeq.getArray(); - for (sal_uInt16 i = 0; i < aChildren.Count(); i++) + for (sal_uInt16 i = 0; i < aChildren.size(); i++) { - SwSectionFmt *const pChild = aChildren.GetObject(i)->GetFmt(); + SwSectionFmt *const pChild = aChildren[i]->GetFmt(); pArray[i] = CreateXTextSection(pChild); } return aSeq; @@ -325,7 +325,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) GetChildSections(aSectionsArr); // and search for current header section - const sal_uInt16 nCount = aSectionsArr.Count(); + const sal_uInt16 nCount = aSectionsArr.size(); sal_Bool bHeaderPresent = sal_False; for(sal_uInt16 i = 0; i < nCount; i++) { |