diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-13 11:49:57 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-14 11:15:39 +0200 |
commit | fef16d0e0dbf877b5ab600973d17c4d826fd8b8e (patch) | |
tree | dc2c05dcbf5b9c263f4146a1f6e035f5317b4935 | |
parent | 73fafa6a6f84c68516e6cbac8832e762b68de924 (diff) |
loplugin:returnconstant in SwTextCursor
Change-Id: If695e6f1564ca37e9bb9870c6fee20d639fb721c
Reviewed-on: https://gerrit.libreoffice.org/58962
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/core/text/frmcrsr.cxx | 30 | ||||
-rw-r--r-- | sw/source/core/text/frminf.cxx | 35 | ||||
-rw-r--r-- | sw/source/core/text/itrcrsr.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/text/itrtxt.hxx | 4 |
4 files changed, 37 insertions, 49 deletions
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx index 64b4721f3bab..7e90e16f654f 100644 --- a/sw/source/core/text/frmcrsr.cxx +++ b/sw/source/core/text/frmcrsr.cxx @@ -277,8 +277,11 @@ bool SwTextFrame::GetCharRect( SwRect& rOrig, const SwPosition &rPos, nNextOfst = aLine.GetEnd(); // See comment in AdjustFrame // Include the line's last char? - bRet = bRightMargin ? aLine.GetEndCharRect( &rOrig, nOffset, pCMS, nMaxY ) - : aLine.GetCharRect( &rOrig, nOffset, pCMS, nMaxY ); + if (bRightMargin) + aLine.GetEndCharRect( &rOrig, nOffset, pCMS, nMaxY ); + else + aLine.GetCharRect( &rOrig, nOffset, pCMS, nMaxY ); + bRet = true; } if ( pFrame->IsRightToLeft() ) @@ -423,23 +426,20 @@ bool SwTextFrame::GetAutoPos( SwRect& rOrig, const SwPosition &rPos ) const SwTextCursor aLine( pFrame, &aInf ); SwCursorMoveState aTmpState( MV_SETONLYTEXT ); aTmpState.m_bRealHeight = true; - if( aLine.GetCharRect( &rOrig, nOffset, &aTmpState, nMaxY ) ) + aLine.GetCharRect( &rOrig, nOffset, &aTmpState, nMaxY ); + if( aTmpState.m_aRealHeight.X() >= 0 ) { - if( aTmpState.m_aRealHeight.X() >= 0 ) - { - rOrig.Pos().AdjustY(aTmpState.m_aRealHeight.X() ); - rOrig.Height( aTmpState.m_aRealHeight.Y() ); - } + rOrig.Pos().AdjustY(aTmpState.m_aRealHeight.X() ); + rOrig.Height( aTmpState.m_aRealHeight.Y() ); + } - if ( pFrame->IsRightToLeft() ) - pFrame->SwitchLTRtoRTL( rOrig ); + if ( pFrame->IsRightToLeft() ) + pFrame->SwitchLTRtoRTL( rOrig ); - if ( aRectFnSet.IsVert() ) - pFrame->SwitchHorizontalToVertical( rOrig ); + if ( aRectFnSet.IsVert() ) + pFrame->SwitchHorizontalToVertical( rOrig ); - return true; - } - return false; + return true; } } diff --git a/sw/source/core/text/frminf.cxx b/sw/source/core/text/frminf.cxx index 909c3855817a..f3df1bbaa46c 100644 --- a/sw/source/core/text/frminf.cxx +++ b/sw/source/core/text/frminf.cxx @@ -90,10 +90,8 @@ SwTwips SwTextFrameInfo::GetLineStart( const SwTextCursor &rLine ) return rLine.GetLineStart(); SwRect aRect; - if( const_cast<SwTextCursor&>(rLine).GetCharRect( &aRect, nTextStart ) ) - return aRect.Left(); - - return rLine.GetLineStart(); + const_cast<SwTextCursor&>(rLine).GetCharRect( &aRect, nTextStart ); + return aRect.Left(); } // Where does the text start (without whitespace)? (relative in the Frame) @@ -115,28 +113,20 @@ SwTwips SwTextFrameInfo::GetCharPos(TextFrameIndex const nChar, bool bCenter) co SwTwips nStt, nNext; SwRect aRect; - if( aLine.GetCharRect( &aRect, nChar ) ) - { - if ( aRectFnSet.IsVert() ) - pFrame->SwitchHorizontalToVertical( aRect ); + aLine.GetCharRect( &aRect, nChar ); + if ( aRectFnSet.IsVert() ) + pFrame->SwitchHorizontalToVertical( aRect ); - nStt = aRectFnSet.GetLeft(aRect); - } - else - nStt = aLine.GetLineStart(); + nStt = aRectFnSet.GetLeft(aRect); if( !bCenter ) return nStt - aRectFnSet.GetLeft(pFrame->getFrameArea()); - if (aLine.GetCharRect( &aRect, nChar + TextFrameIndex(1) )) - { - if ( aRectFnSet.IsVert() ) - pFrame->SwitchHorizontalToVertical( aRect ); + aLine.GetCharRect( &aRect, nChar + TextFrameIndex(1) ); + if ( aRectFnSet.IsVert() ) + pFrame->SwitchHorizontalToVertical( aRect ); - nNext = aRectFnSet.GetLeft(aRect); - } - else - nNext = aLine.GetLineStart(); + nNext = aRectFnSet.GetLeft(aRect); return (( nNext + nStt ) / 2 ) - aRectFnSet.GetLeft(pFrame->getFrameArea()); } @@ -302,9 +292,8 @@ sal_Int32 SwTextFrameInfo::GetBigIndent(TextFrameIndex& rFndPos, return 0; SwRect aRect; - return aLine.GetCharRect( &aRect, rFndPos ) - ? static_cast<sal_Int32>(aRect.Left() - pFrame->getFrameArea().Left() - pFrame->getFramePrintArea().Left()) - : 0; + aLine.GetCharRect( &aRect, rFndPos ); + return static_cast<sal_Int32>(aRect.Left() - pFrame->getFrameArea().Left() - pFrame->getFramePrintArea().Left()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 4103b8505b77..f3770ba31ae3 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -391,7 +391,7 @@ void SwTextCursor::CtorInitTextCursor( SwTextFrame *pNewFrame, SwTextSizeInfo *p } // 1170: Ancient bug: Shift-End forgets the last character ... -bool SwTextCursor::GetEndCharRect(SwRect* pOrig, const TextFrameIndex nOfst, +void SwTextCursor::GetEndCharRect(SwRect* pOrig, const TextFrameIndex nOfst, SwCursorMoveState* pCMS, const long nMax ) { // 1170: Ambiguity of document positions @@ -404,13 +404,16 @@ bool SwTextCursor::GetEndCharRect(SwRect* pOrig, const TextFrameIndex nOfst, if( nOfst != GetStart() || !m_pCurr->GetLen() ) { // 8810: Master line RightMargin, after that LeftMargin - const bool bRet = GetCharRect( pOrig, nOfst, pCMS, nMax ); + GetCharRect( pOrig, nOfst, pCMS, nMax ); bRightMargin = nOfst >= GetEnd() && nOfst < TextFrameIndex(GetInfo().GetText().getLength()); - return bRet; + return; } if( !GetPrev() || !GetPrev()->GetLen() || !PrevLine() ) - return GetCharRect( pOrig, nOfst, pCMS, nMax ); + { + GetCharRect( pOrig, nOfst, pCMS, nMax ); + return; + } // If necessary, as catch up, do the adjustment GetAdjusted(); @@ -455,8 +458,6 @@ bool SwTextCursor::GetEndCharRect(SwRect* pOrig, const TextFrameIndex nOfst, OSL_ENSURE( nPorHeight, "GetCharRect: Missing Portion-Height" ); pCMS->m_aRealHeight.setY( nPorHeight ); } - - return true; } // internal function, called by SwTextCursor::GetCharRect() to calculate @@ -1168,7 +1169,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst, } } -bool SwTextCursor::GetCharRect( SwRect* pOrig, TextFrameIndex const nOfst, +void SwTextCursor::GetCharRect( SwRect* pOrig, TextFrameIndex const nOfst, SwCursorMoveState* pCMS, const long nMax ) { CharCursorToLine(nOfst); @@ -1251,8 +1252,6 @@ bool SwTextCursor::GetCharRect( SwRect* pOrig, TextFrameIndex const nOfst, if( nOut > 0 ) pOrig->Pos().AdjustX( -(nOut + 10) ); } - - return true; } // Return: Offset in String diff --git a/sw/source/core/text/itrtxt.hxx b/sw/source/core/text/itrtxt.hxx index 5acf472bed77..c61e759eb289 100644 --- a/sw/source/core/text/itrtxt.hxx +++ b/sw/source/core/text/itrtxt.hxx @@ -277,9 +277,9 @@ public: { CtorInitTextCursor(pTextFrame, pTextSizeInf); } - bool GetCharRect(SwRect *, TextFrameIndex, SwCursorMoveState* = nullptr, + void GetCharRect(SwRect *, TextFrameIndex, SwCursorMoveState* = nullptr, const long nMax = 0 ); - bool GetEndCharRect(SwRect *, TextFrameIndex, SwCursorMoveState* = nullptr, + void GetEndCharRect(SwRect *, TextFrameIndex, SwCursorMoveState* = nullptr, const long nMax = 0 ); TextFrameIndex GetCursorOfst( SwPosition *pPos, const Point &rPoint, bool bChgNode, SwCursorMoveState* = nullptr ) const; |