[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 7 08:41:38 UTC 2020


 emfio/source/reader/mtftools.cxx |   50 +++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 10 deletions(-)

New commits:
commit 943dce614a796801e84b83e3cacc17e5432e8aa4
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Dec 4 09:42:15 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Dec 7 09:41:06 2020 +0100

    ofz#28271 divide-by-zero
    
    Change-Id: Ib3f47dcb0a5e327f5385ccff328f410a15b2cc91
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107202
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 9ad212b17dfa..778adeb429ba 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -322,8 +322,14 @@ namespace emfio
                         fY2  = mnWinOrgY-fY2;
                         fX2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH * 10;
                         fY2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH * 10;
-                        fX2 += mnDevOrgX * static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
-                        fY2 += mnDevOrgY * static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        double nDevOrgX = mnDevOrgX;
+                        if (mnPixX)
+                            nDevOrgX *= static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
+                        fX2 += nDevOrgX;
+                        double nDevOrgY = mnDevOrgY;
+                        if (mnPixY)
+                            nDevOrgY *= static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        fY2 += nDevOrgY;
                     }
                     break;
                     case MM_HIENGLISH :
@@ -332,8 +338,14 @@ namespace emfio
                         fY2  = mnWinOrgY-fY2;
                         fX2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH;
                         fY2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH;
-                        fX2 += mnDevOrgX * static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
-                        fY2 += mnDevOrgY * static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        double nDevOrgX = mnDevOrgX;
+                        if (mnPixX)
+                            nDevOrgX *= static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
+                        fX2 += nDevOrgX;
+                        double nDevOrgY = mnDevOrgY;
+                        if (mnPixY)
+                            nDevOrgY *= static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        fY2 += nDevOrgY;
                     }
                     break;
                     case MM_TWIPS:
@@ -342,8 +354,14 @@ namespace emfio
                         fY2  = mnWinOrgY-fY2;
                         fX2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH / MILLIINCH_PER_TWIPS;
                         fY2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH / MILLIINCH_PER_TWIPS;
-                        fX2 += mnDevOrgX * static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
-                        fY2 += mnDevOrgY * static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        double nDevOrgX = mnDevOrgX;
+                        if (mnPixX)
+                            nDevOrgX *= static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
+                        fX2 += nDevOrgX;
+                        double nDevOrgY = mnDevOrgY;
+                        if (mnPixY)
+                            nDevOrgY *= static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        fY2 += nDevOrgY;
                     }
                     break;
                     case MM_LOMETRIC :
@@ -352,16 +370,28 @@ namespace emfio
                         fY2  = mnWinOrgY-fY2;
                         fX2 *= 10;
                         fY2 *= 10;
-                        fX2 += mnDevOrgX * static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
-                        fY2 += mnDevOrgY * static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        double nDevOrgX = mnDevOrgX;
+                        if (mnPixX)
+                            nDevOrgX *= static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
+                        fX2 += nDevOrgX;
+                        double nDevOrgY = mnDevOrgY;
+                        if (mnPixY)
+                            nDevOrgY *= static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        fY2 += nDevOrgY;
                     }
                     break;
                     case MM_HIMETRIC : // in hundredth of a millimeter
                     {
                         fX2 -= mnWinOrgX;
                         fY2  = mnWinOrgY-fY2;
-                        fX2 += mnDevOrgX * static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
-                        fY2 += mnDevOrgY * static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        double nDevOrgX = mnDevOrgX;
+                        if (mnPixX)
+                            nDevOrgX *= static_cast<double>(mnMillX) * 100.0 / static_cast<double>(mnPixX);
+                        fX2 += nDevOrgX;
+                        double nDevOrgY = mnDevOrgY;
+                        if (mnPixY)
+                            nDevOrgY *= static_cast<double>(mnMillY) * 100.0 / static_cast<double>(mnPixY);
+                        fY2 += nDevOrgY;
                     }
                     break;
                     default :


More information about the Libreoffice-commits mailing list