[Libreoffice-commits] core.git: sfx2/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Sun Jan 26 14:52:25 UTC 2020


 sfx2/source/control/thumbnailview.cxx |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit b2945902e7a0ad9f033fe67f5ab217d6e31d8d84
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Sun Jan 26 14:56:56 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Sun Jan 26 15:51:51 2020 +0100

    Avoid explicit casts to smaller sal_uInt16 from larger long
    
    ...in what might be attempts to avoid warnings about signed vs. unsigned
    comparisons.
    
    Change-Id: I699718a90dffb4b5bcd3706eddbaf6fba71114fc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87442
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 56cf4213b51d..ba829574d6a3 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -21,6 +21,7 @@
 #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
 #include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
+#include <o3tl/safeint.hxx>
 #include <rtl/ustring.hxx>
 #include <sal/log.hxx>
 #include <svtools/optionsdrawinglayer.hxx>
@@ -290,7 +291,7 @@ void ThumbnailView::CalculateItemPositions (bool bScrollBarUsed)
 
     if ( mnLines <= mnVisLines )
         mnFirstLine = 0;
-    else if ( mnFirstLine > static_cast<sal_uInt16>(mnLines-mnVisLines) )
+    else if ( mnFirstLine > o3tl::make_unsigned(mnLines-mnVisLines) )
         mnFirstLine = static_cast<sal_uInt16>(mnLines-mnVisLines);
 
     mbHasVisibleItems = true;
@@ -1007,7 +1008,7 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId )
         {
             mnFirstLine = nNewLine;
         }
-        else if ( nNewLine > static_cast<sal_uInt16>(mnFirstLine+mnVisLines-1) )
+        else if ( nNewLine > o3tl::make_unsigned(mnFirstLine+mnVisLines-1) )
         {
             mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1);
         }
@@ -1444,7 +1445,7 @@ void SfxThumbnailView::CalculateItemPositions(bool bScrollBarUsed)
 
     if ( mnLines <= mnVisLines )
         mnFirstLine = 0;
-    else if ( mnFirstLine > static_cast<sal_uInt16>(mnLines-mnVisLines) )
+    else if ( mnFirstLine > o3tl::make_unsigned(mnLines-mnVisLines) )
         mnFirstLine = static_cast<sal_uInt16>(mnLines-mnVisLines);
 
     mbHasVisibleItems = true;
@@ -2175,7 +2176,7 @@ void SfxThumbnailView::SelectItem( sal_uInt16 nItemId )
         {
             mnFirstLine = nNewLine;
         }
-        else if ( nNewLine > static_cast<sal_uInt16>(mnFirstLine+mnVisLines-1) )
+        else if ( nNewLine > o3tl::make_unsigned(mnFirstLine+mnVisLines-1) )
         {
             mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1);
         }


More information about the Libreoffice-commits mailing list