summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-07-03 11:31:14 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-07-06 07:04:50 +0000
commite9c3583c2cc27fc88ee81047c236ec99dd51e8de (patch)
treeb3e8394ca1ec402a31b227339366fc790124c1f8 /editeng
parent89c77994d4638c86635c70535fab6508e2f3d900 (diff)
improve the returnbyref loplugin
Change-Id: I1b510a6194282dfa4a9001d473127c5ebc8b44eb Reviewed-on: https://gerrit.libreoffice.org/16731 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editdbg.cxx22
-rw-r--r--editeng/source/editeng/editdoc.cxx51
-rw-r--r--editeng/source/editeng/editdoc.hxx10
-rw-r--r--editeng/source/editeng/editeng.cxx16
-rw-r--r--editeng/source/editeng/impedit.cxx23
-rw-r--r--editeng/source/editeng/impedit2.cxx285
-rw-r--r--editeng/source/editeng/impedit3.cxx233
-rw-r--r--editeng/source/editeng/impedit4.cxx32
8 files changed, 326 insertions, 346 deletions
diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx
index 34f7ddf3a180..a4cbb28cad31 100644
--- a/editeng/source/editeng/editdbg.cxx
+++ b/editeng/source/editeng/editdbg.cxx
@@ -385,17 +385,17 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, bool bInfoBox )
sal_Int32 n = 0;
for ( z = 0; z < nTextPortions; z++ )
{
- TextPortion* pPortion = pPPortion->GetTextPortions()[z];
+ TextPortion& rPortion = pPPortion->GetTextPortions()[z];
aPortionStr.append(' ');
- aPortionStr.append(static_cast<sal_Int32>(pPortion->GetLen()));
+ aPortionStr.append(static_cast<sal_Int32>(rPortion.GetLen()));
aPortionStr.append('(');
- aPortionStr.append(static_cast<sal_Int32>(pPortion->GetSize().Width()));
+ aPortionStr.append(static_cast<sal_Int32>(rPortion.GetSize().Width()));
aPortionStr.append(')');
aPortionStr.append('[');
- aPortionStr.append(static_cast<sal_Int32>(pPortion->GetKind()));
+ aPortionStr.append(static_cast<sal_Int32>(rPortion.GetKind()));
aPortionStr.append(']');
aPortionStr.append(';');
- n += pPortion->GetLen();
+ n += rPortion.GetLen();
}
aPortionStr.append("\nA");
aPortionStr.append(static_cast<sal_Int32>(nPortion));
@@ -410,17 +410,17 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, bool bInfoBox )
sal_uInt16 nLine;
for ( nLine = 0; nLine < pPPortion->GetLines().Count(); nLine++ )
{
- EditLine* pLine = pPPortion->GetLines()[nLine];
+ EditLine& rLine = pPPortion->GetLines()[nLine];
- OString aLine(OUStringToOString(pPPortion->GetNode()->Copy(pLine->GetStart(), pLine->GetEnd() - pLine->GetStart()), RTL_TEXTENCODING_ASCII_US));
+ OString aLine(OUStringToOString(pPPortion->GetNode()->Copy(rLine.GetStart(), rLine.GetEnd() - rLine.GetStart()), RTL_TEXTENCODING_ASCII_US));
fprintf( fp, "\nLine %i\t>%s<", nLine, aLine.getStr() );
}
// then the internal data ...
for ( nLine = 0; nLine < pPPortion->GetLines().Count(); nLine++ )
{
- EditLine* pLine = pPPortion->GetLines()[nLine];
- fprintf( fp, "\nZeile %i:\tStart: %" SAL_PRIdINT32 ",\tEnd: %" SAL_PRIdINT32, nLine, pLine->GetStart(), pLine->GetEnd() );
- fprintf( fp, "\t\tPortions: %" SAL_PRIdINT32 " - %" SAL_PRIdINT32 ".\tHight: %i, Ascent=%i", pLine->GetStartPortion(), pLine->GetEndPortion(), pLine->GetHeight(), pLine->GetMaxAscent() );
+ EditLine& rLine = pPPortion->GetLines()[nLine];
+ fprintf( fp, "\nZeile %i:\tStart: %" SAL_PRIdINT32 ",\tEnd: %" SAL_PRIdINT32, nLine, rLine.GetStart(), rLine.GetEnd() );
+ fprintf( fp, "\t\tPortions: %" SAL_PRIdINT32 " - %" SAL_PRIdINT32 ".\tHight: %i, Ascent=%i", rLine.GetStartPortion(), rLine.GetEndPortion(), rLine.GetHeight(), rLine.GetMaxAscent() );
}
fprintf( fp, "\n-----------------------------------------------------------------------------" );
@@ -494,7 +494,7 @@ bool ParaPortion::DbgCheckTextPortions(ParaPortion const& rPara)
sal_uInt16 nXLen = 0;
for (sal_Int32 nPortion = 0; nPortion < rPara.aTextPortionList.Count(); nPortion++)
{
- nXLen = nXLen + rPara.aTextPortionList[nPortion]->GetLen();
+ nXLen = nXLen + rPara.aTextPortionList[nPortion].GetLen();
}
return nXLen == rPara.pNode->Len();
}
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index d1211eea223e..3f1e34283164 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -439,14 +439,14 @@ sal_Int32 TextPortionList::Count() const
return (sal_Int32)maPortions.size();
}
-const TextPortion* TextPortionList::operator[](sal_Int32 nPos) const
+const TextPortion& TextPortionList::operator[](sal_Int32 nPos) const
{
- return &maPortions[nPos];
+ return maPortions[nPos];
}
-TextPortion* TextPortionList::operator[](sal_Int32 nPos)
+TextPortion& TextPortionList::operator[](sal_Int32 nPos)
{
- return &maPortions[nPos];
+ return maPortions[nPos];
}
void TextPortionList::Append(TextPortion* p)
@@ -636,12 +636,12 @@ sal_Int32 ParaPortion::GetLineNumber( sal_Int32 nIndex ) const
for ( sal_Int32 nLine = 0; nLine < aLineList.Count(); nLine++ )
{
- if ( aLineList[nLine]->IsIn( nIndex ) )
+ if ( aLineList[nLine].IsIn( nIndex ) )
return (sal_Int32)nLine;
}
// Then it should be at the end of the last line!
- DBG_ASSERT( nIndex == aLineList[ aLineList.Count() - 1 ]->GetEnd(), "Index dead wrong!" );
+ DBG_ASSERT( nIndex == aLineList[ aLineList.Count() - 1 ].GetEnd(), "Index dead wrong!" );
return (aLineList.Count()-1);
}
@@ -656,10 +656,10 @@ void ParaPortion::CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormatted
DBG_ASSERT( nLines, "CorrectPortionNumbersFromLine: Empty Portion?" );
if ( nLastFormattedLine < ( nLines - 1 ) )
{
- const EditLine* pLastFormatted = aLineList[ nLastFormattedLine ];
- const EditLine* pUnformatted = aLineList[ nLastFormattedLine+1 ];
- sal_Int32 nPortionDiff = pUnformatted->GetStartPortion() - pLastFormatted->GetEndPortion();
- sal_Int32 nTextDiff = pUnformatted->GetStart() - pLastFormatted->GetEnd();
+ const EditLine& rLastFormatted = aLineList[ nLastFormattedLine ];
+ const EditLine& rUnformatted = aLineList[ nLastFormattedLine+1 ];
+ sal_Int32 nPortionDiff = rUnformatted.GetStartPortion() - rLastFormatted.GetEndPortion();
+ sal_Int32 nTextDiff = rUnformatted.GetStart() - rLastFormatted.GetEnd();
nTextDiff++; // LastFormatted->GetEnd() was included => 1 deducted too much!
// The first unformatted must begin exactly one Portion behind the last
@@ -672,19 +672,19 @@ void ParaPortion::CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormatted
{
for ( sal_Int32 nL = nLastFormattedLine+1; nL < nLines; nL++ )
{
- EditLine* pLine = aLineList[ nL ];
+ EditLine& rLine = aLineList[ nL ];
- pLine->GetStartPortion() = pLine->GetStartPortion() + nPDiff;
- pLine->GetEndPortion() = pLine->GetEndPortion() + nPDiff;
+ rLine.GetStartPortion() = rLine.GetStartPortion() + nPDiff;
+ rLine.GetEndPortion() = rLine.GetEndPortion() + nPDiff;
- pLine->GetStart() = pLine->GetStart() + nTDiff;
- pLine->GetEnd() = pLine->GetEnd() + nTDiff;
+ rLine.GetStart() = rLine.GetStart() + nTDiff;
+ rLine.GetEnd() = rLine.GetEnd() + nTDiff;
- pLine->SetValid();
+ rLine.SetValid();
}
}
}
- DBG_ASSERT( aLineList[ aLineList.Count()-1 ]->GetEnd() == pNode->Len(), "CorrectLines: The end is not right!" );
+ DBG_ASSERT( aLineList[ aLineList.Count()-1 ].GetEnd() == pNode->Len(), "CorrectLines: The end is not right!" );
}
// Shared reverse lookup acceleration pieces ...
@@ -1074,20 +1074,19 @@ Size EditLine::CalcTextSize( ParaPortion& rParaPortion )
{
Size aSz;
Size aTmpSz;
- TextPortion* pPortion;
DBG_ASSERT( rParaPortion.GetTextPortions().Count(), "GetTextSize before CreatePortions !" );
for ( sal_Int32 n = nStartPortion; n <= nEndPortion; n++ )
{
- pPortion = rParaPortion.GetTextPortions()[n];
- switch ( pPortion->GetKind() )
+ TextPortion& rPortion = rParaPortion.GetTextPortions()[n];
+ switch ( rPortion.GetKind() )
{
case PortionKind::TEXT:
case PortionKind::FIELD:
case PortionKind::HYPHENATOR:
{
- aTmpSz = pPortion->GetSize();
+ aTmpSz = rPortion.GetSize();
aSz.Width() += aTmpSz.Width();
if ( aSz.Height() < aTmpSz.Height() )
aSz.Height() = aTmpSz.Height();
@@ -1095,7 +1094,7 @@ Size EditLine::CalcTextSize( ParaPortion& rParaPortion )
break;
case PortionKind::TAB:
{
- aSz.Width() += pPortion->GetSize().Width();
+ aSz.Width() += rPortion.GetSize().Width();
}
break;
case PortionKind::LINEBREAK: break;
@@ -1150,14 +1149,14 @@ sal_Int32 EditLineList::Count() const
return maLines.size();
}
-const EditLine* EditLineList::operator[](sal_Int32 nPos) const
+const EditLine& EditLineList::operator[](sal_Int32 nPos) const
{
- return &maLines[nPos];
+ return maLines[nPos];
}
-EditLine* EditLineList::operator[](sal_Int32 nPos)
+EditLine& EditLineList::operator[](sal_Int32 nPos)
{
- return &maLines[nPos];
+ return maLines[nPos];
}
void EditLineList::Append(EditLine* p)
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 503b91a86b98..ce5e117e0b54 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -459,8 +459,8 @@ public:
sal_Int32 GetStartPos(sal_Int32 nPortion);
void DeleteFromPortion(sal_Int32 nDelFrom);
sal_Int32 Count() const;
- const TextPortion* operator[](sal_Int32 nPos) const;
- TextPortion* operator[](sal_Int32 nPos);
+ const TextPortion& operator[](sal_Int32 nPos) const;
+ TextPortion& operator[](sal_Int32 nPos);
void Append(TextPortion* p);
void Insert(sal_Int32 nPos, TextPortion* p);
@@ -574,8 +574,8 @@ public:
void DeleteFromLine(sal_Int32 nDelFrom);
sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd);
sal_Int32 Count() const;
- const EditLine* operator[](sal_Int32 nPos) const;
- EditLine* operator[](sal_Int32 nPos);
+ const EditLine& operator[](sal_Int32 nPos) const;
+ EditLine& operator[](sal_Int32 nPos);
void Append(EditLine* p);
void Insert(sal_Int32 nPos, EditLine* p);
@@ -633,7 +633,7 @@ public:
void SetVisible( bool bVisible );
bool IsVisible() const { return bVisible; }
- bool IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0]->GetLen() == 0; }
+ bool IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0].GetLen() == 0; }
long GetHeight() const { return ( bVisible ? nHeight : 0 ); }
sal_Int32 GetFirstLineOffset() const { return ( bVisible ? nFirstLineOffset : 0 ); }
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index b8aaa65e1bd9..e6c2fc091dc2 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1777,7 +1777,7 @@ void EditEngine::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList )
sal_Int32 nTextPortions = pParaPortion->GetTextPortions().Count();
for ( sal_Int32 n = 0; n < nTextPortions; n++ )
{
- nEnd = nEnd + pParaPortion->GetTextPortions()[n]->GetLen();
+ nEnd = nEnd + pParaPortion->GetTextPortions()[n].GetLen();
rList.push_back( nEnd );
}
}
@@ -1884,8 +1884,8 @@ long EditEngine::GetFirstLineStartX( sal_Int32 nParagraph )
DBG_ASSERT( pImpEditEngine->IsFormatted() || !pImpEditEngine->IsFormatting(), "GetFirstLineStartX: Doc not formatted - unable to format!" );
if ( !pImpEditEngine->IsFormatted() )
pImpEditEngine->FormatDoc();
- const EditLine* pFirstLine = pPPortion->GetLines()[0];
- nX = pFirstLine->GetStartPosX();
+ const EditLine& rFirstLine = pPPortion->GetLines()[0];
+ nX = rFirstLine.GetStartPosX();
}
return nX;
}
@@ -1916,8 +1916,8 @@ Point EditEngine::GetDocPosTopLeft( sal_Int32 nParagraph )
if ( pPPortion->GetLines().Count() )
{
// Correct it if large Bullet.
- const EditLine* pFirstLine = pPPortion->GetLines()[0];
- aPoint.X() = pFirstLine->GetStartPosX();
+ const EditLine& rFirstLine = pPPortion->GetLines()[0];
+ aPoint.X() = rFirstLine.GetStartPosX();
}
else
{
@@ -1968,8 +1968,8 @@ bool EditEngine::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder )
DBG_ASSERT( pParaPortion, "ParaPortion?" );
sal_Int32 nLine = pParaPortion->GetLineNumber( aPaM.GetIndex() );
- const EditLine* pLine = pParaPortion->GetLines()[nLine];
- Range aLineXPosStartEnd = pImpEditEngine->GetLineXPosStartEnd( pParaPortion, pLine );
+ const EditLine& rLine = pParaPortion->GetLines()[nLine];
+ Range aLineXPosStartEnd = pImpEditEngine->GetLineXPosStartEnd( pParaPortion, &rLine );
if ( ( aDocPos.X() >= aLineXPosStartEnd.Min() - nBorder ) &&
( aDocPos.X() <= aLineXPosStartEnd.Max() + nBorder ) )
{
@@ -2387,7 +2387,7 @@ ParagraphInfos EditEngine::GetParagraphInfos( sal_Int32 nPara )
{
const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara];
const EditLine* pLine = (pParaPortion && pParaPortion->GetLines().Count()) ?
- pParaPortion->GetLines()[0] : NULL;
+ &pParaPortion->GetLines()[0] : NULL;
DBG_ASSERT( pParaPortion && pLine, "GetParagraphInfos - Paragraph out of range" );
if ( pParaPortion && pLine )
{
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 6037249bf076..2331196d67eb 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -251,12 +251,11 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
for ( sal_uInt16 nLine = nStartLine; nLine <= nEndLine; nLine++ )
{
- const EditLine* pLine = pTmpPortion->GetLines()[nLine];
- DBG_ASSERT( pLine, "Line not found: DrawSelection()" );
+ const EditLine& rLine = pTmpPortion->GetLines()[nLine];
bool bPartOfLine = false;
- sal_Int32 nStartIndex = pLine->GetStart();
- sal_Int32 nEndIndex = pLine->GetEnd();
+ sal_Int32 nStartIndex = rLine.GetStart();
+ sal_Int32 nEndIndex = rLine.GetEnd();
if ( ( nPara == nStartPara ) && ( nLine == nStartLine ) && ( nStartIndex != aTmpSel.Min().GetIndex() ) )
{
nStartIndex = aTmpSel.Min().GetIndex();
@@ -289,7 +288,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
// Now that we have Bidi, the first/last index doesn't have to be the 'most outside' position
if ( !bPartOfLine )
{
- Range aLineXPosStartEnd = pEditEngine->GetLineXPosStartEnd(pTmpPortion, pLine);
+ Range aLineXPosStartEnd = pEditEngine->GetLineXPosStartEnd(pTmpPortion, &rLine);
aTopLeft.X() = aLineXPosStartEnd.Min();
aBottomRight.X() = aLineXPosStartEnd.Max();
ImplDrawHighlightRect( pTarget, aTopLeft, aBottomRight, pPolyPoly );
@@ -307,8 +306,8 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
DBG_ASSERT( nTmpEndIndex > nTmpStartIndex, "DrawSelection, Start >= End?" );
- long nX1 = pEditEngine->GetXPos(pTmpPortion, pLine, nTmpStartIndex, true);
- long nX2 = pEditEngine->GetXPos(pTmpPortion, pLine, nTmpEndIndex);
+ long nX1 = pEditEngine->GetXPos(pTmpPortion, &rLine, nTmpStartIndex, true);
+ long nX2 = pEditEngine->GetXPos(pTmpPortion, &rLine, nTmpEndIndex);
Point aPt1( std::min( nX1, nX2 ), aTopLeft.Y() );
Point aPt2( std::max( nX1, nX2 ), aBottomRight.Y() );
@@ -762,10 +761,10 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16
aEditCursor.Left() = aEditCursor.Right() = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY|GETCRSR_PREFERPORTIONSTART ).Left();
sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true );
- const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
- if ( pTextPortion->GetKind() == PortionKind::TAB )
+ const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+ if ( rTextPortion.GetKind() == PortionKind::TAB )
{
- aEditCursor.Right() += pTextPortion->GetSize().Width();
+ aEditCursor.Right() += rTextPortion.GetSize().Width();
}
else
{
@@ -946,8 +945,8 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16
if ( IsInsertMode() && !aEditSelection.HasRange() && ( pEditEngine->pImpEditEngine->HasDifferentRTLLevels( aPaM.GetNode() ) ) )
{
sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, (nShowCursorFlags & GETCRSR_PREFERPORTIONSTART) != 0 );
- const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
- sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft();
+ const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+ sal_uInt16 nRTLLevel = rTextPortion.GetRightToLeft();
if ( nRTLLevel%2 )
nCursorDir = CursorDirection::RTL;
else
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 6d1321b12ecd..8795dc0ec3c6 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -486,9 +486,9 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( GetEditDoc().GetPos( aPaM.GetNode() ) );
sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), true );
- const EditLine* pLine = pParaPortion->GetLines()[nLine];
- if ( pLine && ( nInputEnd > pLine->GetEnd() ) )
- nInputEnd = pLine->GetEnd();
+ const EditLine& rLine = pParaPortion->GetLines()[nLine];
+ if ( nInputEnd > rLine.GetEnd() )
+ nInputEnd = rLine.GetEnd();
Rectangle aR2 = PaMtoEditCursor( EditPaM( aPaM.GetNode(), nInputEnd ), GETCRSR_ENDOFLINE );
Rectangle aRect = pView->GetImpEditView()->GetWindowPos( aR1 );
pView->GetWindow()->SetCursorRect( &aRect, aR2.Left()-aR1.Right() );
@@ -544,20 +544,17 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( GetEditDoc().GetPos( aPaM.GetNode() ) );
sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), true );
- const EditLine* pLine = pParaPortion->GetLines()[nLine];
- if ( pLine )
+ const EditLine& rLine = pParaPortion->GetLines()[nLine];
+ std::unique_ptr<Rectangle[]> aRects(new Rectangle[ mpIMEInfos->nLen ]);
+ for (sal_Int32 i = 0; i < mpIMEInfos->nLen; ++i)
{
- std::unique_ptr<Rectangle[]> aRects(new Rectangle[ mpIMEInfos->nLen ]);
- for (sal_Int32 i = 0; i < mpIMEInfos->nLen; ++i)
- {
- sal_Int32 nInputPos = mpIMEInfos->aPos.GetIndex() + i;
- if ( nInputPos > pLine->GetEnd() )
- nInputPos = pLine->GetEnd();
- Rectangle aR2 = GetEditCursor( pParaPortion, nInputPos );
- aRects[ i ] = pView->GetImpEditView()->GetWindowPos( aR2 );
- }
- pView->GetWindow()->SetCompositionCharRect( aRects.get(), mpIMEInfos->nLen );
+ sal_Int32 nInputPos = mpIMEInfos->aPos.GetIndex() + i;
+ if ( nInputPos > rLine.GetEnd() )
+ nInputPos = rLine.GetEnd();
+ Rectangle aR2 = GetEditCursor( pParaPortion, nInputPos );
+ aRects[ i ] = pView->GetImpEditView()->GetWindowPos( aR2 );
}
+ pView->GetWindow()->SetCompositionCharRect( aRects.get(), mpIMEInfos->nLen );
}
}
@@ -927,14 +924,14 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara );
sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), false );
- const EditLine* pLine = pParaPortion->GetLines()[nLine];
- bool bEmptyLine = pLine->GetStart() == pLine->GetEnd();
+ const EditLine& rLine = pParaPortion->GetLines()[nLine];
+ bool bEmptyLine = rLine.GetStart() == rLine.GetEnd();
pEditView->pImpEditView->nExtraCursorFlags = 0;
if ( !bEmptyLine )
{
- OUString aLine = aPaM.GetNode()->GetString().copy(pLine->GetStart(), pLine->GetEnd() - pLine->GetStart());
+ OUString aLine = aPaM.GetNode()->GetString().copy(rLine.GetStart(), rLine.GetEnd() - rLine.GetStart());
const sal_Unicode* pLineString = aLine.getStr();
@@ -949,12 +946,12 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
ubidi_close( pBidi );
- aPaM.SetIndex( nLogPos + pLine->GetStart() );
+ aPaM.SetIndex( nLogPos + rLine.GetStart() );
sal_Int32 nTmp;
sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTmp, true );
- const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
- sal_Int32 nRTLLevel = pTextPortion->GetRightToLeft();
+ const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+ sal_Int32 nRTLLevel = rTextPortion.GetRightToLeft();
bool bPortionRTL = (nRTLLevel%2) != 0;
if ( bStart )
@@ -983,8 +980,8 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara );
sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), false );
- const EditLine* pLine = pParaPortion->GetLines()[nLine];
- bool bEmptyLine = pLine->GetStart() == pLine->GetEnd();
+ const EditLine& rLine = pParaPortion->GetLines()[nLine];
+ bool bEmptyLine = rLine.GetStart() == rLine.GetEnd();
pEditView->pImpEditView->nExtraCursorFlags = 0;
@@ -1017,10 +1014,10 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
// Check if we are within a portion and don't have overwrite mode, then it's easy...
sal_Int32 nPortionStart;
sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, false );
- const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+ const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
- bool bPortionBoundary = ( aPaM.GetIndex() == nPortionStart ) || ( aPaM.GetIndex() == (nPortionStart+pTextPortion->GetLen()) );
- sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft();
+ bool bPortionBoundary = ( aPaM.GetIndex() == nPortionStart ) || ( aPaM.GetIndex() == (nPortionStart+rTextPortion.GetLen()) );
+ sal_uInt16 nRTLLevel = rTextPortion.GetRightToLeft();
// Portion boundary doesn't matter if both have same RTL level
sal_Int32 nRTLLevelNextPortion = -1;
@@ -1028,8 +1025,8 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
{
sal_Int32 nTmp;
sal_Int32 nNextTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex()+1, nTmp, !bLogicalBackward );
- const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nNextTextPortion];
- nRTLLevelNextPortion = pNextTextPortion->GetRightToLeft();
+ const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nNextTextPortion];
+ nRTLLevelNextPortion = rNextTextPortion.GetRightToLeft();
}
if ( !bPortionBoundary || ( nRTLLevel == nRTLLevelNextPortion ) )
@@ -1053,8 +1050,8 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
bool bGotoStartOfNextLine = false;
bool bGotoEndOfPrevLine = false;
- OUString aLine = aPaM.GetNode()->GetString().copy(pLine->GetStart(), pLine->GetEnd() - pLine->GetStart());
- const sal_Int32 nPosInLine = aPaM.GetIndex() - pLine->GetStart();
+ OUString aLine = aPaM.GetNode()->GetString().copy(rLine.GetStart(), rLine.GetEnd() - rLine.GetStart());
+ const sal_Int32 nPosInLine = aPaM.GetIndex() - rLine.GetStart();
const sal_Unicode* pLineString = aLine.getStr();
@@ -1083,7 +1080,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
if ( !bGotoEndOfPrevLine && !bGotoStartOfNextLine )
{
- aPaM.SetIndex( pLine->GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
+ aPaM.SetIndex( rLine.GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
pEditView->pImpEditView->SetCursorBidiLevel( 0 );
}
}
@@ -1096,8 +1093,8 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
sal_Int32 nPortionStart;
sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, bBeforePortion );
- const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
- bool bRTLPortion = (pTextPortion->GetRightToLeft() % 2) != 0;
+ const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+ bool bRTLPortion = (rTextPortion.GetRightToLeft() % 2) != 0;
// -1: We are 'behind' the character
long nVisPos = (long)ubidi_getVisualIndex( pBidi, bWasBehind ? nPosInLine-1 : nPosInLine, &nError );
@@ -1117,16 +1114,16 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
if ( !bGotoEndOfPrevLine && !bGotoStartOfNextLine )
{
- aPaM.SetIndex( pLine->GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
+ aPaM.SetIndex( rLine.GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
// RTL portion, stay visually on the left side.
sal_Int32 _nPortionStart;
// sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, !bRTLPortion );
sal_Int32 _nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), _nPortionStart, true );
- const TextPortion* _pTextPortion = pParaPortion->GetTextPortions()[_nTextPortion];
- if ( bVisualToLeft && !bRTLPortion && ( _pTextPortion->GetRightToLeft() % 2 ) )
+ const TextPortion& _rTextPortion = pParaPortion->GetTextPortions()[_nTextPortion];
+ if ( bVisualToLeft && !bRTLPortion && ( _rTextPortion.GetRightToLeft() % 2 ) )
aPaM.SetIndex( aPaM.GetIndex()+1 );
- else if ( !bVisualToLeft && bRTLPortion && ( bWasBehind || !(_pTextPortion->GetRightToLeft() % 2 )) )
+ else if ( !bVisualToLeft && bRTLPortion && ( bWasBehind || !(_rTextPortion.GetRightToLeft() % 2 )) )
aPaM.SetIndex( aPaM.GetIndex()+1 );
pEditView->pImpEditView->SetCursorBidiLevel( _nPortionStart );
@@ -1213,12 +1210,12 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView* pView )
const ParaPortion* pPPortion = FindParaPortion( rPaM.GetNode() );
OSL_ENSURE( pPPortion, "No matching portion found: CursorUp ");
sal_Int32 nLine = pPPortion->GetLineNumber( rPaM.GetIndex() );
- const EditLine* pLine = pPPortion->GetLines()[nLine];
+ const EditLine& rLine = pPPortion->GetLines()[nLine];
long nX;
if ( pView->pImpEditView->nTravelXPos == TRAVEL_X_DONTKNOW )
{
- nX = GetXPos( pPPortion, pLine, rPaM.GetIndex() );
+ nX = GetXPos( pPPortion, &rLine, rPaM.GetIndex() );
pView->pImpEditView->nTravelXPos = nX+nOnePixelInRef;
}
else
@@ -1227,13 +1224,13 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView* pView )
EditPaM aNewPaM( rPaM );
if ( nLine ) // same paragraph
{
- const EditLine* pPrevLine = pPPortion->GetLines()[nLine-1];
- aNewPaM.SetIndex( GetChar( pPPortion, pPrevLine, nX ) );
+ const EditLine& rPrevLine = pPPortion->GetLines()[nLine-1];
+ aNewPaM.SetIndex( GetChar( pPPortion, &rPrevLine, nX ) );
// If a previous automatically wrapped line, and one has to be exactly
// at the end of this line, the cursor lands on the current line at the
// beginning. See Problem: Last character of an automatically wrapped
// Row = cursor
- if ( aNewPaM.GetIndex() && ( aNewPaM.GetIndex() == pLine->GetStart() ) )
+ if ( aNewPaM.GetIndex() && ( aNewPaM.GetIndex() == rLine.GetStart() ) )
aNewPaM = CursorLeft( aNewPaM );
}
else // previous paragraph
@@ -1241,10 +1238,9 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView* pView )
const ParaPortion* pPrevPortion = GetPrevVisPortion( pPPortion );
if ( pPrevPortion )
{
- pLine = pPrevPortion->GetLines()[pPrevPortion->GetLines().Count()-1];
- OSL_ENSURE( pLine, "Line in front not found: CursorUp" );
+ const EditLine& rLine2 = pPrevPortion->GetLines()[pPrevPortion->GetLines().Count()-1];
aNewPaM.SetNode( pPrevPortion->GetNode() );
- aNewPaM.SetIndex( GetChar( pPrevPortion, pLine, nX+nOnePixelInRef ) );
+ aNewPaM.SetIndex( GetChar( pPrevPortion, &rLine2, nX+nOnePixelInRef ) );
}
}
@@ -1262,8 +1258,8 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView* pView )
long nX;
if ( pView->pImpEditView->nTravelXPos == TRAVEL_X_DONTKNOW )
{
- const EditLine* pLine = pPPortion->GetLines()[nLine];
- nX = GetXPos( pPPortion, pLine, rPaM.GetIndex() );
+ const EditLine& rLine = pPPortion->GetLines()[nLine];
+ nX = GetXPos( pPPortion, &rLine, rPaM.GetIndex() );
pView->pImpEditView->nTravelXPos = nX+nOnePixelInRef;
}
else
@@ -1272,10 +1268,10 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView* pView )
EditPaM aNewPaM( rPaM );
if ( nLine < pPPortion->GetLines().Count()-1 )
{
- const EditLine* pNextLine = pPPortion->GetLines()[nLine+1];
- aNewPaM.SetIndex( GetChar( pPPortion, pNextLine, nX ) );
+ const EditLine& rNextLine = pPPortion->GetLines()[nLine+1];
+ aNewPaM.SetIndex( GetChar( pPPortion, &rNextLine, nX ) );
// Special treatment, see CursorUp ...
- if ( ( aNewPaM.GetIndex() == pNextLine->GetEnd() ) && ( aNewPaM.GetIndex() > pNextLine->GetStart() ) && ( aNewPaM.GetIndex() < pPPortion->GetNode()->Len() ) )
+ if ( ( aNewPaM.GetIndex() == rNextLine.GetEnd() ) && ( aNewPaM.GetIndex() > rNextLine.GetStart() ) && ( aNewPaM.GetIndex() < pPPortion->GetNode()->Len() ) )
aNewPaM = CursorLeft( aNewPaM );
}
else // next paragraph
@@ -1283,13 +1279,12 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView* pView )
const ParaPortion* pNextPortion = GetNextVisPortion( pPPortion );
if ( pNextPortion )
{
- const EditLine* pLine = pNextPortion->GetLines()[0];
- OSL_ENSURE( pLine, "Line in front not found: CursorUp" );
+ const EditLine& rLine = pNextPortion->GetLines()[0];
aNewPaM.SetNode( pNextPortion->GetNode() );
// Never at the very end when several lines, because then a line
// below the cursor appears.
- aNewPaM.SetIndex( GetChar( pNextPortion, pLine, nX+nOnePixelInRef ) );
- if ( ( aNewPaM.GetIndex() == pLine->GetEnd() ) && ( aNewPaM.GetIndex() > pLine->GetStart() ) && ( pNextPortion->GetLines().Count() > 1 ) )
+ aNewPaM.SetIndex( GetChar( pNextPortion, &rLine, nX+nOnePixelInRef ) );
+ if ( ( aNewPaM.GetIndex() == rLine.GetEnd() ) && ( aNewPaM.GetIndex() > rLine.GetStart() ) && ( pNextPortion->GetLines().Count() > 1 ) )
aNewPaM = CursorLeft( aNewPaM );
}
}
@@ -1302,11 +1297,10 @@ EditPaM ImpEditEngine::CursorStartOfLine( const EditPaM& rPaM )
const ParaPortion* pCurPortion = FindParaPortion( rPaM.GetNode() );
OSL_ENSURE( pCurPortion, "No Portion for the PaM ?" );
sal_Int32 nLine = pCurPortion->GetLineNumber( rPaM.GetIndex() );
- const EditLine* pLine = pCurPortion->GetLines()[nLine];
- OSL_ENSURE( pLine, "Current line not found ?!" );
+ const EditLine& rLine = pCurPortion->GetLines()[nLine];
EditPaM aNewPaM( rPaM );
- aNewPaM.SetIndex( pLine->GetStart() );
+ aNewPaM.SetIndex( rLine.GetStart() );
return aNewPaM;
}
@@ -1315,12 +1309,11 @@ EditPaM ImpEditEngine::CursorEndOfLine( const EditPaM& rPaM )
const ParaPortion* pCurPortion = FindParaPortion( rPaM.GetNode() );
OSL_ENSURE( pCurPortion, "No Portion for the PaM ?" );
sal_Int32 nLine = pCurPortion->GetLineNumber( rPaM.GetIndex() );
- const EditLine* pLine = pCurPortion->GetLines()[nLine];
- OSL_ENSURE( pLine, "Current line not found ?!" );
+ const EditLine& rLine = pCurPortion->GetLines()[nLine];
EditPaM aNewPaM( rPaM );
- aNewPaM.SetIndex( pLine->GetEnd() );
- if ( pLine->GetEnd() > pLine->GetStart() )
+ aNewPaM.SetIndex( rLine.GetEnd() );
+ if ( rLine.GetEnd() > rLine.GetStart() )
{
if ( aNewPaM.GetNode()->IsFeature( aNewPaM.GetIndex() - 1 ) )
{
@@ -1970,8 +1963,8 @@ bool ImpEditEngine::HasDifferentRTLLevels( const ContentNode* pNode )
sal_uInt16 nRTLLevel = IsRightToLeft( nPara ) ? 1 : 0;
for ( sal_Int32 n = 0; n < (sal_Int32)pParaPortion->GetTextPortions().Count(); n++ )
{
- const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n];
- if ( pTextPortion->GetRightToLeft() != nRTLLevel )
+ const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[n];
+ if ( rTextPortion.GetRightToLeft() != nRTLLevel )
{
bHasDifferentRTLLevels = true;
break;
@@ -3059,8 +3052,6 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
if ( !IsFormatted() && !IsFormatting() )
FormatDoc();
- EditLine* pLine;
-
long nMaxWidth = 0;
long nCurWidth = 0;
@@ -3082,8 +3073,7 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
sal_Int32 nLines = (sal_Int32)pPortion->GetLines().Count();
for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ )
{
- pLine = pPortion->GetLines()[nLine];
- OSL_ENSURE( pLine, "NULL-Pointer in the line iterator in CalcWidth" );
+ EditLine& rLine = pPortion->GetLines()[nLine];
// nCurWidth = pLine->GetStartPosX();
// For Center- or Right- alignment it depends on the paper
// width, here not preferred. I general, it is best not leave it
@@ -3102,7 +3092,7 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
}
}
nCurWidth += GetXValue( rLRItem.GetRight() );
- nCurWidth += CalcLineWidth( pPortion, pLine, bIgnoreExtraSpace );
+ nCurWidth += CalcLineWidth( pPortion, &rLine, bIgnoreExtraSpace );
if ( nCurWidth > nMaxWidth )
{
nMaxWidth = nCurWidth;
@@ -3132,21 +3122,21 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
sal_Int32 nPos = pLine->GetStart();
for ( sal_Int32 nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ )
{
- const TextPortion* pTextPortion = pPortion->GetTextPortions()[nTP];
- switch ( pTextPortion->GetKind() )
+ const TextPortion& rTextPortion = pPortion->GetTextPortions()[nTP];
+ switch ( rTextPortion.GetKind() )
{
case PortionKind::FIELD:
case PortionKind::HYPHENATOR:
case PortionKind::TAB:
{
- nWidth += pTextPortion->GetSize().Width();
+ nWidth += rTextPortion.GetSize().Width();
}
break;
case PortionKind::TEXT:
{
if ( ( eJustification != SVX_ADJUST_BLOCK ) || ( !bIgnoreExtraSpace ) )
{
- nWidth += pTextPortion->GetSize().Width();
+ nWidth += rTextPortion.GetSize().Width();
}
else
{
@@ -3154,13 +3144,13 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont );
aTmpFont.SetPhysFont( GetRefDevice() );
ImplInitDigitMode(GetRefDevice(), aTmpFont.GetLanguage());
- nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nPos, pTextPortion->GetLen(), NULL ).Width();
+ nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen(), NULL ).Width();
}
}
break;
case PortionKind::LINEBREAK: break;
}
- nPos = nPos + pTextPortion->GetLen();
+ nPos = nPos + rTextPortion.GetLen();
}
GetRefDevice()->Pop();
@@ -3217,9 +3207,8 @@ sal_Int32 ImpEditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) con
OSL_ENSURE( pPPortion, "Paragraph not found: GetLineLen" );
if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
{
- const EditLine* pLine = pPPortion->GetLines()[nLine];
- OSL_ENSURE( pLine, "Line not found: GetLineHeight" );
- return pLine->GetLen();
+ const EditLine& rLine = pPPortion->GetLines()[nLine];
+ return rLine.GetLen();
}
return -1;
@@ -3233,10 +3222,9 @@ void ImpEditEngine::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int3
rStart = rEnd = -1; // default values in case of error
if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
{
- const EditLine* pLine = pPPortion->GetLines()[nLine];
- assert(pLine && "Line not found: GetLineBoundaries");
- rStart = pLine->GetStart();
- rEnd = pLine->GetEnd();
+ const EditLine& rLine = pPPortion->GetLines()[nLine];
+ rStart = rLine.GetStart();
+ rEnd = rLine.GetEnd();
}
}
@@ -3274,9 +3262,8 @@ sal_uInt16 ImpEditEngine::GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine )
OSL_ENSURE( pPPortion, "Paragraph not found: GetLineHeight" );
if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
{
- const EditLine* pLine = pPPortion->GetLines()[nLine];
- OSL_ENSURE( pLine, "Paragraph not found: GetLineHeight" );
- return pLine->GetHeight();
+ const EditLine& rLine = pPPortion->GetLines()[nLine];
+ return rLine.GetHeight();
}
return 0xFFFF;
@@ -3565,15 +3552,15 @@ Range ImpEditEngine::GetInvalidYOffsets( ParaPortion* pPortion )
sal_Int32 nLine;
for ( nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
{
- const EditLine* pL = pPortion->GetLines()[nLine];
- if ( pL->IsInvalid() )
+ const EditLine& rL = pPortion->GetLines()[nLine];
+ if ( rL.IsInvalid() )
{
nFirstInvalid = nLine;
break;
}
if ( nLine && !aStatus.IsOutliner() ) // not the first line
aRange.Min() += nSBL;
- aRange.Min() += pL->GetHeight();
+ aRange.Min() += rL.GetHeight();
}
OSL_ENSURE( nFirstInvalid != -1, "No invalid line found in GetInvalidYOffset(1)" );
@@ -3589,22 +3576,22 @@ Range ImpEditEngine::GetInvalidYOffsets( ParaPortion* pPortion )
{
for ( nLine = nFirstInvalid; nLine < pPortion->GetLines().Count(); nLine++ )
{
- const EditLine* pL = pPortion->GetLines()[nLine];
- if ( pL->IsValid() )
+ const EditLine& rL = pPortion->GetLines()[nLine];
+ if ( rL.IsValid() )
{
nLastInvalid = nLine;
break;
}
if ( nLine && !aStatus.IsOutliner() )
aRange.Max() += nSBL;
- aRange.Max() += pL->GetHeight();
+ aRange.Max() += rL.GetHeight();
}
if( ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP ) && rLSItem.GetPropLineSpace() &&
( rLSItem.GetPropLineSpace() < 100 ) )
{
- const EditLine* pL = pPortion->GetLines()[nFirstInvalid];
- long n = pL->GetTxtHeight() * ( 100L - rLSItem.GetPropLineSpace() );
+ const EditLine& rL = pPortion->GetLines()[nFirstInvalid];
+ long n = rL.GetTxtHeight() * ( 100L - rLSItem.GetPropLineSpace() );
n /= 100;
aRange.Min() -= n;
aRange.Max() += n;
@@ -3637,17 +3624,17 @@ EditPaM ImpEditEngine::GetPaM( ParaPortion* pPortion, Point aDocPos, bool bSmart
const EditLine* pLine = NULL;
for ( sal_Int32 nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
{
- const EditLine* pTmpLine = pPortion->GetLines()[nLine];
- nY += pTmpLine->GetHeight();
+ const EditLine& rTmpLine = pPortion->GetLines()[nLine];
+ nY += rTmpLine.GetHeight();
if ( !aStatus.IsOutliner() )
nY += nSBL;
if ( nY > aDocPos.Y() )
{
- pLine = pTmpLine;
+ pLine = &rTmpLine;
break; // correct Y-position is not of interest
}
- nCurIndex = nCurIndex + pTmpLine->GetLen();
+ nCurIndex = nCurIndex + rTmpLine.GetLen();
}
if ( !pLine ) // may happen only in the range of SA!
@@ -3665,7 +3652,7 @@ EditPaM ImpEditEngine::GetPaM( ParaPortion* pPortion, Point aDocPos, bool bSmart
aPaM.SetIndex( nCurIndex );
if ( nCurIndex && ( nCurIndex == pLine->GetEnd() ) &&
- ( pLine != pPortion->GetLines()[pPortion->GetLines().Count()-1] ) )
+ ( pLine != &pPortion->GetLines()[pPortion->GetLines().Count()-1] ) )
{
aPaM = CursorLeft( aPaM, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL );
}
@@ -3685,9 +3672,9 @@ sal_Int32 ImpEditEngine::GetChar(
// Search best matching portion with GetPortionXOffset()
for ( sal_Int32 i = pLine->GetStartPortion(); i <= pLine->GetEndPortion(); i++ )
{
- const TextPortion* pPortion = pParaPortion->GetTextPortions()[i];
+ const TextPortion& rPortion = pParaPortion->GetTextPortions()[i];
long nXLeft = GetPortionXOffset( pParaPortion, pLine, i );
- long nXRight = nXLeft + pPortion->GetSize().Width();
+ long nXRight = nXLeft + rPortion.GetSize().Width();
if ( ( nXLeft <= nXPos ) && ( nXRight >= nXPos ) )
{
nChar = nCurIndex;
@@ -3695,7 +3682,7 @@ sal_Int32 ImpEditEngine::GetChar(
// Search within Portion...
// Don't search within special portions...
- if ( pPortion->GetKind() != PortionKind::TEXT )
+ if ( rPortion.GetKind() != PortionKind::TEXT )
{
// ...but check on which side
if ( bSmart )
@@ -3708,12 +3695,12 @@ sal_Int32 ImpEditEngine::GetChar(
}
else
{
- sal_Int32 nMax = pPortion->GetLen();
+ sal_Int32 nMax = rPortion.GetLen();
sal_Int32 nOffset = -1;
sal_Int32 nTmpCurIndex = nChar - pLine->GetStart();
long nXInPortion = nXPos - nXLeft;
- if ( pPortion->IsRightToLeft() )
+ if ( rPortion.IsRightToLeft() )
nXInPortion = nXRight - nXPos;
// Search in Array...
@@ -3775,7 +3762,7 @@ sal_Int32 ImpEditEngine::GetChar(
}
}
- nCurIndex = nCurIndex + pPortion->GetLen();
+ nCurIndex = nCurIndex + rPortion.GetLen();
}
if ( nChar == -1 )
@@ -3813,15 +3800,15 @@ long ImpEditEngine::GetPortionXOffset(
for ( sal_Int32 i = pLine->GetStartPortion(); i < nTextPortion; i++ )
{
- const TextPortion* pPortion = pParaPortion->GetTextPortions()[i];
- switch ( pPortion->GetKind() )
+ const TextPortion& rPortion = pParaPortion->GetTextPortions()[i];
+ switch ( rPortion.GetKind() )
{
case PortionKind::FIELD:
case PortionKind::TEXT:
case PortionKind::HYPHENATOR:
case PortionKind::TAB:
{
- nX += pPortion->GetSize().Width();
+ nX += rPortion.GetSize().Width();
}
break;
case PortionKind::LINEBREAK: break;
@@ -3831,18 +3818,18 @@ long ImpEditEngine::GetPortionXOffset(
sal_Int32 nPara = GetEditDoc().GetPos( pParaPortion->GetNode() );
bool bR2LPara = IsRightToLeft( nPara );
- const TextPortion* pDestPortion = pParaPortion->GetTextPortions()[nTextPortion];
- if ( pDestPortion->GetKind() != PortionKind::TAB )
+ const TextPortion& rDestPortion = pParaPortion->GetTextPortions()[nTextPortion];
+ if ( rDestPortion.GetKind() != PortionKind::TAB )
{
- if ( !bR2LPara && pDestPortion->GetRightToLeft() )
+ if ( !bR2LPara && rDestPortion.GetRightToLeft() )
{
// Portions behind must be added, visual before this portion
sal_Int32 nTmpPortion = nTextPortion+1;
while ( nTmpPortion <= pLine->GetEndPortion() )
{
- const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
- if ( pNextTextPortion->GetRightToLeft() && ( pNextTextPortion->GetKind() != PortionKind::TAB ) )
- nX += pNextTextPortion->GetSize().Width();
+ const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+ if ( rNextTextPortion.GetRightToLeft() && ( rNextTextPortion.GetKind() != PortionKind::TAB ) )
+ nX += rNextTextPortion.GetSize().Width();
else
break;
nTmpPortion++;
@@ -3852,22 +3839,22 @@ long ImpEditEngine::GetPortionXOffset(
while ( nTmpPortion > pLine->GetStartPortion() )
{
--nTmpPortion;
- const TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
- if ( pPrevTextPortion->GetRightToLeft() && ( pPrevTextPortion->GetKind() != PortionKind::TAB ) )
- nX -= pPrevTextPortion->GetSize().Width();
+ const TextPortion& rPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+ if ( rPrevTextPortion.GetRightToLeft() && ( rPrevTextPortion.GetKind() != PortionKind::TAB ) )
+ nX -= rPrevTextPortion.GetSize().Width();
else
break;
}
}
- else if ( bR2LPara && !pDestPortion->IsRightToLeft() )
+ else if ( bR2LPara && !rDestPortion.IsRightToLeft() )
{
// Portions behind must be removed, visual behind this portion
sal_Int32 nTmpPortion = nTextPortion+1;
while ( nTmpPortion <= pLine->GetEndPortion() )
{
- const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
- if ( !pNextTextPortion->IsRightToLeft() && ( pNextTextPortion->GetKind() != PortionKind::TAB ) )
- nX += pNextTextPortion->GetSize().Width();
+ const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+ if ( !rNextTextPortion.IsRightToLeft() && ( rNextTextPortion.GetKind() != PortionKind::TAB ) )
+ nX += rNextTextPortion.GetSize().Width();
else
break;
nTmpPortion++;
@@ -3877,9 +3864,9 @@ long ImpEditEngine::GetPortionXOffset(
while ( nTmpPortion > pLine->GetStartPortion() )
{
--nTmpPortion;
- const TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
- if ( !pPrevTextPortion->IsRightToLeft() && ( pPrevTextPortion->GetKind() != PortionKind::TAB ) )
- nX -= pPrevTextPortion->GetSize().Width();
+ const TextPortion& rPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+ if ( !rPrevTextPortion.IsRightToLeft() && ( rPrevTextPortion.GetKind() != PortionKind::TAB ) )
+ nX -= rPrevTextPortion.GetSize().Width();
else
break;
}
@@ -3891,7 +3878,7 @@ long ImpEditEngine::GetPortionXOffset(
OSL_ENSURE( GetTextRanger() || GetPaperSize().Width(), "GetPortionXOffset - paper size?!" );
OSL_ENSURE( GetTextRanger() || (nX <= GetPaperSize().Width()), "GetPortionXOffset - position out of paper size!" );
nX = GetPaperSize().Width() - nX;
- nX -= pDestPortion->GetSize().Width();
+ nX -= rDestPortion.GetSize().Width();
}
return nX;
@@ -3915,28 +3902,28 @@ long ImpEditEngine::GetXPos(
OSL_ENSURE( ( nTextPortion >= pLine->GetStartPortion() ) && ( nTextPortion <= pLine->GetEndPortion() ), "GetXPos: Portion not in current line! " );
- const TextPortion* pPortion = pParaPortion->GetTextPortions()[nTextPortion];
+ const TextPortion& rPortion = pParaPortion->GetTextPortions()[nTextPortion];
long nX = GetPortionXOffset( pParaPortion, pLine, nTextPortion );
// calc text width, portion size may include CJK/CTL spacing...
// But the array might not be init yet, if using text ranger this method is called within CreateLines()...
- long nPortionTextWidth = pPortion->GetSize().Width();
- if ( ( pPortion->GetKind() == PortionKind::TEXT ) && pPortion->GetLen() && !GetTextRanger() )
- nPortionTextWidth = pLine->GetCharPosArray()[nTextPortionStart + pPortion->GetLen() - 1 - pLine->GetStart()];
+ long nPortionTextWidth = rPortion.GetSize().Width();
+ if ( ( rPortion.GetKind() == PortionKind::TEXT ) && rPortion.GetLen() && !GetTextRanger() )
+ nPortionTextWidth = pLine->GetCharPosArray()[nTextPortionStart + rPortion.GetLen() - 1 - pLine->GetStart()];
if ( nTextPortionStart != nIndex )
{
// Search within portion...
- if ( nIndex == ( nTextPortionStart + pPortion->GetLen() ) )
+ if ( nIndex == ( nTextPortionStart + rPortion.GetLen() ) )
{
// End of Portion
- if ( pPortion->GetKind() == PortionKind::TAB )
+ if ( rPortion.GetKind() == PortionKind::TAB )
{
if ( nTextPortion+1 < pParaPortion->GetTextPortions().Count() )
{
- const TextPortion* pNextPortion = pParaPortion->GetTextPortions()[nTextPortion+1];
- if ( pNextPortion->GetKind() != PortionKind::TAB )
+ const TextPortion& rNextPortion = pParaPortion->GetTextPortions()[nTextPortion+1];
+ if ( rNextPortion.GetKind() != PortionKind::TAB )
{
if ( !bPreferPortionStart )
nX = GetXPos( pParaPortion, pLine, nIndex, true );
@@ -3949,12 +3936,12 @@ long ImpEditEngine::GetXPos(
nX += nPortionTextWidth;
}
}
- else if ( !pPortion->IsRightToLeft() )
+ else if ( !rPortion.IsRightToLeft() )
{
nX += nPortionTextWidth;
}
}
- else if ( pPortion->GetKind() == PortionKind::TEXT )
+ else if ( rPortion.GetKind() == PortionKind::TEXT )
{
OSL_ENSURE( nIndex != pLine->GetStart(), "Strange behavior in new GetXPos()" );
OSL_ENSURE( pLine && pLine->GetCharPosArray().size(), "svx::ImpEditEngine::GetXPos(), portion in an empty line?" );
@@ -3971,7 +3958,7 @@ long ImpEditEngine::GetXPos(
// old code restored see #i112788 (which leaves #i74188 unfixed again)
long nPosInPortion = pLine->GetCharPosArray()[nPos];
- if ( !pPortion->IsRightToLeft() )
+ if ( !rPortion.IsRightToLeft() )
{
nX += nPosInPortion;
}
@@ -3980,28 +3967,28 @@ long ImpEditEngine::GetXPos(
nX += nPortionTextWidth - nPosInPortion;
}
- if ( pPortion->GetExtraInfos() && pPortion->GetExtraInfos()->bCompressed )
+ if ( rPortion.GetExtraInfos() && rPortion.GetExtraInfos()->bCompressed )
{
- nX += pPortion->GetExtraInfos()->nPortionOffsetX;
- if ( pPortion->GetExtraInfos()->nAsianCompressionTypes & CHAR_PUNCTUATIONRIGHT )
+ nX += rPortion.GetExtraInfos()->nPortionOffsetX;
+ if ( rPortion.GetExtraInfos()->nAsianCompressionTypes & CHAR_PUNCTUATIONRIGHT )
{
sal_uInt8 nType = GetCharTypeForCompression( pParaPortion->GetNode()->GetChar( nIndex ) );
if ( nType == CHAR_PUNCTUATIONRIGHT && !pLine->GetCharPosArray().empty() )
{
sal_Int32 n = nIndex - nTextPortionStart;
const long* pDXArray = &pLine->GetCharPosArray()[0]+( nTextPortionStart-pLine->GetStart() );
- sal_Int32 nCharWidth = ( ( (n+1) < pPortion->GetLen() ) ? pDXArray[n] : pPortion->GetSize().Width() )
+ sal_Int32 nCharWidth = ( ( (n+1) < rPortion.GetLen() ) ? pDXArray[n] : rPortion.GetSize().Width() )
- ( n ? pDXArray[n-1] : 0 );
- if ( (n+1) < pPortion->GetLen() )
+ if ( (n+1) < rPortion.GetLen() )
{
// smaller, when char behind is CHAR_PUNCTUATIONRIGHT also
nType = GetCharTypeForCompression( pParaPortion->GetNode()->GetChar( nIndex+1 ) );
if ( nType == CHAR_PUNCTUATIONRIGHT )
{
- sal_Int32 nNextCharWidth = ( ( (n+2) < pPortion->GetLen() ) ? pDXArray[n+1] : pPortion->GetSize().Width() )
+ sal_Int32 nNextCharWidth = ( ( (n+2) < rPortion.GetLen() ) ? pDXArray[n+1] : rPortion.GetSize().Width() )
- pDXArray[n];
sal_Int32 nCompressed = nNextCharWidth/2;
- nCompressed *= pPortion->GetExtraInfos()->nMaxCompression100thPercent;
+ nCompressed *= rPortion.GetExtraInfos()->nMaxCompression100thPercent;
nCompressed /= 10000;
nCharWidth += nCompressed;
}
@@ -4019,7 +4006,7 @@ long ImpEditEngine::GetXPos(
}
else // if ( nIndex == pLine->GetStart() )
{
- if ( pPortion->IsRightToLeft() )
+ if ( rPortion.IsRightToLeft() )
{
nX += nPortionTextWidth;
}
@@ -4037,7 +4024,7 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
{
OSL_ENSURE( pPortion->GetLines().Count(), "Paragraph with no lines in ParaPortion::CalcHeight" );
for (sal_Int32 nLine = 0; nLine < pPortion->GetLines().Count(); ++nLine)
- pPortion->nHeight += pPortion->GetLines()[nLine]->GetHeight();
+ pPortion->nHeight += pPortion->GetLines()[nLine].GetHeight();
if ( !aStatus.IsOutliner() )
{
@@ -4153,15 +4140,15 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex,
bool bEOL = ( nFlags & GETCRSR_ENDOFLINE ) != 0;
for (sal_Int32 nLine = 0; nLine < nLineCount; ++nLine)
{
- const EditLine* pTmpLine = pPortion->GetLines()[nLine];
- if ( ( pTmpLine->GetStart() == nIndex ) || ( pTmpLine->IsIn( nIndex, bEOL ) ) )
+ const EditLine& rTmpLine = pPortion->GetLines()[nLine];
+ if ( ( rTmpLine.GetStart() == nIndex ) || ( rTmpLine.IsIn( nIndex, bEOL ) ) )
{
- pLine = pTmpLine;
+ pLine = &rTmpLine;
break;
}
- nCurIndex = nCurIndex + pTmpLine->GetLen();
- nY += pTmpLine->GetHeight();
+ nCurIndex = nCurIndex + rTmpLine.GetLen();
+ nY += rTmpLine.GetHeight();
if ( !aStatus.IsOutliner() )
nY += nSBL;
}
@@ -4170,7 +4157,7 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex,
// Cursor at the End of the paragraph.
OSL_ENSURE( nIndex == nCurIndex, "Index dead wrong in GetEditCursor!" );
- pLine = pPortion->GetLines()[nLineCount-1];
+ pLine = &pPortion->GetLines()[nLineCount-1];
nY -= pLine->GetHeight();
if ( !aStatus.IsOutliner() )
nY -= nSBL;
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 2cace763c8b4..7511b33e3c70 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -638,8 +638,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
for ( sal_Int32 nTP = 0; nTP < nPortions; nTP++ )
{
// There must be no start / end in the deleted area.
- TextPortion* const pTP = pParaPortion->GetTextPortions()[ nTP ];
- nPos = nPos + pTP->GetLen();
+ const TextPortion& rTP = pParaPortion->GetTextPortions()[ nTP ];
+ nPos = nPos + rTP.GetLen();
if ( ( nPos > nStart ) && ( nPos < nEnd ) )
{
bQuickFormat = false;
@@ -683,20 +683,20 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
sal_Int32 nLine = pParaPortion->GetLines().Count()-1;
for ( sal_Int32 nL = 0; nL <= nLine; nL++ )
{
- EditLine* pLine = pParaPortion->GetLines()[nL];
- if ( pLine->GetEnd() > nRealInvalidStart ) // not nInvalidStart!
+ EditLine& rLine = pParaPortion->GetLines()[nL];
+ if ( rLine.GetEnd() > nRealInvalidStart ) // not nInvalidStart!
{
nLine = nL;
break;
}
- pLine->SetValid();
+ rLine.SetValid();
}
// Begin one line before...
// If it is typed at the end, the line in front cannot change.
if ( nLine && ( !pParaPortion->IsSimpleInvalid() || ( nInvalidEnd < pNode->Len() ) || ( nInvalidDiff <= 0 ) ) )
nLine--;
- EditLine* pLine = pParaPortion->GetLines()[nLine];
+ EditLine* pLine = &pParaPortion->GetLines()[nLine];
static Rectangle aZeroArea = Rectangle( Point(), Point() );
Rectangle aBulletArea( aZeroArea );
@@ -868,7 +868,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
while ( ( nTmpWidth < nXWidth ) && !bEOL && ( nTmpPortion < pParaPortion->GetTextPortions().Count() ) )
{
nPortionStart = nTmpPos;
- pPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+ pPortion = &pParaPortion->GetTextPortions()[nTmpPortion];
if ( pPortion->GetKind() == PortionKind::HYPHENATOR )
{
// Throw away a Portion, if necessary correct the one before,
@@ -878,16 +878,16 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
if (nTmpPortion && nTmpLen)
{
nTmpPortion--;
- TextPortion* pPrev = pParaPortion->GetTextPortions()[nTmpPortion];
- DBG_ASSERT( pPrev->GetKind() == PortionKind::TEXT, "Portion?!" );
- nTmpWidth -= pPrev->GetSize().Width();
- nTmpPos = nTmpPos - pPrev->GetLen();
- pPrev->SetLen(pPrev->GetLen() + nTmpLen);
- pPrev->GetSize().Width() = (-1);
+ TextPortion& rPrev = pParaPortion->GetTextPortions()[nTmpPortion];
+ DBG_ASSERT( rPrev.GetKind() == PortionKind::TEXT, "Portion?!" );
+ nTmpWidth -= rPrev.GetSize().Width();
+ nTmpPos = nTmpPos - rPrev.GetLen();
+ rPrev.SetLen(rPrev.GetLen() + nTmpLen);
+ rPrev.GetSize().Width() = (-1);
}
DBG_ASSERT( nTmpPortion < pParaPortion->GetTextPortions().Count(), "No more Portions left!" );
- pPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+ pPortion = &pParaPortion->GetTextPortions()[nTmpPortion];
}
DBG_ASSERT( pPortion->GetKind() != PortionKind::HYPHENATOR, "CreateLines: Hyphenator-Portion!" );
DBG_ASSERT( pPortion->GetLen() || bProcessingEmptyLine, "Empty Portion in CreateLines ?!" );
@@ -1101,8 +1101,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
long nWidthAfterTab = 0;
for ( sal_Int32 n = aCurrentTab.nTabPortion+1; n <= nTmpPortion; n++ )
{
- const TextPortion* pTP = pParaPortion->GetTextPortions()[n];
- nWidthAfterTab += pTP->GetSize().Width();
+ const TextPortion& rTP = pParaPortion->GetTextPortions()[n];
+ nWidthAfterTab += rTP.GetSize().Width();
}
long nW = nWidthAfterTab; // Length before tab position
if ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_RIGHT )
@@ -1119,7 +1119,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
sal_Int32 nDecPos = aText.indexOf( aCurrentTab.aTabStop.GetDecimal() );
if ( nDecPos != -1 )
{
- nW -= pParaPortion->GetTextPortions()[nTmpPortion]->GetSize().Width();
+ nW -= pParaPortion->GetTextPortions()[nTmpPortion].GetSize().Width();
nW += aTmpFont.QuickGetTextSize( GetRefDevice(), pParaPortion->GetNode()->GetString(), nTmpPos, nDecPos, NULL ).Width();
aCurrentTab.bValid = false;
}
@@ -1134,9 +1134,9 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
nW = nMaxW;
aCurrentTab.bValid = false;
}
- TextPortion* const pTabPortion = pParaPortion->GetTextPortions()[aCurrentTab.nTabPortion];
- pTabPortion->GetSize().Width() = aCurrentTab.nTabPos - aCurrentTab.nStartPosX - nW - nStartX;
- nTmpWidth = aCurrentTab.nStartPosX + pTabPortion->GetSize().Width() + nWidthAfterTab;
+ TextPortion& rTabPortion = pParaPortion->GetTextPortions()[aCurrentTab.nTabPortion];
+ rTabPortion.GetSize().Width() = aCurrentTab.nTabPos - aCurrentTab.nStartPosX - nW - nStartX;
+ nTmpWidth = aCurrentTab.nStartPosX + rTabPortion.GetSize().Width() + nWidthAfterTab;
}
nTmpPos = nTmpPos + pPortion->GetLen();
@@ -1173,9 +1173,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
DBG_ASSERT( pPortion->GetKind() == PortionKind::TEXT, "Len>1, but no TextPortion?" );
nTmpWidth -= pPortion->GetSize().Width();
sal_Int32 nP = SplitTextPortion( pParaPortion, nTmpPos, pLine );
- const TextPortion* p = pParaPortion->GetTextPortions()[nP];
- DBG_ASSERT( p, "Portion ?!" );
- nTmpWidth += p->GetSize().Width();
+ nTmpWidth += pParaPortion->GetTextPortions()[nP].GetSize().Width();
}
}
else if ( nTmpWidth >= nXWidth )
@@ -1283,16 +1281,16 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
sal_Int32 nTPos = pLine->GetStart();
for ( sal_Int32 nP = pLine->GetStartPortion(); nP <= pLine->GetEndPortion(); nP++ )
{
- const TextPortion* pTP = pParaPortion->GetTextPortions()[nP];
+ const TextPortion& rTP = pParaPortion->GetTextPortions()[nP];
// problem with hard font height attribute, when everything but the line break has this attribute
- if ( pTP->GetKind() != PortionKind::LINEBREAK )
+ if ( rTP.GetKind() != PortionKind::LINEBREAK )
{
SeekCursor( pNode, nTPos+1, aTmpFont );
aTmpFont.SetPhysFont( GetRefDevice() );
ImplInitDigitMode(GetRefDevice(), aTmpFont.GetLanguage());
RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont );
}
- nTPos = nTPos + pTP->GetLen();
+ nTPos = nTPos + rTP.GetLen();
}
sal_uInt16 nLineHeight = aFormatterMetrics.GetHeight();
if ( nLineHeight > pLine->GetHeight() )
@@ -1379,11 +1377,11 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
// Width from HangingPunctuation was set to 0 in ImpBreakLine,
// check for rel width now, maybe create compression...
long n = nMaxLineWidth - aTextSize.Width();
- TextPortion* const pTP = pParaPortion->GetTextPortions()[pLine->GetEndPortion()];
+ TextPortion& rTP = pParaPortion->GetTextPortions()[pLine->GetEndPortion()];
sal_Int32 nPosInArray = pLine->GetEnd()-1-pLine->GetStart();
long nNewValue = ( nPosInArray ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 ) + n;
pLine->GetCharPosArray()[ nPosInArray ] = nNewValue;
- pTP->GetSize().Width() += n;
+ rTP.GetSize().Width() += n;
}
pLine->SetTextWidth( aTextSize.Width() );
@@ -1507,7 +1505,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
// Next line or maybe a new line....
pLine = 0;
if ( nLine < pParaPortion->GetLines().Count()-1 )
- pLine = pParaPortion->GetLines()[++nLine];
+ pLine = &pParaPortion->GetLines()[++nLine];
if ( pLine && ( nIndex >= pNode->Len() ) )
{
nDelFromLine = nLine;
@@ -1696,9 +1694,8 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uIn
{
// -2: The new one is already inserted.
#ifdef DBG_UTIL
- EditLine* pLastLine = pParaPortion->GetLines()[pParaPortion->GetLines().Count()-2];
- DBG_ASSERT( pLastLine, "soft wrap no line?!" );
- DBG_ASSERT( pLastLine->GetEnd() == pParaPortion->GetNode()->Len(), "different anyway?" );
+ EditLine& rLastLine = pParaPortion->GetLines()[pParaPortion->GetLines().Count()-2];
+ DBG_ASSERT( rLastLine.GetEnd() == pParaPortion->GetNode()->Len(), "different anyway?" );
#endif
sal_Int32 nPos = pParaPortion->GetTextPortions().Count() - 1 ;
pTmpLine->SetStartPortion( nPos );
@@ -1943,12 +1940,12 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
if ( bCompressBlank || bHangingPunctuation )
{
- TextPortion* const pTP = pParaPortion->GetTextPortions()[nEndPortion];
- DBG_ASSERT( pTP->GetKind() == PortionKind::TEXT, "BlankRubber: No TextPortion!" );
+ TextPortion& rTP = pParaPortion->GetTextPortions()[nEndPortion];
+ DBG_ASSERT( rTP.GetKind() == PortionKind::TEXT, "BlankRubber: No TextPortion!" );
DBG_ASSERT( nBreakPos > pLine->GetStart(), "SplitTextPortion at the beginning of the line?" );
sal_Int32 nPosInArray = nBreakPos - 1 - pLine->GetStart();
- pTP->GetSize().Width() = ( nPosInArray && ( pTP->GetLen() > 1 ) ) ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0;
- pLine->GetCharPosArray()[ nPosInArray ] = pTP->GetSize().Width();
+ rTP.GetSize().Width() = ( nPosInArray && ( rTP.GetLen() > 1 ) ) ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0;
+ pLine->GetCharPosArray()[ nPosInArray ] = rTP.GetSize().Width();
}
else if ( bHyphenated )
{
@@ -1958,13 +1955,13 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
OUString aHyphText(CH_HYPH);
if ( (cAlternateReplChar || cAlternateExtraChar) && bAltFullRight ) // alternation after the break doesn't supported
{
- TextPortion* pPrev = pParaPortion->GetTextPortions()[nEndPortion];
- DBG_ASSERT( pPrev && pPrev->GetLen(), "Hyphenate: Prev portion?!" );
- pPrev->SetLen( pPrev->GetLen() - nAltDelChar );
+ TextPortion& rPrev = pParaPortion->GetTextPortions()[nEndPortion];
+ DBG_ASSERT( rPrev.GetLen(), "Hyphenate: Prev portion?!" );
+ rPrev.SetLen( rPrev.GetLen() - nAltDelChar );
pHyphPortion->SetLen( nAltDelChar );
if (cAlternateReplChar && !bAltFullLeft) pHyphPortion->SetExtraValue( cAlternateReplChar );
// Correct width of the portion above:
- pPrev->GetSize().Width() =
+ rPrev.GetSize().Width() =
pLine->GetCharPosArray()[ nBreakPos-1 - pLine->GetStart() - nAltDelChar ];
}
@@ -2043,18 +2040,18 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
aPositions.pop_back();
sal_Int32 nPortionStart, nPortion;
nPortion = pParaPortion->GetTextPortions().FindPortion( nLastChar+1, nPortionStart );
- TextPortion* pLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
+ TextPortion& rLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
long nRealWidth = pLine->GetCharPosArray()[nLastChar-nFirstChar];
long nBlankWidth = nRealWidth;
if ( nLastChar > nPortionStart )
nBlankWidth -= pLine->GetCharPosArray()[nLastChar-nFirstChar-1];
// Possibly the blank has already been deducted in ImpBreakLine:
- if ( nRealWidth == pLastPortion->GetSize().Width() )
+ if ( nRealWidth == rLastPortion.GetSize().Width() )
{
// For the last character the portion must stop behind the blank
// => Simplify correction:
- DBG_ASSERT( ( nPortionStart + pLastPortion->GetLen() ) == ( nLastChar+1 ), "Blank actually not at the end of the portion!?");
- pLastPortion->GetSize().Width() -= nBlankWidth;
+ DBG_ASSERT( ( nPortionStart + rLastPortion.GetLen() ) == ( nLastChar+1 ), "Blank actually not at the end of the portion!?");
+ rLastPortion.GetSize().Width() -= nBlankWidth;
nRemainingSpace += nBlankWidth;
}
pLine->GetCharPosArray()[nLastChar-nFirstChar] -= nBlankWidth;
@@ -2076,16 +2073,16 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
{
sal_Int32 nPortionStart, nPortion;
nPortion = pParaPortion->GetTextPortions().FindPortion( nChar, nPortionStart, true );
- TextPortion* pLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
+ TextPortion& rLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
// The width of the portion:
- pLastPortion->GetSize().Width() += nMore4Everyone;
+ rLastPortion.GetSize().Width() += nMore4Everyone;
if ( nSomeExtraSpace )
- pLastPortion->GetSize().Width()++;
+ rLastPortion.GetSize().Width()++;
// Correct positions in array
// Even for kashidas just change positions, VCL will then draw the kashida automatically
- sal_Int32 nPortionEnd = nPortionStart + pLastPortion->GetLen();
+ sal_Int32 nPortionEnd = nPortionStart + rLastPortion.GetLen();
for ( sal_Int32 _n = nChar; _n < nPortionEnd; _n++ )
{
pLine->GetCharPosArray()[_n-nFirstChar] += nMore4Everyone;
@@ -2233,15 +2230,15 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos
sal_Int32 nPortions = pPortion->GetTextPortions().Count();
for ( nSplitPortion = 0; nSplitPortion < nPortions; nSplitPortion++ )
{
- TextPortion* pTP = pPortion->GetTextPortions()[nSplitPortion];
- nTmpPos = nTmpPos + pTP->GetLen();
+ TextPortion& rTP = pPortion->GetTextPortions()[nSplitPortion];
+ nTmpPos = nTmpPos + rTP.GetLen();
if ( nTmpPos >= nPos )
{
if ( nTmpPos == nPos ) // then nothing needs to be split
{
return nSplitPortion;
}
- pTextPortion = pTP;
+ pTextPortion = &rTP;
break;
}
}
@@ -2339,24 +2336,24 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rS
sal_Int32 nP;
for ( nP = 0; nP < (sal_Int32)pParaPortion->GetTextPortions().Count(); nP++ )
{
- const TextPortion* pTmpPortion = pParaPortion->GetTextPortions()[nP];
- nPortionStart = nPortionStart + pTmpPortion->GetLen();
+ const TextPortion& rTmpPortion = pParaPortion->GetTextPortions()[nP];
+ nPortionStart = nPortionStart + rTmpPortion.GetLen();
if ( nPortionStart >= nStartPos )
{
- nPortionStart = nPortionStart - pTmpPortion->GetLen();
+ nPortionStart = nPortionStart - rTmpPortion.GetLen();
rStart = nPortionStart;
nInvPortion = nP;
break;
}
}
DBG_ASSERT( nP < pParaPortion->GetTextPortions().Count() || !pParaPortion->GetTextPortions().Count(), "Nothing to delete: CreateTextPortions" );
- if ( nInvPortion && ( nPortionStart+pParaPortion->GetTextPortions()[nInvPortion]->GetLen() > nStartPos ) )
+ if ( nInvPortion && ( nPortionStart+pParaPortion->GetTextPortions()[nInvPortion].GetLen() > nStartPos ) )
{
// prefer one in front ...
// But only if it was in the middle of the portion of, otherwise it
// might be the only one in the row in front!
nInvPortion--;
- nPortionStart = nPortionStart - pParaPortion->GetTextPortions()[nInvPortion]->GetLen();
+ nPortionStart = nPortionStart - pParaPortion->GetTextPortions()[nInvPortion].GetLen();
}
pParaPortion->GetTextPortions().DeleteFromPortion( nInvPortion );
@@ -2399,11 +2396,11 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
// A blank portion may be here, if the paragraph was empty,
// or if a line was created by a hard line break.
if ( ( nNewPortionPos < (sal_Int32)pParaPortion->GetTextPortions().Count() ) &&
- !pParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() )
+ !pParaPortion->GetTextPortions()[nNewPortionPos].GetLen() )
{
- TextPortion* const pTP = pParaPortion->GetTextPortions()[nNewPortionPos];
- DBG_ASSERT( pTP->GetKind() == PortionKind::TEXT, "the empty portion was no TextPortion!" );
- pTP->SetLen( pTP->GetLen() + nNewChars );
+ TextPortion& rTP = pParaPortion->GetTextPortions()[nNewPortionPos];
+ DBG_ASSERT( rTP.GetKind() == PortionKind::TEXT, "the empty portion was no TextPortion!" );
+ rTP.SetLen( rTP.GetLen() + nNewChars );
}
else
{
@@ -2416,10 +2413,9 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
sal_Int32 nPortionStart;
const sal_Int32 nTP = pParaPortion->GetTextPortions().
FindPortion( nStartPos, nPortionStart );
- TextPortion* const pTP = pParaPortion->GetTextPortions()[ nTP ];
- DBG_ASSERT( pTP, "RecalcTextPortion: Portion not found" );
- pTP->SetLen( pTP->GetLen() + nNewChars );
- pTP->GetSize().Width() = (-1);
+ TextPortion& rTP = pParaPortion->GetTextPortions()[ nTP ];
+ rTP.SetLen( rTP.GetLen() + nNewChars );
+ rTP.GetSize().Width() = (-1);
}
}
else
@@ -2438,7 +2434,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
TextPortion* pTP = 0;
for ( nPortion = 0; nPortion < nPortions; nPortion++ )
{
- pTP = pParaPortion->GetTextPortions()[ nPortion ];
+ pTP = &pParaPortion->GetTextPortions()[ nPortion ];
if ( ( nPos+pTP->GetLen() ) > nStartPos )
{
DBG_ASSERT( nPos <= nStartPos, "Wrong Start!" );
@@ -2455,8 +2451,8 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
pParaPortion->GetTextPortions().Remove( nPortion );
if ( nType == PortionKind::LINEBREAK )
{
- TextPortion* pNext = pParaPortion->GetTextPortions()[ nPortion ];
- if ( pNext && !pNext->GetLen() )
+ TextPortion& rNext = pParaPortion->GetTextPortions()[ nPortion ];
+ if ( !rNext.GetLen() )
{
// Remove dummy portion
pParaPortion->GetTextPortions().Remove( nPortion );
@@ -2475,17 +2471,17 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
{
// No HYPHENATOR portion is allowed to get stuck right at the end...
sal_Int32 nLastPortion = nPortionCount - 1;
- pTP = pParaPortion->GetTextPortions()[nLastPortion];
+ pTP = &pParaPortion->GetTextPortions()[nLastPortion];
if ( pTP->GetKind() == PortionKind::HYPHENATOR )
{
// Discard portion; if possible, correct the ones before,
// if the Hyphenator portion has swallowed one character...
if ( nLastPortion && pTP->GetLen() )
{
- TextPortion* pPrev = pParaPortion->GetTextPortions()[nLastPortion - 1];
- DBG_ASSERT( pPrev->GetKind() == PortionKind::TEXT, "Portion?!" );
- pPrev->SetLen( pPrev->GetLen() + pTP->GetLen() );
- pPrev->GetSize().Width() = (-1);
+ TextPortion& rPrev = pParaPortion->GetTextPortions()[nLastPortion - 1];
+ DBG_ASSERT( rPrev.GetKind() == PortionKind::TEXT, "Portion?!" );
+ rPrev.SetLen( rPrev.GetLen() + pTP->GetLen() );
+ rPrev.GetSize().Width() = (-1);
}
pParaPortion->GetTextPortions().Remove( nLastPortion );
}
@@ -2926,7 +2922,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ )
{
- pLine = pPortion->GetLines()[nLine];
+ pLine = &pPortion->GetLines()[nLine];
nIndex = pLine->GetStart();
DBG_ASSERT( pLine, "NULL-Pointer in the line iterator in UpdateViews" );
aTmpPos = aStartPos;
@@ -2975,8 +2971,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
for ( sal_Int32 nPortion = pLine->GetStartPortion(); nPortion <= pLine->GetEndPortion(); nPortion++ )
{
DBG_ASSERT( pPortion->GetTextPortions().Count(), "Line without Textportion in Paint!" );
- const TextPortion* pTextPortion = pPortion->GetTextPortions()[nPortion];
- DBG_ASSERT( pTextPortion, "NULL-Pointer in Portion iterator in UpdateViews" );
+ const TextPortion& rTextPortion = pPortion->GetTextPortions()[nPortion];
long nPortionXOffset = GetPortionXOffset( pPortion, pLine, nPortion );
if ( !IsVertical() )
@@ -2992,7 +2987,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
break; // No further output in line necessary
}
- switch ( pTextPortion->GetKind() )
+ switch ( rTextPortion.GetKind() )
{
case PortionKind::TEXT:
case PortionKind::FIELD:
@@ -3002,7 +2997,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
bool bDrawFrame = false;
- if ( ( pTextPortion->GetKind() == PortionKind::FIELD ) && !aTmpFont.IsTransparent() &&
+ if ( ( rTextPortion.GetKind() == PortionKind::FIELD ) && !aTmpFont.IsTransparent() &&
( GetBackgroundColor() != COL_AUTO ) && GetBackgroundColor().IsDark() &&
( IsAutoColorEnabled() && ( pOutDev->GetOutDevType() != OUTDEV_PRINTER ) ) )
{
@@ -3013,12 +3008,12 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
}
#if OSL_DEBUG_LEVEL > 2
- if ( pTextPortion->GetKind() == PORTIONKIND_HYPHENATOR )
+ if ( rTextPortion.GetKind() == PORTIONKIND_HYPHENATOR )
{
aTmpFont.SetFillColor( COL_LIGHTGRAY );
aTmpFont.SetTransparent( sal_False );
}
- if ( pTextPortion->GetRightToLeft() )
+ if ( rTextPortion.GetRightToLeft() )
{
aTmpFont.SetFillColor( COL_LIGHTGRAY );
aTmpFont.SetTransparent( sal_False );
@@ -3043,11 +3038,11 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
const long* pDXArray = 0;
std::unique_ptr<long[]> pTmpDXArray;
- if ( pTextPortion->GetKind() == PortionKind::TEXT )
+ if ( rTextPortion.GetKind() == PortionKind::TEXT )
{
aText = pPortion->GetNode()->GetString();
nTextStart = nIndex;
- nTextLen = pTextPortion->GetLen();
+ nTextLen = rTextPortion.GetLen();
if (!pLine->GetCharPosArray().empty())
pDXArray = &pLine->GetCharPosArray()[0]+( nIndex-pLine->GetStart() );
@@ -3055,7 +3050,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
if ( aStatus.MarkFields() )
{
sal_Int32 nTmpIdx;
- const sal_Int32 nTmpEnd = nTextStart + pTextPortion->GetLen();
+ const sal_Int32 nTmpEnd = nTextStart + rTextPortion.GetLen();
for ( nTmpIdx = nTextStart; nTmpIdx <= nTmpEnd ; ++nTmpIdx )
{
@@ -3069,7 +3064,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
long nHalfBlankWidth = aTmpFont.QuickGetTextSize( pOutDev, aBlank, 0, 1, 0 ).Width() / 2;
const long nAdvanceX = ( nTmpIdx == nTmpEnd ?
- pTextPortion->GetSize().Width() :
+ rTextPortion.GetSize().Width() :
pDXArray[ nTmpIdx - nTextStart ] ) - nHalfBlankWidth;
const long nAdvanceY = -pLine->GetMaxAscent();
@@ -3140,7 +3135,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
}
}
}
- else if ( pTextPortion->GetKind() == PortionKind::FIELD )
+ else if ( rTextPortion.GetKind() == PortionKind::FIELD )
{
const EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature(nIndex);
DBG_ASSERT( pAttr, "Field not found");
@@ -3148,7 +3143,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
aText = static_cast<const EditCharAttribField*>(pAttr)->GetFieldValue();
nTextStart = 0;
nTextLen = aText.getLength();
- ExtraPortionInfo *pExtraInfo = pTextPortion->GetExtraInfos();
+ ExtraPortionInfo *pExtraInfo = rTextPortion.GetExtraInfos();
// Do not split the Fields into different lines while editing
if( bStripOnly && !bParsingFields && pExtraInfo && pExtraInfo->lineBreaksList.size() )
{
@@ -3206,10 +3201,10 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
}
}
- else if ( pTextPortion->GetKind() == PortionKind::HYPHENATOR )
+ else if ( rTextPortion.GetKind() == PortionKind::HYPHENATOR )
{
- if ( pTextPortion->GetExtraValue() )
- aText = OUString(pTextPortion->GetExtraValue());
+ if ( rTextPortion.GetExtraValue() )
+ aText = OUString(rTextPortion.GetExtraValue());
aText += OUStringLiteral1<CH_HYPH>();
nTextStart = 0;
nTextLen = aText.getLength();
@@ -3224,20 +3219,20 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
GetRefDevice()->SetFont( _aOldFont );
}
- long nTxtWidth = pTextPortion->GetSize().Width();
+ long nTxtWidth = rTextPortion.GetSize().Width();
Point aOutPos( aTmpPos );
aRedLineTmpPos = aTmpPos;
// In RTL portions spell markup pos should be at the start of the
// first chara as well. That is on the right end of the portion
- if (pTextPortion->IsRightToLeft())
- aRedLineTmpPos.X() += pTextPortion->GetSize().Width();
+ if (rTextPortion.IsRightToLeft())
+ aRedLineTmpPos.X() += rTextPortion.GetSize().Width();
if ( bStripOnly )
{
EEngineData::WrongSpellVector aWrongSpellVector;
- if(GetStatus().DoOnlineSpelling() && pTextPortion->GetLen())
+ if(GetStatus().DoOnlineSpelling() && rTextPortion.GetLen())
{
WrongList* pWrongs = pPortion->GetNode()->GetWrongList();
@@ -3245,7 +3240,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
{
size_t nStart = nIndex, nEnd = 0;
bool bWrong = pWrongs->NextWrong(nStart, nEnd);
- const size_t nMaxEnd(nIndex + pTextPortion->GetLen());
+ const size_t nMaxEnd(nIndex + rTextPortion.GetLen());
while(bWrong)
{
@@ -3284,7 +3279,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
const SvxFieldData* pFieldData = 0;
- if(PortionKind::FIELD == pTextPortion->GetKind())
+ if(PortionKind::FIELD == rTextPortion.GetKind())
{
const EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature(nIndex);
const SvxFieldItem* pFieldItem = dynamic_cast<const SvxFieldItem*>(pAttr->GetItem());
@@ -3318,7 +3313,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
// StripPortions() data callback
GetEditEnginePtr()->DrawingText( aOutPos, aText, nTextStart, nTextLen, pDXArray,
- aTmpFont, n, nIndex, pTextPortion->GetRightToLeft(),
+ aTmpFont, n, nIndex, rTextPortion.GetRightToLeft(),
aWrongSpellVector.size() ? &aWrongSpellVector : 0,
pFieldData,
bEndOfLine, bEndOfParagraph, false, // support for EOL/EOP TEXT comments
@@ -3408,16 +3403,16 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
}
}
Point aRealOutPos( aOutPos );
- if ( ( pTextPortion->GetKind() == PortionKind::TEXT )
- && pTextPortion->GetExtraInfos() && pTextPortion->GetExtraInfos()->bCompressed
- && pTextPortion->GetExtraInfos()->bFirstCharIsRightPunktuation )
+ if ( ( rTextPortion.GetKind() == PortionKind::TEXT )
+ && rTextPortion.GetExtraInfos() && rTextPortion.GetExtraInfos()->bCompressed
+ && rTextPortion.GetExtraInfos()->bFirstCharIsRightPunktuation )
{
- aRealOutPos.X() += pTextPortion->GetExtraInfos()->nPortionOffsetX;
+ aRealOutPos.X() += rTextPortion.GetExtraInfos()->nPortionOffsetX;
}
// RTL portions with (#i37132#)
// compressed blank should not paint this blank:
- if ( pTextPortion->IsRightToLeft() && nTextLen >= 2 &&
+ if ( rTextPortion.IsRightToLeft() && nTextLen >= 2 &&
pDXArray[ nTextLen - 1 ] ==
pDXArray[ nTextLen - 2 ] &&
' ' == aText[nTextStart + nTextLen - 1] )
@@ -3432,14 +3427,14 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
aTopLeft.Y() -= pLine->GetMaxAscent();
if ( nOrientation )
aTopLeft = lcl_ImplCalcRotatedPos( aTopLeft, aOrigin, nSin, nCos );
- Rectangle aRect( aTopLeft, pTextPortion->GetSize() );
+ Rectangle aRect( aTopLeft, rTextPortion.GetSize() );
pOutDev->DrawRect( aRect );
}
// PDF export:
if ( pPDFExtOutDevData )
{
- if ( pTextPortion->GetKind() == PortionKind::FIELD )
+ if ( rTextPortion.GetKind() == PortionKind::FIELD )
{
const EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature(nIndex);
const SvxFieldItem* pFieldItem = dynamic_cast<const SvxFieldItem*>(pAttr->GetItem());
@@ -3451,7 +3446,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
Point aTopLeft( aTmpPos );
aTopLeft.Y() -= pLine->GetMaxAscent();
- Rectangle aRect( aTopLeft, pTextPortion->GetSize() );
+ Rectangle aRect( aTopLeft, rTextPortion.GetSize() );
vcl::PDFExtOutDevBookmarkEntry aBookmark;
aBookmark.nLinkId = pPDFExtOutDevData->CreateLink( aRect );
aBookmark.aBookmark = static_cast<const SvxURLField*>(pFieldData)->GetURL();
@@ -3464,7 +3459,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
}
const WrongList* const pWrongList = pPortion->GetNode()->GetWrongList();
- if ( GetStatus().DoOnlineSpelling() && pWrongList && !pWrongList->empty() && pTextPortion->GetLen() )
+ if ( GetStatus().DoOnlineSpelling() && pWrongList && !pWrongList->empty() && rTextPortion.GetLen() )
{
{//#105750# adjust LinePos for superscript or subscript text
short _nEsc = aTmpFont.GetEscapement();
@@ -3479,7 +3474,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
}
Color aOldColor( pOutDev->GetLineColor() );
pOutDev->SetLineColor( Color( GetColorConfig().GetColorValue( svtools::SPELL ).nColor ) );
- lcl_DrawRedLines( pOutDev, aTmpFont.GetSize().Height(), aRedLineTmpPos, (size_t)nIndex, (size_t)nIndex + pTextPortion->GetLen(), pDXArray, pPortion->GetNode()->GetWrongList(), nOrientation, aOrigin, IsVertical(), pTextPortion->IsRightToLeft() );
+ lcl_DrawRedLines( pOutDev, aTmpFont.GetSize().Height(), aRedLineTmpPos, (size_t)nIndex, (size_t)nIndex + rTextPortion.GetLen(), pDXArray, pPortion->GetNode()->GetWrongList(), nOrientation, aOrigin, IsVertical(), rTextPortion.IsRightToLeft() );
pOutDev->SetLineColor( aOldColor );
}
}
@@ -3488,7 +3483,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
pTmpDXArray.reset();
- if ( pTextPortion->GetKind() == PortionKind::FIELD )
+ if ( rTextPortion.GetKind() == PortionKind::FIELD )
{
const EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature(nIndex);
DBG_ASSERT( pAttr, "Field not found" );
@@ -3513,27 +3508,27 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
break;
case PortionKind::TAB:
{
- if ( pTextPortion->GetExtraValue() && ( pTextPortion->GetExtraValue() != ' ' ) )
+ if ( rTextPortion.GetExtraValue() && ( rTextPortion.GetExtraValue() != ' ' ) )
{
SeekCursor( pPortion->GetNode(), nIndex+1, aTmpFont, pOutDev );
aTmpFont.SetTransparent( false );
aTmpFont.SetEscapement( 0 );
aTmpFont.SetPhysFont( pOutDev );
long nCharWidth = aTmpFont.QuickGetTextSize( pOutDev,
- OUString(pTextPortion->GetExtraValue()), 0, 1, NULL ).Width();
+ OUString(rTextPortion.GetExtraValue()), 0, 1, NULL ).Width();
sal_Int32 nChars = 2;
if( nCharWidth )
- nChars = pTextPortion->GetSize().Width() / nCharWidth;
+ nChars = rTextPortion.GetSize().Width() / nCharWidth;
if ( nChars < 2 )
nChars = 2; // is compressed by DrawStretchText.
else if ( nChars == 2 )
nChars = 3; // looks better
OUStringBuffer aBuf;
- comphelper::string::padToLength(aBuf, nChars, pTextPortion->GetExtraValue());
+ comphelper::string::padToLength(aBuf, nChars, rTextPortion.GetExtraValue());
OUString aText(aBuf.makeStringAndClear());
aTmpFont.QuickDrawText( pOutDev, aTmpPos, aText, 0, aText.getLength(), NULL );
- pOutDev->DrawStretchText( aTmpPos, pTextPortion->GetSize().Width(), aText );
+ pOutDev->DrawStretchText( aTmpPos, rTextPortion.GetSize().Width(), aText );
if ( bStripOnly )
{
@@ -3546,9 +3541,9 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
// StripPortions() data callback
GetEditEnginePtr()->DrawingTab( aTmpPos,
- pTextPortion->GetSize().Width(),
- OUString(pTextPortion->GetExtraValue()),
- aTmpFont, n, nIndex, pTextPortion->GetRightToLeft(),
+ rTextPortion.GetSize().Width(),
+ OUString(rTextPortion.GetExtraValue()),
+ aTmpFont, n, nIndex, rTextPortion.GetRightToLeft(),
bEndOfLine, bEndOfParagraph,
aOverlineColor, aTextLineColor);
}
@@ -3581,7 +3576,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
if( bParsingFields )
nPortion--;
else
- nIndex = nIndex + pTextPortion->GetLen();
+ nIndex = nIndex + rTextPortion.GetLen();
}
}
@@ -4101,8 +4096,8 @@ long ImpEditEngine::CalcVertLineSpacing(Point& rStartPos) const
nTotalLineCount += nLineCount;
for (sal_Int32 j = 0; j < nLineCount; ++j)
{
- const EditLine* pLine = rLines[j];
- nTotalOccupiedHeight += pLine->GetHeight();
+ const EditLine& rLine = rLines[j];
+ nTotalOccupiedHeight += rLine.GetHeight();
if (j < nLineCount-1)
nTotalOccupiedHeight += nSBL;
nTotalOccupiedHeight += nUL;
@@ -4526,7 +4521,7 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion*
std::vector<TextPortion*> aCompressedPortions;
sal_Int32 nPortion = pLine->GetEndPortion();
- TextPortion* pTP = pParaPortion->GetTextPortions()[ nPortion ];
+ TextPortion* pTP = &pParaPortion->GetTextPortions()[ nPortion ];
while ( pTP && ( pTP->GetKind() == PortionKind::TEXT ) )
{
if ( pTP->GetExtraInfos() && pTP->GetExtraInfos()->bCompressed )
@@ -4535,7 +4530,7 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion*
nCompressed += pTP->GetExtraInfos()->nOrgWidth - pTP->GetSize().Width();
aCompressedPortions.push_back(pTP);
}
- pTP = ( nPortion > pLine->GetStartPortion() ) ? pParaPortion->GetTextPortions()[ --nPortion ] : NULL;
+ pTP = ( nPortion > pLine->GetStartPortion() ) ? &pParaPortion->GetTextPortions()[ --nPortion ] : NULL;
}
if ( bFoundCompressedPortion )
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index f1075792e052..1fbb791f5b14 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -626,10 +626,10 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
// start at 0, so the index is right ...
for ( sal_Int32 n = 0; n <= nEndPortion; n++ )
{
- const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n];
+ const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[n];
if ( n < nStartPortion )
{
- nIndex = nIndex + pTextPortion->GetLen();
+ nIndex = nIndex + rTextPortion.GetLen();
continue;
}
@@ -660,7 +660,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
rOutput.WriteChar( ' ' );
sal_Int32 nS = nIndex;
- sal_Int32 nE = nIndex + pTextPortion->GetLen();
+ sal_Int32 nE = nIndex + rTextPortion.GetLen();
if ( n == nStartPortion )
nS = nStartPos;
if ( n == nEndPortion )
@@ -676,7 +676,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
bFinishPortion = false;
}
- nIndex = nIndex + pTextPortion->GetLen();
+ nIndex = nIndex + rTextPortion.GetLen();
}
rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PAR ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PARD ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PLAIN );
@@ -1133,8 +1133,8 @@ EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool
sal_uInt16 n;
for ( n = 0; n < nCount; n++ )
{
- const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n];
- TextPortion* pNew = new TextPortion( *pTextPortion );
+ const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[n];
+ TextPortion* pNew = new TextPortion( rTextPortion );
pX->aTextPortions.Append(pNew);
}
@@ -1142,17 +1142,17 @@ EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool
nCount = pParaPortion->GetLines().Count();
for ( n = 0; n < nCount; n++ )
{
- const EditLine* pLine = pParaPortion->GetLines()[n];
- EditLine* pNew = pLine->Clone();
+ const EditLine& rLine = pParaPortion->GetLines()[n];
+ EditLine* pNew = rLine.Clone();
pX->aLines.Append(pNew);
}
#ifdef DBG_UTIL
sal_uInt16 nTest;
int nTPLen = 0, nTxtLen = 0;
for ( nTest = pParaPortion->GetTextPortions().Count(); nTest; )
- nTPLen += pParaPortion->GetTextPortions()[--nTest]->GetLen();
+ nTPLen += pParaPortion->GetTextPortions()[--nTest].GetLen();
for ( nTest = pParaPortion->GetLines().Count(); nTest; )
- nTxtLen += pParaPortion->GetLines()[--nTest]->GetLen();
+ nTxtLen += pParaPortion->GetLines()[--nTest].GetLen();
DBG_ASSERT( ( nTPLen == pParaPortion->GetNode()->Len() ) && ( nTxtLen == pParaPortion->GetNode()->Len() ), "CreateBinTextObject: ParaPortion not completely formatted!" );
#endif
}
@@ -1332,8 +1332,8 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
sal_uInt16 nCount = rXP.aTextPortions.Count();
for ( sal_uInt16 _n = 0; _n < nCount; _n++ )
{
- const TextPortion* pTextPortion = rXP.aTextPortions[_n];
- TextPortion* pNew = new TextPortion( *pTextPortion );
+ const TextPortion& rTextPortion = rXP.aTextPortions[_n];
+ TextPortion* pNew = new TextPortion( rTextPortion );
pParaPortion->GetTextPortions().Insert(_n, pNew);
}
@@ -1342,8 +1342,8 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
nCount = rXP.aLines.Count();
for ( sal_uInt16 m = 0; m < nCount; m++ )
{
- const EditLine* pLine = rXP.aLines[m];
- EditLine* pNew = pLine->Clone();
+ const EditLine& rLine = rXP.aLines[m];
+ EditLine* pNew = rLine.Clone();
pNew->SetInvalid(); // Paint again!
pParaPortion->GetLines().Insert(m, pNew);
}
@@ -1351,9 +1351,9 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
sal_uInt16 nTest;
int nTPLen = 0, nTxtLen = 0;
for ( nTest = pParaPortion->GetTextPortions().Count(); nTest; )
- nTPLen += pParaPortion->GetTextPortions()[--nTest]->GetLen();
+ nTPLen += pParaPortion->GetTextPortions()[--nTest].GetLen();
for ( nTest = pParaPortion->GetLines().Count(); nTest; )
- nTxtLen += pParaPortion->GetLines()[--nTest]->GetLen();
+ nTxtLen += pParaPortion->GetLines()[--nTest].GetLen();
DBG_ASSERT( ( nTPLen == pParaPortion->GetNode()->Len() ) && ( nTxtLen == pParaPortion->GetNode()->Len() ), "InsertBinTextObject: ParaPortion not completely formatted!" );
#endif
}