diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-05-08 15:54:30 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-05-09 21:03:02 +0200 |
commit | 3590b9b33d376d300faf53e5d198c49c6ff4b0a4 (patch) | |
tree | 186d06766ed622bcb51a9df99c83dd1437346024 /sw | |
parent | a69996aab61b1b9206d3e004e283db90d1ca87e2 (diff) |
sw: some rename of variables and reduce const casting
Change-Id: I8e7faf1649dba3228fe52f56269cd769241d07b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93819
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 40 | ||||
-rw-r--r-- | sw/source/core/text/porrst.cxx | 44 |
2 files changed, 43 insertions, 41 deletions
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 797110ceaf45..b7a58b198c6c 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -852,7 +852,7 @@ void SwTextPaintInfo::CalcRect( const SwLinePortion& rPor, * @param bCenter Draw the character centered, otherwise left aligned * @param bRotate Rotate the character if character rotation is set */ -static void lcl_DrawSpecial( const SwTextPaintInfo& rInf, const SwLinePortion& rPor, +static void lcl_DrawSpecial( const SwTextPaintInfo& rTextPaintInfo, const SwLinePortion& rPor, SwRect& rRect, const Color& rCol, sal_Unicode cChar, sal_uInt8 nOptions ) { @@ -860,12 +860,12 @@ static void lcl_DrawSpecial( const SwTextPaintInfo& rInf, const SwLinePortion& r bool bRotate = 0 != ( nOptions & DRAW_SPECIAL_OPTIONS_ROTATE ); // rRect is given in absolute coordinates - if ( rInf.GetTextFrame()->IsRightToLeft() ) - rInf.GetTextFrame()->SwitchRTLtoLTR( rRect ); - if ( rInf.GetTextFrame()->IsVertical() ) - rInf.GetTextFrame()->SwitchVerticalToHorizontal( rRect ); + if ( rTextPaintInfo.GetTextFrame()->IsRightToLeft() ) + rTextPaintInfo.GetTextFrame()->SwitchRTLtoLTR( rRect ); + if ( rTextPaintInfo.GetTextFrame()->IsVertical() ) + rTextPaintInfo.GetTextFrame()->SwitchVerticalToHorizontal( rRect ); - const SwFont* pOldFnt = rInf.GetFont(); + const SwFont* pOldFnt = rTextPaintInfo.GetFont(); // Font is generated only once: static SwFont s_aFnt = [&]() @@ -880,7 +880,7 @@ static void lcl_DrawSpecial( const SwTextPaintInfo& rInf, const SwLinePortion& r // Some of the current values are set at the font: if ( ! bRotate ) - s_aFnt.SetVertical( 0, rInf.GetTextFrame()->IsVertical() ); + s_aFnt.SetVertical( 0, rTextPaintInfo.GetTextFrame()->IsVertical() ); else s_aFnt.SetVertical( pOldFnt->GetOrientation() ); @@ -889,10 +889,12 @@ static void lcl_DrawSpecial( const SwTextPaintInfo& rInf, const SwLinePortion& r Size aFontSize( 0, SPECIAL_FONT_HEIGHT ); s_aFnt.SetSize( aFontSize, s_aFnt.GetActual() ); - const_cast<SwTextPaintInfo&>(rInf).SetFont( &s_aFnt ); + SwTextPaintInfo& rNonConstTextPaintInfo = const_cast<SwTextPaintInfo&>(rTextPaintInfo); + + rNonConstTextPaintInfo.SetFont( &s_aFnt ); // The maximum width depends on the current orientation - const sal_uInt16 nDir = s_aFnt.GetOrientation( rInf.GetTextFrame()->IsVertical() ); + const sal_uInt16 nDir = s_aFnt.GetOrientation( rTextPaintInfo.GetTextFrame()->IsVertical() ); SwTwips nMaxWidth; if (nDir == 900 || nDir == 2700) nMaxWidth = rRect.Height(); @@ -904,7 +906,7 @@ static void lcl_DrawSpecial( const SwTextPaintInfo& rInf, const SwLinePortion& r // check if char fits into rectangle const OUString aTmp( cChar ); - aFontSize = rInf.GetTextSize( aTmp ).SvLSize(); + aFontSize = rTextPaintInfo.GetTextSize( aTmp ).SvLSize(); while ( aFontSize.Width() > nMaxWidth ) { SwTwips nFactor = ( 100 * aFontSize.Width() ) / nMaxWidth; @@ -920,13 +922,13 @@ static void lcl_DrawSpecial( const SwTextPaintInfo& rInf, const SwLinePortion& r s_aFnt.SetSize( aFontSize, nAct ); - aFontSize = rInf.GetTextSize( aTmp ).SvLSize(); + aFontSize = rTextPaintInfo.GetTextSize( aTmp ).SvLSize(); if ( aFontSize.Width() >= nOldWidth ) break; } - const Point aOldPos( rInf.GetPos() ); + const Point aOldPos( rTextPaintInfo.GetPos() ); // adjust values so that tab is vertically and horizontally centered SwTwips nX = rRect.Left(); @@ -936,28 +938,28 @@ static void lcl_DrawSpecial( const SwTextPaintInfo& rInf, const SwLinePortion& r case 0 : if ( bCenter ) nX += ( rRect.Width() - aFontSize.Width() ) / 2; - nY += ( rRect.Height() - aFontSize.Height() ) / 2 + rInf.GetAscent(); + nY += ( rRect.Height() - aFontSize.Height() ) / 2 + rTextPaintInfo.GetAscent(); break; case 900 : if ( bCenter ) - nX += ( rRect.Width() - aFontSize.Height() ) / 2 + rInf.GetAscent(); + nX += ( rRect.Width() - aFontSize.Height() ) / 2 + rTextPaintInfo.GetAscent(); nY += ( rRect.Height() + aFontSize.Width() ) / 2; break; case 2700 : if ( bCenter ) - nX += ( rRect.Width() + aFontSize.Height() ) / 2 - rInf.GetAscent(); + nX += ( rRect.Width() + aFontSize.Height() ) / 2 - rTextPaintInfo.GetAscent(); nY += ( rRect.Height() - aFontSize.Width() ) / 2; break; } Point aTmpPos( nX, nY ); - const_cast<SwTextPaintInfo&>(rInf).SetPos( aTmpPos ); + rNonConstTextPaintInfo.SetPos( aTmpPos ); sal_uInt16 nOldWidth = rPor.Width(); const_cast<SwLinePortion&>(rPor).Width( static_cast<sal_uInt16>(aFontSize.Width()) ); - rInf.DrawText( aTmp, rPor ); + rTextPaintInfo.DrawText( aTmp, rPor ); const_cast<SwLinePortion&>(rPor).Width( nOldWidth ); - const_cast<SwTextPaintInfo&>(rInf).SetFont( const_cast<SwFont*>(pOldFnt) ); - const_cast<SwTextPaintInfo&>(rInf).SetPos( aOldPos ); + rNonConstTextPaintInfo.SetFont( const_cast<SwFont*>(pOldFnt) ); + rNonConstTextPaintInfo.SetPos( aOldPos ); } void SwTextPaintInfo::DrawRect( const SwRect &rRect, bool bRetouche ) const diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 98ad3b82a69f..0cd1523482f1 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -527,10 +527,10 @@ bool SwControlCharPortion::DoPaint(SwTextPaintInfo const&, return true; } -bool SwBookmarkPortion::DoPaint(SwTextPaintInfo const& rInf, - OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const +bool SwBookmarkPortion::DoPaint(SwTextPaintInfo const& rTextPaintInfo, + OUString & rOutString, SwFont & rFont, int & rDeltaY) const { - if (!rInf.GetOpt().IsShowBookmarks()) + if (!rTextPaintInfo.GetOpt().IsShowBookmarks()) { return false; } @@ -539,30 +539,30 @@ bool SwBookmarkPortion::DoPaint(SwTextPaintInfo const& rInf, // init font: we want OpenSymbol to ensure it doesn't look too crazy; // thin and a bit higher than the surrounding text - auto const nOrigAscent(rTmpFont.GetAscent(rInf.GetVsh(), *rInf.GetOut())); - rTmpFont.SetName("OpenSymbol", rTmpFont.GetActual()); - Size size(rTmpFont.GetSize(rTmpFont.GetActual())); + auto const nOrigAscent(rFont.GetAscent(rTextPaintInfo.GetVsh(), *rTextPaintInfo.GetOut())); + rFont.SetName("OpenSymbol", rFont.GetActual()); + Size aSize(rFont.GetSize(rFont.GetActual())); // use also the external leading (line gap) of the portion, but don't use // 100% of it because i can't figure out how to baseline align that - auto const nFactor = (Height() * 95) / size.Height(); - rTmpFont.SetProportion(nFactor); - rTmpFont.SetWeight(WEIGHT_THIN, rTmpFont.GetActual()); - rTmpFont.SetColor(NON_PRINTING_CHARACTER_COLOR); + auto const nFactor = (Height() * 95) / aSize.Height(); + rFont.SetProportion(nFactor); + rFont.SetWeight(WEIGHT_THIN, rFont.GetActual()); + rFont.SetColor(NON_PRINTING_CHARACTER_COLOR); // reset these to default... - rTmpFont.SetAlign(ALIGN_BASELINE); - rTmpFont.SetUnderline(LINESTYLE_NONE); - rTmpFont.SetOverline(LINESTYLE_NONE); - rTmpFont.SetStrikeout(STRIKEOUT_NONE); - rTmpFont.SetOutline(false); - rTmpFont.SetShadow(false); - rTmpFont.SetTransparent(false); - rTmpFont.SetEmphasisMark(FontEmphasisMark::NONE); - rTmpFont.SetEscapement(0); - rTmpFont.SetPitch(PITCH_DONTKNOW, rTmpFont.GetActual()); - rTmpFont.SetRelief(FontRelief::NONE); + rFont.SetAlign(ALIGN_BASELINE); + rFont.SetUnderline(LINESTYLE_NONE); + rFont.SetOverline(LINESTYLE_NONE); + rFont.SetStrikeout(STRIKEOUT_NONE); + rFont.SetOutline(false); + rFont.SetShadow(false); + rFont.SetTransparent(false); + rFont.SetEmphasisMark(FontEmphasisMark::NONE); + rFont.SetEscapement(0); + rFont.SetPitch(PITCH_DONTKNOW, rFont.GetActual()); + rFont.SetRelief(FontRelief::NONE); // adjust Y position to account for different baselines of the fonts - auto const nOSAscent(rTmpFont.GetAscent(rInf.GetVsh(), *rInf.GetOut())); + auto const nOSAscent(rFont.GetAscent(rTextPaintInfo.GetVsh(), *rTextPaintInfo.GetOut())); rDeltaY = nOSAscent - nOrigAscent; return true; |