Kaydet (Commit) 9e5a221f 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

Removing TextLines class by the way

Change-Id: Ic491af976d61cac8e4b37857ff3a76570611d90d
Reviewed-on: https://gerrit.libreoffice.org/12474Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 2c1bf30b
......@@ -24,7 +24,7 @@
#include <vcl/virdev.hxx>
#include <vcl/cursor.hxx>
#include <vector>
#include <boost/ptr_container/ptr_vector.hpp>
class TextNode;
class TextView;
......@@ -162,15 +162,6 @@ public:
inline bool operator != ( const TextLine& rLine ) const;
};
class TextLines : public std::vector<TextLine*> {
public:
~TextLines()
{
for( iterator it = begin(); it != end(); ++it )
delete *it;
}
};
inline bool TextLine::operator == ( const TextLine& rLine ) const
{
return ( ( mnStart == rLine.mnStart ) &&
......@@ -189,15 +180,15 @@ class TEParaPortion
private:
TextNode* mpNode;
TextLines maLines;
boost::ptr_vector<TextLine> maLines;
TETextPortionList maTextPortions;
std::vector<TEWritingDirectionInfo> maWritingDirectionInfos;
sal_uInt16 mnInvalidPosStart;
sal_uInt16 mnInvalidPosStart;
short mnInvalidDiff;
bool mbInvalid;
bool mbSimple; // nur lineares Tippen
bool mbSimple; // only type linearly
TEParaPortion( const TEParaPortion& ) {;}
......@@ -217,7 +208,7 @@ public:
short GetInvalidDiff() const { return mnInvalidDiff; }
TextNode* GetNode() const { return mpNode; }
TextLines& GetLines() { return maLines; }
boost::ptr_vector<TextLine>& GetLines() { return maLines; }
TETextPortionList& GetTextPortions() { return maTextPortions; }
std::vector<TEWritingDirectionInfo>& GetWritingDirectionInfos() { return maWritingDirectionInfos; }
......
......@@ -163,16 +163,16 @@ sal_uInt16 TEParaPortion::GetLineNumber( sal_uInt16 nChar, bool bInclEnd )
{
for ( sal_uInt16 nLine = 0; nLine < maLines.size(); nLine++ )
{
TextLine* pLine = maLines[ nLine ];
if ( ( bInclEnd && ( pLine->GetEnd() >= nChar ) ) ||
( pLine->GetEnd() > nChar ) )
TextLine& pLine = maLines[ nLine ];
if ( ( bInclEnd && ( pLine.GetEnd() >= nChar ) ) ||
( pLine.GetEnd() > nChar ) )
{
return nLine;
}
}
// Then it should be at the end of the last line
OSL_ENSURE(nChar == maLines[maLines.size() - 1]->GetEnd(), "wrong Index");
OSL_ENSURE(nChar == maLines.back().GetEnd(), "wrong Index");
OSL_ENSURE(!bInclEnd, "Line not found: FindLine");
return ( maLines.size() - 1 );
}
......@@ -183,11 +183,11 @@ void TEParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormat
DBG_ASSERT( nLines, "CorrectPortionNumbersFromLine: Leere Portion?" );
if ( nLastFormattedLine < ( nLines - 1 ) )
{
const TextLine* pLastFormatted = maLines[ nLastFormattedLine ];
const TextLine* pUnformatted = maLines[ nLastFormattedLine+1 ];
short nPortionDiff = pUnformatted->GetStartPortion() - pLastFormatted->GetEndPortion();
short nTextDiff = pUnformatted->GetStart() - pLastFormatted->GetEnd();
nTextDiff++; // LastFormatted->GetEnd() was inclusive => subtracted one too much!
const TextLine& pLastFormatted = maLines[ nLastFormattedLine ];
const TextLine& pUnformatted = maLines[ nLastFormattedLine+1 ];
short nPortionDiff = pUnformatted.GetStartPortion() - pLastFormatted.GetEndPortion();
short nTextDiff = pUnformatted.GetStart() - pLastFormatted.GetEnd();
nTextDiff++; // LastFormatted.GetEnd() was inclusive => subtracted one too much!
// The first unformated one has to start exactly one portion past the last
// formated one.
......@@ -198,15 +198,15 @@ void TEParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormat
{
for ( sal_uInt16 nL = nLastFormattedLine+1; nL < nLines; nL++ )
{
TextLine* pLine = maLines[ nL ];
TextLine& pLine = maLines[ nL ];
pLine->GetStartPortion() = pLine->GetStartPortion() + nPDiff;
pLine->GetEndPortion() = pLine->GetEndPortion() + nPDiff;
pLine.GetStartPortion() = pLine.GetStartPortion() + nPDiff;
pLine.GetEndPortion() = pLine.GetEndPortion() + nPDiff;
pLine->GetStart() = pLine->GetStart() + nTDiff;
pLine->GetEnd() = pLine->GetEnd() + nTDiff;
pLine.GetStart() = pLine.GetStart() + nTDiff;
pLine.GetEnd() = pLine.GetEnd() + nTDiff;
pLine->SetValid();
pLine.SetValid();
}
}
}
......
This diff is collapsed.
......@@ -418,9 +418,9 @@ void TextView::ImpHighlight( const TextSelection& rSel )
// iterate over all lines
for ( sal_uInt16 nLine = nStartLine; nLine <= nEndLine; nLine++ )
{
TextLine* pLine = pTEParaPortion->GetLines()[ nLine ];
sal_uInt16 nStartIndex = pLine->GetStart();
sal_uInt16 nEndIndex = pLine->GetEnd();
TextLine& pLine = pTEParaPortion->GetLines()[ nLine ];
sal_uInt16 nStartIndex = pLine.GetStart();
sal_uInt16 nEndIndex = pLine.GetEnd();
if ( ( nPara == nStartPara ) && ( nLine == nStartLine ) )
nStartIndex = aSel.GetStart().GetIndex();
if ( ( nPara == nEndPara ) && ( nLine == nEndLine ) )
......@@ -1030,9 +1030,9 @@ void TextView::Command( const CommandEvent& rCEvt )
TEParaPortion* pParaPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( aPaM.GetPara() );
sal_uInt16 nLine = pParaPortion->GetLineNumber( aPaM.GetIndex(), true );
TextLine* pLine = pParaPortion->GetLines()[ nLine ];
if ( pLine && ( nInputEnd > pLine->GetEnd() ) )
nInputEnd = pLine->GetEnd();
TextLine& pLine = pParaPortion->GetLines()[ nLine ];
if ( nInputEnd > pLine.GetEnd() )
nInputEnd = pLine.GetEnd();
Rectangle aR2 = mpImpl->mpTextEngine->PaMtoEditCursor( TextPaM( aPaM.GetPara(), nInputEnd ) );
long nWidth = aR2.Left()-aR1.Right();
......@@ -1539,8 +1539,8 @@ TextPaM TextView::CursorUp( const TextPaM& rPaM )
// If we need to go to the end of a line that was wrapped automatically,
// the cursor ends up at the beginning of the 2nd line
// Problem: Last character of an automatically wrapped line = Cursor
TextLine* pLine = pPPortion->GetLines()[ nLine - 1 ];
if ( aPaM.GetIndex() && ( aPaM.GetIndex() == pLine->GetEnd() ) )
TextLine& pLine = pPPortion->GetLines()[ nLine - 1 ];
if ( aPaM.GetIndex() && ( aPaM.GetIndex() == pLine.GetEnd() ) )
aPaM.GetIndex()--;
}
else if ( rPaM.GetPara() ) // previous paragraph
......@@ -1576,8 +1576,8 @@ TextPaM TextView::CursorDown( const TextPaM& rPaM )
aPaM.GetIndex() = nCharPos;
// special case CursorUp
TextLine* pLine = pPPortion->GetLines()[ nLine + 1 ];
if ( ( aPaM.GetIndex() == pLine->GetEnd() ) && ( aPaM.GetIndex() > pLine->GetStart() ) && aPaM.GetIndex() < pPPortion->GetNode()->GetText().getLength() )
TextLine& pLine = pPPortion->GetLines()[ nLine + 1 ];
if ( ( aPaM.GetIndex() == pLine.GetEnd() ) && ( aPaM.GetIndex() > pLine.GetStart() ) && aPaM.GetIndex() < pPPortion->GetNode()->GetText().getLength() )
aPaM.GetIndex()--;
}
else if ( rPaM.GetPara() < ( mpImpl->mpTextEngine->mpDoc->GetNodes().Count() - 1 ) ) // next paragraph
......@@ -1586,8 +1586,8 @@ TextPaM TextView::CursorDown( const TextPaM& rPaM )
pPPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( aPaM.GetPara() );
sal_uInt16 nCharPos = mpImpl->mpTextEngine->GetCharPos( aPaM.GetPara(), 0, nX+1 );
aPaM.GetIndex() = nCharPos;
TextLine* pLine = pPPortion->GetLines().front();
if ( ( aPaM.GetIndex() == pLine->GetEnd() ) && ( aPaM.GetIndex() > pLine->GetStart() ) && ( pPPortion->GetLines().size() > 1 ) )
TextLine& pLine = pPPortion->GetLines().front();
if ( ( aPaM.GetIndex() == pLine.GetEnd() ) && ( aPaM.GetIndex() > pLine.GetStart() ) && ( pPPortion->GetLines().size() > 1 ) )
aPaM.GetIndex()--;
}
......@@ -1600,8 +1600,8 @@ TextPaM TextView::CursorStartOfLine( const TextPaM& rPaM )
TEParaPortion* pPPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( rPaM.GetPara() );
sal_uInt16 nLine = pPPortion->GetLineNumber( aPaM.GetIndex(), false );
TextLine* pLine = pPPortion->GetLines()[ nLine ];
aPaM.GetIndex() = pLine->GetStart();
TextLine& pLine = pPPortion->GetLines()[ nLine ];
aPaM.GetIndex() = pLine.GetStart();
return aPaM;
}
......@@ -1612,10 +1612,10 @@ TextPaM TextView::CursorEndOfLine( const TextPaM& rPaM )
TEParaPortion* pPPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( rPaM.GetPara() );
sal_uInt16 nLine = pPPortion->GetLineNumber( aPaM.GetIndex(), false );
TextLine* pLine = pPPortion->GetLines()[ nLine ];
aPaM.GetIndex() = pLine->GetEnd();
TextLine& pLine = pPPortion->GetLines()[ nLine ];
aPaM.GetIndex() = pLine.GetEnd();
if ( pLine->GetEnd() > pLine->GetStart() ) // empty line
if ( pLine.GetEnd() > pLine.GetStart() ) // empty line
{
sal_Unicode cLastChar = pPPortion->GetNode()->GetText()[ aPaM.GetIndex()-1 ];
if ( ( cLastChar == ' ' ) && ( aPaM.GetIndex() != pPPortion->GetNode()->GetText().getLength() ) )
......
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