Kaydet (Commit) bc251565 authored tarafından npcdoom's avatar npcdoom Kaydeden (comit) Luboš Luňák

Remove deprecated List container.

- Converted List to std::vector<Paragraph*>.
- Added Append member function to ParagraphList.
- Updated needed functions from Insert to Append in
outliner/outliner.cxx.
Signed-off-by: 's avatarLuboš Luňák <l.lunak@suse.cz>
üst 7ef6def2
......@@ -603,7 +603,7 @@ void Outliner::SetText( const OutlinerParaObject& rPObj )
Paragraph* pPara = new Paragraph( rPObj.GetParagraphData(nCurPara));
ImplCheckDepth( pPara->nDepth );
pParaList->Insert( pPara, LIST_APPEND );
pParaList->Append(pPara);
ImplCheckNumBulletItem( nCurPara );
}
......
......@@ -123,36 +123,47 @@ void ParagraphList::Clear( BOOL bDestroyParagraphs )
{
if ( bDestroyParagraphs )
{
for ( ULONG n = GetParagraphCount(); n; )
{
Paragraph* pPara = GetParagraph( --n );
delete pPara;
}
std::vector<Paragraph*>::iterator iter;
for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
delete *iter;
}
List::Clear();
maEntries.clear();
}
void ParagraphList::Append( Paragraph* pPara)
{
maEntries.push_back(pPara);
}
void ParagraphList::Insert( Paragraph* pPara, ULONG nAbsPos)
{
maEntries.insert(maEntries.begin()+nAbsPos,pPara);
}
void ParagraphList::Remove( ULONG nPara )
{
maEntries.erase(maEntries.begin() + nPara );
}
void ParagraphList::MoveParagraphs( ULONG nStart, ULONG nDest, ULONG _nCount )
{
if ( ( nDest < nStart ) || ( nDest >= ( nStart + _nCount ) ) )
{
ULONG n;
ParagraphList aParas;
for ( n = 0; n < _nCount; n++ )
{
Paragraph* pPara = GetParagraph( nStart );
aParas.Insert( pPara, LIST_APPEND );
Remove( nStart );
}
std::vector<Paragraph*> aParas;
std::vector<Paragraph*>::iterator iterBeg = maEntries.begin() + nStart;
std::vector<Paragraph*>::iterator iterEnd = iterBeg + _nCount + 1;
std::copy(iterBeg,iterEnd,std::back_inserter(aParas));
maEntries.erase(iterBeg,iterEnd);
if ( nDest > nStart )
nDest -= _nCount;
for ( n = 0; n < _nCount; n++ )
{
Paragraph* pPara = aParas.GetParagraph( n );
Insert( pPara, nDest++ );
}
std::vector<Paragraph*>::iterator iterIns = maEntries.begin() + nDest;
std::copy(aParas.begin(),aParas.end(),std::inserter(maEntries,iterIns));
}
else
{
......@@ -162,35 +173,44 @@ void ParagraphList::MoveParagraphs( ULONG nStart, ULONG nDest, ULONG _nCount )
Paragraph* ParagraphList::NextVisible( Paragraph* pPara ) const
{
ULONG n = GetAbsPos( pPara );
std::vector<Paragraph*>::const_iterator iter = std::find(maEntries.begin(),
maEntries.end(),
pPara);
Paragraph* p = GetParagraph( ++n );
while ( p && !p->IsVisible() )
p = GetParagraph( ++n );
for (; iter != maEntries.end(); ++iter)
{
if ((*iter)->IsVisible())
break;
}
return p;
return iter != maEntries.end() ? *iter : NULL;
}
Paragraph* ParagraphList::PrevVisible( Paragraph* pPara ) const
{
ULONG n = GetAbsPos( pPara );
std::vector<Paragraph*>::const_reverse_iterator iter = std::find(maEntries.rbegin(),
maEntries.rend(),
pPara);
Paragraph* p = n ? GetParagraph( --n ) : NULL;
while ( p && !p->IsVisible() )
p = n ? GetParagraph( --n ) : NULL;
for (; iter != maEntries.rend(); ++iter)
{
if ((*iter)->IsVisible())
break;
}
return p;
return iter != maEntries.rend() ? *iter : NULL;
}
Paragraph* ParagraphList::LastVisible() const
{
ULONG n = GetParagraphCount();
Paragraph* p = n ? GetParagraph( --n ) : NULL;
while ( p && !p->IsVisible() )
p = n ? GetParagraph( --n ) : NULL;
std::vector<Paragraph*>::const_reverse_iterator iter;
for (iter = maEntries.rbegin(); iter != maEntries.rend(); ++iter)
{
if ((*iter)->IsVisible())
break;
}
return p;
return iter != maEntries.rend() ? *iter : NULL;
}
BOOL ParagraphList::HasChilds( Paragraph* pParagraph ) const
......@@ -274,16 +294,32 @@ void ParagraphList::Collapse( Paragraph* pParent )
}
}
ULONG ParagraphList::GetVisPos( Paragraph* pPara )
ULONG ParagraphList::GetAbsPos( Paragraph* pParent ) const
{
ULONG pos = 0;
std::vector<Paragraph*>::const_iterator iter;
for (iter = maEntries.begin(); iter != maEntries.end(); ++iter, ++pos)
{
if (*iter == pParent)
return pos;
}
return ~0;
}
ULONG ParagraphList::GetVisPos( Paragraph* pPara ) const
{
ULONG nVisPos = 0;
ULONG nPos = GetAbsPos( pPara );
for ( ULONG n = 0; n < nPos; n++ )
std::vector<Paragraph*>::const_iterator iter;
for (iter = maEntries.begin(); iter != maEntries.end(); ++iter, ++nVisPos)
{
Paragraph* _pPara = GetParagraph( n );
if ( _pPara->IsVisible() )
nVisPos++;
if (*iter == pPara)
break;
if ((*iter)->IsVisible())
++nVisPos;
}
return nVisPos;
}
......
......@@ -29,27 +29,33 @@
#ifndef _PARALIST_HXX
#define _PARALIST_HXX
class Paragraph;
#include <vector>
#include <tools/list.hxx>
#include <tools/link.hxx>
class ParagraphList : private List
{
private:
Link aVisibleStateChangedHdl;
class Paragraph;
class ParagraphList
{
public:
void Clear( BOOL bDestroyParagraphs );
ULONG GetParagraphCount() const { return List::Count(); }
Paragraph* GetParagraph( ULONG nPos ) const { return (Paragraph*)List::GetObject( nPos ); }
sal_uInt32 GetParagraphCount() const
{
return maEntries.size();
}
ULONG GetAbsPos( Paragraph* pParent ) const { return List::GetPos( pParent ); }
ULONG GetVisPos( Paragraph* pParagraph );
Paragraph* GetParagraph( ULONG nPos ) const
{
return nPos < maEntries.size() ? maEntries[nPos] : NULL;
}
void Insert( Paragraph* pPara, ULONG nAbsPos = LIST_APPEND ) { List::Insert( pPara, nAbsPos ); }
void Remove( ULONG nPara ) { List::Remove( nPara ); }
ULONG GetAbsPos( Paragraph* pParent ) const;
ULONG GetVisPos( Paragraph* pParagraph ) const;
void Append( Paragraph *pPara);
void Insert( Paragraph* pPara, ULONG nAbsPos);
void Remove( ULONG nPara );
void MoveParagraphs( ULONG nStart, ULONG nDest, ULONG nCount );
Paragraph* NextVisible( Paragraph* ) const;
......@@ -67,6 +73,11 @@ public:
void SetVisibleStateChangedHdl( const Link& rLink ) { aVisibleStateChangedHdl = rLink; }
Link GetVisibleStateChangedHdl() const { return aVisibleStateChangedHdl; }
private:
Link aVisibleStateChangedHdl;
std::vector<Paragraph*> maEntries;
};
#endif
......
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