[Libreoffice-commits] core.git: Branch 'libreoffice-6-1-0' - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jul 27 08:07:07 UTC 2018
sw/source/core/text/porfld.cxx | 2 +-
sw/source/uibase/uiview/viewtab.cxx | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
New commits:
commit 5e013eab178df3a27fe036230c80611dd1dccc7d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 23 15:08:41 2018 +0200
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jul 27 10:06:40 2018 +0200
tdf#118716 Inner border of an embedded table can't be dragged around
regression from
commit f14b9d30293f180500fc56d81e5390021758e7c1
convert (a>b?a:b) to std::max(a,b)
In this code
int a;
std::max<sal_uInt16>(a,0)
std::max will first convert a and b to sal_uInt16, therefore potentially
converting a negative number to a positive number due to the conversion
rules. Then it will take the larger number.
While this code
int a;
static_cast<sal_uInt16>(a > 0 ? a : 0)
will compare first, and then convert the larger number to sal_uInt16,
which might result in making a "a" that is larger than 2^16 into a
smaller value, but which will never convert a negative "a" value into a
positive value.
Change-Id: Id4f6df0089b1a74ea4ac1c5d05655e7c1d8f0c7f
Reviewed-on: https://gerrit.libreoffice.org/57846
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
(cherry picked from commit c13865a4caf7898c4e59a5b22bbd493d6dad9661)
Reviewed-on: https://gerrit.libreoffice.org/57909
Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index d40ff3ed3dc0..ac3596f78262 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -830,7 +830,7 @@ bool SwGrfNumPortion::Format( SwTextFormatInfo &rInf )
const bool bFull = rInf.Width() < rInf.X() + Width();
const bool bFly = rInf.GetFly() ||
( rInf.GetLast() && rInf.GetLast()->IsFlyPortion() );
- SetAscent( std::max<sal_uInt16>(GetRelPos(), 0) );
+ SetAscent( GetRelPos() > 0 ? GetRelPos() : 0 );
if( GetAscent() > Height() )
Height( GetAscent() );
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index 4dab2bb0a4bf..545b3f2e48ab 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -1700,8 +1700,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
const int nRgt = (bTableVertical ? nPageHeight : nPageWidth) -
(aTabCols.GetLeftMin() + aTabCols.GetRight());
- const sal_uInt16 nL = std::max< sal_uInt16 >(nLft, 0);
- const sal_uInt16 nR = std::max< sal_uInt16 >(nRgt, 0);
+ const sal_uInt16 nL = static_cast< sal_uInt16 >(std::max(nLft, 0));
+ const sal_uInt16 nR = static_cast< sal_uInt16 >(std::max(nRgt, 0));
SvxColumnItem aColItem(nNum, nL, nR);
@@ -1937,8 +1937,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
const int nRgt = (bVerticalWriting ? nPageWidth : nPageHeight) -
(aTabCols.GetLeftMin() + aTabCols.GetRight());
- const sal_uInt16 nL = std::max< sal_uInt16 >(nLft, 0);
- const sal_uInt16 nR = std::max< sal_uInt16 >(nRgt, 0);
+ const sal_uInt16 nL = static_cast< sal_uInt16 >(std::max(nLft, 0));
+ const sal_uInt16 nR = static_cast< sal_uInt16 >(std::max(nRgt, 0));
SvxColumnItem aColItem(0, nL, nR);
@@ -2011,8 +2011,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
const int nRgt = nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());
- const sal_uInt16 nL = std::max< sal_uInt16 >(nLft, 0);
- const sal_uInt16 nR = std::max< sal_uInt16 >(nRgt, 0);
+ const sal_uInt16 nL = static_cast< sal_uInt16 >(std::max(nLft, 0));
+ const sal_uInt16 nR = static_cast< sal_uInt16 >(std::max(nRgt, 0));
aRectangle.SetLeft( nL );
if(nNum > 1)
More information about the Libreoffice-commits
mailing list