summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authornpcdoom <venccsralph@gmail.com>2011-03-01 13:21:42 -0430
committerLuboš Luňák <l.lunak@suse.cz>2011-03-04 12:10:56 +0100
commita9767204728a08d31673d35cf70b7b92748c3e75 (patch)
tree123d9718ef5d3674791d2213a6a212552e0583c0 /editeng
parent1299e87202fdbc44d7bce849a0fa031e4470ddc9 (diff)
Changed some Insert calls for Append and added some asserts.
Signed-off-by: Luboš Luňák <l.lunak@suse.cz>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/outliner/outliner.cxx10
-rw-r--r--editeng/source/outliner/paralist.cxx11
2 files changed, 15 insertions, 6 deletions
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index a316cfefba40..20b9f4ddd406 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 300354f1340d..ee7d518b4137 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));