[Libreoffice-commits] core.git: 2 commits - filter/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 12 16:29:43 UTC 2020


 filter/source/graphicfilter/icgm/bitmap.cxx |  313 ++++++++++++++--------------
 1 file changed, 159 insertions(+), 154 deletions(-)

New commits:
commit 06687acf67f7846bb521a9a242733e23f330c09c
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Oct 12 16:30:39 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Oct 12 18:26:18 2020 +0200

    reindent CGMBitmap::ImplGetBitmap
    
    no logic change
    
    Change-Id: I1172e97feb5e78b68ed395231a698459687493aa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104216
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/graphicfilter/icgm/bitmap.cxx b/filter/source/graphicfilter/icgm/bitmap.cxx
index 26b837f3be04..75a958474979 100644
--- a/filter/source/graphicfilter/icgm/bitmap.cxx
+++ b/filter/source/graphicfilter/icgm/bitmap.cxx
@@ -79,189 +79,189 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
         return;
     }
 
-    try {
-
-    if (rDesc.mnScanSize) {
-
-    vcl::bitmap::RawBitmap aBitmap( Size( rDesc.mnX, rDesc.mnY ), 24 );
-
-    // the picture may either be read from left to right or right to left, from top to bottom ...
-
-    long nxCount = rDesc.mnX + 1;   // +1 because we are using prefix decreasing
-    long nyCount = rDesc.mnY + 1;
-    long    nx, ny, nxC;
-
-    switch ( rDesc.mnDstBitsPerPixel ) {
-    case 1 : {
-        bool bOk = true;
-        std::vector<Color> palette(2);
-        if ( rDesc.mnLocalColorPrecision == 1 )
-            palette = ImplGeneratePalette( rDesc );
-        else {
-            palette[0] = BMCOL( mpCGM->pElement->nBackGroundColor );
-            palette[1] = ( mpCGM->pElement->nAspectSourceFlags & ASF_FILLINTERIORSTYLE )
-                         ? BMCOL( mpCGM->pElement->pFillBundle->GetColor() )
-                         : BMCOL( mpCGM->pElement->aFillBundle.GetColor() );
-        };
-        for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
-            nxC = nxCount;
-            for ( nx = 0; --nxC; nx++ ) {
-                // this is not fast, but a one bit/pixel format is rarely used
-                const sal_uInt8* pPos = rDesc.mpBuf + (nx >> 3);
-                if (pPos >= rDesc.mpEndBuf)
-                {
-                    SAL_WARN("filter.icgm", "buffer is too small");
-                    bOk = false;
-                    break;
+    try
+    {
+        if (rDesc.mnScanSize)
+        {
+            vcl::bitmap::RawBitmap aBitmap( Size( rDesc.mnX, rDesc.mnY ), 24 );
+
+            // the picture may either be read from left to right or right to left, from top to bottom ...
+
+            long nxCount = rDesc.mnX + 1;   // +1 because we are using prefix decreasing
+            long nyCount = rDesc.mnY + 1;
+            long    nx, ny, nxC;
+
+            switch ( rDesc.mnDstBitsPerPixel ) {
+            case 1 : {
+                bool bOk = true;
+                std::vector<Color> palette(2);
+                if ( rDesc.mnLocalColorPrecision == 1 )
+                    palette = ImplGeneratePalette( rDesc );
+                else {
+                    palette[0] = BMCOL( mpCGM->pElement->nBackGroundColor );
+                    palette[1] = ( mpCGM->pElement->nAspectSourceFlags & ASF_FILLINTERIORSTYLE )
+                                 ? BMCOL( mpCGM->pElement->pFillBundle->GetColor() )
+                                 : BMCOL( mpCGM->pElement->aFillBundle.GetColor() );
+                };
+                for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
+                    nxC = nxCount;
+                    for ( nx = 0; --nxC; nx++ ) {
+                        // this is not fast, but a one bit/pixel format is rarely used
+                        const sal_uInt8* pPos = rDesc.mpBuf + (nx >> 3);
+                        if (pPos >= rDesc.mpEndBuf)
+                        {
+                            SAL_WARN("filter.icgm", "buffer is too small");
+                            bOk = false;
+                            break;
+                        }
+                        sal_uInt8 colorIndex = static_cast<sal_uInt8>((*pPos >> ((nx & 7)^7))) & 1;
+                        aBitmap.SetPixel(ny, nx, palette[colorIndex]);
+                    }
                 }
-                sal_uInt8 colorIndex = static_cast<sal_uInt8>((*pPos >> ((nx & 7)^7))) & 1;
-                aBitmap.SetPixel(ny, nx, palette[colorIndex]);
             }
-        }
-    }
-    break;
-
-    case 2 : {
-        bool bOk = true;
-        auto palette = ImplGeneratePalette( rDesc );
-        for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
-            nxC = nxCount;
-            for ( nx = 0; --nxC; nx++ ) {
-                // this is not fast, but a two bits/pixel format is rarely used
-                const sal_uInt8* pPos = rDesc.mpBuf + (nx >> 2);
-                if (pPos >= rDesc.mpEndBuf)
-                {
-                    SAL_WARN("filter.icgm", "buffer is too small");
-                    bOk = false;
-                    break;
+            break;
+
+            case 2 : {
+                bool bOk = true;
+                auto palette = ImplGeneratePalette( rDesc );
+                for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
+                    nxC = nxCount;
+                    for ( nx = 0; --nxC; nx++ ) {
+                        // this is not fast, but a two bits/pixel format is rarely used
+                        const sal_uInt8* pPos = rDesc.mpBuf + (nx >> 2);
+                        if (pPos >= rDesc.mpEndBuf)
+                        {
+                            SAL_WARN("filter.icgm", "buffer is too small");
+                            bOk = false;
+                            break;
+                        }
+                        aBitmap.SetPixel(ny, nx, palette[static_cast<sal_uInt8>( (*pPos >> (((nx & 3)^3) << 1))) & 3]);
+                    }
                 }
-                aBitmap.SetPixel(ny, nx, palette[static_cast<sal_uInt8>( (*pPos >> (((nx & 3)^3) << 1))) & 3]);
             }
-        }
-    }
-    break;
-
-    case 4 : {
-        bool bOk = true;
-        auto palette = ImplGeneratePalette( rDesc );
-        for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
-            nxC = nxCount;
-            sal_uInt8* pTemp = rDesc.mpBuf;
-            for ( nx = 0; --nxC; nx++ ) {
+            break;
 
-                if (pTemp >= rDesc.mpEndBuf)
-                {
-                    SAL_WARN("filter.icgm", "buffer is too small");
-                    bOk = false;
-                    break;
+            case 4 : {
+                bool bOk = true;
+                auto palette = ImplGeneratePalette( rDesc );
+                for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
+                    nxC = nxCount;
+                    sal_uInt8* pTemp = rDesc.mpBuf;
+                    for ( nx = 0; --nxC; nx++ ) {
+
+                        if (pTemp >= rDesc.mpEndBuf)
+                        {
+                            SAL_WARN("filter.icgm", "buffer is too small");
+                            bOk = false;
+                            break;
+                        }
+
+                        sal_uInt8 nDat = *pTemp++;
+
+                        aBitmap.SetPixel(ny, nx, palette[static_cast<sal_uInt8>(nDat >> 4)]);
+                        if ( --nxC ) {
+                            ++nx;
+                            aBitmap.SetPixel(ny, nx, palette[static_cast<sal_uInt8>(nDat & 15)]);
+                        } else
+                            break;
+                    }
                 }
-
-                sal_uInt8 nDat = *pTemp++;
-
-                aBitmap.SetPixel(ny, nx, palette[static_cast<sal_uInt8>(nDat >> 4)]);
-                if ( --nxC ) {
-                    ++nx;
-                    aBitmap.SetPixel(ny, nx, palette[static_cast<sal_uInt8>(nDat & 15)]);
-                } else
-                    break;
             }
-        }
-    }
-    break;
-
-    case 8 : {
-        bool bOk = true;
-        auto palette = ImplGeneratePalette( rDesc );
-        for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
-            sal_uInt8* pTemp = rDesc.mpBuf;
-            nxC = nxCount;
-            for ( nx = 0; --nxC; nx++ ) {
+            break;
 
-                if (pTemp >= rDesc.mpEndBuf)
-                {
-                    SAL_WARN("filter.icgm", "buffer is too small");
-                    bOk = false;
-                    break;
+            case 8 : {
+                bool bOk = true;
+                auto palette = ImplGeneratePalette( rDesc );
+                for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
+                    sal_uInt8* pTemp = rDesc.mpBuf;
+                    nxC = nxCount;
+                    for ( nx = 0; --nxC; nx++ ) {
+
+                        if (pTemp >= rDesc.mpEndBuf)
+                        {
+                            SAL_WARN("filter.icgm", "buffer is too small");
+                            bOk = false;
+                            break;
+                        }
+
+                        aBitmap.SetPixel(ny, nx, palette[*(pTemp++)]);
+                    }
                 }
-
-                aBitmap.SetPixel(ny, nx, palette[*(pTemp++)]);
             }
-        }
-    }
-    break;
-
-    case 24 : {
-        bool bOk = true;
-        Color aBitmapColor;
-        for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
-            sal_uInt8* pTemp = rDesc.mpBuf;
-            nxC = nxCount;
-            for ( nx = 0; --nxC; nx++ ) {
+            break;
 
-                if (pTemp + 2 >= rDesc.mpEndBuf)
-                {
-                    SAL_WARN("filter.icgm", "buffer is too small");
-                    bOk = false;
-                    break;
+            case 24 : {
+                bool bOk = true;
+                Color aBitmapColor;
+                for (ny = 0; bOk && --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize) {
+                    sal_uInt8* pTemp = rDesc.mpBuf;
+                    nxC = nxCount;
+                    for ( nx = 0; --nxC; nx++ ) {
+
+                        if (pTemp + 2 >= rDesc.mpEndBuf)
+                        {
+                            SAL_WARN("filter.icgm", "buffer is too small");
+                            bOk = false;
+                            break;
+                        }
+
+                        aBitmapColor.SetRed( *pTemp++ );
+                        aBitmapColor.SetGreen( *pTemp++ );
+                        aBitmapColor.SetBlue( *pTemp++ );
+                        aBitmap.SetPixel(ny, nx, aBitmapColor);
+                    }
                 }
-
-                aBitmapColor.SetRed( *pTemp++ );
-                aBitmapColor.SetGreen( *pTemp++ );
-                aBitmapColor.SetBlue( *pTemp++ );
-                aBitmap.SetPixel(ny, nx, aBitmapColor);
             }
-        }
-    }
-    break;
-    }
-
-    if ( rDesc.mbStatus )
-        rDesc.mxBitmap = vcl::bitmap::CreateFromData(std::move(aBitmap));
+            break;
+            }
 
-    }
+            if ( rDesc.mbStatus )
+                rDesc.mxBitmap = vcl::bitmap::CreateFromData(std::move(aBitmap));
+        }
 
-    double nX = rDesc.mnR.X - rDesc.mnQ.X;
-    double nY = rDesc.mnR.Y - rDesc.mnQ.Y;
+        double nX = rDesc.mnR.X - rDesc.mnQ.X;
+        double nY = rDesc.mnR.Y - rDesc.mnQ.Y;
 
-    rDesc.mndy = sqrt( nX * nX + nY * nY );
+        rDesc.mndy = sqrt( nX * nX + nY * nY );
 
-    nX = rDesc.mnR.X - rDesc.mnP.X;
-    nY = rDesc.mnR.Y - rDesc.mnP.Y;
+        nX = rDesc.mnR.X - rDesc.mnP.X;
+        nY = rDesc.mnR.Y - rDesc.mnP.Y;
 
-    rDesc.mndx = sqrt( nX * nX + nY * nY );
+        rDesc.mndx = sqrt( nX * nX + nY * nY );
 
-    nX = rDesc.mnR.X - rDesc.mnP.X;
-    nY = rDesc.mnR.Y - rDesc.mnP.Y;
+        nX = rDesc.mnR.X - rDesc.mnP.X;
+        nY = rDesc.mnR.Y - rDesc.mnP.Y;
 
-    double fSqrt = sqrt(nX * nX + nY * nY);
-    rDesc.mnOrientation = fSqrt != 0.0 ? (acos(nX / fSqrt) * 57.29577951308) : 0.0;
-    if ( nY > 0 )
-        rDesc.mnOrientation = 360 - rDesc.mnOrientation;
+        double fSqrt = sqrt(nX * nX + nY * nY);
+        rDesc.mnOrientation = fSqrt != 0.0 ? (acos(nX / fSqrt) * 57.29577951308) : 0.0;
+        if ( nY > 0 )
+            rDesc.mnOrientation = 360 - rDesc.mnOrientation;
 
-    nX = rDesc.mnQ.X - rDesc.mnR.X;
-    nY = rDesc.mnQ.Y - rDesc.mnR.Y;
+        nX = rDesc.mnQ.X - rDesc.mnR.X;
+        nY = rDesc.mnQ.Y - rDesc.mnR.Y;
 
-    double fAngle = 0.01745329251994 * ( 360 - rDesc.mnOrientation );
-    double fSin = sin(fAngle);
-    double fCos = cos(fAngle);
-    nX = fCos * nX + fSin * nY;
-    nY = -( fSin * nX - fCos * nY );
+        double fAngle = 0.01745329251994 * ( 360 - rDesc.mnOrientation );
+        double fSin = sin(fAngle);
+        double fCos = cos(fAngle);
+        nX = fCos * nX + fSin * nY;
+        nY = -( fSin * nX - fCos * nY );
 
-    fSqrt = sqrt(nX * nX + nY * nY);
-    fAngle = fSqrt != 0.0 ? (acos(nX / fSqrt) * 57.29577951308) : 0.0;
-    if ( nY > 0 )
-        fAngle = 360 - fAngle;
+        fSqrt = sqrt(nX * nX + nY * nY);
+        fAngle = fSqrt != 0.0 ? (acos(nX / fSqrt) * 57.29577951308) : 0.0;
+        if ( nY > 0 )
+            fAngle = 360 - fAngle;
 
-    if ( fAngle > 180 ) {               // is the picture build upwards or downwards ?
-        rDesc.mnOrigin = rDesc.mnP;
-    } else {
-        rDesc.mbVMirror = true;
-        rDesc.mnOrigin = rDesc.mnP;
-        rDesc.mnOrigin.X += rDesc.mnQ.X - rDesc.mnR.X;
-        rDesc.mnOrigin.Y += rDesc.mnQ.Y - rDesc.mnR.Y;
+        if ( fAngle > 180 ) {               // is the picture build upwards or downwards ?
+            rDesc.mnOrigin = rDesc.mnP;
+        } else {
+            rDesc.mbVMirror = true;
+            rDesc.mnOrigin = rDesc.mnP;
+            rDesc.mnOrigin.X += rDesc.mnQ.X - rDesc.mnR.X;
+            rDesc.mnOrigin.Y += rDesc.mnQ.Y - rDesc.mnR.Y;
+        }
     }
-
-    } catch (const std::bad_alloc&) {
+    catch (const std::bad_alloc&)
+    {
         rDesc.mbStatus = false;
     }
 }
commit 77c46e3e259def8569c1bdde072466dcb2781fb4
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Oct 12 16:29:36 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Oct 12 18:26:05 2020 +0200

    ofz: TimeOut short-circuit with a zero mnScanSize
    
    Change-Id: I3ac7848170e8075fe192731495361cb2c5777e75
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104215
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/graphicfilter/icgm/bitmap.cxx b/filter/source/graphicfilter/icgm/bitmap.cxx
index 3075cf733e48..26b837f3be04 100644
--- a/filter/source/graphicfilter/icgm/bitmap.cxx
+++ b/filter/source/graphicfilter/icgm/bitmap.cxx
@@ -81,6 +81,8 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
 
     try {
 
+    if (rDesc.mnScanSize) {
+
     vcl::bitmap::RawBitmap aBitmap( Size( rDesc.mnX, rDesc.mnY ), 24 );
 
     // the picture may either be read from left to right or right to left, from top to bottom ...
@@ -212,6 +214,12 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
     }
     break;
     }
+
+    if ( rDesc.mbStatus )
+        rDesc.mxBitmap = vcl::bitmap::CreateFromData(std::move(aBitmap));
+
+    }
+
     double nX = rDesc.mnR.X - rDesc.mnQ.X;
     double nY = rDesc.mnR.Y - rDesc.mnQ.Y;
 
@@ -253,9 +261,6 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
         rDesc.mnOrigin.Y += rDesc.mnQ.Y - rDesc.mnR.Y;
     }
 
-    if ( rDesc.mbStatus )
-        rDesc.mxBitmap = vcl::bitmap::CreateFromData(std::move(aBitmap));
-
     } catch (const std::bad_alloc&) {
         rDesc.mbStatus = false;
     }


More information about the Libreoffice-commits mailing list