diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-01-12 13:35:22 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-01-14 16:06:07 +0100 |
commit | ee880f953e8b04c736a44fea63513d041681955f (patch) | |
tree | 7eb9067e5f7ee5902e8fa422843ec883a3c58c03 /editeng | |
parent | b5c81b6c36dcd539d3104e7902373d96b3e025f6 (diff) |
editeng: use EditLine as ref. and use const
We assert the EditLine pointer is valid (not nullptr) in some
methods or just expect it to be valid without asserting. If this
is the case then we might as well change the parameter to be a
reference.
Also change EditLine to const&, where this makes sense in the code.
Change-Id: Ia28810fea9d4e053f18fbb45968644545f5bf83b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162012
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 11 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 19 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 140 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 131 |
5 files changed, 150 insertions, 159 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 7af59f499e12..d7a30a60b935 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -866,15 +866,15 @@ EditSelection EditEngine::SelectWord( } tools::Long EditEngine::GetXPos( - const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart) const + const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart) const { - return pImpEditEngine->GetXPos(pParaPortion, pLine, nIndex, bPreferPortionStart); + return pImpEditEngine->GetXPos(pParaPortion, rLine, nIndex, bPreferPortionStart); } Range EditEngine::GetLineXPosStartEnd( - const ParaPortion* pParaPortion, const EditLine* pLine) const + const ParaPortion* pParaPortion, EditLine const& rLine) const { - return pImpEditEngine->GetLineXPosStartEnd(pParaPortion, pLine); + return pImpEditEngine->GetLineXPosStartEnd(pParaPortion, rLine); } bool EditEngine::IsFormatted() const diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index abf3c5337255..c1f20e9e55df 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -576,7 +576,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, nEndIndex = nStartIndex; tools::Rectangle aTmpRect(pEditEngine->pImpEditEngine->GetEditCursor( - &rInfo.rPortion, rInfo.pLine, nStartIndex, GetCursorFlags::NONE)); + &rInfo.rPortion, *rInfo.pLine, nStartIndex, GetCursorFlags::NONE)); const Size aLineOffset = pEditEngine->pImpEditEngine->getTopLeftDocOffset(rInfo.aArea); aTmpRect.Move(0, aLineOffset.Height()); @@ -595,8 +595,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, // Now that we have Bidi, the first/last index doesn't have to be the 'most outside' position if (!bPartOfLine) { - Range aLineXPosStartEnd - = pEditEngine->GetLineXPosStartEnd(&rInfo.rPortion, rInfo.pLine); + Range aLineXPosStartEnd = pEditEngine->GetLineXPosStartEnd(&rInfo.rPortion, *rInfo.pLine); aTmpRect.SetLeft(aLineXPosStartEnd.Min()); aTmpRect.SetRight(aLineXPosStartEnd.Max()); aTmpRect.Move(aLineOffset.Width(), 0); @@ -617,10 +616,8 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, DBG_ASSERT(nTmpEndIndex > nTmpStartIndex, "DrawSelectionXOR, Start >= End?"); - tools::Long nX1 - = pEditEngine->GetXPos(&rInfo.rPortion, rInfo.pLine, nTmpStartIndex, true); - tools::Long nX2 - = pEditEngine->GetXPos(&rInfo.rPortion, rInfo.pLine, nTmpEndIndex); + tools::Long nX1 = pEditEngine->GetXPos(&rInfo.rPortion, *rInfo.pLine, nTmpStartIndex, true); + tools::Long nX2 = pEditEngine->GetXPos(&rInfo.rPortion, *rInfo.pLine, nTmpEndIndex); aTmpRect.SetLeft(std::min(nX1, nX2)); aTmpRect.SetRight(std::max(nX1, nX2)); diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 6705f4e5dc4f..61afaea21b83 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -656,10 +656,10 @@ private: std::tuple<const ParaPortion*, const EditLine*, tools::Long> GetPortionAndLine(Point aDocPos); EditPaM GetPaM( Point aDocPos, bool bSmart = true ); bool IsTextPos(const Point& rDocPos, sal_uInt16 nBorder); - tools::Long GetXPos(const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const; - tools::Long GetPortionXOffset(const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nTextPortion) const; - sal_Int32 GetChar(const ParaPortion* pParaPortion, const EditLine* pLine, tools::Long nX, bool bSmart = true); - Range GetLineXPosStartEnd( const ParaPortion* pParaPortion, const EditLine* pLine ) const; + tools::Long GetXPos(const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const; + tools::Long GetPortionXOffset(const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nTextPortion) const; + sal_Int32 GetChar(const ParaPortion* pParaPortion, EditLine const& rLine, tools::Long nX, bool bSmart = true); + Range GetLineXPosStartEnd(const ParaPortion* pParaPortion, EditLine const& rLine) const; void ParaAttribsToCharAttribs( ContentNode* pNode ); void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const; @@ -687,8 +687,8 @@ private: void RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics, SvxFont& rFont ); void CheckAutoPageSize(); - void ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate ); - void ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, tools::Long nRemainingSpace ); + void ImpBreakLine( ParaPortion* pParaPortion, EditLine& rLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate ); + void ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine& rLine, tools::Long nRemainingSpace ); EditPaM ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pRight, bool bBackward = false ); EditPaM ImpDeleteSelection(const EditSelection& rCurSel); EditPaM ImpInsertParaBreak( EditPaM& rPaM, bool bKeepEndingAttribs = true ); @@ -744,7 +744,7 @@ private: bool ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, sal_Int32 nStartPos, sal_Int32* pDXArray, sal_uInt16 n100thPercentFromMax, bool bManipulateDXArray ); - void ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* pParaPortion, tools::Long nRemainingWidth ); + void ImplExpandCompressedPortions(EditLine& rLine, ParaPortion* pParaPortion, tools::Long nRemainingWidth); void ImplInitLayoutMode(OutputDevice& rOutDev, sal_Int32 nPara, sal_Int32 nIndex); static LanguageType ImplCalcDigitLang(LanguageType eCurLang); @@ -1025,7 +1025,7 @@ public: sal_uInt32 GetTextHeightNTP() const; sal_uInt32 CalcTextWidth( bool bIgnoreExtraSpace); sal_uInt32 CalcParaWidth( sal_Int32 nParagraph, bool bIgnoreExtraSpace ); - sal_uInt32 CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, bool bIgnoreExtraSpace); + sal_uInt32 CalcLineWidth( ParaPortion* pPortion, EditLine const& rLine, bool bIgnoreExtraSpace); sal_Int32 GetLineCount( sal_Int32 nParagraph ) const; sal_Int32 GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const; void GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const; @@ -1052,8 +1052,7 @@ public: } tools::Rectangle PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nFlags = GetCursorFlags::NONE ); - tools::Rectangle GetEditCursor(const ParaPortion* pPortion, const EditLine* pLine, - sal_Int32 nIndex, GetCursorFlags nFlags); + tools::Rectangle GetEditCursor(const ParaPortion* pPortion, EditLine const& rLine, sal_Int32 nIndex, GetCursorFlags nFlags); bool IsModified() const { return maEditDoc.IsModified(); } void SetModifyFlag(bool b) { maEditDoc.SetModified( b ); } diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 6e9351a7c80e..065b28e69f18 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -578,8 +578,7 @@ bool ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView ) { if (rInfo.pLine->IsIn(n)) { - tools::Rectangle aR = GetEditCursor(pParaPortion, rInfo.pLine, n, - GetCursorFlags::NONE); + tools::Rectangle aR = GetEditCursor(pParaPortion, *rInfo.pLine, n, GetCursorFlags::NONE); aR.Move(getTopLeftDocOffset(rInfo.aArea)); aRects[n - nMinPos] = pView->GetImpEditView()->GetWindowPos(aR); } @@ -1275,7 +1274,7 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView const * pView ) tools::Long nX; if ( pView->pImpEditView->nTravelXPos == TRAVEL_X_DONTKNOW ) { - nX = GetXPos( pPPortion, &rLine, rPaM.GetIndex() ); + nX = GetXPos(pPPortion, rLine, rPaM.GetIndex()); pView->pImpEditView->nTravelXPos = nX + mnOnePixelInRef; } else @@ -1285,7 +1284,7 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView const * pView ) if ( nLine ) // same paragraph { const EditLine& rPrevLine = pPPortion->GetLines()[nLine-1]; - aNewPaM.SetIndex( GetChar( pPPortion, &rPrevLine, nX ) ); + 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 @@ -1300,7 +1299,7 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView const * pView ) { const EditLine& rLine2 = pPrevPortion->GetLines()[pPrevPortion->GetLines().Count()-1]; aNewPaM.SetNode( pPrevPortion->GetNode() ); - aNewPaM.SetIndex( GetChar( pPrevPortion, &rLine2, nX + mnOnePixelInRef ) ); + aNewPaM.SetIndex(GetChar(pPrevPortion, rLine2, nX + mnOnePixelInRef)); } } @@ -1319,7 +1318,7 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView const * pView ) if ( pView->pImpEditView->nTravelXPos == TRAVEL_X_DONTKNOW ) { const EditLine& rLine = pPPortion->GetLines()[nLine]; - nX = GetXPos( pPPortion, &rLine, rPaM.GetIndex() ); + nX = GetXPos(pPPortion, rLine, rPaM.GetIndex()); pView->pImpEditView->nTravelXPos = nX + mnOnePixelInRef; } else @@ -1329,7 +1328,7 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView const * pView ) if ( nLine < pPPortion->GetLines().Count()-1 ) { const EditLine& rNextLine = pPPortion->GetLines()[nLine+1]; - aNewPaM.SetIndex( GetChar( pPPortion, &rNextLine, nX ) ); + aNewPaM.SetIndex(GetChar(pPPortion, rNextLine, nX)); // Special treatment, see CursorUp ... if ( ( aNewPaM.GetIndex() == rNextLine.GetEnd() ) && ( aNewPaM.GetIndex() > rNextLine.GetStart() ) && ( aNewPaM.GetIndex() < pPPortion->GetNode()->Len() ) ) aNewPaM = CursorLeft( aNewPaM ); @@ -1343,7 +1342,7 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView const * pView ) aNewPaM.SetNode( pNextPortion->GetNode() ); // Never at the very end when several lines, because then a line // below the cursor appears. - aNewPaM.SetIndex( GetChar( pNextPortion, &rLine, nX + mnOnePixelInRef ) ); + aNewPaM.SetIndex(GetChar(pNextPortion, rLine, nX + mnOnePixelInRef)); if ( ( aNewPaM.GetIndex() == rLine.GetEnd() ) && ( aNewPaM.GetIndex() > rLine.GetStart() ) && ( pNextPortion->GetLines().Count() > 1 ) ) aNewPaM = CursorLeft( aNewPaM ); } @@ -3121,41 +3120,41 @@ EditPaM ImpEditEngine::InsertLineBreak(const EditSelection& aCurSel) // Helper functions -tools::Rectangle ImpEditEngine::GetEditCursor(const ParaPortion* pPortion, const EditLine* pLine, +tools::Rectangle ImpEditEngine::GetEditCursor(const ParaPortion* pPortion, EditLine const& rLine, sal_Int32 nIndex, GetCursorFlags nFlags) { - assert(pPortion && pLine); + assert(pPortion); // nIndex might be not in the line // Search within the line... tools::Long nX; - if ((nIndex == pLine->GetStart()) && (nFlags & GetCursorFlags::StartOfLine)) + if ((nIndex == rLine.GetStart()) && (nFlags & GetCursorFlags::StartOfLine)) { - Range aXRange = GetLineXPosStartEnd(pPortion, pLine); + Range aXRange = GetLineXPosStartEnd(pPortion, rLine); nX = !IsRightToLeft(GetEditDoc().GetPos(pPortion->GetNode())) ? aXRange.Min() : aXRange.Max(); } - else if ((nIndex == pLine->GetEnd()) && (nFlags & GetCursorFlags::EndOfLine)) + else if ((nIndex == rLine.GetEnd()) && (nFlags & GetCursorFlags::EndOfLine)) { - Range aXRange = GetLineXPosStartEnd(pPortion, pLine); + Range aXRange = GetLineXPosStartEnd(pPortion, rLine); nX = !IsRightToLeft(GetEditDoc().GetPos(pPortion->GetNode())) ? aXRange.Max() : aXRange.Min(); } else { - nX = GetXPos(pPortion, pLine, nIndex, bool(nFlags & GetCursorFlags::PreferPortionStart)); + nX = GetXPos(pPortion, rLine, nIndex, bool(nFlags & GetCursorFlags::PreferPortionStart)); } tools::Rectangle aEditCursor; aEditCursor.SetLeft(nX); aEditCursor.SetRight(nX); - aEditCursor.SetBottom(pLine->GetHeight() - 1); + aEditCursor.SetBottom(rLine.GetHeight() - 1); if (nFlags & GetCursorFlags::TextOnly) - aEditCursor.SetTop(aEditCursor.Bottom() - pLine->GetTxtHeight() + 1); + aEditCursor.SetTop(aEditCursor.Bottom() - rLine.GetTxtHeight() + 1); else aEditCursor.SetTop(aEditCursor.Bottom() - - std::min(pLine->GetTxtHeight(), pLine->GetHeight()) + 1); + - std::min(rLine.GetTxtHeight(), rLine.GetHeight()) + 1); return aEditCursor; } @@ -3192,7 +3191,7 @@ tools::Rectangle ImpEditEngine::PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nF if (pLastLine) { - aEditCursor = GetEditCursor(pPortion, pLastLine, nIndex, nFlags); + aEditCursor = GetEditCursor(pPortion, *pLastLine, nIndex, nFlags); aEditCursor.Move(getTopLeftDocOffset(aLineArea)); } else @@ -3334,8 +3333,8 @@ EditPaM ImpEditEngine::GetPaM( Point aDocPos, bool bSmart ) if (const auto& [pPortion, pLine, nLineStartX] = GetPortionAndLine(aDocPos); pPortion) { - sal_Int32 nCurIndex - = GetChar(pPortion, pLine, aDocPos.X() - nLineStartX, bSmart); + assert(pLine); + sal_Int32 nCurIndex = GetChar(pPortion, *pLine, aDocPos.X() - nLineStartX, bSmart); EditPaM aPaM(pPortion->GetNode(), nCurIndex); if (nCurIndex && (nCurIndex == pLine->GetEnd()) @@ -3353,7 +3352,8 @@ bool ImpEditEngine::IsTextPos(const Point& rDocPos, sal_uInt16 nBorder) { if (const auto& [pPortion, pLine, nLineStartX] = GetPortionAndLine(rDocPos); pPortion) { - Range aLineXPosStartEnd = GetLineXPosStartEnd(pPortion, pLine); + assert(pLine); + Range aLineXPosStartEnd = GetLineXPosStartEnd(pPortion, *pLine); if ((rDocPos.X() >= nLineStartX + aLineXPosStartEnd.Min() - nBorder) && (rDocPos.X() <= nLineStartX + aLineXPosStartEnd.Max() + nBorder)) return true; @@ -3412,7 +3412,7 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara, bool bIgnoreExtraSpace sal_Int32 nLines = pPortion->GetLines().Count(); for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ ) { - EditLine& rLine = pPortion->GetLines()[nLine]; + EditLine const& 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 @@ -3431,7 +3431,7 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara, bool bIgnoreExtraSpace } } nCurWidth += scaleXSpacingValue(rLRItem.GetRight()); - nCurWidth += CalcLineWidth( pPortion, &rLine, bIgnoreExtraSpace ); + nCurWidth += CalcLineWidth(pPortion, rLine, bIgnoreExtraSpace); if ( nCurWidth > nMaxWidth ) { nMaxWidth = nCurWidth; @@ -3443,7 +3443,7 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara, bool bIgnoreExtraSpace return static_cast<sal_uInt32>(nMaxWidth); } -sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, bool bIgnoreExtraSpace ) +sal_uInt32 ImpEditEngine::CalcLineWidth(ParaPortion* pPortion, EditLine const& rLine, bool bIgnoreExtraSpace) { sal_Int32 nPara = GetEditDoc().GetPos( pPortion->GetNode() ); @@ -3457,8 +3457,8 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, // Calculation of the width without the Indents ... sal_uInt32 nWidth = 0; - sal_Int32 nPos = pLine->GetStart(); - for ( sal_Int32 nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ ) + sal_Int32 nPos = rLine.GetStart(); + for ( sal_Int32 nTP = rLine.GetStartPortion(); nTP <= rLine.GetEndPortion(); nTP++ ) { const TextPortion& rTextPortion = pPortion->GetTextPortions()[nTP]; switch ( rTextPortion.GetKind() ) @@ -3997,20 +3997,17 @@ EditSelection ImpEditEngine::PasteText( uno::Reference< datatransfer::XTransfera return aNewSelection; } -sal_Int32 ImpEditEngine::GetChar( - const ParaPortion* pParaPortion, const EditLine* pLine, tools::Long nXPos, bool bSmart) +sal_Int32 ImpEditEngine::GetChar(const ParaPortion* pParaPortion, EditLine const& rLine, tools::Long nXPos, bool bSmart) { - assert(pLine); - sal_Int32 nChar = -1; - sal_Int32 nCurIndex = pLine->GetStart(); + sal_Int32 nCurIndex = rLine.GetStart(); // Search best matching portion with GetPortionXOffset() - for ( sal_Int32 i = pLine->GetStartPortion(); i <= pLine->GetEndPortion(); i++ ) + for ( sal_Int32 i = rLine.GetStartPortion(); i <= rLine.GetEndPortion(); i++ ) { const TextPortion& rPortion = pParaPortion->GetTextPortions()[i]; - tools::Long nXLeft = GetPortionXOffset( pParaPortion, pLine, i ); + tools::Long nXLeft = GetPortionXOffset( pParaPortion, rLine, i ); tools::Long nXRight = nXLeft + rPortion.GetSize().Width(); if ( ( nXLeft <= nXPos ) && ( nXRight >= nXPos ) ) { @@ -4034,7 +4031,7 @@ sal_Int32 ImpEditEngine::GetChar( { sal_Int32 nMax = rPortion.GetLen(); sal_Int32 nOffset = -1; - sal_Int32 nTmpCurIndex = nChar - pLine->GetStart(); + sal_Int32 nTmpCurIndex = nChar - rLine.GetStart(); tools::Long nXInPortion = nXPos - nXLeft; if ( rPortion.IsRightToLeft() ) @@ -4043,11 +4040,11 @@ sal_Int32 ImpEditEngine::GetChar( // Search in Array... for ( sal_Int32 x = 0; x < nMax; x++ ) { - tools::Long nTmpPosMax = pLine->GetCharPosArray()[nTmpCurIndex+x]; + tools::Long nTmpPosMax = rLine.GetCharPosArray()[nTmpCurIndex+x]; if ( nTmpPosMax > nXInPortion ) { // Check whether this or the previous... - tools::Long nTmpPosMin = x ? pLine->GetCharPosArray()[nTmpCurIndex+x-1] : 0; + tools::Long nTmpPosMin = x ? rLine.GetCharPosArray()[nTmpCurIndex+x-1] : 0; tools::Long nDiffLeft = nXInPortion - nTmpPosMin; tools::Long nDiffRight = nTmpPosMax - nXInPortion; OSL_ENSURE( nDiffLeft >= 0, "DiffLeft negative" ); @@ -4058,8 +4055,8 @@ sal_Int32 ImpEditEngine::GetChar( // I18N: If there are character position with the length of 0, // they belong to the same character, we can not use this position as an index. // Skip all 0-positions, cheaper than using XBreakIterator: - tools::Long nX = pLine->GetCharPosArray()[nTmpCurIndex + x]; - while(x < nMax && pLine->GetCharPosArray()[nTmpCurIndex + x] == nX) + tools::Long nX = rLine.GetCharPosArray()[nTmpCurIndex + x]; + while(x < nMax && rLine.GetCharPosArray()[nTmpCurIndex + x] == nX) ++x; } nOffset = x; @@ -4112,38 +4109,36 @@ sal_Int32 ImpEditEngine::GetChar( if ( nChar == -1 ) { - nChar = ( nXPos <= pLine->GetStartPosX() ) ? pLine->GetStart() : pLine->GetEnd(); + nChar = ( nXPos <= rLine.GetStartPosX() ) ? rLine.GetStart() : rLine.GetEnd(); } return nChar; } -Range ImpEditEngine::GetLineXPosStartEnd( const ParaPortion* pParaPortion, const EditLine* pLine ) const +Range ImpEditEngine::GetLineXPosStartEnd(const ParaPortion* pParaPortion, EditLine const& rLine) const { Range aLineXPosStartEnd; sal_Int32 nPara = GetEditDoc().GetPos( pParaPortion->GetNode() ); if ( !IsRightToLeft( nPara ) ) { - aLineXPosStartEnd.Min() = pLine->GetStartPosX(); - aLineXPosStartEnd.Max() = pLine->GetStartPosX() + pLine->GetTextWidth(); + aLineXPosStartEnd.Min() = rLine.GetStartPosX(); + aLineXPosStartEnd.Max() = rLine.GetStartPosX() + rLine.GetTextWidth(); } else { - aLineXPosStartEnd.Min() = GetPaperSize().Width() - ( pLine->GetStartPosX() + pLine->GetTextWidth() ); - aLineXPosStartEnd.Max() = GetPaperSize().Width() - pLine->GetStartPosX(); + aLineXPosStartEnd.Min() = GetPaperSize().Width() - (rLine.GetStartPosX() + rLine.GetTextWidth()); + aLineXPosStartEnd.Max() = GetPaperSize().Width() - rLine.GetStartPosX(); } - return aLineXPosStartEnd; } -tools::Long ImpEditEngine::GetPortionXOffset( - const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nTextPortion) const +tools::Long ImpEditEngine::GetPortionXOffset(const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nTextPortion) const { - tools::Long nX = pLine->GetStartPosX(); + tools::Long nX = rLine.GetStartPosX(); - for ( sal_Int32 i = pLine->GetStartPortion(); i < nTextPortion; i++ ) + for ( sal_Int32 i = rLine.GetStartPortion(); i < nTextPortion; i++ ) { const TextPortion& rPortion = pParaPortion->GetTextPortions()[i]; switch ( rPortion.GetKind() ) @@ -4170,7 +4165,7 @@ tools::Long ImpEditEngine::GetPortionXOffset( { // Portions behind must be added, visual before this portion sal_Int32 nTmpPortion = nTextPortion+1; - while ( nTmpPortion <= pLine->GetEndPortion() ) + while ( nTmpPortion <= rLine.GetEndPortion() ) { const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion]; if ( rNextTextPortion.GetRightToLeftLevel() && ( rNextTextPortion.GetKind() != PortionKind::TAB ) ) @@ -4181,7 +4176,7 @@ tools::Long ImpEditEngine::GetPortionXOffset( } // Portions before must be removed, visual behind this portion nTmpPortion = nTextPortion; - while ( nTmpPortion > pLine->GetStartPortion() ) + while ( nTmpPortion > rLine.GetStartPortion() ) { --nTmpPortion; const TextPortion& rPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion]; @@ -4195,7 +4190,7 @@ tools::Long ImpEditEngine::GetPortionXOffset( { // Portions behind must be removed, visual behind this portion sal_Int32 nTmpPortion = nTextPortion+1; - while ( nTmpPortion <= pLine->GetEndPortion() ) + while ( nTmpPortion <= rLine.GetEndPortion() ) { const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion]; if ( !rNextTextPortion.IsRightToLeft() && ( rNextTextPortion.GetKind() != PortionKind::TAB ) ) @@ -4206,7 +4201,7 @@ tools::Long ImpEditEngine::GetPortionXOffset( } // Portions before must be added, visual before this portion nTmpPortion = nTextPortion; - while ( nTmpPortion > pLine->GetStartPortion() ) + while ( nTmpPortion > rLine.GetStartPortion() ) { --nTmpPortion; const TextPortion& rPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion]; @@ -4230,32 +4225,31 @@ tools::Long ImpEditEngine::GetPortionXOffset( } tools::Long ImpEditEngine::GetXPos( - const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart) const + const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart) const { - assert(pLine); - OSL_ENSURE( ( nIndex >= pLine->GetStart() ) && ( nIndex <= pLine->GetEnd() ) , "GetXPos has to be called properly!" ); + OSL_ENSURE( ( nIndex >= rLine.GetStart() ) && ( nIndex <= rLine.GetEnd() ) , "GetXPos has to be called properly!" ); bool bDoPreferPortionStart = bPreferPortionStart; // Assure that the portion belongs to this line: - if ( nIndex == pLine->GetStart() ) + if ( nIndex == rLine.GetStart() ) bDoPreferPortionStart = true; - else if ( nIndex == pLine->GetEnd() ) + else if ( nIndex == rLine.GetEnd() ) bDoPreferPortionStart = false; sal_Int32 nTextPortionStart = 0; sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( nIndex, nTextPortionStart, bDoPreferPortionStart ); - OSL_ENSURE( ( nTextPortion >= pLine->GetStartPortion() ) && ( nTextPortion <= pLine->GetEndPortion() ), "GetXPos: Portion not in current line! " ); + OSL_ENSURE( ( nTextPortion >= rLine.GetStartPortion() ) && ( nTextPortion <= rLine.GetEndPortion() ), "GetXPos: Portion not in current line! " ); const TextPortion& rPortion = pParaPortion->GetTextPortions()[nTextPortion]; - tools::Long nX = GetPortionXOffset( pParaPortion, pLine, nTextPortion ); + tools::Long nX = GetPortionXOffset( pParaPortion, rLine, 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()... tools::Long nPortionTextWidth = rPortion.GetSize().Width(); if ( ( rPortion.GetKind() == PortionKind::TEXT ) && rPortion.GetLen() && !GetTextRanger() ) - nPortionTextWidth = pLine->GetCharPosArray()[nTextPortionStart + rPortion.GetLen() - 1 - pLine->GetStart()]; + nPortionTextWidth = rLine.GetCharPosArray()[nTextPortionStart + rPortion.GetLen() - 1 - rLine.GetStart()]; if ( nTextPortionStart != nIndex ) { @@ -4271,7 +4265,7 @@ tools::Long ImpEditEngine::GetXPos( if ( rNextPortion.GetKind() != PortionKind::TAB ) { if ( !bPreferPortionStart ) - nX = GetXPos( pParaPortion, pLine, nIndex, true ); + nX = GetXPos( pParaPortion, rLine, nIndex, true ); else if ( !IsRightToLeft( GetEditDoc().GetPos( pParaPortion->GetNode() ) ) ) nX += nPortionTextWidth; } @@ -4288,20 +4282,20 @@ tools::Long ImpEditEngine::GetXPos( } else if ( rPortion.GetKind() == PortionKind::TEXT ) { - OSL_ENSURE( nIndex != pLine->GetStart(), "Strange behavior in new GetXPos()" ); - OSL_ENSURE( !pLine->GetCharPosArray().empty(), "svx::ImpEditEngine::GetXPos(), portion in an empty line?" ); + OSL_ENSURE( nIndex != rLine.GetStart(), "Strange behavior in new GetXPos()" ); + OSL_ENSURE( !rLine.GetCharPosArray().empty(), "svx::ImpEditEngine::GetXPos(), portion in an empty line?" ); - if( !pLine->GetCharPosArray().empty() ) + if( !rLine.GetCharPosArray().empty() ) { - sal_Int32 nPos = nIndex - 1 - pLine->GetStart(); - if (nPos < 0 || o3tl::make_unsigned(nPos) >= pLine->GetCharPosArray().size()) + sal_Int32 nPos = nIndex - 1 - rLine.GetStart(); + if (nPos < 0 || o3tl::make_unsigned(nPos) >= rLine.GetCharPosArray().size()) { - nPos = pLine->GetCharPosArray().size()-1; + nPos = rLine.GetCharPosArray().size()-1; OSL_FAIL("svx::ImpEditEngine::GetXPos(), index out of range!"); } // old code restored see #i112788 (which leaves #i74188 unfixed again) - tools::Long nPosInPortion = pLine->GetCharPosArray()[nPos]; + tools::Long nPosInPortion = rLine.GetCharPosArray()[nPos]; if ( !rPortion.IsRightToLeft() ) { @@ -4318,10 +4312,10 @@ tools::Long ImpEditEngine::GetXPos( if ( rPortion.GetExtraInfos()->nAsianCompressionTypes & AsianCompressionFlags::PunctuationRight ) { AsianCompressionFlags nType = GetCharTypeForCompression( pParaPortion->GetNode()->GetChar( nIndex ) ); - if ( nType == AsianCompressionFlags::PunctuationRight && !pLine->GetCharPosArray().empty() ) + if ( nType == AsianCompressionFlags::PunctuationRight && !rLine.GetCharPosArray().empty() ) { sal_Int32 n = nIndex - nTextPortionStart; - const sal_Int32* pDXArray = pLine->GetCharPosArray().data()+( nTextPortionStart-pLine->GetStart() ); + const sal_Int32* pDXArray = rLine.GetCharPosArray().data() + (nTextPortionStart - rLine.GetStart()); sal_Int32 nCharWidth = ( ( (n+1) < rPortion.GetLen() ) ? pDXArray[n] : rPortion.GetSize().Width() ) - ( n ? pDXArray[n-1] : 0 ); if ( (n+1) < rPortion.GetLen() ) @@ -4349,7 +4343,7 @@ tools::Long ImpEditEngine::GetXPos( } } } - else // if ( nIndex == pLine->GetStart() ) + else // if ( nIndex == rLine.GetStart() ) { if ( rPortion.IsRightToLeft() ) { diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 49e0015280f1..d9a20723826e 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -877,7 +877,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) { GetTextRanger()->SetVertical( IsEffectivelyVertical() ); - tools::Long nTextY = nStartPosY + GetEditCursor( pParaPortion, pLine, pLine->GetStart(), GetCursorFlags::NONE ).Top(); + tools::Long nTextY = nStartPosY + GetEditCursor(pParaPortion, *pLine, pLine->GetStart(), GetCursorFlags::NONE).Top(); if ( !bSameLineAgain ) { SeekCursor( pNode, nTmpPos+1, aTmpFont ); @@ -1419,7 +1419,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) pNode, pPortion, nPortionStart, pDXArray, 10000, true); } if( pPortion ) - ImpBreakLine( pParaPortion, pLine, pPortion, nPortionStart, + ImpBreakLine( pParaPortion, *pLine, pPortion, nPortionStart, nRemainingWidth, bCanHyphenate && bHyphenatePara ); } @@ -1566,7 +1566,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) tools::Long nRemainingWidth = nMaxLineWidth - aTextSize.Width(); if ( nRemainingWidth > 0 ) { - ImplExpandCompressedPortions( pLine, pParaPortion, nRemainingWidth ); + ImplExpandCompressedPortions(*pLine, pParaPortion, nRemainingWidth); aTextSize = pLine->CalcTextSize( *pParaPortion ); } } @@ -1611,7 +1611,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) tools::Long nRemainingSpace = nMaxLineWidth - aTextSize.Width(); pLine->SetStartPosX( nStartX ); if ( nRemainingSpace > 0 && (!bEOC || bDistLastLine) ) - ImpAdjustBlocks( pParaPortion, pLine, nRemainingSpace ); + ImpAdjustBlocks(pParaPortion, *pLine, nRemainingSpace); } break; default: @@ -1918,16 +1918,16 @@ bool ImpEditEngine::FinishCreateLines( ParaPortion* pParaPortion ) return bRet; } -void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate ) +void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine& rLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate ) { ContentNode* const pNode = pParaPortion->GetNode(); - sal_Int32 nBreakInLine = nPortionStart - pLine->GetStart(); + sal_Int32 nBreakInLine = nPortionStart - rLine.GetStart(); sal_Int32 nMax = nBreakInLine + pPortion->GetLen(); - while ( ( nBreakInLine < nMax ) && ( pLine->GetCharPosArray()[nBreakInLine] < nRemainingWidth ) ) + while ( ( nBreakInLine < nMax ) && ( rLine.GetCharPosArray()[nBreakInLine] < nRemainingWidth ) ) nBreakInLine++; - sal_Int32 nMaxBreakPos = nBreakInLine + pLine->GetStart(); + sal_Int32 nMaxBreakPos = nBreakInLine + rLine.GetStart(); sal_Int32 nBreakPos = SAL_MAX_INT32; bool bCompressBlank = false; @@ -1939,7 +1939,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te bool bAltFullRight = false; sal_uInt32 nAltDelChar = 0; - if ( ( nMaxBreakPos < ( nMax + pLine->GetStart() ) ) && ( pNode->GetChar( nMaxBreakPos ) == ' ' ) ) + if ( ( nMaxBreakPos < ( nMax + rLine.GetStart() ) ) && ( pNode->GetChar( nMaxBreakPos ) == ' ' ) ) { // Break behind the blank, blank will be compressed... nBreakPos = nMaxBreakPos + 1; @@ -1947,7 +1947,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te } else { - sal_Int32 nMinBreakPos = pLine->GetStart(); + sal_Int32 nMinBreakPos = rLine.GetStart(); const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs(); for (size_t nAttr = rAttrs.size(); nAttr; ) { @@ -2025,7 +2025,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te } bHangingPunctuation = nBreakPos > nMaxBreakPos; - pLine->SetHangingPunctuation( bHangingPunctuation ); + rLine.SetHangingPunctuation( bHangingPunctuation ); // Whether a separator or not, push the word after the separator through // hyphenation... NMaxBreakPos is the last character that fits into @@ -2054,7 +2054,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te bool bAlternate = xHyphWord->isAlternativeSpelling(); sal_Int32 _nWordLen = 1 + xHyphWord->getHyphenPos(); - if ( ( _nWordLen >= 2 ) && ( (nWordStart+_nWordLen) >= (pLine->GetStart() + 2 ) ) ) + if ( ( _nWordLen >= 2 ) && ( (nWordStart+_nWordLen) >= (rLine.GetStart() + 2 ) ) ) { if ( !bAlternate ) { @@ -2125,27 +2125,27 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te } } - if ( nBreakPos <= pLine->GetStart() ) + if ( nBreakPos <= rLine.GetStart() ) { // No separator in line => Chop! nBreakPos = nMaxBreakPos; // I18N nextCharacters ! - if ( nBreakPos <= pLine->GetStart() ) - nBreakPos = pLine->GetStart() + 1; // Otherwise infinite loop! + if ( nBreakPos <= rLine.GetStart() ) + nBreakPos = rLine.GetStart() + 1; // Otherwise infinite loop! } } // the dickey portion is the end portion - pLine->SetEnd( nBreakPos ); + rLine.SetEnd( nBreakPos ); - sal_Int32 nEndPortion = SplitTextPortion( pParaPortion, nBreakPos, pLine ); + sal_Int32 nEndPortion = SplitTextPortion( pParaPortion, nBreakPos, &rLine); if ( !bCompressBlank && !bHangingPunctuation ) { // When justification is not SvxAdjust::Left, it's important to compress // the trailing space even if there is enough room for the space... // Don't check for SvxAdjust::Left, doesn't matter to compress in this case too... - assert( nBreakPos > pLine->GetStart() && "ImpBreakLines - BreakPos not expected!" ); + assert( nBreakPos > rLine.GetStart() && "ImpBreakLines - BreakPos not expected!" ); if ( pNode->GetChar( nBreakPos-1 ) == ' ' ) bCompressBlank = true; } @@ -2154,12 +2154,12 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te { 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(); - rTP.setWidth( ( nPosInArray && ( rTP.GetLen() > 1 ) ) ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 ); - if (o3tl::make_unsigned(nPosInArray) < pLine->GetCharPosArray().size()) + DBG_ASSERT( nBreakPos > rLine.GetStart(), "SplitTextPortion at the beginning of the line?" ); + sal_Int32 nPosInArray = nBreakPos - 1 - rLine.GetStart(); + rTP.setWidth( ( nPosInArray && ( rTP.GetLen() > 1 ) ) ? rLine.GetCharPosArray()[ nPosInArray-1 ] : 0 ); + if (o3tl::make_unsigned(nPosInArray) < rLine.GetCharPosArray().size()) { - pLine->GetCharPosArray()[ nPosInArray ] = rTP.GetSize().Width(); + rLine.GetCharPosArray()[ nPosInArray ] = rTP.GetSize().Width(); } } else if ( bHyphenated ) @@ -2176,7 +2176,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te if (cAlternateReplChar && !bAltFullLeft) pHyphPortion->SetExtraValue( cAlternateReplChar ); // Correct width of the portion above: rPrev.setWidth( - pLine->GetCharPosArray()[ nBreakPos-1 - pLine->GetStart() - nAltDelChar ] ); + rLine.GetCharPosArray()[ nBreakPos-1 - rLine.GetStart() - nAltDelChar ] ); } // Determine the width of the Hyph-Portion: @@ -2187,18 +2187,20 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te pParaPortion->GetTextPortions().Insert(++nEndPortion, pHyphPortion); } - pLine->SetEndPortion( nEndPortion ); + rLine.SetEndPortion( nEndPortion ); } -void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, tools::Long nRemainingSpace ) +void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine& rLine, tools::Long nRemainingSpace ) { DBG_ASSERT( nRemainingSpace > 0, "AdjustBlocks: Somewhat too little..." ); - assert( pLine && "AdjustBlocks: Line ?!" ); - if ( ( nRemainingSpace < 0 ) || pLine->IsEmpty() ) + + if ( ( nRemainingSpace < 0 ) || rLine.IsEmpty() ) return ; - const sal_Int32 nFirstChar = pLine->GetStart(); - const sal_Int32 nLastChar = pLine->GetEnd() -1; // Last points behind + assert(pParaPortion); + + const sal_Int32 nFirstChar = rLine.GetStart(); + const sal_Int32 nLastChar = rLine.GetEnd() -1; // Last points behind ContentNode* pNode = pParaPortion->GetNode(); DBG_ASSERT( nLastChar < pNode->Len(), "AdjustBlocks: Out of range!" ); @@ -2256,10 +2258,10 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, sal_Int32 nPortionStart, nPortion; nPortion = pParaPortion->GetTextPortions().FindPortion( nLastChar+1, nPortionStart ); TextPortion& rLastPortion = pParaPortion->GetTextPortions()[ nPortion ]; - tools::Long nRealWidth = pLine->GetCharPosArray()[nLastChar-nFirstChar]; + tools::Long nRealWidth = rLine.GetCharPosArray()[nLastChar-nFirstChar]; tools::Long nBlankWidth = nRealWidth; if ( nLastChar > nPortionStart ) - nBlankWidth -= pLine->GetCharPosArray()[nLastChar-nFirstChar-1]; + nBlankWidth -= rLine.GetCharPosArray()[nLastChar-nFirstChar-1]; // Possibly the blank has already been deducted in ImpBreakLine: if ( nRealWidth == rLastPortion.GetSize().Width() ) { @@ -2269,7 +2271,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, rLastPortion.adjustSize(-nBlankWidth, 0); nRemainingSpace += nBlankWidth; } - pLine->GetCharPosArray()[nLastChar-nFirstChar] -= nBlankWidth; + rLine.GetCharPosArray()[nLastChar-nFirstChar] -= nBlankWidth; } size_t nGaps = aPositions.size(); @@ -2283,12 +2285,12 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, // where to only expand the width. if (nKashidas) { - pLine->GetKashidaArray().resize(pLine->GetCharPosArray().size(), false); + rLine.GetKashidaArray().resize(rLine.GetCharPosArray().size(), false); for (size_t i = 0; i < nKashidas; i++) { auto nChar = aPositions[i]; if ( nChar < nLastChar ) - pLine->GetKashidaArray()[nChar-nFirstChar] = 1 /*sal_True*/; + rLine.GetKashidaArray()[nChar-nFirstChar] = 1 /*sal_True*/; } } @@ -2313,9 +2315,9 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, sal_Int32 nPortionEnd = nPortionStart + rLastPortion.GetLen(); for ( sal_Int32 _n = nChar; _n < nPortionEnd; _n++ ) { - pLine->GetCharPosArray()[_n-nFirstChar] += nMore4Everyone; + rLine.GetCharPosArray()[_n-nFirstChar] += nMore4Everyone; if ( nSomeExtraSpace ) - pLine->GetCharPosArray()[_n-nFirstChar]++; + rLine.GetCharPosArray()[_n-nFirstChar]++; } if ( nSomeExtraSpace ) @@ -2324,7 +2326,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, } // Now the text width contains the extra width... - pLine->SetTextWidth( pLine->GetTextWidth() + nRemainingSpace ); + rLine.SetTextWidth(rLine.GetTextWidth() + nRemainingSpace); } // For Kashidas from sw/source/core/text/porlay.cxx @@ -3379,16 +3381,15 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ ) { - const EditLine* const pLine = &pPortion->GetLines()[nLine]; - assert( pLine && "NULL-Pointer in the line iterator in UpdateViews" ); - sal_Int32 nIndex = pLine->GetStart(); - tools::Long nLineHeight = pLine->GetHeight(); + EditLine const& rLine = pPortion->GetLines()[nLine]; + sal_Int32 nIndex = rLine.GetStart(); + tools::Long nLineHeight = rLine.GetHeight(); if (nLine != nLastLine) nLineHeight += nVertLineSpacing; MoveToNextLine(aStartPos, nLineHeight, nColumn, aOrigin); aTmpPos = aStartPos; - adjustXDirectionAware(aTmpPos, pLine->GetStartPosX()); - adjustYDirectionAware(aTmpPos, pLine->GetMaxAscent() - nLineHeight); + adjustXDirectionAware(aTmpPos, rLine.GetStartPosX()); + adjustYDirectionAware(aTmpPos, rLine.GetMaxAscent() - nLineHeight); if ( ( !IsEffectivelyVertical() && ( aStartPos.Y() > aClipRect.Top() ) ) || ( IsEffectivelyVertical() && IsTopToBottom() && aStartPos.X() < aClipRect.Right() ) @@ -3417,12 +3418,12 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po bool bParsingFields = false; std::vector< sal_Int32 >::iterator itSubLines; - for ( sal_Int32 nPortion = pLine->GetStartPortion(); nPortion <= pLine->GetEndPortion(); nPortion++ ) + for ( sal_Int32 nPortion = rLine.GetStartPortion(); nPortion <= rLine.GetEndPortion(); nPortion++ ) { DBG_ASSERT( pPortion->GetTextPortions().Count(), "Line without Textportion in Paint!" ); const TextPortion& rTextPortion = pPortion->GetTextPortions()[nPortion]; - const tools::Long nPortionXOffset = GetPortionXOffset( pPortion, pLine, nPortion ); + const tools::Long nPortionXOffset = GetPortionXOffset( pPortion, rLine, nPortion ); setXDirectionAwareFrom(aTmpPos, aStartPos); adjustXDirectionAware(aTmpPos, nPortionXOffset); if (isXOverflowDirectionAware(aTmpPos, aClipRect)) @@ -3486,13 +3487,13 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aText = pPortion->GetNode()->GetString(); nTextStart = nIndex; nTextLen = rTextPortion.GetLen(); - pDXArray = std::span(pLine->GetCharPosArray().data() + (nIndex - pLine->GetStart()), - pLine->GetCharPosArray().size() - (nIndex - pLine->GetStart())); + pDXArray = std::span(rLine.GetCharPosArray().data() + (nIndex - rLine.GetStart()), + rLine.GetCharPosArray().size() - (nIndex - rLine.GetStart())); - if (!pLine->GetKashidaArray().empty()) + if (!rLine.GetKashidaArray().empty()) { - pKashidaArray = std::span(pLine->GetKashidaArray().data() + (nIndex - pLine->GetStart()), - pLine->GetKashidaArray().size() - (nIndex - pLine->GetStart())); + pKashidaArray = std::span(rLine.GetKashidaArray().data() + (nIndex - rLine.GetStart()), + rLine.GetKashidaArray().size() - (nIndex - rLine.GetStart())); } // Paint control characters (#i55716#) @@ -3520,7 +3521,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po const tools::Long nAdvanceX = ( nTmpIdx == nTmpEnd ? rTextPortion.GetSize().Width() : pDXArray[ nTmpIdx - nTextStart ] ) - nHalfBlankWidth; - const tools::Long nAdvanceY = -pLine->GetMaxAscent(); + const tools::Long nAdvanceY = -rLine.GetMaxAscent(); Point aTopLeftRectPos( aTmpPos ); adjustXDirectionAware(aTopLeftRectPos, nAdvanceX); @@ -3528,7 +3529,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po Point aBottomRightRectPos( aTopLeftRectPos ); adjustXDirectionAware(aBottomRightRectPos, 2 * nHalfBlankWidth); - adjustYDirectionAware(aBottomRightRectPos, pLine->GetHeight()); + adjustYDirectionAware(aBottomRightRectPos, rLine.GetHeight()); rOutDev.Push( vcl::PushFlags::FILLCOLOR ); rOutDev.Push( vcl::PushFlags::LINECOLOR ); @@ -3595,10 +3596,10 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po { if( itSubLines != pExtraInfo->lineBreaksList.begin() ) { - // only use GetMaxAscent(), pLine->GetHeight() will not + // only use GetMaxAscent(), rLine.GetHeight() will not // proceed as needed (see PortionKind::TEXT above and nAdvanceY) // what will lead to a compressed look with multiple lines - const sal_uInt16 nMaxAscent(pLine->GetMaxAscent()); + const sal_uInt16 nMaxAscent(rLine.GetMaxAscent()); aTmpPos += MoveToNextLine(aStartPos, nMaxAscent, nColumn, aOrigin); @@ -3748,7 +3749,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po const lang::Locale aLocale(GetLocale(EditPaM(pPortion->GetNode(), nIndex + 1))); // create EOL and EOP bools - const bool bEndOfLine(nPortion == pLine->GetEndPortion()); + const bool bEndOfLine(nPortion == rLine.GetEndPortion()); const bool bEndOfParagraph(bEndOfLine && nLine + 1 == nLines); // get Overline color (from ((const SvxOverlineItem*)GetItem())->GetColor() in @@ -3895,7 +3896,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po if ( bDrawFrame ) { Point aTopLeft( aTmpPos ); - aTopLeft.AdjustY( -(pLine->GetMaxAscent()) ); + aTopLeft.AdjustY( -(rLine.GetMaxAscent()) ); if ( nOrientation ) aOrigin.RotateAround(aTopLeft, nOrientation); tools::Rectangle aRect( aTopLeft, rTextPortion.GetSize() ); @@ -3908,7 +3909,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po if (auto pUrlField = dynamic_cast<const SvxURLField*>(pFieldData)) { Point aTopLeft(aTmpPos); - aTopLeft.AdjustY(-(pLine->GetMaxAscent())); + aTopLeft.AdjustY(-(rLine.GetMaxAscent())); tools::Rectangle aRect(aTopLeft, rTextPortion.GetSize()); vcl::PDFExtOutDevBookmarkEntry aBookmark; @@ -3996,7 +3997,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po if ( bStripOnly ) { // create EOL and EOP bools - const bool bEndOfLine(nPortion == pLine->GetEndPortion()); + const bool bEndOfLine(nPortion == rLine.GetEndPortion()); const bool bEndOfParagraph(bEndOfLine && nLine + 1 == nLines); const Color aOverlineColor(rOutDev.GetOverlineColor()); @@ -4016,7 +4017,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po // #i108052# When stripping, a callback for _empty_ paragraphs is also needed. // This was optimized away (by not rendering the space-only tab portion), so do // it manually here. - const bool bEndOfLine(nPortion == pLine->GetEndPortion()); + const bool bEndOfLine(nPortion == rLine.GetEndPortion()); const bool bEndOfParagraph(bEndOfLine && nLine + 1 == nLines); const Color aOverlineColor(rOutDev.GetOverlineColor()); @@ -4839,13 +4840,13 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* pNode, } -void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* pParaPortion, tools::Long nRemainingWidth ) +void ImpEditEngine::ImplExpandCompressedPortions(EditLine& rLine, ParaPortion* pParaPortion, tools::Long nRemainingWidth) { bool bFoundCompressedPortion = false; tools::Long nCompressed = 0; std::vector<TextPortion*> aCompressedPortions; - sal_Int32 nPortion = pLine->GetEndPortion(); + sal_Int32 nPortion = rLine.GetEndPortion(); TextPortion* pTP = &pParaPortion->GetTextPortions()[ nPortion ]; while ( pTP && ( pTP->GetKind() == PortionKind::TEXT ) ) { @@ -4855,7 +4856,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 ] : nullptr; + pTP = ( nPortion > rLine.GetStartPortion() ) ? &pParaPortion->GetTextPortions()[ --nPortion ] : nullptr; } if ( !bFoundCompressedPortion ) @@ -4879,8 +4880,8 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* { sal_Int32 nTxtPortion = pParaPortion->GetTextPortions().GetPos( pTP ); sal_Int32 nTxtPortionStart = pParaPortion->GetTextPortions().GetStartPos( nTxtPortion ); - DBG_ASSERT( nTxtPortionStart >= pLine->GetStart(), "Portion doesn't belong to the line!!!" ); - sal_Int32* pDXArray = pLine->GetCharPosArray().data() + (nTxtPortionStart - pLine->GetStart()); + DBG_ASSERT( nTxtPortionStart >= rLine.GetStart(), "Portion doesn't belong to the line!!!" ); + sal_Int32* pDXArray = rLine.GetCharPosArray().data() + (nTxtPortionStart - rLine.GetStart()); if ( pTP->GetExtraInfos()->pOrgDXArray ) memcpy( pDXArray, pTP->GetExtraInfos()->pOrgDXArray.get(), (pTP->GetLen()-1)*sizeof(sal_Int32) ); ImplCalcAsianCompression( pParaPortion->GetNode(), pTP, nTxtPortionStart, pDXArray, static_cast<sal_uInt16>(nCompressPercent), true ); |