sw/source/core/edit/edattr.cxx | 6 ++-- sw/source/core/inc/txtfrm.hxx | 2 - sw/source/core/text/frmcrsr.cxx | 2 - sw/source/core/text/frmform.cxx | 8 +++--- sw/source/core/text/frminf.cxx | 2 - sw/source/core/text/frmpaint.cxx | 4 +-- sw/source/core/text/inftxt.cxx | 4 +-- sw/source/core/text/itrcrsr.cxx | 22 ++++++++-------- sw/source/core/text/itrform2.cxx | 52 +++++++++++++++++++-------------------- sw/source/core/text/itrpaint.cxx | 12 ++++----- sw/source/core/text/itrtxt.cxx | 10 +++---- sw/source/core/text/itrtxt.hxx | 8 +++--- sw/source/core/text/porfld.cxx | 22 ++++++++-------- sw/source/core/text/porglue.cxx | 2 - sw/source/core/text/porlay.cxx | 13 ++++----- sw/source/core/text/porlay.hxx | 12 ++++----- sw/source/core/text/porlin.cxx | 2 - sw/source/core/text/porlin.hxx | 16 ++++++------ sw/source/core/text/pormulti.cxx | 14 +++++----- sw/source/core/text/pormulti.hxx | 2 - sw/source/core/text/porrst.cxx | 2 - sw/source/core/text/possiz.hxx | 31 ++++++++++++----------- sw/source/core/text/txtdrop.cxx | 10 +++---- sw/source/core/text/txtfrm.cxx | 4 +-- sw/source/core/text/txtftn.cxx | 2 - sw/source/core/text/widorp.cxx | 4 +-- 26 files changed, 134 insertions(+), 134 deletions(-)
New commits: commit 203068319e17377cafb9e298a910f42fde417a21 Author: Aron Budea <aron.bu...@collabora.com> AuthorDate: Sat Oct 2 06:13:16 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Oct 6 13:42:27 2021 +0200 tdf#144122 Use signed type to avoid stealthy underflow 301278b656e76b6f42af5cf8a6f5c6c02acfffeb and 6fdd0a3f8b3448a9a246496191908c92156cc38b switched some sal_uInt16 types to sal_uInt32. Additional commits related to the change: 9e075acf2bf1ce6c43fdf5b601507ee0663bd691 and 2634bc59092b24217d984a5845365d703bdb08d2. A fallout from this change was tdf#144305, fixed via 0c3e47cc2f0570a7cd8ff4889763991a86b29f26. Instead of adding further casts to force conversion to signed to avoid unsigned types underflowing into large positive numbers, convert these types to signed SwTwips. Change-Id: Icb7fbae79621d452cd03bb01dc620f60a26f1db0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123014 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 2cb6f41b2484..030e9dd9d088 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -536,10 +536,10 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const SwFrame* pFrame = pCNd->getLayoutFrame( GetLayout() ); if ( pFrame ) { - const sal_uInt32 nFrameWidth = o3tl::narrowing<sal_uInt32>( pFrame->IsVertical() ? + const SwTwips nFrameWidth = pFrame->IsVertical() ? pFrame->getFrameArea().Height() : - pFrame->getFrameArea().Width() ); - bRet = o3tl::narrowing<SwTwips>(nFrameWidth) > (nNext + constTwips_5mm); + pFrame->getFrameArea().Width(); + bRet = nFrameWidth > (nNext + constTwips_5mm); } else bRet = false; diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index f2c8adadf512..7cbc3a4bfabd 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -577,7 +577,7 @@ public: virtual void CheckDirection( bool bVert ) override; /// Returns the sum of line height in pLine - sal_uInt32 GetParHeight() const; + SwTwips GetParHeight() const; inline SwTextFrame *GetFollow(); inline const SwTextFrame *GetFollow() const; diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx index d2d7434b0da2..7a3dd914e28c 100644 --- a/sw/source/core/text/frmcrsr.cxx +++ b/sw/source/core/text/frmcrsr.cxx @@ -590,7 +590,7 @@ bool SwTextFrame::GetModelPositionForViewPoint_(SwPosition* pPos, const Point& r // See comment in AdjustFrame() SwTwips nMaxY = getFrameArea().Top() + getFramePrintArea().Top() + getFramePrintArea().Height(); aLine.TwipsToLine( rPoint.Y() ); - while( aLine.Y() + o3tl::narrowing<SwTwips>(aLine.GetLineHeight()) > nMaxY ) + while( aLine.Y() + aLine.GetLineHeight() > nMaxY ) { if( !aLine.Prev() ) break; diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index 4731a7d99ebd..93b6e2b272d8 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -1184,8 +1184,8 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev ) SwParaPortion *pPara = rLine.GetInfo().GetParaPortion(); const SwLineLayout *pOldCur = rLine.GetCurr(); const TextFrameIndex nOldLen = pOldCur->GetLen(); - const sal_uInt32 nOldAscent = pOldCur->GetAscent(); - const sal_uInt32 nOldHeight = pOldCur->Height(); + const SwTwips nOldAscent = pOldCur->GetAscent(); + const SwTwips nOldHeight = pOldCur->Height(); const SwTwips nOldWidth = pOldCur->Width() + pOldCur->GetHangingMargin(); const bool bOldHyph = pOldCur->IsEndHyph(); SwTwips nOldTop = 0; @@ -1207,7 +1207,7 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev ) bOldHyph == pNew->IsEndHyph(); if ( bUnChg && !bPrev ) { - const tools::Long nWidthDiff = nOldWidth > o3tl::narrowing<SwTwips>(pNew->Width()) + const tools::Long nWidthDiff = nOldWidth > pNew->Width() ? nOldWidth - pNew->Width() : pNew->Width() - nOldWidth; @@ -1261,7 +1261,7 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev ) rLine.SetUnclipped( false ); } } - SwTwips nRght = std::max( nOldWidth, o3tl::narrowing<SwTwips>(pNew->Width()) + + SwTwips nRght = std::max( nOldWidth, pNew->Width() + pNew->GetHangingMargin() ); SwViewShell *pSh = getRootFrame()->GetCurrShell(); const SwViewOption *pOpt = pSh ? pSh->GetViewOptions() : nullptr; diff --git a/sw/source/core/text/frminf.cxx b/sw/source/core/text/frminf.cxx index 92b287d7bd16..bd1e742ea6a7 100644 --- a/sw/source/core/text/frminf.cxx +++ b/sw/source/core/text/frminf.cxx @@ -82,7 +82,7 @@ bool SwTextFrameInfo::IsFilled( const sal_uInt8 nPercent ) const tools::Long nWidth = m_pFrame->getFramePrintArea().Width(); nWidth *= nPercent; nWidth /= 100; - return o3tl::make_unsigned(nWidth) <= pLay->Width(); + return nWidth <= pLay->Width(); } // Where does the text start (without whitespace)? (document global) diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx index 98582b931659..95ecf6cd54ff 100644 --- a/sw/source/core/text/frmpaint.cxx +++ b/sw/source/core/text/frmpaint.cxx @@ -356,7 +356,7 @@ void SwTextFrame::PaintExtraData( const SwRect &rRect ) const SwTextPainter aLine( const_cast<SwTextFrame*>(this), &aInf ); bool bNoDummy = !aLine.GetNext(); // Only one empty line! - while( aLine.Y() + o3tl::narrowing<SwTwips>(aLine.GetLineHeight()) <= rRect.Top() ) + while( aLine.Y() + aLine.GetLineHeight() <= rRect.Top() ) { if( !aLine.GetCurr()->IsDummy() && ( rLineInf.IsCountBlankLines() || @@ -398,7 +398,7 @@ void SwTextFrame::PaintExtraData( const SwRect &rRect ) const bool bNum = bLineNum && ( aExtra.HasNumber() || aExtra.HasDivider() ); if( bRedInMargin || bNum ) { - sal_uInt32 nTmpHeight, nTmpAscent; + SwTwips nTmpHeight, nTmpAscent; aLine.CalcAscentAndHeight( nTmpAscent, nTmpHeight ); if ( bRedInMargin ) { diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index e3546c66db1a..b22ed6efdbcb 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -990,13 +990,13 @@ void SwTextPaintInfo::DrawRedArrow( const SwLinePortion &rPor ) const { aRect.Pos().AdjustY(20 - GetAscent() ); aRect.Pos().AdjustX(20 ); - if( aSize.Height() > o3tl::narrowing<SwTwips>(rPor.Height()) ) + if( aSize.Height() > rPor.Height() ) aRect.Height( rPor.Height() ); cChar = CHAR_LEFT_ARROW; } else { - if( aSize.Height() > o3tl::narrowing<SwTwips>(rPor.Height()) ) + if( aSize.Height() > rPor.Height() ) aRect.Height( rPor.Height() ); aRect.Pos().AdjustY( -(aRect.Height() + 20) ); aRect.Pos().AdjustX( -(aRect.Width() + 20) ); diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 1bcc68373890..cd915f14ea50 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -428,7 +428,7 @@ void SwTextCursor::GetEndCharRect(SwRect* pOrig, const TextFrameIndex nOfst, tools::Long nLast = 0; SwLinePortion *pPor = m_pCurr->GetFirstPortion(); - sal_uInt32 nTmpHeight, nTmpAscent; + SwTwips nTmpHeight, nTmpAscent; CalcAscentAndHeight( nTmpAscent, nTmpHeight ); sal_uInt16 nPorHeight = nTmpHeight; sal_uInt16 nPorAscent = nTmpAscent; @@ -479,7 +479,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst, SwTextSizeInfo aInf( GetInfo(), &aText, m_nStart ); if( GetPropFont() ) aInf.GetFont()->SetProportion( GetPropFont() ); - sal_uInt32 nTmpAscent, nTmpHeight; // Line height + SwTwips nTmpAscent, nTmpHeight; // Line height CalcAscentAndHeight( nTmpAscent, nTmpHeight ); const Size aCharSize( 1, nTmpHeight ); const Point aCharPos; @@ -505,8 +505,8 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst, } else { - sal_uInt32 nPorHeight = nTmpHeight; - sal_uInt32 nPorAscent = nTmpAscent; + SwTwips nPorHeight = nTmpHeight; + SwTwips nPorAscent = nTmpAscent; SwTwips nX = 0; SwTwips nTmpFirst = 0; SwLinePortion *pPor = m_pCurr->GetFirstPortion(); @@ -1051,7 +1051,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst, nPorHeight = nPorAscent; pOrig->Height( nPorHeight + static_cast<SwDropPortion*>(pPor)->GetDropDescent() ); - if( o3tl::narrowing<SwTwips>(nTmpHeight) < pOrig->Height() ) + if( nTmpHeight < pOrig->Height() ) { nTmpAscent = nPorAscent; nTmpHeight = sal_uInt16( pOrig->Height() ); @@ -1266,7 +1266,7 @@ void SwTextCursor::GetCharRect( SwRect* pOrig, TextFrameIndex const nOfst, * Determines if SwTextCursor::GetModelPositionForViewPoint() should consider the next portion when calculating the * doc model position from a Point. */ -static bool ConsiderNextPortionForCursorOffset(const SwLinePortion* pPor, sal_uInt32 nWidth30, sal_uInt16 nX) +static bool ConsiderNextPortionForCursorOffset(const SwLinePortion* pPor, SwTwips nWidth30, sal_uInt16 nX) { if (!pPor->GetNextPortion() || pPor->IsBreakPortion()) { @@ -1323,7 +1323,7 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con // Until here everything in document coordinates. x -= nLeftMargin; - sal_uInt32 nX = sal_uInt16( x ); + SwTwips nX = x; // If there are attribute changes in the line, search for the paragraph, // in which nX is situated. @@ -1342,7 +1342,7 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con // nWidth is the width of the line, or the width of // the paragraph with the font change, in which nX is situated. - sal_uInt32 nWidth = pPor->Width(); + SwTwips nWidth = pPor->Width(); if ( m_pCurr->IsSpaceAdd() || pKanaComp ) { if ( pPor->InSpaceGrp() && nSpaceAdd ) @@ -1372,7 +1372,7 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con } } - sal_uInt32 nWidth30; + SwTwips nWidth30; if ( pPor->IsPostItsPortion() ) nWidth30 = 0; else @@ -1691,12 +1691,12 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con } pCurrPart = pCurrPart->GetFollow(); } - nX = std::max(o3tl::narrowing<sal_uInt32>(0), nX - nSumBorderWidth); + nX = std::max(static_cast<SwTwips>(0), nX - nSumBorderWidth); } // Shift the offset with the left border width else if( GetInfo().GetFont()->GetLeftBorder() && !pPor->GetJoinBorderWithPrev() ) { - nX = std::max(o3tl::narrowing<sal_uInt32>(0), nX - GetInfo().GetFont()->GetLeftBorderSpace()); + nX = std::max(static_cast<SwTwips>(0), nX - GetInfo().GetFont()->GetLeftBorderSpace()); } aDrawInf.SetOffset( nX ); diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 728744276f22..1c52ea7992d9 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -242,7 +242,7 @@ SwLinePortion *SwTextFormatter::Underflow( SwTextFormatInfo &rInf ) // line width is adjusted, so that pPor does not fit to current // line anymore - rInf.Width( o3tl::narrowing<sal_uInt16>(rInf.X() + (pPor->Width() ? pPor->Width() - 1 : 0)) ); + rInf.Width( rInf.X() + (pPor->Width() ? pPor->Width() - 1 : 0) ); rInf.SetLen( pPor->GetLen() ); rInf.SetFull( false ); if( pFly ) @@ -535,7 +535,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) const SwTwips nRestWidth = rInf.Width() - rInf.X(); if ( nKernWidth <= nRestWidth ) - pGridKernPortion->Width( o3tl::narrowing<sal_uInt16>(nKernWidth) ); + pGridKernPortion->Width( nKernWidth ); } if ( pGridKernPortion != pPor ) @@ -622,7 +622,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) (m_pScriptInfo->ScriptType(nTmp - TextFrameIndex(1)) == css::i18n::ScriptType::ASIAN || m_pScriptInfo->ScriptType(nTmp) == css::i18n::ScriptType::ASIAN) ) { - const sal_uInt16 nDist = o3tl::narrowing<sal_uInt16>(rInf.GetFont()->GetHeight()/5); + const SwTwips nDist = rInf.GetFont()->GetHeight()/5; if( nDist ) { @@ -677,7 +677,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) 0; const SwTwips nTmpWidth = i * nGridWidth; const SwTwips nKernWidth = std::min(nTmpWidth - nSumWidth, nRestWidth); - const sal_uInt16 nKernWidth_1 = o3tl::narrowing<sal_uInt16>(nKernWidth / 2); + const SwTwips nKernWidth_1 = nKernWidth / 2; OSL_ENSURE( nKernWidth <= nRestWidth, "Not enough space left for adjusting non-asian text in grid mode" ); @@ -1631,8 +1631,8 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos) // Recycling must be suppressed by changed line height and also // by changed ascent (lowering of baseline). - const sal_uInt32 nOldHeight = m_pCurr->Height(); - const sal_uInt32 nOldAscent = m_pCurr->GetAscent(); + const SwTwips nOldHeight = m_pCurr->Height(); + const SwTwips nOldAscent = m_pCurr->GetAscent(); m_pCurr->SetEndHyph( false ); m_pCurr->SetMidHyph( false ); @@ -1712,7 +1712,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos) if ( IsFlyInCntBase() && (!IsQuick() || (pPorTmp && pPorTmp->IsFlyCntPortion() && !pPorTmp->GetNextPortion() && m_pCurr->Height() > pPorTmp->Height()))) { - sal_uInt32 nTmpAscent, nTmpHeight; + SwTwips nTmpAscent, nTmpHeight; CalcAscentAndHeight( nTmpAscent, nTmpHeight ); AlignFlyInCntBase( Y() + tools::Long( nTmpAscent ) ); m_pCurr->CalcLine( *this, GetInfo() ); @@ -1829,7 +1829,7 @@ void SwTextFormatter::RecalcRealHeight() void SwTextFormatter::CalcRealHeight( bool bNewLine ) { - sal_uInt32 nLineHeight = m_pCurr->Height(); + SwTwips nLineHeight = m_pCurr->Height(); m_pCurr->SetClipping( false ); SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame())); @@ -1863,7 +1863,7 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine ) nTmp = 100; nTmp *= nLineHeight; - nLineHeight = o3tl::narrowing<sal_uInt16>(nTmp / 100); + nLineHeight = nTmp / 100; } m_pCurr->SetRealHeight( nLineHeight ); @@ -1898,7 +1898,7 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine ) nTmp /= 100; if( !nTmp ) ++nTmp; - nLineHeight = o3tl::narrowing<sal_uInt16>(nTmp); + nLineHeight = nTmp; sal_uInt16 nAsc = ( 4 * nLineHeight ) / 5; // 80% #if 0 // could do clipping here (like Word does) @@ -1956,7 +1956,7 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine ) nTmp += nLineHeight; if (nTmp < 1) nTmp = 1; - nLineHeight = o3tl::narrowing<sal_uInt16>(nTmp); + nLineHeight = nTmp; break; } case SvxInterLineSpaceRule::Fix: @@ -2156,8 +2156,8 @@ void SwTextFormatter::UpdatePos( SwLineLayout *pCurrent, Point aStart, SwTwips nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc; pCurrent->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc ); - const sal_uInt32 nTmpHeight = pCurrent->GetRealHeight(); - sal_uInt32 nAscent = pCurrent->GetAscent() + nTmpHeight - pCurrent->Height(); + const SwTwips nTmpHeight = pCurrent->GetRealHeight(); + SwTwips nAscent = pCurrent->GetAscent() + nTmpHeight - pCurrent->Height(); AsCharFlags nFlags = AsCharFlags::UlSpace; if( GetMulti() ) { @@ -2422,7 +2422,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf ) nAscent = pLast->GetAscent(); nHeight = pLast->Height(); - if ( o3tl::narrowing<SwTwips>(m_pCurr->GetRealHeight()) > nHeight ) + if ( m_pCurr->GetRealHeight() > nHeight ) nTop += m_pCurr->GetRealHeight() - nHeight; else // Important for fixed space between lines @@ -2538,7 +2538,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf ) // created: here and in MakeFlyDummies. // IsDummy() is evaluated in IsFirstTextLine(), when moving lines // and in relation with DropCaps. - pFly->Height( sal_uInt16(aInter.Height()) ); + pFly->Height( aInter.Height() ); // nNextTop now contains the margin's bottom edge, which we avoid // or the next margin's top edge, which we need to respect. @@ -2551,10 +2551,10 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf ) { SwTwips nH = nNextTop - aInter.Top(); if( nH < SAL_MAX_UINT16 ) - pFly->Height( sal_uInt16( nH ) ); + pFly->Height( nH ); } - if( nAscent < o3tl::narrowing<SwTwips>(pFly->Height()) ) - pFly->SetAscent( sal_uInt16(nAscent) ); + if( nAscent < pFly->Height() ) + pFly->SetAscent( nAscent ); else pFly->SetAscent( pFly->Height() ); } @@ -2568,9 +2568,9 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf ) } else { - pFly->Height( sal_uInt16(aInter.Height()) ); - if( nAscent < o3tl::narrowing<SwTwips>(pFly->Height()) ) - pFly->SetAscent( sal_uInt16(nAscent) ); + pFly->Height( aInter.Height() ); + if( nAscent < pFly->Height() ) + pFly->SetAscent( nAscent ); else pFly->SetAscent( pFly->Height() ); } @@ -2608,11 +2608,11 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf ) const SwTwips nOfst = nStartX - nGridOrigin; const SwTwips nTmpWidth = rInf.Width() + nOfst; - const sal_uLong i = nTmpWidth / nGridWidth + 1; + const SwTwips i = nTmpWidth / nGridWidth + 1; - const tools::Long nNewWidth = ( i - 1 ) * nGridWidth - nOfst; + const SwTwips nNewWidth = ( i - 1 ) * nGridWidth - nOfst; if ( nNewWidth > 0 ) - rInf.Width( o3tl::narrowing<sal_uInt16>(nNewWidth) ); + rInf.Width( nNewWidth ); else rInf.Width( 0 ); @@ -2649,7 +2649,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf, // we use this one when calculating the base, or the frame would be positioned // too much to the top, sliding down after all causing a repaint in an area // he actually never was in. - sal_uInt32 nAscent = 0; + SwTwips nAscent = 0; const bool bTextFrameVertical = GetInfo().GetTextFrame()->IsVertical(); @@ -2670,7 +2670,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf, { nAscent = rInf.GetLast()->GetAscent(); } - else if( o3tl::narrowing<SwTwips>(nAscent) > nFlyAsc ) + else if( nAscent > nFlyAsc ) nFlyAsc = nAscent; Point aBase( GetLeftMargin() + rInf.X(), Y() + nAscent ); diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx index 8ff1067abd0d..96faaf23615a 100644 --- a/sw/source/core/text/itrpaint.cxx +++ b/sw/source/core/text/itrpaint.cxx @@ -83,14 +83,14 @@ SwLinePortion *SwTextPainter::CalcPaintOfst( const SwRect &rPaint ) { SwLinePortion *pLast = nullptr; // 7529 and 4757: not <= nPaintOfst - while( pPor && o3tl::narrowing<SwTwips>(GetInfo().X() + pPor->Width() + (pPor->Height()/2)) + while( pPor && GetInfo().X() + pPor->Width() + (pPor->Height()/2) < nPaintOfst ) { if( pPor->InSpaceGrp() && GetInfo().GetSpaceAdd() ) { tools::Long nTmp = GetInfo().X() +pPor->Width() + pPor->CalcSpacing( GetInfo().GetSpaceAdd(), GetInfo() ); - if( o3tl::narrowing<SwTwips>(nTmp + (pPor->Height()/2)) >= nPaintOfst ) + if( nTmp + (pPor->Height()/2) >= nPaintOfst ) break; GetInfo().X( nTmp ); GetInfo().SetIdx( GetInfo().GetIdx() + pPor->GetLen() ); @@ -178,7 +178,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip, && GetDropLines() >= GetLineNr(); } - sal_uInt32 nTmpHeight, nTmpAscent; + SwTwips nTmpHeight, nTmpAscent; CalcAscentAndHeight( nTmpAscent, nTmpHeight ); // bClip decides if there's a need to clip @@ -192,7 +192,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip, if( GetInfo().GetPos().X() < rPaint.Left() || GetInfo().GetPos().Y() < rPaint.Top() || - GetInfo().GetPos().Y() + o3tl::narrowing<SwTwips>(nTmpHeight) > rPaint.Top() + rPaint.Height() ) + GetInfo().GetPos().Y() + nTmpHeight > rPaint.Top() + rPaint.Height() ) { bClip = false; rClip.ChgClip( rPaint, m_pFrame, m_pCurr->HasUnderscore() ); @@ -347,7 +347,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip, // A safety distance of half the height is added, so that // TTF-"f" isn't overlapping into the page margin. if( bClip && - o3tl::narrowing<SwTwips>(GetInfo().X() + pPor->Width() + ( pPor->Height() / 2 )) > nMaxRight ) + GetInfo().X() + pPor->Width() + ( pPor->Height() / 2 ) > nMaxRight ) { bClip = false; rClip.ChgClip( rPaint, m_pFrame, m_pCurr->HasUnderscore() ); @@ -480,7 +480,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip, SwTwips nDiff = GetInfo().Y() + nTmpHeight - nTmpAscent - GetTextFrame()->getFrameArea().Bottom(); if( ( nDiff > 0 && (GetEnd() < TextFrameIndex(GetInfo().GetText().getLength()) || - ( nDiff > o3tl::narrowing<SwTwips>(nTmpHeight)/2 && GetPrevLine() ) ) ) || + ( nDiff > nTmpHeight/2 && GetPrevLine() ) ) ) || (nDiff >= 0 && bNextUndersized) ) { diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx index 8e49e490f7e1..8fb8334a83fa 100644 --- a/sw/source/core/text/itrtxt.cxx +++ b/sw/source/core/text/itrtxt.cxx @@ -60,7 +60,7 @@ void SwTextIter::Init() m_nLineNr = 1; } -void SwTextIter::CalcAscentAndHeight( sal_uInt32 &rAscent, sal_uInt32 &rHeight ) const +void SwTextIter::CalcAscentAndHeight( SwTwips &rAscent, SwTwips &rHeight ) const { rHeight = GetLineHeight(); rAscent = m_pCurr->GetAscent() + rHeight - m_pCurr->Height(); @@ -211,9 +211,9 @@ const SwLineLayout *SwTextCursor::CharCursorToLine(TextFrameIndex const nPositio return bPrevious ? PrevLine() : m_pCurr; } -sal_uInt32 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine, +SwTwips SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine, const SwLinePortion* pPor, - sal_uInt32 nPorHeight, sal_uInt32 nPorAscent, + SwTwips nPorHeight, SwTwips nPorAscent, const bool bAutoToCentered ) const { if ( pPor ) @@ -222,7 +222,7 @@ sal_uInt32 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine, nPorAscent = pPor->GetAscent(); } - sal_uInt32 nOfst = rLine.GetRealHeight() - rLine.Height(); + SwTwips nOfst = rLine.GetRealHeight() - rLine.Height(); SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame())); @@ -299,7 +299,7 @@ sal_uInt32 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine, void SwTextIter::TwipsToLine( const SwTwips y) { - while( m_nY + o3tl::narrowing<SwTwips>(GetLineHeight()) <= y && Next() ) + while( m_nY + GetLineHeight() <= y && Next() ) ; while( m_nY > y && Prev() ) ; diff --git a/sw/source/core/text/itrtxt.hxx b/sw/source/core/text/itrtxt.hxx index a547baebd59f..f36932dbd5f9 100644 --- a/sw/source/core/text/itrtxt.hxx +++ b/sw/source/core/text/itrtxt.hxx @@ -113,8 +113,8 @@ public: // Truncates all after pCurr void TruncLines( bool bNoteFollow = false ); - sal_uInt32 GetLineHeight() const { return m_pCurr->GetRealHeight(); } - void CalcAscentAndHeight( sal_uInt32 &rAscent, sal_uInt32 &rHeight ) const; + SwTwips GetLineHeight() const { return m_pCurr->GetRealHeight(); } + void CalcAscentAndHeight( SwTwips &rAscent, SwTwips &rHeight ) const; // Lots of trouble for querying pCurr == pPara bool IsFirstTextLine() const @@ -287,8 +287,8 @@ public: // calculates baseline for portion rPor // bAutoToCentered indicates, if AUTOMATIC mode means CENTERED or BASELINE - sal_uInt32 AdjustBaseLine( const SwLineLayout& rLine, const SwLinePortion* pPor, - sal_uInt32 nPorHeight = 0, sal_uInt32 nAscent = 0, + SwTwips AdjustBaseLine( const SwLineLayout& rLine, const SwLinePortion* pPor, + SwTwips nPorHeight = 0, SwTwips nAscent = 0, const bool bAutoToCentered = false ) const; static void SetRightMargin( const bool bNew ){ s_bRightMargin = bNew; } diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 49ac25ac686d..7b1bf03e10fc 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -594,11 +594,11 @@ bool SwNumberPortion::Format( SwTextFormatInfo &rInf ) // Height has to be changed if ( rInf.IsMulti() ) { - if ( o3tl::narrowing<SwTwips>(Height()) < nDiff ) - Height( sal_uInt16( nDiff ) ); + if ( Height() < nDiff ) + Height( nDiff ); } - else if( o3tl::narrowing<SwTwips>(Width()) < nDiff ) - Width( sal_uInt16(nDiff) ); + else if( Width() < nDiff ) + Width( nDiff ); } return bFull; } @@ -785,7 +785,7 @@ SwGrfNumPortion::SwGrfNumPortion( m_nYPos = 0; m_eOrient = text::VertOrientation::TOP; } - Width( o3tl::narrowing<sal_uInt16>(rGrfSize.Width() + 2 * GRFNUM_SECURE) ); + Width( rGrfSize.Width() + 2 * GRFNUM_SECURE ); m_nFixWidth = Width(); m_nGrfHeight = rGrfSize.Height() + 2 * GRFNUM_SECURE; Height( sal_uInt16(m_nGrfHeight) ); @@ -834,7 +834,7 @@ bool SwGrfNumPortion::Format( SwTextFormatInfo &rInf ) if( bFull ) { - Width( rInf.Width() - o3tl::narrowing<sal_uInt16>(rInf.X()) ); + Width( rInf.Width() - rInf.X() ); if( bFly ) { SetLen(TextFrameIndex(0)); @@ -868,8 +868,8 @@ bool SwGrfNumPortion::Format( SwTextFormatInfo &rInf ) SetHide( true ); } - if( o3tl::narrowing<SwTwips>(Width()) < nDiff ) - Width( sal_uInt16(nDiff) ); + if( Width() < nDiff ) + Width( nDiff ); return bFull; } @@ -1232,7 +1232,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf ) if( nAsc > nMaxAscent ) nMaxAscent = nAsc; if( aSize.Height() - nAsc > nMaxDescent ) - nMaxDescent = o3tl::narrowing<sal_uInt16>(aSize.Height() - nAsc); + nMaxDescent = aSize.Height() - nAsc; } // for one or two characters we double the width of the portion if( nCount < 3 ) @@ -1257,7 +1257,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf ) Height( Height() + nMainAscent - GetAscent() ); SetAscent( nMainAscent ); } - if( o3tl::narrowing<SwTwips>(Height()) < nMainAscent + nMainDescent ) + if( Height() < nMainAscent + nMainDescent ) Height( nMainAscent + nMainDescent ); // We calculate the x positions of the characters in both lines... @@ -1295,7 +1295,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf ) { if( rInf.GetLineStart() == rInf.GetIdx() && (!rInf.GetLast()->InFieldGrp() || !static_cast<SwFieldPortion*>(rInf.GetLast())->IsFollow() ) ) - Width( o3tl::narrowing<sal_uInt16>( rInf.Width() - rInf.X() ) ); + Width( rInf.Width() - rInf.X() ); else { Truncate(); diff --git a/sw/source/core/text/porglue.cxx b/sw/source/core/text/porglue.cxx index 4ccfbbb62172..7c09ded23a2f 100644 --- a/sw/source/core/text/porglue.cxx +++ b/sw/source/core/text/porglue.cxx @@ -215,7 +215,7 @@ void SwMarginPortion::AdjustRight( const SwLineLayout *pCurr ) } while( pPrev != pLeft ) { - if( bNoMove || o3tl::narrowing<SwTwips>(pPrev->PrtWidth()) >= nRightGlue || + if( bNoMove || pPrev->PrtWidth() >= nRightGlue || pPrev->InHyphGrp() || pPrev->IsKernPortion() ) { // The portion before the pRight cannot be moved diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 3b85c71fb624..1380e886fed5 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -196,7 +196,7 @@ void SwLineLayout::DeleteNext() while (pNext); } -void SwLineLayout::Height(const sal_uInt32 nNew, const bool bText) +void SwLineLayout::Height(const SwTwips nNew, const bool bText) { SwPosSize::Height(nNew); if (bText) @@ -371,7 +371,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) } else { - const sal_uInt32 nLineHeight = Height(); + const SwTwips nLineHeight = Height(); Init( GetNextPortion() ); SwLinePortion *pPos = mpNextPortion; SwLinePortion *pLast = this; @@ -434,8 +434,8 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) // We had an attribute change: Sum up/build maxima of length and mass - sal_uInt32 nPosHeight = pPos->Height(); - sal_uInt32 nPosAscent = pPos->GetAscent(); + SwTwips nPosHeight = pPos->Height(); + SwTwips nPosAscent = pPos->GetAscent(); SAL_WARN_IF( nPosHeight < nPosAscent, "sw.core", "SwLineLayout::CalcLine: bad ascent or height" ); @@ -723,9 +723,8 @@ void SwLineLayout::MaxAscentDescent( SwTwips& _orAscent, ( !pTmpPortion->IsFlyCntPortion() && !(pTmpPortion == this && pTmpPortion->GetNextPortion() ) ) ) ) { - SwTwips nPortionAsc = static_cast<SwTwips>(pTmpPortion->GetAscent()); - SwTwips nPortionDesc = static_cast<SwTwips>(pTmpPortion->Height()) - - nPortionAsc; + SwTwips nPortionAsc = pTmpPortion->GetAscent(); + SwTwips nPortionDesc = pTmpPortion->Height() - nPortionAsc; const bool bFlyCmp = pTmpPortion->IsFlyCntPortion() ? static_cast<const SwFlyCntPortion*>(pTmpPortion)->IsMax() : diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx index daeee36c7ad5..68fc8c72c206 100644 --- a/sw/source/core/text/porlay.hxx +++ b/sw/source/core/text/porlay.hxx @@ -83,8 +83,8 @@ private: SwLineLayout *m_pNext; // The next Line std::unique_ptr<std::vector<tools::Long>> m_pLLSpaceAdd; // Used for justified alignment std::unique_ptr<std::deque<sal_uInt16>> m_pKanaComp; // Used for Kana compression - sal_uInt32 m_nRealHeight; // The height resulting from line spacing and register - sal_uInt32 m_nTextHeight; // The max height of all non-FlyCnt portions in this Line + SwTwips m_nRealHeight; // The height resulting from line spacing and register + SwTwips m_nTextHeight; // The max height of all non-FlyCnt portions in this Line bool m_bFormatAdj : 1; bool m_bDummy : 1; bool m_bEndHyph : 1; @@ -110,7 +110,7 @@ private: public: // From SwPosSize using SwPosSize::Height; - virtual void Height(const sal_uInt32 nNew, const bool bText = true) override; + virtual void Height(const SwTwips nNew, const bool bText = true) override; // From SwLinePortion virtual SwLinePortion *Insert( SwLinePortion *pPortion ) override; @@ -167,10 +167,10 @@ public: // Collects the data for the line void CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ); - void SetRealHeight( sal_uInt32 nNew ) { m_nRealHeight = nNew; } - sal_uInt32 GetRealHeight() const { return m_nRealHeight; } + void SetRealHeight( SwTwips nNew ) { m_nRealHeight = nNew; } + SwTwips GetRealHeight() const { return m_nRealHeight; } - sal_uInt16 GetTextHeight() const { return m_nTextHeight; } + SwTwips GetTextHeight() const { return m_nTextHeight; } // Creates the glue chain for short lines SwMarginPortion *CalcLeftMargin(); diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx index 439382a92b63..61db8135f33b 100644 --- a/sw/source/core/text/porlin.cxx +++ b/sw/source/core/text/porlin.cxx @@ -290,7 +290,7 @@ void SwLinePortion::Move( SwTextPaintInfo &rInf ) rInf.IncKanaIdx(); } if( rInf.IsRotated() ) - rInf.Y( rInf.Y() + ( bB2T ? -o3tl::narrowing<SwTwips>(PrtWidth()) : o3tl::narrowing<SwTwips>(PrtWidth()) ) ); + rInf.Y( rInf.Y() + ( bB2T ? -PrtWidth() : PrtWidth() ) ); else if ( bCounterDir ) rInf.X( rInf.X() - PrtWidth() ); else diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx index 6e7525a1a6ad..4801fadfe9f1 100644 --- a/sw/source/core/text/porlin.hxx +++ b/sw/source/core/text/porlin.hxx @@ -55,7 +55,7 @@ protected: SwLinePortion *mpNextPortion; // Count of chars and spaces on the line TextFrameIndex mnLineLength; - sal_uInt32 mnAscent; // Maximum ascender + SwTwips mnAscent; // Maximum ascender SwLinePortion(); private: @@ -75,13 +75,13 @@ public: TextFrameIndex GetLen() const { return mnLineLength; } void SetLen(TextFrameIndex const nLen) { mnLineLength = nLen; } void SetNextPortion( SwLinePortion *pNew ){ mpNextPortion = pNew; } - sal_uInt32 &GetAscent() { return mnAscent; } - sal_uInt32 GetAscent() const { return mnAscent; } - void SetAscent( const sal_uInt32 nNewAsc ) { mnAscent = nNewAsc; } - void PrtWidth( sal_uInt16 nNewWidth ) { Width( nNewWidth ); } - sal_uInt32 PrtWidth() const { return Width(); } - void AddPrtWidth( const sal_uInt32 nNew ) { Width( Width() + nNew ); } - void SubPrtWidth( const sal_uInt16 nNew ) { Width( Width() - nNew ); } + SwTwips &GetAscent() { return mnAscent; } + SwTwips GetAscent() const { return mnAscent; } + void SetAscent( const SwTwips nNewAsc ) { mnAscent = nNewAsc; } + void PrtWidth( SwTwips nNewWidth ) { Width( nNewWidth ); } + SwTwips PrtWidth() const { return Width(); } + void AddPrtWidth( const SwTwips nNew ) { Width( Width() + nNew ); } + void SubPrtWidth( const SwTwips nNew ) { Width( Width() - nNew ); } // Insert methods virtual SwLinePortion *Insert( SwLinePortion *pPortion ); diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 70481628665c..1ea089b106e1 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -413,7 +413,7 @@ void SwDoubleLinePortion::FormatBrackets( SwTextFormatInfo &rInf, SwTwips& nMaxW m_pBracket->nAscent = rInf.GetAscent(); m_pBracket->nHeight = aSize.Height(); aTmpFnt.SetActual( nActualScr ); - if( nMaxWidth > o3tl::narrowing<SwTwips>(aSize.Width()) ) + if( nMaxWidth > aSize.Width() ) { m_pBracket->nPreWidth = aSize.Width(); nMaxWidth -= aSize.Width(); @@ -442,7 +442,7 @@ void SwDoubleLinePortion::FormatBrackets( SwTextFormatInfo &rInf, SwTwips& nMaxW } if( aSize.Height() > m_pBracket->nHeight ) m_pBracket->nHeight = aSize.Height(); - if( nMaxWidth > o3tl::narrowing<SwTwips>(aSize.Width()) ) + if( nMaxWidth > aSize.Width() ) { m_pBracket->nPostWidth = aSize.Width(); nMaxWidth -= aSize.Width(); @@ -644,7 +644,7 @@ SwRubyPortion::SwRubyPortion( const SwMultiCreator& rCreate, const SwFont& rFnt, // If there is a tabulator in smaller line, no adjustment is possible. void SwRubyPortion::Adjust_( SwTextFormatInfo &rInf ) { - SwTwips nLineDiff = o3tl::narrowing<SwTwips>(GetRoot().Width()) - GetRoot().GetNext()->Width(); + SwTwips nLineDiff = GetRoot().Width() - GetRoot().GetNext()->Width(); TextFrameIndex const nOldIdx = rInf.GetIdx(); if( !nLineDiff ) return; @@ -1693,7 +1693,7 @@ void SwTextPainter::PaintMultiPortion( const SwRect &rPaint, } else if ( rMulti.IsRuby() && rMulti.OnRight() && GetInfo().IsRuby() ) { - SwTwips nLineDiff = std::max(( rMulti.GetRoot().Height() - pPor->Width() ) / 2, static_cast<sal_uInt32>(0) ); + SwTwips nLineDiff = std::max(( rMulti.GetRoot().Height() - pPor->Width() ) / 2, static_cast<SwTwips>(0) ); GetInfo().Y( nOfst + nLineDiff ); // Draw the ruby text on top of the preserved space. GetInfo().X( GetInfo().X() - pPor->Height() ); @@ -2183,7 +2183,7 @@ bool SwTextFormatter::BuildMultiPortion( SwTextFormatInfo &rInf, // Setting this to the portion width ( = rMulti.Width() ) // can make GetTextBreak inside SwTextGuess::Guess return too small // values. Therefore we add some extra twips. - if( nActWidth > nTmpX + o3tl::narrowing<SwTwips>(rMulti.Width()) + 6 ) + if( nActWidth > nTmpX + rMulti.Width() + 6 ) nActWidth = nTmpX + rMulti.Width() + 6; nMaxWidth = nActWidth; nActWidth = ( 3 * nMaxWidth + nMinWidth + 3 ) / 4; @@ -2525,7 +2525,7 @@ SwLinePortion* SwTextFormatter::MakeRestPortion( const SwLineLayout* pLine, SwTextCursorSave::SwTextCursorSave( SwTextCursor* pCursor, SwMultiPortion* pMulti, SwTwips nY, - sal_uInt32& nX, + SwTwips& nX, TextFrameIndex const nCurrStart, tools::Long nSpaceAdd ) : pTextCursor(pCursor), @@ -2534,7 +2534,7 @@ SwTextCursorSave::SwTextCursorSave( SwTextCursor* pCursor, { pCursor->m_nStart = nCurrStart; pCursor->m_pCurr = &pMulti->GetRoot(); - while( pCursor->Y() + o3tl::narrowing<SwTwips>(pCursor->GetLineHeight()) < nY && + while( pCursor->Y() + pCursor->GetLineHeight() < nY && pCursor->Next() ) ; // nothing nWidth = pCursor->m_pCurr->Width(); diff --git a/sw/source/core/text/pormulti.hxx b/sw/source/core/text/pormulti.hxx index 854e7d41ce34..045276bdd4b9 100644 --- a/sw/source/core/text/pormulti.hxx +++ b/sw/source/core/text/pormulti.hxx @@ -243,7 +243,7 @@ class SwTextCursorSave bool bSpaceChg; public: SwTextCursorSave( SwTextCursor* pTextCursor, SwMultiPortion* pMulti, - SwTwips nY, sal_uInt32& nX, TextFrameIndex nCurrStart, tools::Long nSpaceAdd); + SwTwips nY, SwTwips& nX, TextFrameIndex nCurrStart, tools::Long nSpaceAdd); ~SwTextCursorSave(); }; diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 83cc1cc57da1..95ec669dddcc 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -642,7 +642,7 @@ void SwControlCharPortion::Paint( const SwTextPaintInfo &rInf ) const Point aOldPos = rInf.GetPos(); Point aNewPos( aOldPos ); - auto const deltaX((o3tl::narrowing<SwTwips>(Width()) / 2) - mnHalfCharWidth); + auto const deltaX((Width() / 2) - mnHalfCharWidth); switch (rInf.GetFont()->GetOrientation(rInf.GetTextFrame()->IsVertical()).get()) { case 0: diff --git a/sw/source/core/text/possiz.hxx b/sw/source/core/text/possiz.hxx index 543f037fde55..772237360e1f 100644 --- a/sw/source/core/text/possiz.hxx +++ b/sw/source/core/text/possiz.hxx @@ -20,21 +20,22 @@ #include <tools/gen.hxx> #include <sal/types.h> +#include <swtypes.hxx> // Compared to the SV sizes SwPosSize is always positive class SwPosSize { - sal_uInt32 m_nWidth; - sal_uInt32 m_nHeight; + SwTwips m_nWidth; + SwTwips m_nHeight; public: - SwPosSize( const sal_uInt32 nW = 0, const sal_uInt32 nH = 0 ) + SwPosSize( const SwTwips nW = 0, const SwTwips nH = 0 ) : m_nWidth(nW) , m_nHeight(nH) { } explicit SwPosSize( const Size &rSize ) - : m_nWidth(sal_uInt32(rSize.Width())) - ,m_nHeight(sal_uInt32(rSize.Height())) + : m_nWidth(SwTwips(rSize.Width())) + , m_nHeight(SwTwips(rSize.Height())) { } #if defined(__COVERITY__) @@ -46,25 +47,25 @@ public: SwPosSize(SwPosSize &&) = default; SwPosSize & operator =(SwPosSize const &) = default; SwPosSize & operator =(SwPosSize &&) = default; - sal_uInt32 Height() const { return m_nHeight; } - virtual void Height(const sal_uInt32 nNew, const bool = true) { m_nHeight = nNew; } - sal_uInt32 Width() const { return m_nWidth; } - void Width( const sal_uInt32 nNew ) { m_nWidth = nNew; } + SwTwips Height() const { return m_nHeight; } + virtual void Height(const SwTwips nNew, const bool = true) { m_nHeight = nNew; } + SwTwips Width() const { return m_nWidth; } + void Width( const SwTwips nNew ) { m_nWidth = nNew; } Size SvLSize() const { return Size( m_nWidth, m_nHeight ); } void SvLSize( const Size &rSize ) { - m_nWidth = sal_uInt32(rSize.Width()); - m_nHeight = sal_uInt32(rSize.Height()); + m_nWidth = SwTwips(rSize.Width()); + m_nHeight = SwTwips(rSize.Height()); } void SvXSize( const Size &rSize ) { - m_nHeight = sal_uInt32(rSize.Width()); - m_nWidth = sal_uInt32(rSize.Height()); + m_nHeight = SwTwips(rSize.Width()); + m_nWidth = SwTwips(rSize.Height()); } SwPosSize& operator=( const Size &rSize ) { - m_nWidth = sal_uInt32(rSize.Width()); - m_nHeight = sal_uInt32(rSize.Height()); + m_nWidth = SwTwips(rSize.Width()); + m_nHeight = SwTwips(rSize.Height()); return *this; } }; diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index e0265b5fabfe..9f6d94a8c28e 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -484,8 +484,8 @@ void SwTextFormatter::CalcDropHeight( const sal_uInt16 nLines ) { const SwLinePortion *const pOldCurr = GetCurr(); sal_uInt16 nDropHght = 0; - sal_uInt32 nAscent = 0; - sal_uInt32 nHeight = 0; + SwTwips nAscent = 0; + SwTwips nHeight = 0; sal_uInt16 nDropLns = 0; const bool bRegisterOld = IsRegisterOn(); m_bRegisterOn = false; @@ -545,8 +545,8 @@ void SwTextFormatter::CalcDropHeight( const sal_uInt16 nLines ) void SwTextFormatter::GuessDropHeight( const sal_uInt16 nLines ) { OSL_ENSURE( nLines, "GuessDropHeight: Give me more Lines!" ); - sal_uInt32 nAscent = 0; - sal_uInt32 nHeight = 0; + SwTwips nAscent = 0; + SwTwips nHeight = 0; SetDropLines( nLines ); if ( GetDropLines() > 1 ) { @@ -678,7 +678,7 @@ void SwTextPainter::PaintDropPortion() Point aLineOrigin( GetTopLeft() ); aLineOrigin.AdjustX(nX ); - sal_uInt32 nTmpAscent, nTmpHeight; + SwTwips nTmpAscent, nTmpHeight; CalcAscentAndHeight( nTmpAscent, nTmpHeight ); aLineOrigin.AdjustY(nTmpAscent ); GetInfo().SetIdx( GetStart() ); diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 35f94b20f948..326300f9a8ad 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -3323,7 +3323,7 @@ bool SwTextFrame::WouldFit( SwTwips &rMaxHeight, bool &bSplit, bool bTst ) return bRet; } -sal_uInt32 SwTextFrame::GetParHeight() const +SwTwips SwTextFrame::GetParHeight() const { OSL_ENSURE( ! IsVertical() || ! IsSwapped(), "SwTextFrame::GetParHeight with swapped frame" ); @@ -3344,7 +3344,7 @@ sal_uInt32 SwTextFrame::GetParHeight() const // TODO: Refactor and improve code const SwLineLayout* pLineLayout = GetPara(); - sal_uInt32 nHeight = pLineLayout ? pLineLayout->GetRealHeight() : 0; + SwTwips nHeight = pLineLayout ? pLineLayout->GetRealHeight() : 0; // Is this paragraph scrolled? Our height until now is at least // one line height too low then diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx index ed9e525da9de..5b3254b7c2ae 100644 --- a/sw/source/core/text/txtftn.cxx +++ b/sw/source/core/text/txtftn.cxx @@ -288,7 +288,7 @@ SwTwips SwTextFrame::GetFootnoteLine( const SwTextFootnote *pFootnote ) const &pFootnote->GetTextNode(), pFootnote->GetStart())); aLine.CharToLine( nPos ); - nRet = aLine.Y() + SwTwips(aLine.GetLineHeight()); + nRet = aLine.Y() + aLine.GetLineHeight(); if( IsVertical() ) nRet = SwitchHorizontalToVertical( nRet ); } diff --git a/sw/source/core/text/widorp.cxx b/sw/source/core/text/widorp.cxx index 141fd9437a84..526f4ea1b794 100644 --- a/sw/source/core/text/widorp.cxx +++ b/sw/source/core/text/widorp.cxx @@ -415,7 +415,7 @@ bool WidowsAndOrphans::FindWidows( SwTextFrame *pFrame, SwTextMargin &rLine ) const SwTwips nTmpRstHeight = aRectFnSet.BottomDist( pMaster->getFrameArea(), aRectFnSet.GetPrtBottom(*pMaster->GetUpper()) ); if ( nTmpRstHeight >= - SwTwips(rLine.GetInfo().GetParaPortion()->Height() ) ) + rLine.GetInfo().GetParaPortion()->Height() ) { pMaster->Prepare( PrepareHint::AdjustSizeWithoutFormatting ); pMaster->InvalidateSize_(); @@ -437,7 +437,7 @@ bool WidowsAndOrphans::FindWidows( SwTextFrame *pFrame, SwTextMargin &rLine ) { SwTwips nTmpRstHeight = aRectFnSet.BottomDist( pMaster->getFrameArea(), aRectFnSet.GetPrtBottom(*pMaster->GetUpper()) ); - if( nTmpRstHeight >= SwTwips(rLine.GetInfo().GetParaPortion()->Height() ) ) + if( nTmpRstHeight >= rLine.GetInfo().GetParaPortion()->Height() ) { pMaster->Prepare( PrepareHint::AdjustSizeWithoutFormatting ); pMaster->InvalidateSize_();