summaryrefslogtreecommitdiff
path: root/vcl/source/edit/textdoc.cxx
diff options
context:
space:
mode:
authorMichaël Lefèvre <lefevre00@yahoo.fr>2014-11-15 11:41:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-11-18 11:32:19 +0000
commit63d8977f9fb0618d36dc8e0ee2f8068b1af92fe6 (patch)
treee70c5ebfabae4b0ca17f9f1ac31045755186641d /vcl/source/edit/textdoc.cxx
parentdf9efbd53d148c713f7d5c391ac06d873b9b4cc1 (diff)
fdo#75757 remove inheritance from std::vector
For TextDoc, also removing ToolsList Change-Id: Id818f61f562317ce106414937253f1748a33315a Reviewed-on: https://gerrit.libreoffice.org/12454 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/edit/textdoc.cxx')
-rw-r--r--vcl/source/edit/textdoc.cxx80
1 files changed, 36 insertions, 44 deletions
diff --git a/vcl/source/edit/textdoc.cxx b/vcl/source/edit/textdoc.cxx
index 560284ccb1d6..324d81b5f519 100644
--- a/vcl/source/edit/textdoc.cxx
+++ b/vcl/source/edit/textdoc.cxx
@@ -407,38 +407,33 @@ void TextNode::Append( const TextNode& rNode )
}
}
+bool TextNode::operator==(TextNode const& other) const
+{
+ return maText == other.maText && &maCharAttribs == &other.maCharAttribs;
+}
+
+
+
TextDoc::TextDoc()
{
mnLeftMargin = 0;
};
-TextDoc::~TextDoc()
-{
- DestroyTextNodes();
-}
-
void TextDoc::Clear()
{
- DestroyTextNodes();
-}
-
-void TextDoc::DestroyTextNodes()
-{
- for ( sal_uLong nNode = 0; nNode < maTextNodes.Count(); nNode++ )
- delete maTextNodes.GetObject( nNode );
maTextNodes.clear();
}
OUString TextDoc::GetText( const sal_Unicode* pSep ) const
{
- sal_uLong nNodes = maTextNodes.Count();
+ sal_uLong nNodes = maTextNodes.size();
OUString aASCIIText;
sal_uLong nLastNode = nNodes-1;
for ( sal_uLong nNode = 0; nNode < nNodes; nNode++ )
{
- TextNode* pNode = maTextNodes.GetObject( nNode );
- OUString aTmp( pNode->GetText() );
+ const TextNode& pNode = maTextNodes[ nNode ];
+ OUString aTmp( pNode.GetText() );
aASCIIText += aTmp;
if ( pSep && ( nNode != nLastNode ) )
aASCIIText += pSep;
@@ -451,9 +446,8 @@ OUString TextDoc::GetText( sal_uLong nPara ) const
{
OUString aText;
- TextNode* pNode = ( nPara < maTextNodes.Count() ) ? maTextNodes.GetObject( nPara ) : 0;
- if ( pNode )
- aText = pNode->GetText();
+ if ( nPara < maTextNodes.size() )
+ aText = maTextNodes[ nPara ].GetText();
return aText;
}
@@ -461,7 +455,7 @@ OUString TextDoc::GetText( sal_uLong nPara ) const
sal_uLong TextDoc::GetTextLen( const sal_Unicode* pSep, const TextSelection* pSel ) const
{
sal_uLong nLen = 0;
- sal_uLong nNodes = maTextNodes.Count();
+ sal_uLong nNodes = maTextNodes.size();
if ( nNodes )
{
sal_uLong nStartNode = 0;
@@ -474,10 +468,10 @@ sal_uLong TextDoc::GetTextLen( const sal_Unicode* pSep, const TextSelection* pSe
for ( sal_uLong nNode = nStartNode; nNode <= nEndNode; nNode++ )
{
- TextNode* pNode = maTextNodes.GetObject( nNode );
+ const TextNode& pNode = maTextNodes[ nNode ];
sal_uInt16 nS = 0;
- sal_Int32 nE = pNode->GetText().getLength();
+ sal_Int32 nE = pNode.GetText().getLength();
if ( pSel && ( nNode == pSel->GetStart().GetPara() ) )
nS = pSel->GetStart().GetIndex();
if ( pSel && ( nNode == pSel->GetEnd().GetPara() ) )
@@ -495,11 +489,11 @@ sal_uLong TextDoc::GetTextLen( const sal_Unicode* pSep, const TextSelection* pSe
TextPaM TextDoc::InsertText( const TextPaM& rPaM, sal_Unicode c )
{
- DBG_ASSERT( c != 0x0A, "TextDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" );
- DBG_ASSERT( c != 0x0D, "TextDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" );
+ DBG_ASSERT( c != 0x0A, "TextDoc::InsertText: Newline not allowed in paragraph!" );
+ DBG_ASSERT( c != 0x0D, "TextDoc::InsertText: Newline not allowed in paragraph!" );
- TextNode* pNode = maTextNodes.GetObject( rPaM.GetPara() );
- pNode->InsertText( rPaM.GetIndex(), c );
+ TextNode& pNode = maTextNodes[ rPaM.GetPara() ];
+ pNode.InsertText( rPaM.GetIndex(), c );
TextPaM aPaM( rPaM.GetPara(), rPaM.GetIndex()+1 );
return aPaM;
@@ -507,11 +501,11 @@ TextPaM TextDoc::InsertText( const TextPaM& rPaM, sal_Unicode c )
TextPaM TextDoc::InsertText( const TextPaM& rPaM, const OUString& rStr )
{
- DBG_ASSERT( rStr.indexOf( 0x0A ) == -1, "TextDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" );
- DBG_ASSERT( rStr.indexOf( 0x0D ) == -1, "TextDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" );
+ DBG_ASSERT( rStr.indexOf( 0x0A ) == -1, "TextDoc::InsertText: Newline not allowed in paragraph!" );
+ DBG_ASSERT( rStr.indexOf( 0x0D ) == -1, "TextDoc::InsertText: Newline not allowed in paragraph!" );
- TextNode* pNode = maTextNodes.GetObject( rPaM.GetPara() );
- pNode->InsertText( rPaM.GetIndex(), rStr );
+ TextNode& pNode = maTextNodes[ rPaM.GetPara() ];
+ pNode.InsertText( rPaM.GetIndex(), rStr );
TextPaM aPaM( rPaM.GetPara(), rPaM.GetIndex()+rStr.getLength() );
return aPaM;
@@ -519,47 +513,45 @@ TextPaM TextDoc::InsertText( const TextPaM& rPaM, const OUString& rStr )
TextPaM TextDoc::InsertParaBreak( const TextPaM& rPaM, bool bKeepEndingAttribs )
{
- TextNode* pNode = maTextNodes.GetObject( rPaM.GetPara() );
- TextNode* pNew = pNode->Split( rPaM.GetIndex(), bKeepEndingAttribs );
+ TextNode& pNode = maTextNodes[ rPaM.GetPara() ];
+ TextNode* pNew = pNode.Split( rPaM.GetIndex(), bKeepEndingAttribs );
- maTextNodes.Insert( pNew, rPaM.GetPara()+1 );
+ maTextNodes.insert( maTextNodes.begin()+rPaM.GetPara()+1, pNew );
TextPaM aPaM( rPaM.GetPara()+1, 0 );
return aPaM;
}
-TextPaM TextDoc::ConnectParagraphs( TextNode* pLeft, TextNode* pRight )
+TextPaM TextDoc::ConnectParagraphs( TextNode& pLeft, const TextNode& pRight )
{
- sal_Int32 nPrevLen = pLeft->GetText().getLength();
- pLeft->Append( *pRight );
+ sal_Int32 nPrevLen = pLeft.GetText().getLength();
+ pLeft.Append( pRight );
// the paragraph on the right vanishes
- sal_uLong nRight = maTextNodes.GetPos( pRight );
- maTextNodes.Remove( nRight );
- delete pRight;
+ RemoveNode( ::std::find( maTextNodes.cbegin(), maTextNodes.cend(), pRight ) - maTextNodes.cbegin() );
- sal_uLong nLeft = maTextNodes.GetPos( pLeft );
+ sal_uLong nLeft = std::find( maTextNodes.begin(), maTextNodes.end(), pLeft ) - maTextNodes.begin();
TextPaM aPaM( nLeft, nPrevLen );
return aPaM;
}
TextPaM TextDoc::RemoveChars( const TextPaM& rPaM, sal_uInt16 nChars )
{
- TextNode* pNode = maTextNodes.GetObject( rPaM.GetPara() );
- pNode->RemoveText( rPaM.GetIndex(), nChars );
+ TextNode& pNode = maTextNodes[ rPaM.GetPara() ];
+ pNode.RemoveText( rPaM.GetIndex(), nChars );
return rPaM;
}
bool TextDoc::IsValidPaM( const TextPaM& rPaM )
{
- if ( rPaM.GetPara() >= maTextNodes.Count() )
+ if ( rPaM.GetPara() >= maTextNodes.size() )
{
OSL_FAIL( "PaM: Para out of range" );
return false;
}
- TextNode * pNode = maTextNodes.GetObject( rPaM.GetPara() );
- if ( rPaM.GetIndex() > pNode->GetText().getLength() )
+ TextNode& pNode = maTextNodes[ rPaM.GetPara() ];
+ if ( rPaM.GetIndex() > pNode.GetText().getLength() )
{
OSL_FAIL( "PaM: Index out of range" );
return false;