Kaydet (Commit) 3a626669 authored tarafından Michaël Lefèvre's avatar Michaël Lefèvre Kaydeden (comit) Caolán McNamara

fdo#75757 Remove inheritance from std::vector

Take care not reproducing fdo#86552 again.

Change-Id: I4a5967e76afcb5467addc81bc9eca61bb65865e7
Reviewed-on: https://gerrit.libreoffice.org/13992Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst b698b936
...@@ -150,21 +150,6 @@ struct TEIMEInfos ...@@ -150,21 +150,6 @@ struct TEIMEInfos
void DestroyAttribs(); void DestroyAttribs();
}; };
// ----------------- Wrapper for old Tools List -------------------
#include <vector>
#include <algorithm>
template <class T> class ToolsList : public ::std::vector< T >
{
public:
size_t Count() const { return ::std::vector< T >::size(); }
size_t GetPos( T pObject ) const { return ( ::std::find( this->begin(), this->end(), pObject ) ) - this->begin(); }
T GetObject( size_t nIndex ) const { return (*this)[nIndex]; }
void Insert( T pObject, size_t nPos ) { ::std::vector< T >::insert( this->begin()+nPos, pObject ); }
void Remove( size_t nPos ) { ::std::vector< T >::erase( this->begin()+nPos ); }
};
#endif // INCLUDED_VCL_TEXTDATA_HXX #endif // INCLUDED_VCL_TEXTDATA_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -424,20 +424,20 @@ void TextDoc::Clear() ...@@ -424,20 +424,20 @@ void TextDoc::Clear()
void TextDoc::DestroyTextNodes() void TextDoc::DestroyTextNodes()
{ {
for ( sal_uLong nNode = 0; nNode < maTextNodes.Count(); nNode++ ) for ( sal_uLong nNode = 0; nNode < maTextNodes.size(); nNode++ )
delete maTextNodes.GetObject( nNode ); delete maTextNodes[ nNode ];
maTextNodes.clear(); maTextNodes.clear();
} }
OUString TextDoc::GetText( const sal_Unicode* pSep ) const OUString TextDoc::GetText( const sal_Unicode* pSep ) const
{ {
sal_uLong nNodes = maTextNodes.Count(); sal_uLong nNodes = maTextNodes.size();
OUString aASCIIText; OUString aASCIIText;
sal_uLong nLastNode = nNodes-1; sal_uLong nLastNode = nNodes-1;
for ( sal_uLong nNode = 0; nNode < nNodes; nNode++ ) for ( sal_uLong nNode = 0; nNode < nNodes; nNode++ )
{ {
TextNode* pNode = maTextNodes.GetObject( nNode ); TextNode* pNode = maTextNodes[ nNode ];
OUString aTmp( pNode->GetText() ); OUString aTmp( pNode->GetText() );
aASCIIText += aTmp; aASCIIText += aTmp;
if ( pSep && ( nNode != nLastNode ) ) if ( pSep && ( nNode != nLastNode ) )
...@@ -451,7 +451,7 @@ OUString TextDoc::GetText( sal_uLong nPara ) const ...@@ -451,7 +451,7 @@ OUString TextDoc::GetText( sal_uLong nPara ) const
{ {
OUString aText; OUString aText;
TextNode* pNode = ( nPara < maTextNodes.Count() ) ? maTextNodes.GetObject( nPara ) : 0; TextNode* pNode = ( nPara < maTextNodes.size() ) ? maTextNodes[ nPara ] : 0;
if ( pNode ) if ( pNode )
aText = pNode->GetText(); aText = pNode->GetText();
...@@ -461,7 +461,7 @@ OUString TextDoc::GetText( sal_uLong nPara ) const ...@@ -461,7 +461,7 @@ OUString TextDoc::GetText( sal_uLong nPara ) const
sal_uLong TextDoc::GetTextLen( const sal_Unicode* pSep, const TextSelection* pSel ) const sal_uLong TextDoc::GetTextLen( const sal_Unicode* pSep, const TextSelection* pSel ) const
{ {
sal_uLong nLen = 0; sal_uLong nLen = 0;
sal_uLong nNodes = maTextNodes.Count(); sal_uLong nNodes = maTextNodes.size();
if ( nNodes ) if ( nNodes )
{ {
sal_uLong nStartNode = 0; sal_uLong nStartNode = 0;
...@@ -474,7 +474,7 @@ sal_uLong TextDoc::GetTextLen( const sal_Unicode* pSep, const TextSelection* pSe ...@@ -474,7 +474,7 @@ sal_uLong TextDoc::GetTextLen( const sal_Unicode* pSep, const TextSelection* pSe
for ( sal_uLong nNode = nStartNode; nNode <= nEndNode; nNode++ ) for ( sal_uLong nNode = nStartNode; nNode <= nEndNode; nNode++ )
{ {
TextNode* pNode = maTextNodes.GetObject( nNode ); TextNode* pNode = maTextNodes[ nNode ];
sal_uInt16 nS = 0; sal_uInt16 nS = 0;
sal_Int32 nE = pNode->GetText().getLength(); sal_Int32 nE = pNode->GetText().getLength();
...@@ -498,7 +498,7 @@ TextPaM TextDoc::InsertText( const TextPaM& rPaM, sal_Unicode c ) ...@@ -498,7 +498,7 @@ TextPaM TextDoc::InsertText( const TextPaM& rPaM, sal_Unicode c )
DBG_ASSERT( c != 0x0A, "TextDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" ); 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 != 0x0D, "TextDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" );
TextNode* pNode = maTextNodes.GetObject( rPaM.GetPara() ); TextNode* pNode = maTextNodes[ rPaM.GetPara() ];
pNode->InsertText( rPaM.GetIndex(), c ); pNode->InsertText( rPaM.GetIndex(), c );
TextPaM aPaM( rPaM.GetPara(), rPaM.GetIndex()+1 ); TextPaM aPaM( rPaM.GetPara(), rPaM.GetIndex()+1 );
...@@ -510,7 +510,7 @@ TextPaM TextDoc::InsertText( const TextPaM& rPaM, const OUString& rStr ) ...@@ -510,7 +510,7 @@ 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( 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( 0x0D ) == -1, "TextDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" );
TextNode* pNode = maTextNodes.GetObject( rPaM.GetPara() ); TextNode* pNode = maTextNodes[ rPaM.GetPara() ];
pNode->InsertText( rPaM.GetIndex(), rStr ); pNode->InsertText( rPaM.GetIndex(), rStr );
TextPaM aPaM( rPaM.GetPara(), rPaM.GetIndex()+rStr.getLength() ); TextPaM aPaM( rPaM.GetPara(), rPaM.GetIndex()+rStr.getLength() );
...@@ -519,10 +519,10 @@ TextPaM TextDoc::InsertText( const TextPaM& rPaM, const OUString& rStr ) ...@@ -519,10 +519,10 @@ TextPaM TextDoc::InsertText( const TextPaM& rPaM, const OUString& rStr )
TextPaM TextDoc::InsertParaBreak( const TextPaM& rPaM, bool bKeepEndingAttribs ) TextPaM TextDoc::InsertParaBreak( const TextPaM& rPaM, bool bKeepEndingAttribs )
{ {
TextNode* pNode = maTextNodes.GetObject( rPaM.GetPara() ); TextNode* pNode = maTextNodes[ rPaM.GetPara() ];
TextNode* pNew = pNode->Split( rPaM.GetIndex(), bKeepEndingAttribs ); 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 ); TextPaM aPaM( rPaM.GetPara()+1, 0 );
return aPaM; return aPaM;
...@@ -534,18 +534,17 @@ TextPaM TextDoc::ConnectParagraphs( TextNode* pLeft, TextNode* pRight ) ...@@ -534,18 +534,17 @@ TextPaM TextDoc::ConnectParagraphs( TextNode* pLeft, TextNode* pRight )
pLeft->Append( *pRight ); pLeft->Append( *pRight );
// the paragraph on the right vanishes // the paragraph on the right vanishes
sal_uLong nRight = maTextNodes.GetPos( pRight ); maTextNodes.erase( std::find( maTextNodes.begin(), maTextNodes.end(), pRight ) );
maTextNodes.Remove( nRight );
delete pRight; delete pRight;
sal_uLong nLeft = maTextNodes.GetPos( pLeft ); sal_uLong nLeft = ::std::find( maTextNodes.begin(), maTextNodes.end(), pLeft ) - maTextNodes.begin();
TextPaM aPaM( nLeft, nPrevLen ); TextPaM aPaM( nLeft, nPrevLen );
return aPaM; return aPaM;
} }
TextPaM TextDoc::RemoveChars( const TextPaM& rPaM, sal_uInt16 nChars ) TextPaM TextDoc::RemoveChars( const TextPaM& rPaM, sal_uInt16 nChars )
{ {
TextNode* pNode = maTextNodes.GetObject( rPaM.GetPara() ); TextNode* pNode = maTextNodes[ rPaM.GetPara() ];
pNode->RemoveText( rPaM.GetIndex(), nChars ); pNode->RemoveText( rPaM.GetIndex(), nChars );
return rPaM; return rPaM;
...@@ -553,12 +552,12 @@ TextPaM TextDoc::RemoveChars( const TextPaM& rPaM, sal_uInt16 nChars ) ...@@ -553,12 +552,12 @@ TextPaM TextDoc::RemoveChars( const TextPaM& rPaM, sal_uInt16 nChars )
bool TextDoc::IsValidPaM( const TextPaM& rPaM ) bool TextDoc::IsValidPaM( const TextPaM& rPaM )
{ {
if ( rPaM.GetPara() >= maTextNodes.Count() ) if ( rPaM.GetPara() >= maTextNodes.size() )
{ {
OSL_FAIL( "PaM: Para out of range" ); OSL_FAIL( "PaM: Para out of range" );
return false; return false;
} }
TextNode * pNode = maTextNodes.GetObject( rPaM.GetPara() ); TextNode * pNode = maTextNodes[ rPaM.GetPara() ];
if ( rPaM.GetIndex() > pNode->GetText().getLength() ) if ( rPaM.GetIndex() > pNode->GetText().getLength() )
{ {
OSL_FAIL( "PaM: Index out of range" ); OSL_FAIL( "PaM: Index out of range" );
......
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ public:
class TextDoc class TextDoc
{ {
private: private:
ToolsList<TextNode*> maTextNodes; std::vector<TextNode*> maTextNodes;
sal_uInt16 mnLeftMargin; sal_uInt16 mnLeftMargin;
protected: protected:
...@@ -102,8 +102,8 @@ public: ...@@ -102,8 +102,8 @@ public:
void Clear(); void Clear();
ToolsList<TextNode*>& GetNodes() { return maTextNodes; } std::vector<TextNode*>& GetNodes() { return maTextNodes; }
const ToolsList<TextNode*>& GetNodes() const { return maTextNodes; } const std::vector<TextNode*>& GetNodes() const { return maTextNodes; }
TextPaM RemoveChars( const TextPaM& rPaM, sal_uInt16 nChars ); TextPaM RemoveChars( const TextPaM& rPaM, sal_uInt16 nChars );
TextPaM InsertText( const TextPaM& rPaM, sal_Unicode c ); TextPaM InsertText( const TextPaM& rPaM, sal_Unicode c );
......
This diff is collapsed.
...@@ -173,20 +173,20 @@ void TextUndoDelPara::Undo() ...@@ -173,20 +173,20 @@ void TextUndoDelPara::Undo()
void TextUndoDelPara::Redo() void TextUndoDelPara::Redo()
{ {
// pNode is not valid anymore in case an Undo joined paragraphs // pNode is not valid anymore in case an Undo joined paragraphs
mpNode = GetDoc()->GetNodes().GetObject( mnPara ); mpNode = GetDoc()->GetNodes()[ mnPara ];
delete GetTEParaPortions()->GetObject( mnPara ); delete GetTEParaPortions()->GetObject( mnPara );
GetTEParaPortions()->Remove( mnPara ); GetTEParaPortions()->Remove( mnPara );
// do not delete Node because of Undo! // do not delete Node because of Undo!
GetDoc()->GetNodes().Remove( mnPara ); GetDoc()->GetNodes().erase( ::std::find( GetDoc()->GetNodes().begin(), GetDoc()->GetNodes().end(), mpNode ) );
GetTextEngine()->ImpParagraphRemoved( mnPara ); GetTextEngine()->ImpParagraphRemoved( mnPara );
mbDelObject = true; // belongs again to the Undo mbDelObject = true; // belongs again to the Undo
sal_uLong nParas = GetDoc()->GetNodes().Count(); sal_uLong nParas = GetDoc()->GetNodes().size();
sal_uLong n = mnPara < nParas ? mnPara : (nParas-1); sal_uLong n = mnPara < nParas ? mnPara : (nParas-1);
TextNode* pN = GetDoc()->GetNodes().GetObject( n ); TextNode* pN = GetDoc()->GetNodes()[ n ];
TextPaM aPaM( n, pN->GetText().getLength() ); TextPaM aPaM( n, pN->GetText().getLength() );
SetSelection( aPaM ); SetSelection( aPaM );
} }
......
This diff is collapsed.
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