sd/source/ui/view/drviews9.cxx |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

New commits:
commit 63f85e4e74dff8982b1be11d70a547458fbfad8e
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sun Nov 2 15:01:58 2025 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Nov 3 10:39:07 2025 +0100

    cid#1659749 silence Division or modulo by float zero
    
    Change-Id: Iab7cf97f85895b46744161e5e107b75cb33c1d8c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193326
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx
index d13e7c9b9280..ce9de552d30f 100644
--- a/sd/source/ui/view/drviews9.cxx
+++ b/sd/source/ui/view/drviews9.cxx
@@ -96,30 +96,30 @@ void DrawViewShell::ExecGallery(SfxRequest const & rReq)
         aPageSize.AdjustHeight( -(pPage->GetUpperBorder() + 
pPage->GetLowerBorder()) );
 
         // If the image is too large we make it fit into the page
-        if ( ( ( aSize.Height() > aPageSize.Height() ) || ( aSize.Width()   > 
aPageSize.Width() ) ) &&
-            aSize.Height() && aPageSize.Height() )
+        const auto nSizeHeight = aSize.Height(), nSizeWidth = aSize.Width();
+        const auto nPageHeight = aPageSize.Height(), nPageWidth = 
aPageSize.Width();
+        if ((nSizeHeight > nPageHeight || nSizeWidth > nPageWidth) &&
+            nSizeHeight && nPageHeight)
         {
-            float fGrfWH =  static_cast<float>(aSize.Width()) /
-                            static_cast<float>(aSize.Height());
-            float fWinWH =  static_cast<float>(aPageSize.Width()) /
-                            static_cast<float>(aPageSize.Height());
+            float fGrfWH =  static_cast<float>(nSizeWidth) / 
static_cast<float>(nSizeHeight);
+            float fWinWH =  static_cast<float>(nPageWidth) / 
static_cast<float>(nPageHeight);
 
             // constrain size to page size if necessary
-            if ((fGrfWH != 0.F) && (fGrfWH < fWinWH))
+            if (fGrfWH < fWinWH)
             {
-                aSize.setWidth( static_cast<::tools::Long>(aPageSize.Height() 
* fGrfWH) );
-                aSize.setHeight( aPageSize.Height() );
+                aSize.setWidth( static_cast<::tools::Long>(nPageHeight * 
fGrfWH) );
+                aSize.setHeight( nPageHeight );
             }
             else
             {
-                aSize.setWidth( aPageSize.Width() );
-                aSize.setHeight( static_cast<::tools::Long>(aPageSize.Width() 
/ fGrfWH) );
+                aSize.setWidth( nPageWidth );
+                aSize.setHeight( static_cast<::tools::Long>(nPageWidth / 
fGrfWH) );
             }
         }
 
         // set output rectangle for graphic
-        Point aPnt ((aPageSize.Width()  - aSize.Width())  / 2,
-                    (aPageSize.Height() - aSize.Height()) / 2);
+        Point aPnt ((nPageWidth  - aSize.Width())  / 2,
+                    (nPageHeight - aSize.Height()) / 2);
         aPnt += Point(pPage->GetLeftBorder(), pPage->GetUpperBorder());
         ::tools::Rectangle aRect (aPnt, aSize);
 

Reply via email to