summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAron Budea <aron.budea@collabora.com>2021-10-04 23:52:33 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2021-10-06 02:21:59 +0200
commit702b7578754344464f0b3c39abb7bf025387a29b (patch)
tree8ac9dab789acb1d6ebc0de0d0c7939725830aaf3
parentRevert "sw: eliminate recently added static_cast<SwTwips>() calls" (diff)
downloadcore-702b7578754344464f0b3c39abb7bf025387a29b.tar.gz
core-702b7578754344464f0b3c39abb7bf025387a29b.zip
tdf#144122, tdf#144305 Revert "sw: allow the height of a line...
...to be larger than 65536 twips" Revert in libreoffice-7-2 due to hard to detect underflows introduced as a side-effect of the type changes. This reverts commit 301278b656e76b6f42af5cf8a6f5c6c02acfffeb. Change-Id: I0e10b4b56155c24314b84b34e8ce0bfa1999dd36 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123095 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--sw/qa/core/text/data/line-height.fodt32
-rw-r--r--sw/qa/core/text/text.cxx16
-rw-r--r--sw/source/core/inc/txtfrm.hxx2
-rw-r--r--sw/source/core/text/frmcrsr.cxx2
-rw-r--r--sw/source/core/text/frmform.cxx8
-rw-r--r--sw/source/core/text/frmpaint.cxx4
-rw-r--r--sw/source/core/text/inftxt.cxx4
-rw-r--r--sw/source/core/text/itrcrsr.cxx10
-rw-r--r--sw/source/core/text/itrform2.cxx26
-rw-r--r--sw/source/core/text/itrpaint.cxx12
-rw-r--r--sw/source/core/text/itrtxt.cxx10
-rw-r--r--sw/source/core/text/itrtxt.hxx8
-rw-r--r--sw/source/core/text/porfld.cxx8
-rw-r--r--sw/source/core/text/porfly.cxx2
-rw-r--r--sw/source/core/text/porlay.cxx8
-rw-r--r--sw/source/core/text/porlay.hxx10
-rw-r--r--sw/source/core/text/porlin.hxx8
-rw-r--r--sw/source/core/text/pormulti.cxx10
-rw-r--r--sw/source/core/text/porrst.cxx2
-rw-r--r--sw/source/core/text/possiz.hxx30
-rw-r--r--sw/source/core/text/txtdrop.cxx10
-rw-r--r--sw/source/core/text/txtfrm.cxx4
22 files changed, 89 insertions, 137 deletions
diff --git a/sw/qa/core/text/data/line-height.fodt b/sw/qa/core/text/data/line-height.fodt
deleted file mode 100644
index d784ec241bed..000000000000
--- a/sw/qa/core/text/data/line-height.fodt
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<office:document xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:mimetype="application/vnd.oasis.opendocument.text">
- <office:automatic-styles>
- <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics"/>
- <style:page-layout style:name="pm1">
- <style:page-layout-properties fo:page-width="84.1cm" fo:page-height="118.9cm" fo:margin-top="0cm" fo:margin-bottom="0cm" fo:margin-left="0cm" fo:margin-right="0cm"/>
- </style:page-layout>
- </office:automatic-styles>
- <office:master-styles>
- <style:master-page style:name="Standard" style:page-layout-name="pm1"/>
- </office:master-styles>
- <office:body>
- <office:text>
- <text:p><draw:frame draw:style-name="fr1" draw:name="Image1" text:anchor-type="as-char" svg:width="84.1cm" svg:height="118.9cm" draw:z-index="0"><draw:image draw:mime-type="image/png"><office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz
- UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA
- AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4
- AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+
- BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49
- cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn
- /878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF
- QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo
- YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo
- 2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A
- cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA
- AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A
- hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6
- 5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA
- AABJRU5ErkJggg==
- </office:binary-data></draw:image></draw:frame></text:p>
- </office:text>
- </office:body>
-</office:document>
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index d38b6a3e62cc..4db880e687f4 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -135,22 +135,6 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTabOverMarginSection)
CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(5000), nWidth);
}
-CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLineHeight)
-{
- // Given a document with an as-char image, height in twips not fitting into sal_uInt16:
- createSwDoc(DATA_DIRECTORY, "line-height.fodt");
-
- // When laying out that document:
- xmlDocUniquePtr pXmlDoc = parseLayoutDump();
-
- // Then make sure its top is the top of the page:
- // Without the accompanying fix in place, this test would have failed with:
- // - Expected: 284
- // - Actual : -65252
- // due to various unsigned integer truncations.
- assertXPath(pXmlDoc, "//fly/infos/bounds", "top", OUString::number(DOCUMENTBORDER));
-}
-
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index 0a2f4fbbd2bc..abef52f448aa 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -578,7 +578,7 @@ public:
virtual void CheckDirection( bool bVert ) override;
/// Returns the sum of line height in pLine
- sal_uInt32 GetParHeight() const;
+ sal_uInt16 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 554599d60568..b120d17399a7 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() + static_cast<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 763645891c88..f9f6935e9a9d 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -1182,8 +1182,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 sal_uInt16 nOldAscent = pOldCur->GetAscent();
+ const sal_uInt16 nOldHeight = pOldCur->Height();
const SwTwips nOldWidth = pOldCur->Width() + pOldCur->GetHangingMargin();
const bool bOldHyph = pOldCur->IsEndHyph();
SwTwips nOldTop = 0;
@@ -1205,7 +1205,7 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev )
bOldHyph == pNew->IsEndHyph();
if ( bUnChg && !bPrev )
{
- const tools::Long nWidthDiff = nOldWidth > static_cast<SwTwips>(pNew->Width())
+ const tools::Long nWidthDiff = nOldWidth > pNew->Width()
? nOldWidth - pNew->Width()
: pNew->Width() - nOldWidth;
@@ -1259,7 +1259,7 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev )
rLine.SetUnclipped( false );
}
}
- SwTwips nRght = std::max( nOldWidth, static_cast<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/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index 93007bfcf539..7f35ea7633b6 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() + static_cast<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;
+ sal_uInt16 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 cb7cb3b36c63..6dbfdc4d6e56 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1023,13 +1023,13 @@ void SwTextPaintInfo::DrawRedArrow( const SwLinePortion &rPor ) const
{
aRect.Pos().AdjustY(20 - GetAscent() );
aRect.Pos().AdjustX(20 );
- if( aSize.Height() > static_cast<SwTwips>(rPor.Height()) )
+ if( aSize.Height() > rPor.Height() )
aRect.Height( rPor.Height() );
cChar = CHAR_LEFT_ARROW;
}
else
{
- if( aSize.Height() > static_cast<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 94ee6dd7562f..0abc174dc514 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;
+ sal_uInt16 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
+ sal_uInt16 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;
+ sal_uInt16 nPorHeight = nTmpHeight;
+ sal_uInt16 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( static_cast<SwTwips>(nTmpHeight) < pOrig->Height() )
+ if( nTmpHeight < pOrig->Height() )
{
nTmpAscent = nPorAscent;
nTmpHeight = sal_uInt16( pOrig->Height() );
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index be712337c8e9..65fb9e52145c 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -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 sal_uInt16 nOldHeight = m_pCurr->Height();
+ const sal_uInt16 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;
+ sal_uInt16 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();
+ sal_uInt16 nLineHeight = m_pCurr->Height();
m_pCurr->SetClipping( false );
SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame()));
@@ -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 sal_uInt16 nTmpHeight = pCurrent->GetRealHeight();
+ sal_uInt16 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 ( static_cast<SwTwips>(m_pCurr->GetRealHeight()) > nHeight )
+ if ( m_pCurr->GetRealHeight() > nHeight )
nTop += m_pCurr->GetRealHeight() - nHeight;
else
// Important for fixed space between lines
@@ -2553,7 +2553,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
if( nH < SAL_MAX_UINT16 )
pFly->Height( sal_uInt16( nH ) );
}
- if( nAscent < static_cast<SwTwips>(pFly->Height()) )
+ if( nAscent < pFly->Height() )
pFly->SetAscent( sal_uInt16(nAscent) );
else
pFly->SetAscent( pFly->Height() );
@@ -2569,7 +2569,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
else
{
pFly->Height( sal_uInt16(aInter.Height()) );
- if( nAscent < static_cast<SwTwips>(pFly->Height()) )
+ if( nAscent < pFly->Height() )
pFly->SetAscent( sal_uInt16(nAscent) );
else
pFly->SetAscent( pFly->Height() );
@@ -2645,7 +2645,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;
+ sal_uInt16 nAscent = 0;
const bool bTextFrameVertical = GetInfo().GetTextFrame()->IsVertical();
@@ -2655,9 +2655,9 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf,
pFly->GetRefPoint().Y() );
if ( bUseFlyAscent )
- nAscent = std::abs( int( bTextFrameVertical ?
+ nAscent = static_cast<sal_uInt16>( std::abs( int( bTextFrameVertical ?
pFly->GetRelPos().X() :
- pFly->GetRelPos().Y() ) );
+ pFly->GetRelPos().Y() ) ) );
// Check if be prefer to use the ascent of the last portion:
if ( IsQuick() ||
@@ -2666,7 +2666,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf,
{
nAscent = rInf.GetLast()->GetAscent();
}
- else if( static_cast<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 88c8236887ad..75493bad82be 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 && static_cast<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( static_cast<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;
+ sal_uInt16 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() + static_cast<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 &&
- static_cast<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 > static_cast<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 88c09c47e7ce..220977a24d6d 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( sal_uInt16 &rAscent, sal_uInt16 &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,
+sal_uInt16 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
const SwLinePortion* pPor,
- sal_uInt32 nPorHeight, sal_uInt32 nPorAscent,
+ sal_uInt16 nPorHeight, sal_uInt16 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();
+ sal_uInt16 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 + static_cast<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 960d383fe7cf..f155ee6cc484 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;
+ sal_uInt16 GetLineHeight() const { return m_pCurr->GetRealHeight(); }
+ void CalcAscentAndHeight( sal_uInt16 &rAscent, sal_uInt16 &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,
+ sal_uInt16 AdjustBaseLine( const SwLineLayout& rLine, const SwLinePortion* pPor,
+ sal_uInt16 nPorHeight = 0, sal_uInt16 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 6f576983ab55..21ab8eecd351 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -594,10 +594,10 @@ bool SwNumberPortion::Format( SwTextFormatInfo &rInf )
// Height has to be changed
if ( rInf.IsMulti() )
{
- if ( static_cast<SwTwips>(Height()) < nDiff )
+ if ( Height() < nDiff )
Height( sal_uInt16( nDiff ) );
}
- else if( static_cast<SwTwips>(Width()) < nDiff )
+ else if( Width() < nDiff )
Width( sal_uInt16(nDiff) );
}
return bFull;
@@ -868,7 +868,7 @@ bool SwGrfNumPortion::Format( SwTextFormatInfo &rInf )
SetHide( true );
}
- if( static_cast<SwTwips>(Width()) < nDiff )
+ if( Width() < nDiff )
Width( sal_uInt16(nDiff) );
return bFull;
}
@@ -1257,7 +1257,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf )
Height( Height() + nMainAscent - GetAscent() );
SetAscent( nMainAscent );
}
- if( static_cast<SwTwips>(Height()) < nMainAscent + nMainDescent )
+ if( Height() < nMainAscent + nMainDescent )
Height( nMainAscent + nMainDescent );
// We calculate the x positions of the characters in both lines...
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 000acd4bb61d..7b43703e2ff9 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -424,7 +424,7 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase,
SwTwips nRelPos = aObjPositioning.GetRelPosY();
if ( nRelPos < 0 )
{
- mnAscent = -nRelPos;
+ mnAscent = static_cast<sal_uInt16>(-nRelPos);
if( mnAscent > Height() )
Height( mnAscent );
}
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 95809edf540d..a9db3460a09d 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -199,7 +199,7 @@ void SwLineLayout::DeleteNext()
delete a;
}
-void SwLineLayout::Height(const sal_uInt32 nNew, const bool bText)
+void SwLineLayout::Height(const sal_uInt16 nNew, const bool bText)
{
SwPosSize::Height(nNew);
if (bText)
@@ -374,7 +374,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
}
else
{
- const sal_uInt32 nLineHeight = Height();
+ const sal_uInt16 nLineHeight = Height();
Init( GetNextPortion() );
SwLinePortion *pPos = mpNextPortion;
SwLinePortion *pLast = this;
@@ -437,8 +437,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();
+ sal_uInt16 nPosHeight = pPos->Height();
+ sal_uInt16 nPosAscent = pPos->GetAscent();
SAL_WARN_IF( nPosHeight < nPosAscent,
"sw.core", "SwLineLayout::CalcLine: bad ascent or height" );
diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx
index 5234a537fa4c..249ed81f088f 100644
--- a/sw/source/core/text/porlay.hxx
+++ b/sw/source/core/text/porlay.hxx
@@ -81,8 +81,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
+ sal_uInt16 m_nRealHeight; // The height resulting from line spacing and register
+ sal_uInt16 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;
@@ -108,7 +108,7 @@ private:
public:
// From SwPosSize
using SwPosSize::Height;
- virtual void Height(const sal_uInt32 nNew, const bool bText = true) override;
+ virtual void Height(const sal_uInt16 nNew, const bool bText = true) override;
// From SwLinePortion
virtual SwLinePortion *Insert( SwLinePortion *pPortion ) override;
@@ -165,8 +165,8 @@ 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( sal_uInt16 nNew ) { m_nRealHeight = nNew; }
+ sal_uInt16 GetRealHeight() const { return m_nRealHeight; }
sal_uInt16 GetTextHeight() const { return m_nTextHeight; }
diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx
index bca2025a2c6b..0a12ae25af3c 100644
--- a/sw/source/core/text/porlin.hxx
+++ b/sw/source/core/text/porlin.hxx
@@ -53,7 +53,7 @@ protected:
SwLinePortion *mpNextPortion;
// Count of chars and spaces on the line
TextFrameIndex mnLineLength;
- sal_uInt32 mnAscent; // Maximum ascender
+ sal_uInt16 mnAscent; // Maximum ascender
SwLinePortion();
private:
@@ -73,9 +73,9 @@ 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; }
+ sal_uInt16 &GetAscent() { return mnAscent; }
+ sal_uInt16 GetAscent() const { return mnAscent; }
+ void SetAscent( const sal_uInt16 nNewAsc ) { mnAscent = nNewAsc; }
void PrtWidth( sal_uInt16 nNewWidth ) { Width( nNewWidth ); }
sal_uInt16 PrtWidth() const { return Width(); }
void AddPrtWidth( const sal_uInt16 nNew ) { Width( Width() + nNew ); }
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index def38b80ee04..f713e976fbed 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -399,7 +399,7 @@ void SwDoubleLinePortion::FormatBrackets( SwTextFormatInfo &rInf, SwTwips& nMaxW
m_pBracket->nAscent = rInf.GetAscent();
m_pBracket->nHeight = aSize.Height();
aTmpFnt.SetActual( nActualScr );
- if( nMaxWidth > static_cast<SwTwips>(aSize.Width()) )
+ if( nMaxWidth > aSize.Width() )
{
m_pBracket->nPreWidth = aSize.Width();
nMaxWidth -= aSize.Width();
@@ -428,7 +428,7 @@ void SwDoubleLinePortion::FormatBrackets( SwTextFormatInfo &rInf, SwTwips& nMaxW
}
if( aSize.Height() > m_pBracket->nHeight )
m_pBracket->nHeight = aSize.Height();
- if( nMaxWidth > static_cast<SwTwips>(aSize.Width()) )
+ if( nMaxWidth > aSize.Width() )
{
m_pBracket->nPostWidth = aSize.Width();
nMaxWidth -= aSize.Width();
@@ -1679,7 +1679,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, 0 );
GetInfo().Y( nOfst + nLineDiff );
// Draw the ruby text on top of the preserved space.
GetInfo().X( GetInfo().X() - pPor->Height() );
@@ -2169,7 +2169,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 + static_cast<SwTwips>(rMulti.Width()) + 6 )
+ if( nActWidth > nTmpX + rMulti.Width() + 6 )
nActWidth = nTmpX + rMulti.Width() + 6;
nMaxWidth = nActWidth;
nActWidth = ( 3 * nMaxWidth + nMinWidth + 3 ) / 4;
@@ -2520,7 +2520,7 @@ SwTextCursorSave::SwTextCursorSave( SwTextCursor* pCursor,
{
pCursor->m_nStart = nCurrStart;
pCursor->m_pCurr = &pMulti->GetRoot();
- while( pCursor->Y() + static_cast<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/porrst.cxx b/sw/source/core/text/porrst.cxx
index d8d48f3671dc..1164a0fcb183 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((static_cast<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..fc31ffc11e39 100644
--- a/sw/source/core/text/possiz.hxx
+++ b/sw/source/core/text/possiz.hxx
@@ -24,17 +24,17 @@
// Compared to the SV sizes SwPosSize is always positive
class SwPosSize
{
- sal_uInt32 m_nWidth;
- sal_uInt32 m_nHeight;
+ sal_uInt16 m_nWidth;
+ sal_uInt16 m_nHeight;
public:
- SwPosSize( const sal_uInt32 nW = 0, const sal_uInt32 nH = 0 )
+ SwPosSize( const sal_uInt16 nW = 0, const sal_uInt16 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(sal_uInt16(rSize.Width()))
+ ,m_nHeight(sal_uInt16(rSize.Height()))
{
}
#if defined(__COVERITY__)
@@ -46,25 +46,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; }
+ sal_uInt16 Height() const { return m_nHeight; }
+ virtual void Height(const sal_uInt16 nNew, const bool = true) { m_nHeight = nNew; }
+ sal_uInt16 Width() const { return m_nWidth; }
+ void Width( const sal_uInt16 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 = sal_uInt16(rSize.Width());
+ m_nHeight = sal_uInt16(rSize.Height());
}
void SvXSize( const Size &rSize )
{
- m_nHeight = sal_uInt32(rSize.Width());
- m_nWidth = sal_uInt32(rSize.Height());
+ m_nHeight = sal_uInt16(rSize.Width());
+ m_nWidth = sal_uInt16(rSize.Height());
}
SwPosSize& operator=( const Size &rSize )
{
- m_nWidth = sal_uInt32(rSize.Width());
- m_nHeight = sal_uInt32(rSize.Height());
+ m_nWidth = sal_uInt16(rSize.Width());
+ m_nHeight = sal_uInt16(rSize.Height());
return *this;
}
};
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index e5ac47c692f7..54c60551f7bb 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;
+ sal_uInt16 nAscent = 0;
+ sal_uInt16 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;
+ sal_uInt16 nAscent = 0;
+ sal_uInt16 nHeight = 0;
SetDropLines( nLines );
if ( GetDropLines() > 1 )
{
@@ -678,7 +678,7 @@ void SwTextPainter::PaintDropPortion()
Point aLineOrigin( GetTopLeft() );
aLineOrigin.AdjustX(nX );
- sal_uInt32 nTmpAscent, nTmpHeight;
+ sal_uInt16 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 a85f2977a8d4..57ef2431daac 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -3322,7 +3322,7 @@ bool SwTextFrame::WouldFit( SwTwips &rMaxHeight, bool &bSplit, bool bTst )
return bRet;
}
-sal_uInt32 SwTextFrame::GetParHeight() const
+sal_uInt16 SwTextFrame::GetParHeight() const
{
OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
"SwTextFrame::GetParHeight with swapped frame" );
@@ -3343,7 +3343,7 @@ sal_uInt32 SwTextFrame::GetParHeight() const
// TODO: Refactor and improve code
const SwLineLayout* pLineLayout = GetPara();
- sal_uInt32 nHeight = pLineLayout ? pLineLayout->GetRealHeight() : 0;
+ sal_uInt16 nHeight = pLineLayout ? pLineLayout->GetRealHeight() : 0;
// Is this paragraph scrolled? Our height until now is at least
// one line height too low then