[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu May 20 20:38:44 UTC 2021


 sw/qa/core/text/data/line-height.fodt |   32 ++++++++++++++++++++++++++++++++
 sw/qa/core/text/text.cxx              |   16 ++++++++++++++++
 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/frmpaint.cxx      |    4 ++--
 sw/source/core/text/inftxt.cxx        |    4 ++--
 sw/source/core/text/itrcrsr.cxx       |   10 +++++-----
 sw/source/core/text/itrform2.cxx      |   26 +++++++++++++-------------
 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        |    8 ++++----
 sw/source/core/text/porfly.cxx        |    2 +-
 sw/source/core/text/porlay.cxx        |    8 ++++----
 sw/source/core/text/porlay.hxx        |   10 +++++-----
 sw/source/core/text/porlin.hxx        |    8 ++++----
 sw/source/core/text/pormulti.cxx      |   10 +++++-----
 sw/source/core/text/porrst.cxx        |    2 +-
 sw/source/core/text/possiz.hxx        |   30 +++++++++++++++---------------
 sw/source/core/text/txtdrop.cxx       |   10 +++++-----
 sw/source/core/text/txtfrm.cxx        |    4 ++--
 22 files changed, 137 insertions(+), 89 deletions(-)

New commits:
commit 301278b656e76b6f42af5cf8a6f5c6c02acfffeb
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu May 20 18:02:12 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu May 20 22:38:03 2021 +0200

    sw: allow the height of a line to be larger than 65536 twips
    
    The line height can be quite large if the line contains an as-char
    image.
    
    Found by temporarily changing static_cast<sal_uInt16>() in sw/ to a
    template function to make these conversions implicit (excluding cases
    where the input and output types can't convert implicitly), then asking
    -fsanitize=implicit-unsigned-integer-truncation
    -fsanitize=implicit-signed-integer-truncation to flag the problematic
    conversions.
    
    The first hit was in SwFlyCntPortion::SetBase() (that's where 67408
    turns into 1872), then the same pattern at many other places.
    
    Change-Id: Ie12f490ed8dd5c531f11506c97598ce4f7610e2e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115873
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/core/text/data/line-height.fodt b/sw/qa/core/text/data/line-height.fodt
new file mode 100644
index 000000000000..d784ec241bed
--- /dev/null
+++ b/sw/qa/core/text/data/line-height.fodt
@@ -0,0 +1,32 @@
+<?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 4db880e687f4..d38b6a3e62cc 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -135,6 +135,22 @@ 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 abef52f448aa..0a2f4fbbd2bc 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_uInt16 GetParHeight() const;
+    sal_uInt32 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 a4cab82d92b1..21af2c622af1 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() + aLine.GetLineHeight() > nMaxY )
+        while( aLine.Y() + static_cast<SwTwips>(aLine.GetLineHeight()) > nMaxY )
         {
             if( !aLine.Prev() )
                 break;
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 0304661e8438..5aade6a0169b 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -1177,8 +1177,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_uInt16 nOldAscent = pOldCur->GetAscent();
-    const sal_uInt16 nOldHeight = pOldCur->Height();
+    const sal_uInt32 nOldAscent = pOldCur->GetAscent();
+    const sal_uInt32 nOldHeight = pOldCur->Height();
     const SwTwips nOldWidth = pOldCur->Width() + pOldCur->GetHangingMargin();
     const bool bOldHyph = pOldCur->IsEndHyph();
     SwTwips nOldTop = 0;
@@ -1200,7 +1200,7 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev )
                   bOldHyph == pNew->IsEndHyph();
     if ( bUnChg && !bPrev )
     {
-        const tools::Long nWidthDiff = nOldWidth > pNew->Width()
+        const tools::Long nWidthDiff = nOldWidth > static_cast<SwTwips>(pNew->Width())
                                 ? nOldWidth - pNew->Width()
                                 : pNew->Width() - nOldWidth;
 
@@ -1254,7 +1254,7 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev )
                 rLine.SetUnclipped( false );
             }
         }
-        SwTwips nRght = std::max( nOldWidth, pNew->Width() +
+        SwTwips nRght = std::max( nOldWidth, static_cast<SwTwips>(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 7f35ea7633b6..93007bfcf539 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() + aLine.GetLineHeight() <= rRect.Top() )
+        while( aLine.Y() + static_cast<SwTwips>(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_uInt16 nTmpHeight, nTmpAscent;
+                            sal_uInt32 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 bb63a36ae157..261a171d3d6d 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() > rPor.Height() )
+        if( aSize.Height() > static_cast<SwTwips>(rPor.Height()) )
             aRect.Height( rPor.Height() );
         cChar = CHAR_LEFT_ARROW;
     }
     else
     {
-        if( aSize.Height() > rPor.Height() )
+        if( aSize.Height() > static_cast<SwTwips>(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 f7c6380cb3bb..c8c2803cb9b0 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_uInt16 nTmpHeight, nTmpAscent;
+    sal_uInt32 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_uInt16 nTmpAscent, nTmpHeight;  // Line height
+    sal_uInt32 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_uInt16 nPorHeight = nTmpHeight;
-        sal_uInt16 nPorAscent = nTmpAscent;
+        sal_uInt32 nPorHeight = nTmpHeight;
+        sal_uInt32 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( nTmpHeight < pOrig->Height() )
+                    if( static_cast<SwTwips>(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 d35159f12d84..504a13668fb2 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -1574,8 +1574,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_uInt16 nOldHeight = m_pCurr->Height();
-    const sal_uInt16 nOldAscent = m_pCurr->GetAscent();
+    const sal_uInt32 nOldHeight = m_pCurr->Height();
+    const sal_uInt32 nOldAscent = m_pCurr->GetAscent();
 
     m_pCurr->SetEndHyph( false );
     m_pCurr->SetMidHyph( false );
@@ -1655,7 +1655,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos)
         if ( IsFlyInCntBase() && (!IsQuick() || (pPorTmp && pPorTmp->IsFlyCntPortion() && !pPorTmp->GetNextPortion() &&
             m_pCurr->Height() > pPorTmp->Height())))
         {
-            sal_uInt16 nTmpAscent, nTmpHeight;
+            sal_uInt32 nTmpAscent, nTmpHeight;
             CalcAscentAndHeight( nTmpAscent, nTmpHeight );
             AlignFlyInCntBase( Y() + tools::Long( nTmpAscent ) );
             m_pCurr->CalcLine( *this, GetInfo() );
@@ -1772,7 +1772,7 @@ void SwTextFormatter::RecalcRealHeight()
 
 void SwTextFormatter::CalcRealHeight( bool bNewLine )
 {
-    sal_uInt16 nLineHeight = m_pCurr->Height();
+    sal_uInt32 nLineHeight = m_pCurr->Height();
     m_pCurr->SetClipping( false );
 
     SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame()));
@@ -2099,8 +2099,8 @@ void SwTextFormatter::UpdatePos( SwLineLayout *pCurrent, Point aStart,
     SwTwips nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc;
     pCurrent->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc );
 
-    const sal_uInt16 nTmpHeight = pCurrent->GetRealHeight();
-    sal_uInt16 nAscent = pCurrent->GetAscent() + nTmpHeight - pCurrent->Height();
+    const sal_uInt32 nTmpHeight = pCurrent->GetRealHeight();
+    sal_uInt32 nAscent = pCurrent->GetAscent() + nTmpHeight - pCurrent->Height();
     AsCharFlags nFlags = AsCharFlags::UlSpace;
     if( GetMulti() )
     {
@@ -2365,7 +2365,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
         nAscent = pLast->GetAscent();
         nHeight = pLast->Height();
 
-        if ( m_pCurr->GetRealHeight() > nHeight )
+        if ( static_cast<SwTwips>(m_pCurr->GetRealHeight()) > nHeight )
             nTop += m_pCurr->GetRealHeight() - nHeight;
         else
             // Important for fixed space between lines
@@ -2496,7 +2496,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
             if( nH < SAL_MAX_UINT16 )
                 pFly->Height( sal_uInt16( nH ) );
         }
-        if( nAscent < pFly->Height() )
+        if( nAscent < static_cast<SwTwips>(pFly->Height()) )
             pFly->SetAscent( sal_uInt16(nAscent) );
         else
             pFly->SetAscent( pFly->Height() );
@@ -2512,7 +2512,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
         else
         {
             pFly->Height( sal_uInt16(aInter.Height()) );
-            if( nAscent < pFly->Height() )
+            if( nAscent < static_cast<SwTwips>(pFly->Height()) )
                 pFly->SetAscent( sal_uInt16(nAscent) );
             else
                 pFly->SetAscent( pFly->Height() );
@@ -2588,7 +2588,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_uInt16 nAscent = 0;
+    sal_uInt32 nAscent = 0;
 
     const bool bTextFrameVertical = GetInfo().GetTextFrame()->IsVertical();
 
@@ -2598,9 +2598,9 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf,
                                       pFly->GetRefPoint().Y() );
 
     if ( bUseFlyAscent )
-         nAscent = static_cast<sal_uInt16>( std::abs( int( bTextFrameVertical ?
+         nAscent = 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() ||
@@ -2609,7 +2609,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf,
     {
         nAscent = rInf.GetLast()->GetAscent();
     }
-    else if( nAscent > nFlyAsc )
+    else if( static_cast<SwTwips>(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 75493bad82be..88c8236887ad 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 && GetInfo().X() + pPor->Width() + (pPor->Height()/2)
+        while( pPor && static_cast<SwTwips>(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( nTmp + (pPor->Height()/2) >= nPaintOfst )
+                if( static_cast<SwTwips>(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_uInt16 nTmpHeight, nTmpAscent;
+    sal_uInt32 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() + nTmpHeight > rPaint.Top() + rPaint.Height() )
+            GetInfo().GetPos().Y() + static_cast<SwTwips>(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 &&
-            GetInfo().X() + pPor->Width() + ( pPor->Height() / 2 ) > nMaxRight )
+            static_cast<SwTwips>(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 > nTmpHeight/2 && GetPrevLine() ) ) ) ||
+                        ( nDiff > static_cast<SwTwips>(nTmpHeight)/2 && GetPrevLine() ) ) ) ||
                     (nDiff >= 0 && bNextUndersized) )
 
                 {
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index 220977a24d6d..88c09c47e7ce 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_uInt16 &rAscent, sal_uInt16 &rHeight ) const
+void SwTextIter::CalcAscentAndHeight( sal_uInt32 &rAscent, sal_uInt32 &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_uInt16 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
+sal_uInt32 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
                                     const SwLinePortion* pPor,
-                                    sal_uInt16 nPorHeight, sal_uInt16 nPorAscent,
+                                    sal_uInt32 nPorHeight, sal_uInt32 nPorAscent,
                                     const bool bAutoToCentered ) const
 {
     if ( pPor )
@@ -222,7 +222,7 @@ sal_uInt16 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
         nPorAscent = pPor->GetAscent();
     }
 
-    sal_uInt16 nOfst = rLine.GetRealHeight() - rLine.Height();
+    sal_uInt32 nOfst = rLine.GetRealHeight() - rLine.Height();
 
     SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame()));
 
@@ -299,7 +299,7 @@ sal_uInt16 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
 
 void SwTextIter::TwipsToLine( const SwTwips y)
 {
-    while( m_nY + GetLineHeight() <= y && Next() )
+    while( m_nY + static_cast<SwTwips>(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 f155ee6cc484..960d383fe7cf 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_uInt16 GetLineHeight() const { return m_pCurr->GetRealHeight(); }
-    void CalcAscentAndHeight( sal_uInt16 &rAscent, sal_uInt16 &rHeight ) const;
+    sal_uInt32 GetLineHeight() const { return m_pCurr->GetRealHeight(); }
+    void CalcAscentAndHeight( sal_uInt32 &rAscent, sal_uInt32 &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_uInt16 AdjustBaseLine( const SwLineLayout& rLine, const SwLinePortion* pPor,
-                           sal_uInt16 nPorHeight = 0, sal_uInt16 nAscent = 0,
+    sal_uInt32 AdjustBaseLine( const SwLineLayout& rLine, const SwLinePortion* pPor,
+                           sal_uInt32 nPorHeight = 0, sal_uInt32 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
old mode 100644
new mode 100755
index 21ab8eecd351..6f576983ab55
--- 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 ( Height() < nDiff )
+            if ( static_cast<SwTwips>(Height()) < nDiff )
                 Height( sal_uInt16( nDiff ) );
         }
-        else if( Width() < nDiff )
+        else if( static_cast<SwTwips>(Width()) < nDiff )
             Width( sal_uInt16(nDiff) );
     }
     return bFull;
@@ -868,7 +868,7 @@ bool SwGrfNumPortion::Format( SwTextFormatInfo &rInf )
             SetHide( true );
     }
 
-    if( Width() < nDiff )
+    if( static_cast<SwTwips>(Width()) < nDiff )
         Width( sal_uInt16(nDiff) );
     return bFull;
 }
@@ -1257,7 +1257,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf )
         Height( Height() + nMainAscent - GetAscent() );
         SetAscent( nMainAscent );
     }
-    if( Height() < nMainAscent + nMainDescent )
+    if( static_cast<SwTwips>(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 34edc3082b71..8fd2bc4c9d3c 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -421,7 +421,7 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase,
         SwTwips nRelPos = aObjPositioning.GetRelPosY();
         if ( nRelPos < 0 )
         {
-            mnAscent = static_cast<sal_uInt16>(-nRelPos);
+            mnAscent = -nRelPos;
             if( mnAscent > Height() )
                 Height( mnAscent );
         }
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 3d26e990c50c..ae4f499992b2 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_uInt16 nNew, const bool bText)
+void SwLineLayout::Height(const sal_uInt32 nNew, const bool bText)
 {
     SwPosSize::Height(nNew);
     if (bText)
@@ -374,7 +374,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
         }
         else
         {
-            const sal_uInt16 nLineHeight = Height();
+            const sal_uInt32 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_uInt16 nPosHeight = pPos->Height();
-                sal_uInt16 nPosAscent = pPos->GetAscent();
+                sal_uInt32 nPosHeight = pPos->Height();
+                sal_uInt32 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 249ed81f088f..5234a537fa4c 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_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
+    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
     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_uInt16 nNew, const bool bText = true) override;
+    virtual void Height(const sal_uInt32 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_uInt16 nNew ) { m_nRealHeight = nNew; }
-    sal_uInt16 GetRealHeight() const { return m_nRealHeight; }
+    void SetRealHeight( sal_uInt32 nNew ) { m_nRealHeight = nNew; }
+    sal_uInt32 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 3d2b8dad29e4..2648dbbdf6c5 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_uInt16 mnAscent;      // Maximum ascender
+    sal_uInt32 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_uInt16 &GetAscent() { return mnAscent; }
-    sal_uInt16 GetAscent() const { return mnAscent; }
-    void SetAscent( const sal_uInt16 nNewAsc ) { mnAscent = nNewAsc; }
+    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_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 c51fb973ad29..37c5a4e48594 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();
         pTmpFnt->SetActual( nActualScr );
-        if( nMaxWidth > aSize.Width() )
+        if( nMaxWidth > static_cast<SwTwips>(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 > aSize.Width() )
+        if( nMaxWidth > static_cast<SwTwips>(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, 0 );
+            SwTwips nLineDiff = std::max(( rMulti.GetRoot().Height() - pPor->Width() ) / 2, static_cast<sal_uInt32>(0) );
             GetInfo().Y( nOfst + nLineDiff );
             // Draw the ruby text on top of the preserved space.
             GetInfo().X( GetInfo().X() - pPor->Height() );
@@ -2168,7 +2168,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 + rMulti.Width() + 6 )
+            if( nActWidth > nTmpX + static_cast<SwTwips>(rMulti.Width()) + 6 )
                 nActWidth = nTmpX + rMulti.Width() + 6;
             nMaxWidth = nActWidth;
             nActWidth = ( 3 * nMaxWidth + nMinWidth + 3 ) / 4;
@@ -2519,7 +2519,7 @@ SwTextCursorSave::SwTextCursorSave( SwTextCursor* pCursor,
 {
     pCursor->m_nStart = nCurrStart;
     pCursor->m_pCurr = &pMulti->GetRoot();
-    while( pCursor->Y() + pCursor->GetLineHeight() < nY &&
+    while( pCursor->Y() + static_cast<SwTwips>(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 1164a0fcb183..d8d48f3671dc 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((Width() / 2) - mnHalfCharWidth);
+    auto const deltaX((static_cast<SwTwips>(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 fc31ffc11e39..543f037fde55 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_uInt16 m_nWidth;
-    sal_uInt16 m_nHeight;
+    sal_uInt32 m_nWidth;
+    sal_uInt32 m_nHeight;
 public:
-    SwPosSize( const sal_uInt16 nW = 0, const sal_uInt16 nH = 0 )
+    SwPosSize( const sal_uInt32 nW = 0, const sal_uInt32 nH = 0 )
         : m_nWidth(nW)
         , m_nHeight(nH)
     {
     }
     explicit SwPosSize( const Size &rSize )
-        : m_nWidth(sal_uInt16(rSize.Width()))
-        ,m_nHeight(sal_uInt16(rSize.Height()))
+        : m_nWidth(sal_uInt32(rSize.Width()))
+        ,m_nHeight(sal_uInt32(rSize.Height()))
     {
     }
 #if defined(__COVERITY__)
@@ -46,25 +46,25 @@ public:
     SwPosSize(SwPosSize &&) = default;
     SwPosSize & operator =(SwPosSize const &) = default;
     SwPosSize & operator =(SwPosSize &&) = default;
-    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; }
+    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; }
     Size SvLSize() const { return Size( m_nWidth, m_nHeight ); }
     void SvLSize( const Size &rSize )
     {
-        m_nWidth  = sal_uInt16(rSize.Width());
-        m_nHeight = sal_uInt16(rSize.Height());
+        m_nWidth  = sal_uInt32(rSize.Width());
+        m_nHeight = sal_uInt32(rSize.Height());
     }
     void SvXSize( const Size &rSize )
     {
-        m_nHeight = sal_uInt16(rSize.Width());
-        m_nWidth = sal_uInt16(rSize.Height());
+        m_nHeight = sal_uInt32(rSize.Width());
+        m_nWidth = sal_uInt32(rSize.Height());
     }
     SwPosSize& operator=( const Size &rSize )
     {
-        m_nWidth  = sal_uInt16(rSize.Width());
-        m_nHeight = sal_uInt16(rSize.Height());
+        m_nWidth  = sal_uInt32(rSize.Width());
+        m_nHeight = sal_uInt32(rSize.Height());
         return *this;
     }
 };
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index 54c60551f7bb..e5ac47c692f7 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_uInt16 nAscent = 0;
-    sal_uInt16 nHeight = 0;
+    sal_uInt32 nAscent = 0;
+    sal_uInt32 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_uInt16 nAscent = 0;
-    sal_uInt16 nHeight = 0;
+    sal_uInt32 nAscent = 0;
+    sal_uInt32 nHeight = 0;
     SetDropLines( nLines );
     if ( GetDropLines() > 1 )
     {
@@ -678,7 +678,7 @@ void SwTextPainter::PaintDropPortion()
     Point aLineOrigin( GetTopLeft() );
 
     aLineOrigin.AdjustX(nX );
-    sal_uInt16 nTmpAscent, nTmpHeight;
+    sal_uInt32 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 6a91cfd36a3d..d640737b773d 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_uInt16 SwTextFrame::GetParHeight() const
+sal_uInt32 SwTextFrame::GetParHeight() const
 {
     OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
             "SwTextFrame::GetParHeight with swapped frame" );
@@ -3343,7 +3343,7 @@ sal_uInt16 SwTextFrame::GetParHeight() const
 
     // TODO: Refactor and improve code
     const SwLineLayout* pLineLayout = GetPara();
-    sal_uInt16 nHeight = pLineLayout ? pLineLayout->GetRealHeight() : 0;
+    sal_uInt32 nHeight = pLineLayout ? pLineLayout->GetRealHeight() : 0;
 
     // Is this paragraph scrolled? Our height until now is at least
     // one line height too low then


More information about the Libreoffice-commits mailing list