From fef16d0e0dbf877b5ab600973d17c4d826fd8b8e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 13 Aug 2018 11:49:57 +0200 Subject: loplugin:returnconstant in SwTextCursor Change-Id: If695e6f1564ca37e9bb9870c6fee20d639fb721c Reviewed-on: https://gerrit.libreoffice.org/58962 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/text/frmcrsr.cxx | 30 +++++++++++++++--------------- sw/source/core/text/frminf.cxx | 35 ++++++++++++----------------------- sw/source/core/text/itrcrsr.cxx | 17 ++++++++--------- sw/source/core/text/itrtxt.hxx | 4 ++-- 4 files changed, 37 insertions(+), 49 deletions(-) (limited to 'sw') 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(rLine).GetCharRect( &aRect, nTextStart ) ) - return aRect.Left(); - - return rLine.GetLineStart(); + const_cast(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(aRect.Left() - pFrame->getFrameArea().Left() - pFrame->getFramePrintArea().Left()) - : 0; + aLine.GetCharRect( &aRect, rFndPos ); + return static_cast(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; -- cgit 7-1'>distro/nisz/libreoffice-7-1 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2019-10-04add gbuild function for a common PCH and use it in sc/ and sax/Luboš Luňák
2018-05-31Initial steps to make also Calc usable from Automation clientsTor Lillqvist
2017-04-21gbuild: Remove MSVC 2013 legacy codeDavid Ostrovsky
2015-03-11sc: use constructor syntax in scd.componentChris Sherlock
2014-05-01Simplify type detectorsMaxim Monastirsky
2013-11-14Move MediaDescriptor from comphelper to unotoolsStephan Bergmann
2013-04-22Move to MPLv2 license headers, with ESC decision and author's permission.Michael Meeks
2013-02-05Skeleton for new excel biff format detector service.Kohei Yoshida
2013-01-26gbuild: do not copy boost headers aroundMichael Stahl
2012-09-28gbuild: invert handling of standard system libraries:Michael Stahl
2012-09-28gbuild: replace direct gb_STDLIBS use with ...Michael Stahl
2012-09-28gbuild: split uwinapi out of gb_STDLIBSMichael Stahl
2012-07-02targetted improvement of UNO API includes / usageMichael Meeks
2012-04-08gbuild: "use" vs. "add":Michael Stahl
2012-03-10gbuild: get rid of realpath in gb_Foo_set_includeMatúš Kukan
2012-02-23Unify indentationTor Lillqvist
2012-02-10fdo#39491 remove nonexistent include pathsMatúš Kukan
2011-11-27remove pch from the include listNorbert Thiebaud
2011-11-27remove pre-compiled header support in gbuild and gbuildified moduleNorbert Thiebaud
2011-11-23add a stripStart, can replace EraseLeadingCharsCaolán McNamara
2011-08-10prefer makefile-gmake-mode to plain makefile-modeTakeshi Abe
2011-07-30Add consistent Emacs and vim mode linesTor Lillqvist
2011-07-22postmerge fixes for gnumake4Bjoern Michaelsen
2011-07-21resyncing to masterBjoern Michaelsen
2011-06-21gnumake4: postmerge fixes in scBjoern Michaelsen
2011-06-18remove all traces of offuh from makefilesDavid Tardon
2011-04-28Remove unnecessary include in sc buildNorbert Thiebaud
2011-03-31Fix windows linking of sc moduleFridrich Štrba
2011-03-29Fix Windows build of SCFridrich Štrba
2011-03-25gnumake support for calc.Norbert Thiebaud