[Libreoffice-commits] .: 5 commits - editeng/source svx/inc svx/source
Lubos Lunak
llunak at kemper.freedesktop.org
Fri Mar 4 03:11:09 PST 2011
editeng/source/outliner/outliner.cxx | 12 +--
editeng/source/outliner/paralist.cxx | 127 +++++++++++++++++++++++------------
editeng/source/outliner/paralist.hxx | 35 ++++++---
svx/inc/svx/gallery1.hxx | 7 +
svx/inc/svx/sdasaitm.hxx | 7 +
svx/inc/svx/svdmark.hxx | 7 +
svx/inc/svx/svdmrkv.hxx | 2
svx/source/gallery2/gallery1.cxx | 27 +++----
svx/source/svdraw/svdattr.cxx | 54 +++++---------
svx/source/svdraw/svdedtv.cxx | 37 ++++++----
svx/source/svdraw/svdmark.cxx | 10 +-
11 files changed, 187 insertions(+), 138 deletions(-)
New commits:
commit 1cd7e16000244ed328834d0cac6bf43c05d8d44a
Author: npcdoom <venccsralph at gmail.com>
Date: Wed Mar 2 09:45:41 2011 -0430
Remode deprecated List container.
Signed-off-by: LuboÅ¡ LuÅák <l.lunak at suse.cz>
diff --git a/svx/inc/svx/sdasaitm.hxx b/svx/inc/svx/sdasaitm.hxx
index a77e040..8e98620 100644
--- a/svx/inc/svx/sdasaitm.hxx
+++ b/svx/inc/svx/sdasaitm.hxx
@@ -29,8 +29,9 @@
#ifndef _SDASAITM_HXX
#define _SDASAITM_HXX
+#include <vector>
+
#include <svl/poolitem.hxx>
-#include <tools/list.hxx>
class SdrCustomShapeAdjustmentValue
{
@@ -47,7 +48,7 @@ class SdrCustomShapeAdjustmentValue
class SdrCustomShapeAdjustmentItem : public SfxPoolItem
{
- List aAdjustmentValueList;
+ std::vector<SdrCustomShapeAdjustmentValue> aAdjustmentValueList;
public :
@@ -68,7 +69,7 @@ class SdrCustomShapeAdjustmentItem : public SfxPoolItem
virtual bool QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 ) const;
virtual bool PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 );
- sal_uInt32 GetCount() const { return aAdjustmentValueList.Count(); };
+ sal_uInt32 GetCount() const { return aAdjustmentValueList.size(); };
SVX_DLLPUBLIC const SdrCustomShapeAdjustmentValue& GetValue( sal_uInt32 nIndex ) const;
SVX_DLLPUBLIC void SetValue( sal_uInt32 nIndex,
const SdrCustomShapeAdjustmentValue& rVal );
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 477a966..f7ccb3f 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -1482,9 +1482,6 @@ SdrCustomShapeAdjustmentItem::SdrCustomShapeAdjustmentItem( SvStream& rIn, sal_u
SdrCustomShapeAdjustmentItem::~SdrCustomShapeAdjustmentItem()
{
- void* pPtr;
- for ( pPtr = aAdjustmentValueList.First(); pPtr; pPtr = aAdjustmentValueList.Next() )
- delete (SdrCustomShapeAdjustmentValue*)pPtr;
}
int SdrCustomShapeAdjustmentItem::operator==( const SfxPoolItem& rCmp ) const
@@ -1492,18 +1489,13 @@ int SdrCustomShapeAdjustmentItem::operator==( const SfxPoolItem& rCmp ) const
int bRet = SfxPoolItem::operator==( rCmp );
if ( bRet )
{
- bRet = ((SdrCustomShapeAdjustmentItem&)rCmp).GetCount() == GetCount();
- if ( bRet )
+ bRet = GetCount() == ((SdrCustomShapeAdjustmentItem&)rCmp).GetCount();
+
+ if (bRet)
{
- sal_uInt32 i;
- for ( i = 0; i < GetCount(); i++ )
- {
- if ( ((SdrCustomShapeAdjustmentItem&)rCmp).GetValue( i ).nValue != GetValue( i ).nValue )
- {
- bRet = 0;
- break;
- }
- }
+ for (sal_uInt32 i = 0; i < GetCount(); ++i)
+ if (aAdjustmentValueList[i].nValue != ((SdrCustomShapeAdjustmentItem&)rCmp).aAdjustmentValueList[i].nValue)
+ return false;
}
}
return bRet;
@@ -1550,13 +1542,11 @@ SvStream& SdrCustomShapeAdjustmentItem::Store( SvStream& rOut, sal_uInt16 nItemV
SfxPoolItem* SdrCustomShapeAdjustmentItem::Clone( SfxItemPool * /*pPool*/) const
{
- sal_uInt32 i;
SdrCustomShapeAdjustmentItem* pItem = new SdrCustomShapeAdjustmentItem;
- for ( i = 0; i < GetCount(); i++ )
- {
- const SdrCustomShapeAdjustmentValue& rVal = GetValue( i );
- pItem->SetValue( i, rVal );
- }
+
+ if (pItem)
+ pItem->aAdjustmentValueList = aAdjustmentValueList;
+
return pItem;
}
@@ -1566,19 +1556,15 @@ const SdrCustomShapeAdjustmentValue& SdrCustomShapeAdjustmentItem::GetValue( sal
if ( aAdjustmentValueList.Count() <= nIndex )
OSL_FAIL( "SdrCustomShapeAdjustemntItem::GetValue - nIndex out of range (SJ)" );
#endif
- return *(SdrCustomShapeAdjustmentValue*)aAdjustmentValueList.GetObject( nIndex );
+ return aAdjustmentValueList[nIndex];
}
void SdrCustomShapeAdjustmentItem::SetValue( sal_uInt32 nIndex, const SdrCustomShapeAdjustmentValue& rVal )
{
- sal_uInt32 i;
- for ( i = GetCount(); i <= nIndex; i++ )
- {
- SdrCustomShapeAdjustmentValue* pItem = new SdrCustomShapeAdjustmentValue;
- aAdjustmentValueList.Insert( pItem, LIST_APPEND );
- }
- SdrCustomShapeAdjustmentValue& rValue = *(SdrCustomShapeAdjustmentValue*)aAdjustmentValueList.GetObject( nIndex );
- rValue.nValue = rVal.nValue;
+ for (sal_uInt32 i = aAdjustmentValueList.size(); i <= nIndex; i++ )
+ aAdjustmentValueList.push_back(SdrCustomShapeAdjustmentValue());
+
+ aAdjustmentValueList[nIndex] = rVal;
}
sal_uInt16 SdrCustomShapeAdjustmentItem::GetVersion( sal_uInt16 /*nFileFormatVersion*/) const
@@ -1606,19 +1592,17 @@ bool SdrCustomShapeAdjustmentItem::PutValue( const uno::Any& rVal, BYTE /*nMembe
if( !( rVal >>= aSequence ) )
return false;
- void* pPtr;
- for ( pPtr = aAdjustmentValueList.First(); pPtr; pPtr = aAdjustmentValueList.Next() )
- delete (SdrCustomShapeAdjustmentValue*)pPtr;
+ aAdjustmentValueList.clear();
sal_uInt32 i, nCount = aSequence.getLength();
if ( nCount )
{
+ SdrCustomShapeAdjustmentValue val;
const sal_Int32* pPtr2 = aSequence.getConstArray();
for ( i = 0; i < nCount; i++ )
{
- SdrCustomShapeAdjustmentValue* pItem = new SdrCustomShapeAdjustmentValue;
- pItem->nValue = *pPtr2++;
- aAdjustmentValueList.Insert( pItem, LIST_APPEND );
+ val.nValue = *pPtr2++;
+ aAdjustmentValueList.push_back(val);
}
}
return true;
commit e7150001421e530d0bf7fdedb42572f07bcffa56
Author: npcdoom <venccsralph at gmail.com>
Date: Wed Mar 2 10:07:01 2011 -0430
Remove deprecated List container.
Signed-off-by: LuboÅ¡ LuÅák <l.lunak at suse.cz>
diff --git a/svx/inc/svx/svdmark.hxx b/svx/inc/svx/svdmark.hxx
index 2fd1034..b9d3aaa 100644
--- a/svx/inc/svx/svdmark.hxx
+++ b/svx/inc/svx/svdmark.hxx
@@ -29,9 +29,10 @@
#ifndef _SVDMARK_HXX
#define _SVDMARK_HXX
+#include <vector>
+
#include <tools/contnr.hxx>
#include <tools/string.hxx>
-#include <tools/list.hxx>
#include "svx/svxdllapi.h"
#include <svx/sdrobjectuser.hxx>
@@ -378,7 +379,7 @@ namespace sdr
SdrMarkList maMarkedObjectList;
SdrMarkList maEdgesOfMarkedNodes;
SdrMarkList maMarkedEdgesOfMarkedNodes;
- List maAllMarkedObjects;
+ std::vector<SdrObject*> maAllMarkedObjects;
// bitfield
unsigned mbEdgesOfMarkedNodesDirty : 1;
@@ -398,7 +399,7 @@ namespace sdr
const SdrMarkList& GetEdgesOfMarkedNodes() const;
const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const;
- const List& GetAllMarkedObjects() const;
+ const std::vector<SdrObject*>& GetAllMarkedObjects() const;
SdrMarkList& GetMarkedObjectListWriteAccess()
{
diff --git a/svx/inc/svx/svdmrkv.hxx b/svx/inc/svx/svdmrkv.hxx
index 896a239..30da68e 100644
--- a/svx/inc/svx/svdmrkv.hxx
+++ b/svx/inc/svx/svdmrkv.hxx
@@ -286,7 +286,7 @@ public:
// die selbst jedoch nicht markiert sind.
const SdrMarkList& GetEdgesOfMarkedNodes() const { return mpSdrViewSelection->GetEdgesOfMarkedNodes(); }
const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const { return mpSdrViewSelection->GetMarkedEdgesOfMarkedNodes(); }
- const List& GetTransitiveHullOfMarkedObjects() const { return mpSdrViewSelection->GetAllMarkedObjects(); }
+ const std::vector<SdrObject*>& GetTransitiveHullOfMarkedObjects() const { return mpSdrViewSelection->GetAllMarkedObjects(); }
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index 693f933..023f20b 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -341,37 +341,44 @@ void SdrEditView::EndUndo()
void SdrEditView::ImpBroadcastEdgesOfMarkedNodes()
{
- const List& rAllMarkedObjects = GetTransitiveHullOfMarkedObjects();
+ std::vector<SdrObject*>::const_iterator iterPos;
+ const std::vector<SdrObject*>& rAllMarkedObjects = GetTransitiveHullOfMarkedObjects();
// #i13033#
// New mechanism to search for necessary disconnections for
// changed connectors inside the transitive hull of all at
// the beginning of UNDO selected objects
- for(sal_uInt32 a(0L); a < rAllMarkedObjects.Count(); a++)
+ for(sal_uInt32 a(0L); a < rAllMarkedObjects.size(); a++)
{
- SdrEdgeObj* pEdge = PTR_CAST(SdrEdgeObj, (SdrObject*)rAllMarkedObjects.GetObject(a));
+ SdrEdgeObj* pEdge = PTR_CAST(SdrEdgeObj, rAllMarkedObjects[a]);
if(pEdge)
{
SdrObject* pObj1 = pEdge->GetConnectedNode(sal_False);
SdrObject* pObj2 = pEdge->GetConnectedNode(sal_True);
- if(pObj1
- && LIST_ENTRY_NOTFOUND == rAllMarkedObjects.GetPos(pObj1)
- && !pEdge->CheckNodeConnection(sal_False))
+ if(pObj1 && !pEdge->CheckNodeConnection(sal_False))
{
- if( IsUndoEnabled() )
- AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
- pEdge->DisconnectFromNode(sal_False);
+ iterPos = std::find(rAllMarkedObjects.begin(),rAllMarkedObjects.end(),pObj1);
+
+ if (iterPos == rAllMarkedObjects.end())
+ {
+ if( IsUndoEnabled() )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
+ pEdge->DisconnectFromNode(sal_False);
+ }
}
- if(pObj2
- && LIST_ENTRY_NOTFOUND == rAllMarkedObjects.GetPos(pObj2)
- && !pEdge->CheckNodeConnection(sal_True))
+ if(pObj2 && !pEdge->CheckNodeConnection(sal_True))
{
- if( IsUndoEnabled() )
- AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
- pEdge->DisconnectFromNode(sal_True);
+ iterPos = std::find(rAllMarkedObjects.begin(),rAllMarkedObjects.end(),pObj2);
+
+ if (iterPos == rAllMarkedObjects.end())
+ {
+ if( IsUndoEnabled() )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
+ pEdge->DisconnectFromNode(sal_True);
+ }
}
}
}
diff --git a/svx/source/svdraw/svdmark.cxx b/svx/source/svdraw/svdmark.cxx
index 5b60131..439dcdb 100644
--- a/svx/source/svdraw/svdmark.cxx
+++ b/svx/source/svdraw/svdmark.cxx
@@ -905,7 +905,7 @@ namespace sdr
mbEdgesOfMarkedNodesDirty = sal_True;
maEdgesOfMarkedNodes.Clear();
maMarkedEdgesOfMarkedNodes.Clear();
- maAllMarkedObjects.Clear();
+ maAllMarkedObjects.clear();
}
}
@@ -929,12 +929,10 @@ namespace sdr
return maMarkedEdgesOfMarkedNodes;
}
- const List& ViewSelection::GetAllMarkedObjects() const
+ const std::vector<SdrObject*>& ViewSelection::GetAllMarkedObjects() const
{
if(mbEdgesOfMarkedNodesDirty)
- {
((ViewSelection*)this)->ImpForceEdgesOfMarkedNodes();
- }
return maAllMarkedObjects;
}
@@ -961,7 +959,7 @@ namespace sdr
}
}
- maAllMarkedObjects.Insert(pObj, LIST_APPEND);
+ maAllMarkedObjects.push_back(pObj);
}
}
@@ -973,7 +971,7 @@ namespace sdr
maMarkedObjectList.ForceSort();
maEdgesOfMarkedNodes.Clear();
maMarkedEdgesOfMarkedNodes.Clear();
- maAllMarkedObjects.Clear();
+ maAllMarkedObjects.clear();
// #126320# GetMarkCount after ForceSort
const ULONG nMarkAnz(maMarkedObjectList.GetMarkCount());
commit 1ef24ac804eae796526eba6b6010c99bb2829d63
Author: npcdoom <venccsralph at gmail.com>
Date: Tue Mar 1 13:21:42 2011 -0430
Changed some Insert calls for Append and added some asserts.
Signed-off-by: LuboÅ¡ LuÅák <l.lunak at suse.cz>
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 57f811a..b5cfad5 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -65,7 +65,7 @@
// calculate if it's RTL or not
#include <unicode/ubidi.h>
-
+#include <cassert>
using ::std::advance;
#define DEFAULT_SCALE 75
@@ -646,7 +646,7 @@ void Outliner::AddText( const OutlinerParaObject& rPObj )
for( USHORT n = 0; n < rPObj.Count(); n++ )
{
pPara = new Paragraph( rPObj.GetParagraphData(n) );
- pParaList->Insert( pPara, LIST_APPEND );
+ pParaList->Append(pPara);
USHORT nP = sal::static_int_cast< USHORT >(nPara+n);
DBG_ASSERT(pParaList->GetAbsPos(pPara)==nP,"AddText:Out of sync");
ImplInitDepth( nP, pPara->GetDepth(), FALSE );
@@ -1178,7 +1178,7 @@ ULONG Outliner::Read( SvStream& rInput, const String& rBaseURL, USHORT eFormat,
for ( n = 0; n < nParas; n++ )
{
Paragraph* pPara = new Paragraph( 0 );
- pParaList->Insert( pPara, LIST_APPEND );
+ pParaList->Append(pPara);
if ( eFormat == EE_FORMAT_BIN )
{
@@ -1341,7 +1341,7 @@ Outliner::Outliner( SfxItemPool* pPool, USHORT nMode )
pParaList = new ParagraphList;
pParaList->SetVisibleStateChangedHdl( LINK( this, Outliner, ParaVisibleStateChangedHdl ) );
Paragraph* pPara = new Paragraph( 0 );
- pParaList->Insert( pPara, LIST_APPEND );
+ pParaList->Append(pPara);
bFirstParaIsEmpty = TRUE;
pEditEngine = new OutlinerEditEng( this, pPool );
@@ -2025,7 +2025,7 @@ void Outliner::Clear()
ImplBlockInsertionCallbacks( TRUE );
pEditEngine->Clear();
pParaList->Clear( TRUE );
- pParaList->Insert( new Paragraph( nMinDepth ), LIST_APPEND );
+ pParaList->Append( new Paragraph( nMinDepth ));
bFirstParaIsEmpty = TRUE;
ImplBlockInsertionCallbacks( FALSE );
}
diff --git a/editeng/source/outliner/paralist.cxx b/editeng/source/outliner/paralist.cxx
index 324be65..f018318 100644
--- a/editeng/source/outliner/paralist.cxx
+++ b/editeng/source/outliner/paralist.cxx
@@ -30,9 +30,12 @@
#include "precompiled_editeng.hxx"
#include <paralist.hxx>
+
#include <editeng/outliner.hxx> // only because of Paragraph, this must be changed!
#include <editeng/numdef.hxx>
+#include <osl/diagnose.h>
+
DBG_NAME(Paragraph)
ParagraphData::ParagraphData()
@@ -138,21 +141,27 @@ void ParagraphList::Append( Paragraph* pPara)
void ParagraphList::Insert( Paragraph* pPara, ULONG nAbsPos)
{
+ OSL_ASSERT(nAbsPos != ULONG_MAX && nAbsPos <= maEntries.size());
+
maEntries.insert(maEntries.begin()+nAbsPos,pPara);
}
void ParagraphList::Remove( ULONG nPara )
{
+ OSL_ASSERT(nPara < maEntries.size());
+
maEntries.erase(maEntries.begin() + nPara );
}
void ParagraphList::MoveParagraphs( ULONG nStart, ULONG nDest, ULONG _nCount )
{
+ OSL_ASSERT(nStart < maEntries.size() && nDest < maEntries.size());
+
if ( ( nDest < nStart ) || ( nDest >= ( nStart + _nCount ) ) )
{
std::vector<Paragraph*> aParas;
std::vector<Paragraph*>::iterator iterBeg = maEntries.begin() + nStart;
- std::vector<Paragraph*>::iterator iterEnd = iterBeg + _nCount + 1;
+ std::vector<Paragraph*>::iterator iterEnd = iterBeg + _nCount;
std::copy(iterBeg,iterEnd,std::back_inserter(aParas));
commit 60ad7f2628119a32d468d90173cc066c7bff817e
Author: npcdoom <venccsralph at gmail.com>
Date: Sun Feb 27 22:22:17 2011 -0430
Remove deprecated List container in gallery1.
Signed-off-by: LuboÅ¡ LuÅák <l.lunak at suse.cz>
diff --git a/svx/inc/svx/gallery1.hxx b/svx/inc/svx/gallery1.hxx
index 8f93dd0..b0f3ee5 100644
--- a/svx/inc/svx/gallery1.hxx
+++ b/svx/inc/svx/gallery1.hxx
@@ -31,12 +31,10 @@
#include <tools/string.hxx>
#include <tools/urlobj.hxx>
-#include <tools/list.hxx>
#include <svl/brdcst.hxx>
#include "svx/svxdllapi.h"
#include <cstdio>
-#include <list>
#include <vector>
// ---------------------
@@ -120,6 +118,7 @@ SvStream& operator>>( SvStream& rIn, GalleryImportThemeEntry& rEntry );
class SfxListener;
class GalleryTheme;
+class GalleryThemeCacheEntry;
class Gallery : public SfxBroadcaster
{
@@ -127,11 +126,13 @@ class Gallery : public SfxBroadcaster
friend Gallery* createGallery( const rtl::OUString& );
friend void disposeGallery( Gallery* );
+ typedef std::vector<GalleryThemeCacheEntry*> GalleryCacheThemeList;
+
private:
GalleryThemeList aThemeList;
GalleryImportThemeList aImportList;
- List aThemeCache;
+ GalleryCacheThemeList aThemeCache;
INetURLObject aRelURL;
INetURLObject aUserURL;
rtl_TextEncoding nReadTextEncoding;
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 82d354a..b5065f1 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -838,11 +838,14 @@ GalleryTheme* Gallery::ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry
if( pThemeEntry )
{
- GalleryThemeCacheEntry* pEntry;
-
- for( pEntry = (GalleryThemeCacheEntry*) aThemeCache.First(); pEntry && !pTheme; pEntry = (GalleryThemeCacheEntry*) aThemeCache.Next() )
- if( pThemeEntry == pEntry->GetThemeEntry() )
- pTheme = pEntry->GetTheme();
+ for (GalleryCacheThemeList::const_iterator it = aThemeCache.begin(); it != aThemeCache.end(); ++it)
+ {
+ if (pThemeEntry == (*it)->GetThemeEntry())
+ {
+ pTheme = (*it)->GetTheme();
+ break;
+ }
+ }
if( !pTheme )
{
@@ -874,7 +877,7 @@ GalleryTheme* Gallery::ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry
}
if( pTheme )
- aThemeCache.Insert( new GalleryThemeCacheEntry( pThemeEntry, pTheme ), LIST_APPEND );
+ aThemeCache.push_back( new GalleryThemeCacheEntry( pThemeEntry, pTheme ));
}
}
@@ -885,15 +888,13 @@ GalleryTheme* Gallery::ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry
void Gallery::ImplDeleteCachedTheme( GalleryTheme* pTheme )
{
- GalleryThemeCacheEntry* pEntry;
- BOOL bDone = FALSE;
-
- for( pEntry = (GalleryThemeCacheEntry*) aThemeCache.First(); pEntry && !bDone; pEntry = (GalleryThemeCacheEntry*) aThemeCache.Next() )
+ for (GalleryCacheThemeList::iterator it = aThemeCache.begin(); it != aThemeCache.end(); ++it)
{
- if( pTheme == pEntry->GetTheme() )
+ if (pTheme == (*it)->GetTheme())
{
- delete (GalleryThemeCacheEntry*) aThemeCache.Remove( pEntry );
- bDone = TRUE;
+ delete *it;
+ aThemeCache.erase(it);
+ break;
}
}
}
commit 3c43a5b32ff0a224b2a31917cfe636579872c129
Author: npcdoom <venccsralph at gmail.com>
Date: Sun Feb 27 21:14:03 2011 -0430
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: LuboÅ¡ LuÅák <l.lunak at suse.cz>
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 2b1a23c..57f811a 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -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 );
}
diff --git a/editeng/source/outliner/paralist.cxx b/editeng/source/outliner/paralist.cxx
index 55c7462..324be65 100644
--- a/editeng/source/outliner/paralist.cxx
+++ b/editeng/source/outliner/paralist.cxx
@@ -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;
}
diff --git a/editeng/source/outliner/paralist.hxx b/editeng/source/outliner/paralist.hxx
index 410887c..d9095ea 100644
--- a/editeng/source/outliner/paralist.hxx
+++ b/editeng/source/outliner/paralist.hxx
@@ -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
More information about the Libreoffice-commits
mailing list