Kaydet (Commit) f2e52807 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Stahl

Convert SV_DECL_PTRARR(SwSections) to std::vector

Change-Id: Ie41c43dc0cb5b64240122e76df20ff1a57f8532a
üst 84a0fb09
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <sfx2/Metadatable.hxx> #include <sfx2/Metadatable.hxx>
#include <frmfmt.hxx> #include <frmfmt.hxx>
#include <vector>
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
...@@ -59,7 +60,7 @@ class SwTOXBase; ...@@ -59,7 +60,7 @@ class SwTOXBase;
SV_DECL_REF( SwServerObject ) SV_DECL_REF( SwServerObject )
#endif #endif
SV_DECL_PTRARR( SwSections, SwSection*, 0 ) typedef std::vector<SwSection*> SwSections;
enum SectionType { CONTENT_SECTION, enum SectionType { CONTENT_SECTION,
TOX_HEADER_SECTION, TOX_HEADER_SECTION,
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include <unosection.hxx> #include <unosection.hxx>
#include <switerator.hxx> #include <switerator.hxx>
#include <svl/smplhint.hxx> #include <svl/smplhint.hxx>
#include <algorithm>
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -104,7 +105,6 @@ TYPEINIT1(SwSection,SwClient ); ...@@ -104,7 +105,6 @@ TYPEINIT1(SwSection,SwClient );
typedef SwSection* SwSectionPtr; typedef SwSection* SwSectionPtr;
SV_IMPL_PTRARR( SwSections, SwSection*)
SV_IMPL_PTRARR(SwSectionFmts,SwSectionFmt*) SV_IMPL_PTRARR(SwSectionFmts,SwSectionFmt*)
...@@ -902,30 +902,24 @@ sal_Bool SwSectionFmt::GetInfo( SfxPoolItem& rInfo ) const ...@@ -902,30 +902,24 @@ sal_Bool SwSectionFmt::GetInfo( SfxPoolItem& rInfo ) const
return SwModify::GetInfo( rInfo ); return SwModify::GetInfo( rInfo );
} }
extern "C" { static bool lcl_SectionCmpPos( const SwSection *pFirst, const SwSection *pSecond)
{
int SAL_CALL lcl_SectionCmpPos( const void *pFirst, const void *pSecond) const SwSectionFmt* pFSectFmt = pFirst->GetFmt();
{ const SwSectionFmt* pSSectFmt = pSecond->GetFmt();
const SwSectionFmt* pFSectFmt = (*(SwSectionPtr*)pFirst)->GetFmt(); OSL_ENSURE( pFSectFmt && pSSectFmt &&
const SwSectionFmt* pSSectFmt = (*(SwSectionPtr*)pSecond)->GetFmt(); pFSectFmt->GetCntnt(sal_False).GetCntntIdx() &&
OSL_ENSURE( pFSectFmt && pSSectFmt && pSSectFmt->GetCntnt(sal_False).GetCntntIdx(),
pFSectFmt->GetCntnt(sal_False).GetCntntIdx() && "ungueltige Sections" );
pSSectFmt->GetCntnt(sal_False).GetCntntIdx(), return pFSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex() <
"ungueltige Sections" ); pSSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex();
return (int)((long)pFSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex()) - }
pSSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex();
}
int SAL_CALL lcl_SectionCmpNm( const void *pFirst, const void *pSecond) static bool lcl_SectionCmpNm( const SwSection *pFSect, const SwSection *pSSect)
{ {
const SwSectionPtr pFSect = *(SwSectionPtr*)pFirst; OSL_ENSURE( pFSect && pSSect, "ungueltige Sections" );
const SwSectionPtr pSSect = *(SwSectionPtr*)pSecond; StringCompare const eCmp =
OSL_ENSURE( pFSect && pSSect, "ungueltige Sections" ); pFSect->GetSectionName().CompareTo( pSSect->GetSectionName() );
StringCompare const eCmp = return eCmp == COMPARE_LESS;
pFSect->GetSectionName().CompareTo( pSSect->GetSectionName() );
return eCmp == COMPARE_EQUAL ? 0
: eCmp == COMPARE_LESS ? 1 : -1;
}
} }
// alle Sections, die von dieser abgeleitet sind // alle Sections, die von dieser abgeleitet sind
...@@ -933,7 +927,7 @@ sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr, ...@@ -933,7 +927,7 @@ sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr,
SectionSort eSort, SectionSort eSort,
sal_Bool bAllSections ) const sal_Bool bAllSections ) const
{ {
rArr.Remove( 0, rArr.Count() ); rArr.clear();
if( GetDepends() ) if( GetDepends() )
{ {
...@@ -944,33 +938,25 @@ sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr, ...@@ -944,33 +938,25 @@ sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr,
( 0 != ( pIdx = pLast->GetCntnt(sal_False). ( 0 != ( pIdx = pLast->GetCntnt(sal_False).
GetCntntIdx()) && &pIdx->GetNodes() == &GetDoc()->GetNodes() )) GetCntntIdx()) && &pIdx->GetNodes() == &GetDoc()->GetNodes() ))
{ {
const SwSection* Dummy = pLast->GetSection(); SwSection* pDummy = pLast->GetSection();
rArr.C40_INSERT( SwSection, rArr.push_back( pDummy );
Dummy,
rArr.Count() );
} }
// noch eine Sortierung erwuenscht ? // noch eine Sortierung erwuenscht ?
if( 1 < rArr.Count() ) if( 1 < rArr.size() )
switch( eSort ) switch( eSort )
{ {
case SORTSECT_NAME: case SORTSECT_NAME:
qsort( (void*)rArr.GetData(), std::sort( rArr.begin(), rArr.end(), lcl_SectionCmpNm );
rArr.Count(),
sizeof( SwSectionPtr ),
lcl_SectionCmpNm );
break; break;
case SORTSECT_POS: case SORTSECT_POS:
qsort( (void*)rArr.GetData(), std::sort( rArr.begin(), rArr.end(), lcl_SectionCmpPos );
rArr.Count(),
sizeof( SwSectionPtr ),
lcl_SectionCmpPos );
break; break;
case SORTSECT_NOT: break; case SORTSECT_NOT: break;
} }
} }
return rArr.Count(); return rArr.size();
} }
// erfrage, ob sich die Section im Nodes-Array oder UndoNodes-Array // erfrage, ob sich die Section im Nodes-Array oder UndoNodes-Array
......
...@@ -930,7 +930,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, ...@@ -930,7 +930,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
SwSections aSectArr; SwSections aSectArr;
pSectionFmt->GetChildSections(aSectArr, pSectionFmt->GetChildSections(aSectArr,
SORTSECT_NOT, sal_False); 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]; SwSection* pSect = aSectArr[i];
if(pSect->GetType() == TOX_HEADER_SECTION) if(pSect->GetType() == TOX_HEADER_SECTION)
......
...@@ -255,11 +255,11 @@ SwXTextSection::getChildSections() throw (uno::RuntimeException) ...@@ -255,11 +255,11 @@ SwXTextSection::getChildSections() throw (uno::RuntimeException)
SwSections aChildren; SwSections aChildren;
rSectionFmt.GetChildSections(aChildren, SORTSECT_NOT, sal_False); 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(); 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); pArray[i] = CreateXTextSection(pChild);
} }
return aSeq; return aSeq;
...@@ -325,7 +325,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) ...@@ -325,7 +325,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
GetChildSections(aSectionsArr); GetChildSections(aSectionsArr);
// and search for current header section // and search for current header section
const sal_uInt16 nCount = aSectionsArr.Count(); const sal_uInt16 nCount = aSectionsArr.size();
sal_Bool bHeaderPresent = sal_False; sal_Bool bHeaderPresent = sal_False;
for(sal_uInt16 i = 0; i < nCount; i++) for(sal_uInt16 i = 0; i < nCount; 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