vcl/inc/win/salgdi.h               |    2 
 vcl/win/gdi/DWriteTextRenderer.cxx |   22 -
 vcl/win/gdi/gdiimpl.cxx            |  561 ++++++++++++++++---------------------
 vcl/win/gdi/salbmp.cxx             |  300 +++++++++----------
 vcl/win/gdi/salfont.cxx            |   90 ++---
 vcl/win/gdi/salgdi.cxx             |  361 +++++++++++------------
 vcl/win/gdi/salprn.cxx             |  310 ++++++++++----------
 vcl/win/gdi/winlayout.cxx          |   36 +-
 8 files changed, 808 insertions(+), 874 deletions(-)

New commits:
commit 7dd7ac0311cfc74137b569c5473e14e73738762d
Author:     Noel Grandin <noelgran...@collabora.co.uk>
AuthorDate: Tue Feb 4 10:14:59 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Feb 4 10:43:03 2025 +0100

    flatten some windows GDI code
    
    Change-Id: I9dd2d795803c588da235d9ae9baf213abd208ff8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181086
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx 
b/vcl/win/gdi/DWriteTextRenderer.cxx
index cb3c1ba4c060..15441a8389e1 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -269,19 +269,19 @@ IDWriteFontFace* 
D2DWriteTextOutRenderer::GetDWriteFace(const WinFontInstance& r
                                                         float* lfSize) const
 {
     auto pFontFace = rWinFont.GetDWFontFace();
-    if (pFontFace)
-    {
-        LOGFONTW aLogFont;
-        HFONT hFont = rWinFont.GetHFONT();
+    if (!pFontFace)
+        return nullptr;
 
-        GetObjectW(hFont, sizeof(LOGFONTW), &aLogFont);
-        float dpix, dpiy;
-        mpRT->GetDpi(&dpix, &dpiy);
-        *lfSize = aLogFont.lfHeight * 96.0f / dpiy;
+    LOGFONTW aLogFont;
+    HFONT hFont = rWinFont.GetHFONT();
 
-        assert(*lfSize < 0);
-        *lfSize *= -1;
-    }
+    GetObjectW(hFont, sizeof(LOGFONTW), &aLogFont);
+    float dpix, dpiy;
+    mpRT->GetDpi(&dpix, &dpiy);
+    *lfSize = aLogFont.lfHeight * 96.0f / dpiy;
+
+    assert(*lfSize < 0);
+    *lfSize *= -1;
 
     return pFontFace;
 }
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 2f731d98f6b3..fa5dc31d2374 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -514,101 +514,101 @@ namespace {
 void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, const WinSalBitmap& 
rSalBitmap,
                      bool bPrinter, int nDrawMode )
 {
-    if( hDC )
-    {
-        HGLOBAL     hDrawDIB;
-        HBITMAP     hDrawDDB = rSalBitmap.ImplGethDDB();
-        std::optional<WinSalBitmap> xTmpSalBmp;
-        bool        bPrintDDB = ( bPrinter && hDrawDDB );
+    if( !hDC )
+        return;
 
-        if( bPrintDDB )
-        {
-            xTmpSalBmp.emplace();
-            xTmpSalBmp->Create(rSalBitmap, 
vcl::bitDepthToPixelFormat(rSalBitmap.GetBitCount()));
-            hDrawDIB = xTmpSalBmp->ImplGethDIB();
-        }
-        else
-            hDrawDIB = rSalBitmap.ImplGethDIB();
+    HGLOBAL     hDrawDIB;
+    HBITMAP     hDrawDDB = rSalBitmap.ImplGethDDB();
+    std::optional<WinSalBitmap> xTmpSalBmp;
+    bool        bPrintDDB = ( bPrinter && hDrawDDB );
+
+    if( bPrintDDB )
+    {
+        xTmpSalBmp.emplace();
+        xTmpSalBmp->Create(rSalBitmap, 
vcl::bitDepthToPixelFormat(rSalBitmap.GetBitCount()));
+        hDrawDIB = xTmpSalBmp->ImplGethDIB();
+    }
+    else
+        hDrawDIB = rSalBitmap.ImplGethDIB();
 
-        if( hDrawDIB )
+    if( hDrawDIB )
+    {
+        if (PBITMAPINFO pBI = static_cast<PBITMAPINFO>(GlobalLock( hDrawDIB )))
         {
-            if (PBITMAPINFO pBI = static_cast<PBITMAPINFO>(GlobalLock( 
hDrawDIB )))
-            {
-                PBYTE               pBits = reinterpret_cast<PBYTE>(pBI) + 
pBI->bmiHeader.biSize +
-                                            
WinSalBitmap::ImplGetDIBColorCount( hDrawDIB ) * sizeof( RGBQUAD );
-                const int           nOldStretchMode = SetStretchBltMode( hDC, 
STRETCH_DELETESCANS );
-
-                StretchDIBits( hDC,
-                               static_cast<int>(rPosAry.mnDestX), 
static_cast<int>(rPosAry.mnDestY),
-                               static_cast<int>(rPosAry.mnDestWidth), 
static_cast<int>(rPosAry.mnDestHeight),
-                               static_cast<int>(rPosAry.mnSrcX), 
static_cast<int>(pBI->bmiHeader.biHeight - rPosAry.mnSrcHeight - 
rPosAry.mnSrcY),
-                               static_cast<int>(rPosAry.mnSrcWidth), 
static_cast<int>(rPosAry.mnSrcHeight),
-                               pBits, pBI, DIB_RGB_COLORS, nDrawMode );
-
-                GlobalUnlock( hDrawDIB );
-                SetStretchBltMode( hDC, nOldStretchMode );
-            }
+            PBYTE               pBits = reinterpret_cast<PBYTE>(pBI) + 
pBI->bmiHeader.biSize +
+                                        WinSalBitmap::ImplGetDIBColorCount( 
hDrawDIB ) * sizeof( RGBQUAD );
+            const int           nOldStretchMode = SetStretchBltMode( hDC, 
STRETCH_DELETESCANS );
+
+            StretchDIBits( hDC,
+                           static_cast<int>(rPosAry.mnDestX), 
static_cast<int>(rPosAry.mnDestY),
+                           static_cast<int>(rPosAry.mnDestWidth), 
static_cast<int>(rPosAry.mnDestHeight),
+                           static_cast<int>(rPosAry.mnSrcX), 
static_cast<int>(pBI->bmiHeader.biHeight - rPosAry.mnSrcHeight - 
rPosAry.mnSrcY),
+                           static_cast<int>(rPosAry.mnSrcWidth), 
static_cast<int>(rPosAry.mnSrcHeight),
+                           pBits, pBI, DIB_RGB_COLORS, nDrawMode );
+
+            GlobalUnlock( hDrawDIB );
+            SetStretchBltMode( hDC, nOldStretchMode );
         }
-        else if( hDrawDDB && !bPrintDDB )
-        {
-            ScopedCachedHDC<CACHED_HDC_DRAW> hBmpDC(hDrawDDB);
+    }
+    else if( hDrawDDB && !bPrintDDB )
+    {
+        ScopedCachedHDC<CACHED_HDC_DRAW> hBmpDC(hDrawDDB);
 
-            COLORREF    nOldBkColor = RGB(0xFF,0xFF,0xFF);
-            COLORREF    nOldTextColor = RGB(0,0,0);
-            bool        bMono = ( rSalBitmap.GetBitCount() == 1 );
+        COLORREF    nOldBkColor = RGB(0xFF,0xFF,0xFF);
+        COLORREF    nOldTextColor = RGB(0,0,0);
+        bool        bMono = ( rSalBitmap.GetBitCount() == 1 );
 
-            if( bMono )
+        if( bMono )
+        {
+            COLORREF nBkColor = RGB( 0xFF, 0xFF, 0xFF );
+            COLORREF nTextColor = RGB( 0x00, 0x00, 0x00 );
+            //fdo#33455 handle 1 bit depth pngs with palette entries
+            //to set fore/back colors
+            if (BitmapBuffer* pBitmapBuffer = 
const_cast<WinSalBitmap&>(rSalBitmap).AcquireBuffer(BitmapAccessMode::Info))
             {
-                COLORREF nBkColor = RGB( 0xFF, 0xFF, 0xFF );
-                COLORREF nTextColor = RGB( 0x00, 0x00, 0x00 );
-                //fdo#33455 handle 1 bit depth pngs with palette entries
-                //to set fore/back colors
-                if (BitmapBuffer* pBitmapBuffer = 
const_cast<WinSalBitmap&>(rSalBitmap).AcquireBuffer(BitmapAccessMode::Info))
+                const BitmapPalette& rPalette = pBitmapBuffer->maPalette;
+                if (rPalette.GetEntryCount() == 2)
                 {
-                    const BitmapPalette& rPalette = pBitmapBuffer->maPalette;
-                    if (rPalette.GetEntryCount() == 2)
-                    {
-                        Color nCol = rPalette[0];
-                        nTextColor = RGB( nCol.GetRed(), nCol.GetGreen(), 
nCol.GetBlue() );
-                        nCol = rPalette[1];
-                        nBkColor = RGB( nCol.GetRed(), nCol.GetGreen(), 
nCol.GetBlue() );
-                    }
-                    
const_cast<WinSalBitmap&>(rSalBitmap).ReleaseBuffer(pBitmapBuffer, 
BitmapAccessMode::Info);
+                    Color nCol = rPalette[0];
+                    nTextColor = RGB( nCol.GetRed(), nCol.GetGreen(), 
nCol.GetBlue() );
+                    nCol = rPalette[1];
+                    nBkColor = RGB( nCol.GetRed(), nCol.GetGreen(), 
nCol.GetBlue() );
                 }
-                nOldBkColor = SetBkColor( hDC, nBkColor );
-                nOldTextColor = ::SetTextColor( hDC, nTextColor );
+                
const_cast<WinSalBitmap&>(rSalBitmap).ReleaseBuffer(pBitmapBuffer, 
BitmapAccessMode::Info);
             }
+            nOldBkColor = SetBkColor( hDC, nBkColor );
+            nOldTextColor = ::SetTextColor( hDC, nTextColor );
+        }
 
-            if ( (rPosAry.mnSrcWidth  == rPosAry.mnDestWidth) &&
-                 (rPosAry.mnSrcHeight == rPosAry.mnDestHeight) )
-            {
-                BitBlt( hDC,
+        if ( (rPosAry.mnSrcWidth  == rPosAry.mnDestWidth) &&
+             (rPosAry.mnSrcHeight == rPosAry.mnDestHeight) )
+        {
+            BitBlt( hDC,
+                    static_cast<int>(rPosAry.mnDestX), 
static_cast<int>(rPosAry.mnDestY),
+                    static_cast<int>(rPosAry.mnDestWidth), 
static_cast<int>(rPosAry.mnDestHeight),
+                    hBmpDC.get(),
+                    static_cast<int>(rPosAry.mnSrcX), 
static_cast<int>(rPosAry.mnSrcY),
+                    nDrawMode );
+        }
+        else
+        {
+            const int nOldStretchMode = SetStretchBltMode( hDC, 
STRETCH_DELETESCANS );
+
+            StretchBlt( hDC,
                         static_cast<int>(rPosAry.mnDestX), 
static_cast<int>(rPosAry.mnDestY),
                         static_cast<int>(rPosAry.mnDestWidth), 
static_cast<int>(rPosAry.mnDestHeight),
                         hBmpDC.get(),
                         static_cast<int>(rPosAry.mnSrcX), 
static_cast<int>(rPosAry.mnSrcY),
+                        static_cast<int>(rPosAry.mnSrcWidth), 
static_cast<int>(rPosAry.mnSrcHeight),
                         nDrawMode );
-            }
-            else
-            {
-                const int nOldStretchMode = SetStretchBltMode( hDC, 
STRETCH_DELETESCANS );
-
-                StretchBlt( hDC,
-                            static_cast<int>(rPosAry.mnDestX), 
static_cast<int>(rPosAry.mnDestY),
-                            static_cast<int>(rPosAry.mnDestWidth), 
static_cast<int>(rPosAry.mnDestHeight),
-                            hBmpDC.get(),
-                            static_cast<int>(rPosAry.mnSrcX), 
static_cast<int>(rPosAry.mnSrcY),
-                            static_cast<int>(rPosAry.mnSrcWidth), 
static_cast<int>(rPosAry.mnSrcHeight),
-                            nDrawMode );
 
-                SetStretchBltMode( hDC, nOldStretchMode );
-            }
+            SetStretchBltMode( hDC, nOldStretchMode );
+        }
 
-            if( bMono )
-            {
-                SetBkColor( hDC, nOldBkColor );
-                ::SetTextColor( hDC, nOldTextColor );
-            }
+        if( bMono )
+        {
+            SetBkColor( hDC, nOldBkColor );
+            ::SetTextColor( hDC, nOldTextColor );
         }
     }
 }
@@ -932,24 +932,20 @@ sal_uInt16 WinSalGraphicsImpl::GetBitCount() const
 
 tools::Long WinSalGraphicsImpl::GetGraphicsWidth() const
 {
-    if( mrParent.gethWnd() && IsWindow( mrParent.gethWnd() ) )
-    {
-        WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() );
-        if( pFrame )
-        {
-            if (pFrame->GetWidth())
-                return pFrame->GetWidth();
-            else
-            {
-                // TODO: perhaps not needed, width should always be up-to-date
-                RECT aRect;
-                GetClientRect( mrParent.gethWnd(), &aRect );
-                return aRect.right;
-            }
-        }
-    }
+    if( !mrParent.gethWnd() || !IsWindow( mrParent.gethWnd() ) )
+        return 0;
+
+    WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() );
+    if( !pFrame )
+        return 0;
 
-    return 0;
+    if (pFrame->GetWidth())
+        return pFrame->GetWidth();
+
+    // TODO: perhaps not needed, width should always be up-to-date
+    RECT aRect;
+    GetClientRect( mrParent.gethWnd(), &aRect );
+    return aRect.right;
 }
 
 void WinSalGraphicsImpl::ResetClipRegion()
@@ -966,16 +962,12 @@ void WinSalGraphicsImpl::ResetClipRegion()
 static bool containsOnlyHorizontalAndVerticalEdges(const basegfx::B2DPolygon& 
rCandidate)
 {
     if(rCandidate.areControlPointsUsed())
-    {
         return false;
-    }
 
     const sal_uInt32 nPointCount(rCandidate.count());
 
     if(nPointCount < 2)
-    {
         return true;
-    }
 
     const sal_uInt32 nEdgeCount(rCandidate.isClosed() ? nPointCount + 1 : 
nPointCount);
     basegfx::B2DPoint aLast(rCandidate.getB2DPoint(0));
@@ -999,9 +991,7 @@ static bool containsOnlyHorizontalAndVerticalEdges(const 
basegfx::B2DPolygon& rC
 static bool containsOnlyHorizontalAndVerticalEdges(const 
basegfx::B2DPolyPolygon& rCandidate)
 {
     if(rCandidate.areControlPointsUsed())
-    {
         return false;
-    }
 
     for(auto const& rPolygon : rCandidate)
     {
@@ -1291,15 +1281,15 @@ void WinSalGraphicsImpl::SetLineColor(Color nColor)
 HPEN WinSalGraphicsImpl::SearchStockPen(COLORREF nPenColor)
 {
     // Only screen, because printer has problems, when we use stock objects.
-    if (!mrParent.isPrinter())
-    {
-        const SalData* pSalData = GetSalData();
+    if (mrParent.isPrinter())
+        return nullptr;
 
-        for (sal_uInt16 i = 0; i < pSalData->mnStockPenCount; i++)
-        {
-            if (nPenColor == pSalData->maStockPenColorAry[i])
-                return pSalData->mhStockPenAry[i];
-        }
+    const SalData* pSalData = GetSalData();
+
+    for (sal_uInt16 i = 0; i < pSalData->mnStockPenCount; i++)
+    {
+        if (nPenColor == pSalData->maStockPenColorAry[i])
+            return pSalData->mhStockPenAry[i];
     }
 
     return nullptr;
@@ -1847,78 +1837,76 @@ static void impAddB2DPolygonToGDIPlusGraphicsPathReal(
     bool bPixelSnapHairline)
 {
     sal_uInt32 nCount(rPolygon.count());
+    if(nCount == 0)
+        return;
+
+    const sal_uInt32 nEdgeCount(rPolygon.isClosed() ? nCount : nCount - 1);
+    if(nEdgeCount == 0)
+        return;
 
-    if(nCount)
+    const bool bControls(rPolygon.areControlPointsUsed());
+    basegfx::B2DPoint aCurr(rPolygon.getB2DPoint(0));
+    basegfx::B2DHomMatrix aObjectToDeviceInv;
+
+    if(bPixelSnapHairline)
     {
-        const sal_uInt32 nEdgeCount(rPolygon.isClosed() ? nCount : nCount - 1);
+        aCurr = impPixelSnap(rPolygon, rObjectToDevice, aObjectToDeviceInv, 0);
+    }
 
-        if(nEdgeCount)
+    for(sal_uInt32 a(0); a < nEdgeCount; a++)
+    {
+        const sal_uInt32 nNextIndex((a + 1) % nCount);
+        basegfx::B2DPoint aNext(rPolygon.getB2DPoint(nNextIndex));
+        const bool b1stControlPointUsed(bControls && 
rPolygon.isNextControlPointUsed(a));
+        const bool b2ndControlPointUsed(bControls && 
rPolygon.isPrevControlPointUsed(nNextIndex));
+
+        if(bPixelSnapHairline)
         {
-            const bool bControls(rPolygon.areControlPointsUsed());
-            basegfx::B2DPoint aCurr(rPolygon.getB2DPoint(0));
-            basegfx::B2DHomMatrix aObjectToDeviceInv;
+            aNext = impPixelSnap(rPolygon, rObjectToDevice, 
aObjectToDeviceInv, nNextIndex);
+        }
 
-            if(bPixelSnapHairline)
+        if(b1stControlPointUsed || b2ndControlPointUsed)
+        {
+            basegfx::B2DPoint aCa(rPolygon.getNextControlPoint(a));
+            basegfx::B2DPoint aCb(rPolygon.getPrevControlPoint(nNextIndex));
+
+            // tdf#99165 MS Gdiplus cannot handle creating correct extra 
geometry for fat lines
+            // with LineCap or LineJoin when a bezier segment starts or ends 
trivial, e.g. has
+            // no 1st or 2nd control point, despite that these are 
mathematically correct definitions
+            // (basegfx can handle that).
+            // Caution: This error (and it's correction) might be necessary 
for other graphical
+            // sub-systems in a similar way.
+            // tdf#101026 The 1st attempt to create a mathematically correct 
replacement control
+            // vector was wrong. Best alternative is one as close as possible 
which means short.
+            if(!b1stControlPointUsed)
             {
-                aCurr = impPixelSnap(rPolygon, rObjectToDevice, 
aObjectToDeviceInv, 0);
+                aCa = aCurr + ((aCb - aCurr) * 0.0005);
             }
-
-            for(sal_uInt32 a(0); a < nEdgeCount; a++)
+            else if(!b2ndControlPointUsed)
             {
-                const sal_uInt32 nNextIndex((a + 1) % nCount);
-                basegfx::B2DPoint aNext(rPolygon.getB2DPoint(nNextIndex));
-                const bool b1stControlPointUsed(bControls && 
rPolygon.isNextControlPointUsed(a));
-                const bool b2ndControlPointUsed(bControls && 
rPolygon.isPrevControlPointUsed(nNextIndex));
-
-                if(bPixelSnapHairline)
-                {
-                    aNext = impPixelSnap(rPolygon, rObjectToDevice, 
aObjectToDeviceInv, nNextIndex);
-                }
-
-                if(b1stControlPointUsed || b2ndControlPointUsed)
-                {
-                    basegfx::B2DPoint aCa(rPolygon.getNextControlPoint(a));
-                    basegfx::B2DPoint 
aCb(rPolygon.getPrevControlPoint(nNextIndex));
-
-                    // tdf#99165 MS Gdiplus cannot handle creating correct 
extra geometry for fat lines
-                    // with LineCap or LineJoin when a bezier segment starts 
or ends trivial, e.g. has
-                    // no 1st or 2nd control point, despite that these are 
mathematically correct definitions
-                    // (basegfx can handle that).
-                    // Caution: This error (and it's correction) might be 
necessary for other graphical
-                    // sub-systems in a similar way.
-                    // tdf#101026 The 1st attempt to create a mathematically 
correct replacement control
-                    // vector was wrong. Best alternative is one as close as 
possible which means short.
-                    if(!b1stControlPointUsed)
-                    {
-                        aCa = aCurr + ((aCb - aCurr) * 0.0005);
-                    }
-                    else if(!b2ndControlPointUsed)
-                    {
-                        aCb = aNext + ((aCa - aNext) * 0.0005);
-                    }
+                aCb = aNext + ((aCa - aNext) * 0.0005);
+            }
 
-                    rGraphicsPath.AddBezier(
-                        static_cast< Gdiplus::REAL >(aCurr.getX()), 
static_cast< Gdiplus::REAL >(aCurr.getY()),
-                        static_cast< Gdiplus::REAL >(aCa.getX()), static_cast< 
Gdiplus::REAL >(aCa.getY()),
-                        static_cast< Gdiplus::REAL >(aCb.getX()), static_cast< 
Gdiplus::REAL >(aCb.getY()),
-                        static_cast< Gdiplus::REAL >(aNext.getX()), 
static_cast< Gdiplus::REAL >(aNext.getY()));
-                }
-                else
-                {
-                    rGraphicsPath.AddLine(
-                        static_cast< Gdiplus::REAL >(aCurr.getX()), 
static_cast< Gdiplus::REAL >(aCurr.getY()),
-                        static_cast< Gdiplus::REAL >(aNext.getX()), 
static_cast< Gdiplus::REAL >(aNext.getY()));
-                }
+            rGraphicsPath.AddBezier(
+                static_cast< Gdiplus::REAL >(aCurr.getX()), static_cast< 
Gdiplus::REAL >(aCurr.getY()),
+                static_cast< Gdiplus::REAL >(aCa.getX()), static_cast< 
Gdiplus::REAL >(aCa.getY()),
+                static_cast< Gdiplus::REAL >(aCb.getX()), static_cast< 
Gdiplus::REAL >(aCb.getY()),
+                static_cast< Gdiplus::REAL >(aNext.getX()), static_cast< 
Gdiplus::REAL >(aNext.getY()));
+        }
+        else
+        {
+            rGraphicsPath.AddLine(
+                static_cast< Gdiplus::REAL >(aCurr.getX()), static_cast< 
Gdiplus::REAL >(aCurr.getY()),
+                static_cast< Gdiplus::REAL >(aNext.getX()), static_cast< 
Gdiplus::REAL >(aNext.getY()));
+        }
 
-                if(a + 1 < nEdgeCount)
-                {
-                    aCurr = aNext;
+        if(a + 1 < nEdgeCount)
+        {
+            aCurr = aNext;
 
-                    if(bNoLineJoin)
-                    {
-                        rGraphicsPath.StartFigure();
-                    }
-                }
+            if(bNoLineJoin)
+            {
+                rGraphicsPath.StartFigure();
             }
         }
     }
@@ -1974,17 +1962,17 @@ sal_Int64 
SystemDependentData_GraphicsPath::estimateUsageInBytes() const
 {
     sal_Int64 nRetval(0);
 
-    if(mpGraphicsPath)
-    {
-        const INT nPointCount(mpGraphicsPath->GetPointCount());
+    if(!mpGraphicsPath)
+        return 0;
 
-        if(0 != nPointCount)
-        {
-            // Each point has
-            // - 2 x sizeof(Gdiplus::REAL)
-            // - 1 byte (see GetPathTypes in docu)
-            nRetval = nPointCount * ((2 * sizeof(Gdiplus::REAL)) + 1);
-        }
+    const INT nPointCount(mpGraphicsPath->GetPointCount());
+
+    if(0 != nPointCount)
+    {
+        // Each point has
+        // - 2 x sizeof(Gdiplus::REAL)
+        // - 1 byte (see GetPathTypes in docu)
+        nRetval = nPointCount * ((2 * sizeof(Gdiplus::REAL)) + 1);
     }
 
     return nRetval;
@@ -2503,34 +2491,32 @@ static void setInterpolationMode(
 
 bool WinSalGraphicsImpl::TryDrawBitmapGDIPlus(const SalTwoRect& rTR, const 
SalBitmap& rSrcBitmap)
 {
-    if(rTR.mnSrcWidth && rTR.mnSrcHeight && rTR.mnDestWidth && 
rTR.mnDestHeight)
-    {
-        assert(dynamic_cast<const WinSalBitmap*>(&rSrcBitmap));
+    if(!rTR.mnSrcWidth || !rTR.mnSrcHeight || !rTR.mnDestWidth || 
!rTR.mnDestHeight)
+        return false;
 
-        const WinSalBitmap& rSalBitmap = static_cast< const WinSalBitmap& 
>(rSrcBitmap);
-        std::shared_ptr< Gdiplus::Bitmap > 
aARGB(rSalBitmap.ImplGetGdiPlusBitmap());
+    assert(dynamic_cast<const WinSalBitmap*>(&rSrcBitmap));
 
-        if(aARGB)
-        {
-            Gdiplus::Graphics aGraphics(mrParent.getHDC());
+    const WinSalBitmap& rSalBitmap = static_cast< const WinSalBitmap& 
>(rSrcBitmap);
+    std::shared_ptr< Gdiplus::Bitmap > 
aARGB(rSalBitmap.ImplGetGdiPlusBitmap());
 
-            setInterpolationMode(
-                aGraphics,
-                rTR.mnSrcWidth,
-                rTR.mnDestWidth,
-                rTR.mnSrcHeight,
-                rTR.mnDestHeight);
+    if(!aARGB)
+        return false;
 
-            paintToGdiPlus(
-                aGraphics,
-                rTR,
-                *aARGB);
+    Gdiplus::Graphics aGraphics(mrParent.getHDC());
 
-            return true;
-        }
-    }
+    setInterpolationMode(
+        aGraphics,
+        rTR.mnSrcWidth,
+        rTR.mnDestWidth,
+        rTR.mnSrcHeight,
+        rTR.mnDestHeight);
 
-    return false;
+    paintToGdiPlus(
+        aGraphics,
+        rTR,
+        *aARGB);
+
+    return true;
 }
 
 bool WinSalGraphicsImpl::blendBitmap(
@@ -2554,36 +2540,34 @@ bool WinSalGraphicsImpl::drawAlphaBitmap(
     const SalBitmap& rSrcBitmap,
     const SalBitmap& rAlphaBmp)
 {
-    if(rTR.mnSrcWidth && rTR.mnSrcHeight && rTR.mnDestWidth && 
rTR.mnDestHeight)
-    {
-        assert(dynamic_cast<const WinSalBitmap*>(&rSrcBitmap));
-        assert(dynamic_cast<const WinSalBitmap*>(&rAlphaBmp));
+    if(!rTR.mnSrcWidth || !rTR.mnSrcHeight || !rTR.mnDestWidth || 
!rTR.mnDestHeight)
+        return false;
 
-        const WinSalBitmap& rSalBitmap = static_cast< const WinSalBitmap& 
>(rSrcBitmap);
-        const WinSalBitmap& rSalAlpha = static_cast< const WinSalBitmap& 
>(rAlphaBmp);
-        std::shared_ptr< Gdiplus::Bitmap > 
aARGB(rSalBitmap.ImplGetGdiPlusBitmap(&rSalAlpha));
+    assert(dynamic_cast<const WinSalBitmap*>(&rSrcBitmap));
+    assert(dynamic_cast<const WinSalBitmap*>(&rAlphaBmp));
 
-        if(aARGB)
-        {
-            Gdiplus::Graphics aGraphics(mrParent.getHDC());
+    const WinSalBitmap& rSalBitmap = static_cast< const WinSalBitmap& 
>(rSrcBitmap);
+    const WinSalBitmap& rSalAlpha = static_cast< const WinSalBitmap& 
>(rAlphaBmp);
+    std::shared_ptr< Gdiplus::Bitmap > 
aARGB(rSalBitmap.ImplGetGdiPlusBitmap(&rSalAlpha));
 
-            setInterpolationMode(
-                aGraphics,
-                rTR.mnSrcWidth,
-                rTR.mnDestWidth,
-                rTR.mnSrcHeight,
-                rTR.mnDestHeight);
+    if(!aARGB)
+        return false;
 
-            paintToGdiPlus(
-                aGraphics,
-                rTR,
-                *aARGB);
+    Gdiplus::Graphics aGraphics(mrParent.getHDC());
 
-            return true;
-        }
-    }
+    setInterpolationMode(
+        aGraphics,
+        rTR.mnSrcWidth,
+        rTR.mnDestWidth,
+        rTR.mnSrcHeight,
+        rTR.mnDestHeight);
 
-    return false;
+    paintToGdiPlus(
+        aGraphics,
+        rTR,
+        *aARGB);
+
+    return true;
 }
 
 bool WinSalGraphicsImpl::drawTransformedBitmap(
@@ -2604,56 +2588,54 @@ bool WinSalGraphicsImpl::drawTransformedBitmap(
     const WinSalBitmap* pSalAlpha = static_cast< const WinSalBitmap* 
>(pAlphaBitmap);
     std::shared_ptr< Gdiplus::Bitmap > 
aARGB(rSalBitmap.ImplGetGdiPlusBitmap(pSalAlpha));
 
-    if(aARGB)
-    {
-        const tools::Long nSrcWidth(aARGB->GetWidth());
-        const tools::Long nSrcHeight(aARGB->GetHeight());
+    if(!aARGB)
+        return false;
 
-        if(nSrcWidth && nSrcHeight)
-        {
-            const tools::Long 
nDestWidth(basegfx::fround<tools::Long>(basegfx::B2DVector(rX - 
rNull).getLength()));
-            const tools::Long 
nDestHeight(basegfx::fround<tools::Long>(basegfx::B2DVector(rY - 
rNull).getLength()));
+    const tools::Long nSrcWidth(aARGB->GetWidth());
+    const tools::Long nSrcHeight(aARGB->GetHeight());
 
-            if(nDestWidth && nDestHeight)
-            {
-                Gdiplus::Graphics aGraphics(mrParent.getHDC());
-                Gdiplus::PointF aDestPoints[3];
-                Gdiplus::ImageAttributes aAttributes;
-
-                setInterpolationMode(
-                    aGraphics,
-                    nSrcWidth,
-                    nDestWidth,
-                    nSrcHeight,
-                    nDestHeight);
-
-                // this mode is only capable of drawing the whole bitmap to a 
parallelogram
-                aDestPoints[0].X = Gdiplus::REAL(rNull.getX());
-                aDestPoints[0].Y = Gdiplus::REAL(rNull.getY());
-                aDestPoints[1].X = Gdiplus::REAL(rX.getX());
-                aDestPoints[1].Y = Gdiplus::REAL(rX.getY());
-                aDestPoints[2].X = Gdiplus::REAL(rY.getX());
-                aDestPoints[2].Y = Gdiplus::REAL(rY.getY());
-
-                aAttributes.SetWrapMode(Gdiplus::WrapModeTileFlipXY);
-
-                aGraphics.DrawImage(
-                    aARGB.get(),
-                    aDestPoints,
-                    3,
-                    Gdiplus::REAL(0.0),
-                    Gdiplus::REAL(0.0),
-                    Gdiplus::REAL(nSrcWidth),
-                    Gdiplus::REAL(nSrcHeight),
-                    Gdiplus::UnitPixel,
-                    &aAttributes);
-            }
-        }
+    if(!nSrcWidth || !nSrcHeight)
+        return true;
+
+    const tools::Long 
nDestWidth(basegfx::fround<tools::Long>(basegfx::B2DVector(rX - 
rNull).getLength()));
+    const tools::Long 
nDestHeight(basegfx::fround<tools::Long>(basegfx::B2DVector(rY - 
rNull).getLength()));
 
+    if(!nDestWidth || !nDestHeight)
         return true;
-    }
 
-    return false;
+    Gdiplus::Graphics aGraphics(mrParent.getHDC());
+    Gdiplus::PointF aDestPoints[3];
+    Gdiplus::ImageAttributes aAttributes;
+
+    setInterpolationMode(
+        aGraphics,
+        nSrcWidth,
+        nDestWidth,
+        nSrcHeight,
+        nDestHeight);
+
+    // this mode is only capable of drawing the whole bitmap to a parallelogram
+    aDestPoints[0].X = Gdiplus::REAL(rNull.getX());
+    aDestPoints[0].Y = Gdiplus::REAL(rNull.getY());
+    aDestPoints[1].X = Gdiplus::REAL(rX.getX());
+    aDestPoints[1].Y = Gdiplus::REAL(rX.getY());
+    aDestPoints[2].X = Gdiplus::REAL(rY.getX());
+    aDestPoints[2].Y = Gdiplus::REAL(rY.getY());
+
+    aAttributes.SetWrapMode(Gdiplus::WrapModeTileFlipXY);
+
+    aGraphics.DrawImage(
+        aARGB.get(),
+        aDestPoints,
+        3,
+        Gdiplus::REAL(0.0),
+        Gdiplus::REAL(0.0),
+        Gdiplus::REAL(nSrcWidth),
+        Gdiplus::REAL(nSrcHeight),
+        Gdiplus::UnitPixel,
+        &aAttributes);
+
+    return true;
 }
 
 bool WinSalGraphicsImpl::hasFastDrawTransformedBitmap() const
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index 4559e22f30ed..65960e5cc550 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -103,52 +103,50 @@ 
SystemDependentData_GdiPlusBitmap::SystemDependentData_GdiPlusBitmap(
 
 sal_Int64 SystemDependentData_GdiPlusBitmap::estimateUsageInBytes() const
 {
-    sal_Int64 nRetval(0);
+    if(!mpGdiPlusBitmap)
+        return 0;
 
-    if(mpGdiPlusBitmap)
-    {
-        const UINT nWidth(mpGdiPlusBitmap->GetWidth());
-        const UINT nHeight(mpGdiPlusBitmap->GetHeight());
+    const UINT nWidth(mpGdiPlusBitmap->GetWidth());
+    const UINT nHeight(mpGdiPlusBitmap->GetHeight());
 
-        if(0 != nWidth && 0 != nHeight)
-        {
-            nRetval = nWidth * nHeight;
+    if(0 == nWidth || 0 == nHeight)
+        return 0;
 
-            switch(mpGdiPlusBitmap->GetPixelFormat())
-            {
-                case PixelFormat1bppIndexed:
-                    nRetval /= 8;
-                    break;
-                case PixelFormat4bppIndexed:
-                    nRetval /= 4;
-                    break;
-                case PixelFormat16bppGrayScale:
-                case PixelFormat16bppRGB555:
-                case PixelFormat16bppRGB565:
-                case PixelFormat16bppARGB1555:
-                    nRetval *= 2;
-                    break;
-                case PixelFormat24bppRGB:
-                    nRetval *= 3;
-                    break;
-                case PixelFormat32bppRGB:
-                case PixelFormat32bppARGB:
-                case PixelFormat32bppPARGB:
-                case PixelFormat32bppCMYK:
-                    nRetval *= 4;
-                    break;
-                case PixelFormat48bppRGB:
-                    nRetval *= 6;
-                    break;
-                case PixelFormat64bppARGB:
-                case PixelFormat64bppPARGB:
-                    nRetval *= 8;
-                    break;
-                default:
-                case PixelFormat8bppIndexed:
-                    break;
-            }
-        }
+    sal_Int64 nRetval = nWidth * nHeight;
+
+    switch(mpGdiPlusBitmap->GetPixelFormat())
+    {
+        case PixelFormat1bppIndexed:
+            nRetval /= 8;
+            break;
+        case PixelFormat4bppIndexed:
+            nRetval /= 4;
+            break;
+        case PixelFormat16bppGrayScale:
+        case PixelFormat16bppRGB555:
+        case PixelFormat16bppRGB565:
+        case PixelFormat16bppARGB1555:
+            nRetval *= 2;
+            break;
+        case PixelFormat24bppRGB:
+            nRetval *= 3;
+            break;
+        case PixelFormat32bppRGB:
+        case PixelFormat32bppARGB:
+        case PixelFormat32bppPARGB:
+        case PixelFormat32bppCMYK:
+            nRetval *= 4;
+            break;
+        case PixelFormat48bppRGB:
+            nRetval *= 6;
+            break;
+        case PixelFormat64bppARGB:
+        case PixelFormat64bppPARGB:
+            nRetval *= 8;
+            break;
+        default:
+        case PixelFormat8bppIndexed:
+            break;
     }
 
     return nRetval;
@@ -469,29 +467,26 @@ bool WinSalBitmap::Create( const SalBitmap& rSSalBitmap )
     assert(!mhDIB && "already created");
     assert(!mhDDB && "already created");
 
-    bool bRet = false;
     const WinSalBitmap& rSalBitmap = static_cast<const 
WinSalBitmap&>(rSSalBitmap);
 
-    if ( rSalBitmap.mhDIB || rSalBitmap.mhDDB )
-    {
-        HANDLE hNewHdl = ImplCopyDIBOrDDB( rSalBitmap.mhDIB ? rSalBitmap.mhDIB 
: rSalBitmap.mhDDB,
-                                           rSalBitmap.mhDIB != nullptr );
+    if ( !rSalBitmap.mhDIB && !rSalBitmap.mhDDB )
+        return false;
 
-        if ( hNewHdl )
-        {
-            if( rSalBitmap.mhDIB )
-                mhDIB = static_cast<HGLOBAL>(hNewHdl);
-            else if( rSalBitmap.mhDDB )
-                mhDDB = static_cast<HBITMAP>(hNewHdl);
+    HANDLE hNewHdl = ImplCopyDIBOrDDB( rSalBitmap.mhDIB ? rSalBitmap.mhDIB : 
rSalBitmap.mhDDB,
+                                       rSalBitmap.mhDIB != nullptr );
 
-            maSize = rSalBitmap.maSize;
-            mnBitCount = rSalBitmap.mnBitCount;
+    if ( !hNewHdl )
+        return false;
 
-            bRet = true;
-        }
-    }
+    if( rSalBitmap.mhDIB )
+        mhDIB = static_cast<HGLOBAL>(hNewHdl);
+    else if( rSalBitmap.mhDDB )
+        mhDDB = static_cast<HBITMAP>(hNewHdl);
 
-    return bRet;
+    maSize = rSalBitmap.maSize;
+    mnBitCount = rSalBitmap.mnBitCount;
+
+    return true;
 }
 
 bool WinSalBitmap::Create( const SalBitmap& rSSalBmp, SalGraphics* pSGraphics )
@@ -537,55 +532,55 @@ bool WinSalBitmap::Create(const SalBitmap& rSSalBmp, 
vcl::PixelFormat eNewPixelF
     assert(!mhDIB && "already created");
     assert(!mhDDB && "already created");
 
-    bool bRet = false;
-
     const WinSalBitmap& rSalBmp = static_cast<const WinSalBitmap&>(rSSalBmp);
 
     assert( rSalBmp.mhDDB && "why copy an empty WinSalBitmap");
 
-    if( rSalBmp.mhDDB )
-    {
-        mhDIB = ImplCreateDIB( rSalBmp.maSize, eNewPixelFormat, 
BitmapPalette() );
+    if( !rSalBmp.mhDDB )
+        return false;
 
-        if( mhDIB )
-        {
-            if (PBITMAPINFO pBI = static_cast<PBITMAPINFO>(GlobalLock( mhDIB 
)))
-            {
-                const int   nLines = static_cast<int>(rSalBmp.maSize.Height());
-                HDC         hDC = GetDC( nullptr );
-                PBYTE       pBits = reinterpret_cast<PBYTE>(pBI) + 
pBI->bmiHeader.biSize +
-                                    ImplGetDIBColorCount( mhDIB ) * sizeof( 
RGBQUAD );
-                SalData*    pSalData = GetSalData();
-                HPALETTE    hOldPal = nullptr;
-
-                if ( pSalData->mhDitherPal )
-                {
-                    hOldPal = SelectPalette( hDC, pSalData->mhDitherPal, TRUE 
);
-                    RealizePalette( hDC );
-                }
+    mhDIB = ImplCreateDIB( rSalBmp.maSize, eNewPixelFormat, BitmapPalette() );
 
-                if( GetDIBits( hDC, rSalBmp.mhDDB, 0, nLines, pBits, pBI, 
DIB_RGB_COLORS ) == nLines )
-                {
-                    GlobalUnlock( mhDIB );
-                    maSize = rSalBmp.maSize;
-                    mnBitCount = vcl::pixelFormatBitCount(eNewPixelFormat);
-                    bRet = true;
-                }
-                else
-                {
-                    GlobalUnlock( mhDIB );
-                    GlobalFree( mhDIB );
-                    mhDIB = nullptr;
-                }
+    if( !mhDIB )
+        return false;
 
-                if( hOldPal )
-                    SelectPalette( hDC, hOldPal, TRUE );
+    PBITMAPINFO pBI = static_cast<PBITMAPINFO>(GlobalLock( mhDIB ));
+    if (!pBI)
+        return false;
 
-                ReleaseDC( nullptr, hDC );
-            }
-        }
+    bool bRet = false;
+    const int   nLines = static_cast<int>(rSalBmp.maSize.Height());
+    HDC         hDC = GetDC( nullptr );
+    PBYTE       pBits = reinterpret_cast<PBYTE>(pBI) + pBI->bmiHeader.biSize +
+                        ImplGetDIBColorCount( mhDIB ) * sizeof( RGBQUAD );
+    SalData*    pSalData = GetSalData();
+    HPALETTE    hOldPal = nullptr;
+
+    if ( pSalData->mhDitherPal )
+    {
+        hOldPal = SelectPalette( hDC, pSalData->mhDitherPal, TRUE );
+        RealizePalette( hDC );
     }
 
+    if( GetDIBits( hDC, rSalBmp.mhDDB, 0, nLines, pBits, pBI, DIB_RGB_COLORS ) 
== nLines )
+    {
+        GlobalUnlock( mhDIB );
+        maSize = rSalBmp.maSize;
+        mnBitCount = vcl::pixelFormatBitCount(eNewPixelFormat);
+        bRet = true;
+    }
+    else
+    {
+        GlobalUnlock( mhDIB );
+        GlobalFree( mhDIB );
+        mhDIB = nullptr;
+    }
+
+    if( hOldPal )
+        SelectPalette( hDC, hOldPal, TRUE );
+
+    ReleaseDC( nullptr, hDC );
+
     return bRet;
 }
 
@@ -595,20 +590,18 @@ bool WinSalBitmap::Create( const css::uno::Reference< 
css::rendering::XBitmapCan
         xFastPropertySet( rBitmapCanvas, css::uno::UNO_QUERY );
 
     assert( xFastPropertySet && "creating without an xFastPropertySet?");
+    if( !xFastPropertySet )
+        return false;
 
-    if( xFastPropertySet )
-    {
-        css::uno::Sequence< css::uno::Any > args;
+    css::uno::Sequence< css::uno::Any > args;
+    if( !(xFastPropertySet->getFastPropertyValue(bMask ? 2 : 1) >>= args) )
+        return false;
 
-        if( xFastPropertySet->getFastPropertyValue(bMask ? 2 : 1) >>= args ) {
-            sal_Int64 aHBmp64;
+    sal_Int64 aHBmp64;
+    if( !(args[0] >>= aHBmp64) )
+        return false;
 
-            if( args[0] >>= aHBmp64 ) {
-                return Create( reinterpret_cast<HBITMAP>(aHBmp64) );
-            }
-        }
-    }
-    return false;
+    return Create( reinterpret_cast<HBITMAP>(aHBmp64) );
 }
 
 sal_uInt16 WinSalBitmap::ImplGetDIBColorCount( HGLOBAL hDIB )
@@ -616,26 +609,25 @@ sal_uInt16 WinSalBitmap::ImplGetDIBColorCount( HGLOBAL 
hDIB )
     if (!hDIB)
         return 0;
 
-    sal_uInt16 nColors = 0;
+    PBITMAPINFO  pBI = static_cast<PBITMAPINFO>(GlobalLock( hDIB ));
+    if (!pBI)
+        return 0;
 
-    if (PBITMAPINFO  pBI = static_cast<PBITMAPINFO>(GlobalLock( hDIB )))
+    sal_uInt16 nColors = 0;
+    if ( pBI->bmiHeader.biSize != sizeof( BITMAPCOREHEADER ) )
     {
-
-        if ( pBI->bmiHeader.biSize != sizeof( BITMAPCOREHEADER ) )
+        if( pBI->bmiHeader.biBitCount <= 8 )
         {
-            if( pBI->bmiHeader.biBitCount <= 8 )
-            {
-                if ( pBI->bmiHeader.biClrUsed )
-                    nColors = 
static_cast<sal_uInt16>(pBI->bmiHeader.biClrUsed);
-                else
-                    nColors = 1 << pBI->bmiHeader.biBitCount;
-            }
+            if ( pBI->bmiHeader.biClrUsed )
+                nColors = static_cast<sal_uInt16>(pBI->bmiHeader.biClrUsed);
+            else
+                nColors = 1 << pBI->bmiHeader.biBitCount;
         }
-        else if( reinterpret_cast<PBITMAPCOREHEADER>(pBI)->bcBitCount <= 8 )
-            nColors = 1 << 
reinterpret_cast<PBITMAPCOREHEADER>(pBI)->bcBitCount;
-
-        GlobalUnlock( hDIB );
     }
+    else if( reinterpret_cast<PBITMAPCOREHEADER>(pBI)->bcBitCount <= 8 )
+        nColors = 1 << reinterpret_cast<PBITMAPCOREHEADER>(pBI)->bcBitCount;
+
+    GlobalUnlock( hDIB );
 
     return nColors;
 }
@@ -750,49 +742,49 @@ BitmapBuffer* WinSalBitmap::AcquireBuffer( 
BitmapAccessMode /*nMode*/ )
     if (!mhDIB)
         return nullptr;
 
+    PBITMAPINFO pBI = static_cast<PBITMAPINFO>(GlobalLock( mhDIB ));
+    if (!pBI)
+        return nullptr;
+
     std::unique_ptr<BitmapBuffer> pBuffer;
+    PBITMAPINFOHEADER   pBIH = &pBI->bmiHeader;
 
-    if (PBITMAPINFO pBI = static_cast<PBITMAPINFO>(GlobalLock( mhDIB )))
+    if( pBIH->biPlanes == 1 )
     {
-        PBITMAPINFOHEADER   pBIH = &pBI->bmiHeader;
+        pBuffer.reset(new BitmapBuffer);
 
-        if( pBIH->biPlanes == 1 )
-        {
-            pBuffer.reset(new BitmapBuffer);
+        pBuffer->meFormat = pBIH->biBitCount == 8 ? ScanlineFormat::N8BitPal :
+                            pBIH->biBitCount == 24 ? 
ScanlineFormat::N24BitTcBgr :
+                            pBIH->biBitCount == 32 ? 
ScanlineFormat::N32BitTcXrgb :
+                            ScanlineFormat::NONE;
+        assert (pBuffer->meFormat != ScanlineFormat::NONE);
 
-            pBuffer->meFormat = pBIH->biBitCount == 8 ? 
ScanlineFormat::N8BitPal :
-                                pBIH->biBitCount == 24 ? 
ScanlineFormat::N24BitTcBgr :
-                                pBIH->biBitCount == 32 ? 
ScanlineFormat::N32BitTcXrgb :
-                                ScanlineFormat::NONE;
-            assert (pBuffer->meFormat != ScanlineFormat::NONE);
+        if (pBuffer->meFormat != ScanlineFormat::NONE)
+        {
+            pBuffer->mnWidth = maSize.Width();
+            pBuffer->mnHeight = maSize.Height();
+            pBuffer->mnScanlineSize = AlignedWidth4Bytes( maSize.Width() * 
pBIH->biBitCount );
+            pBuffer->mnBitCount = static_cast<sal_uInt16>(pBIH->biBitCount);
 
-            if (pBuffer->meFormat != ScanlineFormat::NONE)
+            if( pBuffer->mnBitCount <= 8 )
             {
-                pBuffer->mnWidth = maSize.Width();
-                pBuffer->mnHeight = maSize.Height();
-                pBuffer->mnScanlineSize = AlignedWidth4Bytes( maSize.Width() * 
pBIH->biBitCount );
-                pBuffer->mnBitCount = 
static_cast<sal_uInt16>(pBIH->biBitCount);
+                const sal_uInt16 nPalCount = ImplGetDIBColorCount( mhDIB );
 
-                if( pBuffer->mnBitCount <= 8 )
-                {
-                    const sal_uInt16 nPalCount = ImplGetDIBColorCount( mhDIB );
-
-                    pBuffer->maPalette.SetEntryCount( nPalCount );
-                    memcpy( pBuffer->maPalette.ImplGetColorBuffer(), 
pBI->bmiColors, nPalCount * sizeof( RGBQUAD ) );
-                    pBuffer->mpBits = reinterpret_cast<PBYTE>(pBI) + 
pBI->bmiHeader.biSize + nPalCount * sizeof( RGBQUAD );
-                }
-                else
-                    pBuffer->mpBits = reinterpret_cast<PBYTE>(pBI) + 
pBI->bmiHeader.biSize;
+                pBuffer->maPalette.SetEntryCount( nPalCount );
+                memcpy( pBuffer->maPalette.ImplGetColorBuffer(), 
pBI->bmiColors, nPalCount * sizeof( RGBQUAD ) );
+                pBuffer->mpBits = reinterpret_cast<PBYTE>(pBI) + 
pBI->bmiHeader.biSize + nPalCount * sizeof( RGBQUAD );
             }
             else
-            {
-                GlobalUnlock( mhDIB );
-                pBuffer.reset();
-            }
+                pBuffer->mpBits = reinterpret_cast<PBYTE>(pBI) + 
pBI->bmiHeader.biSize;
         }
         else
+        {
             GlobalUnlock( mhDIB );
+            pBuffer.reset();
+        }
     }
+    else
+        GlobalUnlock( mhDIB );
 
     return pBuffer.release();
 }
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 06a90a361f18..312f5c60b97f 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -473,38 +473,38 @@ static FontAttributes WinFont2DevFontAttributes( const 
ENUMLOGFONTEXW& rEnumFont
 void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, Font& rFont )
 {
     OUString aFontName( o3tl::toU(rLogFont.lfFaceName) );
-    if (!aFontName.isEmpty())
-    {
-        rFont.SetFamilyName( aFontName );
-        rFont.SetCharSet( ImplCharSetToSal( rLogFont.lfCharSet ) );
-        rFont.SetFamily( ImplFamilyToSal( rLogFont.lfPitchAndFamily ) );
-        rFont.SetPitch( ImplLogPitchToSal( rLogFont.lfPitchAndFamily ) );
-        rFont.SetWeight( ImplWeightToSal( rLogFont.lfWeight ) );
-
-        tools::Long nFontHeight = rLogFont.lfHeight;
-        if ( nFontHeight < 0 )
-            nFontHeight = -nFontHeight;
-        tools::Long nDPIY = GetDeviceCaps( hDC, LOGPIXELSY );
-        if( !nDPIY )
-            nDPIY = 600;
-        nFontHeight *= 72;
-        nFontHeight += nDPIY/2;
-        nFontHeight /= nDPIY;
-        rFont.SetFontSize( Size( 0, nFontHeight ) );
-        rFont.SetOrientation( 
Degree10(static_cast<sal_Int16>(rLogFont.lfEscapement)) );
-        if ( rLogFont.lfItalic )
-            rFont.SetItalic( ITALIC_NORMAL );
-        else
-            rFont.SetItalic( ITALIC_NONE );
-        if ( rLogFont.lfUnderline )
-            rFont.SetUnderline( LINESTYLE_SINGLE );
-        else
-            rFont.SetUnderline( LINESTYLE_NONE );
-        if ( rLogFont.lfStrikeOut )
-            rFont.SetStrikeout( STRIKEOUT_SINGLE );
-        else
-            rFont.SetStrikeout( STRIKEOUT_NONE );
-    }
+    if (aFontName.isEmpty())
+        return;
+
+    rFont.SetFamilyName( aFontName );
+    rFont.SetCharSet( ImplCharSetToSal( rLogFont.lfCharSet ) );
+    rFont.SetFamily( ImplFamilyToSal( rLogFont.lfPitchAndFamily ) );
+    rFont.SetPitch( ImplLogPitchToSal( rLogFont.lfPitchAndFamily ) );
+    rFont.SetWeight( ImplWeightToSal( rLogFont.lfWeight ) );
+
+    tools::Long nFontHeight = rLogFont.lfHeight;
+    if ( nFontHeight < 0 )
+        nFontHeight = -nFontHeight;
+    tools::Long nDPIY = GetDeviceCaps( hDC, LOGPIXELSY );
+    if( !nDPIY )
+        nDPIY = 600;
+    nFontHeight *= 72;
+    nFontHeight += nDPIY/2;
+    nFontHeight /= nDPIY;
+    rFont.SetFontSize( Size( 0, nFontHeight ) );
+    rFont.SetOrientation( 
Degree10(static_cast<sal_Int16>(rLogFont.lfEscapement)) );
+    if ( rLogFont.lfItalic )
+        rFont.SetItalic( ITALIC_NORMAL );
+    else
+        rFont.SetItalic( ITALIC_NONE );
+    if ( rLogFont.lfUnderline )
+        rFont.SetUnderline( LINESTYLE_SINGLE );
+    else
+        rFont.SetUnderline( LINESTYLE_NONE );
+    if ( rLogFont.lfStrikeOut )
+        rFont.SetStrikeout( STRIKEOUT_SINGLE );
+    else
+        rFont.SetStrikeout( STRIKEOUT_NONE );
 }
 
 WinFontFace::WinFontFace(const ENUMLOGFONTEXW& rEnumFont, const 
NEWTEXTMETRICW& rMetric)
@@ -923,20 +923,20 @@ static int lcl_AddFontResource(SalData& rSalData, const 
OUString& rFontFileURL,
 
     int nRet = AddFontResourceExW(o3tl::toW(aFontSystemPath.getStr()), 
FR_PRIVATE, nullptr);
     SAL_WARN_IF(nRet <= 0, "vcl.fonts", "AddFontResourceExW failed for " << 
rFontFileURL);
-    if (nRet > 0)
+    if (nRet <= 0)
+        return nRet;
+
+    TempFontItem* pNewItem = new TempFontItem;
+    pNewItem->maFontResourcePath = aFontSystemPath;
+    if (bShared)
     {
-        TempFontItem* pNewItem = new TempFontItem;
-        pNewItem->maFontResourcePath = aFontSystemPath;
-        if (bShared)
-        {
-            pNewItem->mpNextItem = rSalData.mpSharedTempFontItem;
-            rSalData.mpSharedTempFontItem = pNewItem;
-        }
-        else
-        {
-            pNewItem->mpNextItem = rSalData.mpOtherTempFontItem;
-            rSalData.mpOtherTempFontItem = pNewItem;
-        }
+        pNewItem->mpNextItem = rSalData.mpSharedTempFontItem;
+        rSalData.mpSharedTempFontItem = pNewItem;
+    }
+    else
+    {
+        pNewItem->mpNextItem = rSalData.mpOtherTempFontItem;
+        rSalData.mpOtherTempFontItem = pNewItem;
     }
     return nRet;
 }
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 1040810975c6..978f4cf95309 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -400,20 +400,20 @@ static void ImplInsertSysColorEntry( int nSysIndex )
 {
     const DWORD nRGB = GetSysColor( nSysIndex );
 
-    if ( !ImplIsPaletteEntry( GetRValue( nRGB ), GetGValue( nRGB ), GetBValue( 
nRGB ) ) )
+    if ( ImplIsPaletteEntry( GetRValue( nRGB ), GetGValue( nRGB ), GetBValue( 
nRGB ) ) )
+        return;
+
+    if ( !pFirstSysColor )
     {
-        if ( !pFirstSysColor )
-        {
-            pActSysColor = pFirstSysColor = new SysColorEntry;
-            pFirstSysColor->nRGB = nRGB;
-            pFirstSysColor->pNext = nullptr;
-        }
-        else
-        {
-            pActSysColor = pActSysColor->pNext = new SysColorEntry;
-            pActSysColor->nRGB = nRGB;
-            pActSysColor->pNext = nullptr;
-        }
+        pActSysColor = pFirstSysColor = new SysColorEntry;
+        pFirstSysColor->nRGB = nRGB;
+        pFirstSysColor->pNext = nullptr;
+    }
+    else
+    {
+        pActSysColor = pActSysColor->pNext = new SysColorEntry;
+        pActSysColor->nRGB = nRGB;
+        pActSysColor->pNext = nullptr;
     }
 }
 
@@ -936,63 +936,64 @@ static BYTE* ImplSearchEntry( BYTE* pSource, BYTE const * 
pDest, sal_uLong nComp
 
 static bool ImplGetBoundingBox( double* nNumb, BYTE* pSource, sal_uLong nSize )
 {
-    bool    bRetValue = false;
     BYTE* pDest = ImplSearchEntry( pSource, reinterpret_cast<BYTE const 
*>("%%BoundingBox:"), nSize, 14 );
-    if ( pDest )
-    {
-        nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
-        pDest += 14;
+    if ( !pDest )
+        return false;
+
+    bool    bRetValue = false;
+
+    nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
+    pDest += 14;
 
-        int nSizeLeft = nSize - ( pDest - pSource );
-        if ( nSizeLeft > 100 )
-            nSizeLeft = 100;    // only 100 bytes following the bounding box 
will be checked
+    int nSizeLeft = nSize - ( pDest - pSource );
+    if ( nSizeLeft > 100 )
+        nSizeLeft = 100;    // only 100 bytes following the bounding box will 
be checked
 
-        int i;
-        for ( i = 0; ( i < 4 ) && nSizeLeft; i++ )
+    int i;
+    for ( i = 0; ( i < 4 ) && nSizeLeft; i++ )
+    {
+        int     nDivision = 1;
+        bool    bDivision = false;
+        bool    bNegative = false;
+        bool    bValid = true;
+
+        while ( ( --nSizeLeft ) && ( ( *pDest == ' ' ) || ( *pDest == 0x9 ) ) 
) pDest++;
+        BYTE nByte = *pDest;
+        while ( nSizeLeft && ( nByte != ' ' ) && ( nByte != 0x9 ) && ( nByte 
!= 0xd ) && ( nByte != 0xa ) )
         {
-            int     nDivision = 1;
-            bool    bDivision = false;
-            bool    bNegative = false;
-            bool    bValid = true;
-
-            while ( ( --nSizeLeft ) && ( ( *pDest == ' ' ) || ( *pDest == 0x9 
) ) ) pDest++;
-            BYTE nByte = *pDest;
-            while ( nSizeLeft && ( nByte != ' ' ) && ( nByte != 0x9 ) && ( 
nByte != 0xd ) && ( nByte != 0xa ) )
+            switch ( nByte )
             {
-                switch ( nByte )
-                {
-                    case '.' :
+                case '.' :
+                    if ( bDivision )
+                        bValid = false;
+                    else
+                        bDivision = true;
+                    break;
+                case '-' :
+                    bNegative = true;
+                    break;
+                default :
+                    if ( ( nByte < '0' ) || ( nByte > '9' ) )
+                        nSizeLeft = 1;  // error parsing the bounding box 
values
+                    else if ( bValid )
+                    {
                         if ( bDivision )
-                            bValid = false;
-                        else
-                            bDivision = true;
-                        break;
-                    case '-' :
-                        bNegative = true;
-                        break;
-                    default :
-                        if ( ( nByte < '0' ) || ( nByte > '9' ) )
-                            nSizeLeft = 1;  // error parsing the bounding box 
values
-                        else if ( bValid )
-                        {
-                            if ( bDivision )
-                                nDivision*=10;
-                            nNumb[i] *= 10;
-                            nNumb[i] += nByte - '0';
-                        }
-                        break;
-                }
-                nSizeLeft--;
-                nByte = *(++pDest);
+                            nDivision*=10;
+                        nNumb[i] *= 10;
+                        nNumb[i] += nByte - '0';
+                    }
+                    break;
             }
-            if ( bNegative )
-                nNumb[i] = -nNumb[i];
-            if ( bDivision && ( nDivision != 1 ) )
-                nNumb[i] /= nDivision;
+            nSizeLeft--;
+            nByte = *(++pDest);
         }
-        if ( i == 4 )
-            bRetValue = true;
+        if ( bNegative )
+            nNumb[i] = -nNumb[i];
+        if ( bDivision && ( nDivision != 1 ) )
+            nNumb[i] /= nDivision;
     }
+    if ( i == 4 )
+        bRetValue = true;
     return bRetValue;
 }
 
@@ -1000,138 +1001,134 @@ static bool ImplGetBoundingBox( double* nNumb, BYTE* 
pSource, sal_uLong nSize )
 
 bool WinSalGraphics::drawEPS( tools::Long nX, tools::Long nY, tools::Long 
nWidth, tools::Long nHeight, void* pPtr, sal_uInt32 nSize )
 {
-    bool bRetValue = false;
 
-    if ( mbPrinter )
+    if ( !mbPrinter )
+        return false;
+
+    int nEscape = POSTSCRIPT_PASSTHROUGH;
+    if ( !Escape( getHDC(), QUERYESCSUPPORT, sizeof( int ), 
reinterpret_cast<LPSTR>(&nEscape), nullptr ) )
+        return false;
+
+    double  nBoundingBox[4];
+    if ( !ImplGetBoundingBox( nBoundingBox, static_cast<BYTE*>(pPtr), nSize ) )
+        return false;
+
+    OStringBuffer aBuf( POSTSCRIPT_BUFSIZE );
+
+    // reserve place for a sal_uInt16
+    aBuf.append( "aa" );
+
+    // #107797# Write out EPS encapsulation header
+
+    // directly taken from the PLRM 3.0, p. 726. Note:
+    // this will definitely cause problems when
+    // recursively creating and embedding PostScript files
+    // in OOo, since we use statically-named variables
+    // here (namely, b4_Inc_state_salWin, dict_count_salWin and
+    // op_count_salWin). Currently, I have no idea on how to
+    // work around that, except from scanning and
+    // interpreting the EPS for unused identifiers.
+
+    // append the real text
+    aBuf.append( "

/b4_Inc_state_salWin save def
"
+                 "/dict_count_salWin countdictstack def
"
+                 "/op_count_salWin count 1 sub def
"
+                 "userdict begin
"
+                 "/showpage {} def
"
+                 "0 setgray 0 setlinecap
"
+                 "1 setlinewidth 0 setlinejoin
"
+                 "10 setmiterlimit [] 0 setdash newpath
"
+                 "/languagelevel where
"
+                 "{
"
+                 "  pop languagelevel
"
+                 "  1 ne
"
+                 "  {
"
+                 "    false setstrokeadjust false setoverprint
"
+                 "  } if
"
+                 "} if

" );
+
+    // #i10737# Apply clipping manually
+
+    // Windows seems to ignore any clipping at the HDC,
+    // when followed by a POSTSCRIPT_PASSTHROUGH
+
+    // Check whether we've got a clipping, consisting of
+    // exactly one rect (other cases should be, but aren't
+    // handled currently)
+
+    // TODO: Handle more than one rectangle here (take
+    // care, the buffer can handle only POSTSCRIPT_BUFSIZE
+    // characters!)
+    if ( mhRegion != nullptr &&
+         mpStdClipRgnData != nullptr &&
+         mpClipRgnData == mpStdClipRgnData &&
+         mpClipRgnData->rdh.nCount == 1 )
     {
-        int nEscape = POSTSCRIPT_PASSTHROUGH;
-
-        if ( Escape( getHDC(), QUERYESCSUPPORT, sizeof( int ), 
reinterpret_cast<LPSTR>(&nEscape), nullptr ) )
-        {
-            double  nBoundingBox[4];
+        RECT* pRect = &(mpClipRgnData->rdh.rcBound);
+
+        aBuf.append( "
newpath
"
+                     + OString::number(pRect->left) + " " + 
OString::number(pRect->top)
+                     + " moveto
"
+                     + OString::number(pRect->right) + " " + 
OString::number(pRect->top)
+                     + " lineto
"
+                     + OString::number(pRect->right) + " "
+                     + OString::number(pRect->bottom) + " lineto
"
+                     + OString::number(pRect->left) + " "
+                     + OString::number(pRect->bottom) + " lineto
"
+                     "closepath
"
+                     "clip
"
+                     "newpath
" );
+    }
 
-            if ( ImplGetBoundingBox( nBoundingBox, static_cast<BYTE*>(pPtr), 
nSize ) )
-            {
-                OStringBuffer aBuf( POSTSCRIPT_BUFSIZE );
-
-                // reserve place for a sal_uInt16
-                aBuf.append( "aa" );
-
-                // #107797# Write out EPS encapsulation header
-
-                // directly taken from the PLRM 3.0, p. 726. Note:
-                // this will definitely cause problems when
-                // recursively creating and embedding PostScript files
-                // in OOo, since we use statically-named variables
-                // here (namely, b4_Inc_state_salWin, dict_count_salWin and
-                // op_count_salWin). Currently, I have no idea on how to
-                // work around that, except from scanning and
-                // interpreting the EPS for unused identifiers.
-
-                // append the real text
-                aBuf.append( "

/b4_Inc_state_salWin save def
"
-                             "/dict_count_salWin countdictstack def
"
-                             "/op_count_salWin count 1 sub def
"
-                             "userdict begin
"
-                             "/showpage {} def
"
-                             "0 setgray 0 setlinecap
"
-                             "1 setlinewidth 0 setlinejoin
"
-                             "10 setmiterlimit [] 0 setdash newpath
"
-                             "/languagelevel where
"
-                             "{
"
-                             "  pop languagelevel
"
-                             "  1 ne
"
-                             "  {
"
-                             "    false setstrokeadjust false setoverprint
"
-                             "  } if
"
-                             "} if

" );
-
-                // #i10737# Apply clipping manually
-
-                // Windows seems to ignore any clipping at the HDC,
-                // when followed by a POSTSCRIPT_PASSTHROUGH
-
-                // Check whether we've got a clipping, consisting of
-                // exactly one rect (other cases should be, but aren't
-                // handled currently)
-
-                // TODO: Handle more than one rectangle here (take
-                // care, the buffer can handle only POSTSCRIPT_BUFSIZE
-                // characters!)
-                if ( mhRegion != nullptr &&
-                     mpStdClipRgnData != nullptr &&
-                     mpClipRgnData == mpStdClipRgnData &&
-                     mpClipRgnData->rdh.nCount == 1 )
-                {
-                    RECT* pRect = &(mpClipRgnData->rdh.rcBound);
-
-                    aBuf.append( "
newpath
"
-                                 + OString::number(pRect->left) + " " + 
OString::number(pRect->top)
-                                 + " moveto
"
-                                 + OString::number(pRect->right) + " " + 
OString::number(pRect->top)
-                                 + " lineto
"
-                                 + OString::number(pRect->right) + " "
-                                 + OString::number(pRect->bottom) + " lineto
"
-                                 + OString::number(pRect->left) + " "
-                                 + OString::number(pRect->bottom) + " lineto
"
-                                 "closepath
"
-                                 "clip
"
-                                 "newpath
" );
-                }
+    // #107797# Write out buffer
 
-                // #107797# Write out buffer
+    *reinterpret_cast<sal_uInt16*>(const_cast<char *>(aBuf.getStr())) = 
static_cast<sal_uInt16>( aBuf.getLength() - 2 );
+    Escape ( getHDC(), nEscape, aBuf.getLength(), aBuf.getStr(), nullptr );
 
-                *reinterpret_cast<sal_uInt16*>(const_cast<char 
*>(aBuf.getStr())) = static_cast<sal_uInt16>( aBuf.getLength() - 2 );
-                Escape ( getHDC(), nEscape, aBuf.getLength(), aBuf.getStr(), 
nullptr );
+    // #107797# Write out EPS transformation code
 
-                // #107797# Write out EPS transformation code
+    double  dM11 = nWidth / ( nBoundingBox[2] - nBoundingBox[0] );
+    double  dM22 = nHeight / (nBoundingBox[1] - nBoundingBox[3] );
+    // reserve a sal_uInt16 again
+    aBuf.setLength( 2 );
+    aBuf.append( "

[" + OString::number(dM11) + " 0 0 " + OString::number(dM22) + " "
+                 + OString::number(nX - ( dM11 * nBoundingBox[0] )) + " "
+                 + OString::number(nY - ( dM22 * nBoundingBox[3] )) + "] concat
"
+                 "%%BeginDocument:
" );
+    *reinterpret_cast<sal_uInt16*>(const_cast<char *>(aBuf.getStr())) = 
static_cast<sal_uInt16>( aBuf.getLength() - 2 );
+    Escape ( getHDC(), nEscape, aBuf.getLength(), aBuf.getStr(), nullptr );
 
-                double  dM11 = nWidth / ( nBoundingBox[2] - nBoundingBox[0] );
-                double  dM22 = nHeight / (nBoundingBox[1] - nBoundingBox[3] );
-                // reserve a sal_uInt16 again
-                aBuf.setLength( 2 );
-                aBuf.append( "

[" + OString::number(dM11) + " 0 0 " + OString::number(dM22) + " "
-                             + OString::number(nX - ( dM11 * nBoundingBox[0] 
)) + " "
-                             + OString::number(nY - ( dM22 * nBoundingBox[3] 
)) + "] concat
"
-                             "%%BeginDocument:
" );
-                *reinterpret_cast<sal_uInt16*>(const_cast<char 
*>(aBuf.getStr())) = static_cast<sal_uInt16>( aBuf.getLength() - 2 );
-                Escape ( getHDC(), nEscape, aBuf.getLength(), aBuf.getStr(), 
nullptr );
+    // #107797# Write out actual EPS content
 
-                // #107797# Write out actual EPS content
+    sal_uLong   nToDo = nSize;
+    sal_uLong   nDoNow;
+    while ( nToDo )
+    {
+        nDoNow = nToDo;
+        if ( nToDo > POSTSCRIPT_BUFSIZE - 2 )
+            nDoNow = POSTSCRIPT_BUFSIZE - 2;
+        // the following is based on the string buffer allocation
+        // of size POSTSCRIPT_BUFSIZE at construction time of aBuf
+        *reinterpret_cast<sal_uInt16*>(const_cast<char *>(aBuf.getStr())) = 
static_cast<sal_uInt16>(nDoNow);
+        memcpy( const_cast<char *>(aBuf.getStr() + 2), 
static_cast<BYTE*>(pPtr) + nSize - nToDo, nDoNow );
+        sal_uLong nResult = Escape ( getHDC(), nEscape, nDoNow + 2, 
aBuf.getStr(), nullptr );
+        if (!nResult )
+            break;
+        nToDo -= nResult;
+    }
 
-                sal_uLong   nToDo = nSize;
-                sal_uLong   nDoNow;
-                while ( nToDo )
-                {
-                    nDoNow = nToDo;
-                    if ( nToDo > POSTSCRIPT_BUFSIZE - 2 )
-                        nDoNow = POSTSCRIPT_BUFSIZE - 2;
-                    // the following is based on the string buffer allocation
-                    // of size POSTSCRIPT_BUFSIZE at construction time of aBuf
-                    *reinterpret_cast<sal_uInt16*>(const_cast<char 
*>(aBuf.getStr())) = static_cast<sal_uInt16>(nDoNow);
-                    memcpy( const_cast<char *>(aBuf.getStr() + 2), 
static_cast<BYTE*>(pPtr) + nSize - nToDo, nDoNow );
-                    sal_uLong nResult = Escape ( getHDC(), nEscape, nDoNow + 
2, aBuf.getStr(), nullptr );
-                    if (!nResult )
-                        break;
-                    nToDo -= nResult;
-                }
+    // #107797# Write out EPS encapsulation footer
 
-                // #107797# Write out EPS encapsulation footer
-
-                // reserve a sal_uInt16 again
-                aBuf.setLength( 2 );
-                aBuf.append( "%%EndDocument
"
-                             "count op_count_salWin sub {pop} repeat
"
-                             "countdictstack dict_count_salWin sub {end} repeat
"
-                             "b4_Inc_state_salWin restore

" );
-                *reinterpret_cast<sal_uInt16*>(const_cast<char 
*>(aBuf.getStr())) = static_cast<sal_uInt16>( aBuf.getLength() - 2 );
-                Escape ( getHDC(), nEscape, aBuf.getLength(), aBuf.getStr(), 
nullptr );
-                bRetValue = true;
-            }
-        }
-    }
+    // reserve a sal_uInt16 again
+    aBuf.setLength( 2 );
+    aBuf.append( "%%EndDocument
"
+                 "count op_count_salWin sub {pop} repeat
"
+                 "countdictstack dict_count_salWin sub {end} repeat
"
+                 "b4_Inc_state_salWin restore

" );
+    *reinterpret_cast<sal_uInt16*>(const_cast<char *>(aBuf.getStr())) = 
static_cast<sal_uInt16>( aBuf.getLength() - 2 );
+    Escape ( getHDC(), nEscape, aBuf.getLength(), aBuf.getStr(), nullptr );
 
-    return bRetValue;
+    return true;
 }
 
 SystemGraphicsData WinSalGraphics::GetGraphicsData() const
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 393c8c7b1f3a..07c5666a46fe 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -161,61 +161,61 @@ void WinSalInstance::GetPrinterQueueInfo( 
ImplPrnQueueList* pList )
     DWORD           nBytes = 0;
     DWORD           nInfoPrn4 = 0;
     EnumPrintersW( PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, nullptr, 4, 
nullptr, 0, &nBytes, &nInfoPrn4 );
-    if ( nBytes )
+    if ( !nBytes )
+        return;
+
+    PRINTER_INFO_4W* pWinInfo4 = static_cast<PRINTER_INFO_4W*>(std::malloc( 
nBytes ));
+    assert(pWinInfo4 && "Don't handle OOM conditions");
+    if ( EnumPrintersW( PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, 
nullptr, 4, reinterpret_cast<LPBYTE>(pWinInfo4), nBytes, &nBytes, &nInfoPrn4 ) )
     {
-        PRINTER_INFO_4W* pWinInfo4 = 
static_cast<PRINTER_INFO_4W*>(std::malloc( nBytes ));
-        assert(pWinInfo4 && "Don't handle OOM conditions");
-        if ( EnumPrintersW( PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, 
nullptr, 4, reinterpret_cast<LPBYTE>(pWinInfo4), nBytes, &nBytes, &nInfoPrn4 ) )
+        for ( i = 0; i < nInfoPrn4; i++ )
         {
-            for ( i = 0; i < nInfoPrn4; i++ )
-            {
-                std::unique_ptr<SalPrinterQueueInfo> pInfo(new 
SalPrinterQueueInfo);
-                pInfo->maPrinterName = o3tl::toU(pWinInfo4[i].pPrinterName);
-                pInfo->mnStatus      = PrintQueueFlags::NONE;
-                pInfo->mnJobs        = 0;
-                pList->Add( std::move(pInfo) );
-            }
+            std::unique_ptr<SalPrinterQueueInfo> pInfo(new 
SalPrinterQueueInfo);
+            pInfo->maPrinterName = o3tl::toU(pWinInfo4[i].pPrinterName);
+            pInfo->mnStatus      = PrintQueueFlags::NONE;
+            pInfo->mnJobs        = 0;
+            pList->Add( std::move(pInfo) );
         }
-        std::free( pWinInfo4 );
     }
+    std::free( pWinInfo4 );
 }
 
 void WinSalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo )
 {
     HANDLE hPrinter = nullptr;
     LPWSTR pPrnName = 
const_cast<LPWSTR>(o3tl::toW(pInfo->maPrinterName.getStr()));
-    if( OpenPrinterW( pPrnName, &hPrinter, nullptr ) )
+    if( !OpenPrinterW( pPrnName, &hPrinter, nullptr ) )
+        return;
+
+    DWORD               nBytes = 0;
+    GetPrinterW( hPrinter, 2, nullptr, 0, &nBytes );
+    if( nBytes )
     {
-        DWORD               nBytes = 0;
-        GetPrinterW( hPrinter, 2, nullptr, 0, &nBytes );
-        if( nBytes )
+        PRINTER_INFO_2W* pWinInfo2 = 
static_cast<PRINTER_INFO_2W*>(std::malloc(nBytes));
+        assert(pWinInfo2 && "Don't handle OOM conditions");
+        if( GetPrinterW( hPrinter, 2, reinterpret_cast<LPBYTE>(pWinInfo2), 
nBytes, &nBytes ) )
         {
-            PRINTER_INFO_2W* pWinInfo2 = 
static_cast<PRINTER_INFO_2W*>(std::malloc(nBytes));
-            assert(pWinInfo2 && "Don't handle OOM conditions");
-            if( GetPrinterW( hPrinter, 2, reinterpret_cast<LPBYTE>(pWinInfo2), 
nBytes, &nBytes ) )
-            {
-                if( pWinInfo2->pDriverName )
-                    pInfo->maDriver = o3tl::toU(pWinInfo2->pDriverName);
-                OUString aPortName;
-                if ( pWinInfo2->pPortName )
-                    aPortName = o3tl::toU(pWinInfo2->pPortName);
-                // pLocation can be 0 (the Windows docu doesn't describe this)
-                if ( pWinInfo2->pLocation && *pWinInfo2->pLocation )
-                    pInfo->maLocation = o3tl::toU(pWinInfo2->pLocation);
-                else
-                    pInfo->maLocation = aPortName;
-                // pComment can be 0 (the Windows docu doesn't describe this)
-                if ( pWinInfo2->pComment )
-                    pInfo->maComment = o3tl::toU(pWinInfo2->pComment);
-                pInfo->mnStatus      = ImplWinQueueStatusToSal( 
pWinInfo2->Status );
-                pInfo->mnJobs        = pWinInfo2->cJobs;
-                if( ! pInfo->moPortName )
-                    pInfo->moPortName = aPortName;
-            }
-            std::free(pWinInfo2);
+            if( pWinInfo2->pDriverName )
+                pInfo->maDriver = o3tl::toU(pWinInfo2->pDriverName);
+            OUString aPortName;
+            if ( pWinInfo2->pPortName )
+                aPortName = o3tl::toU(pWinInfo2->pPortName);
+            // pLocation can be 0 (the Windows docu doesn't describe this)
+            if ( pWinInfo2->pLocation && *pWinInfo2->pLocation )
+                pInfo->maLocation = o3tl::toU(pWinInfo2->pLocation);
+            else
+                pInfo->maLocation = aPortName;
+            // pComment can be 0 (the Windows docu doesn't describe this)
+            if ( pWinInfo2->pComment )
+                pInfo->maComment = o3tl::toU(pWinInfo2->pComment);
+            pInfo->mnStatus      = ImplWinQueueStatusToSal( pWinInfo2->Status 
);
+            pInfo->mnJobs        = pWinInfo2->cJobs;
+            if( ! pInfo->moPortName )
+                pInfo->moPortName = aPortName;
         }
-        ClosePrinter( hPrinter );
+        std::free(pWinInfo2);
     }
+    ClosePrinter( hPrinter );
 }
 
 OUString WinSalInstance::GetDefaultPrinter()
@@ -248,79 +248,79 @@ static DWORD ImplDeviceCaps( WinSalInfoPrinter const * 
pPrinter, WORD nCaps,
 static bool ImplTestSalJobSetup( WinSalInfoPrinter const * pPrinter,
                                  ImplJobSetup* pSetupData, bool bDelete )
 {
-    if ( pSetupData && pSetupData->GetDriverData() )
+    if ( !pSetupData || !pSetupData->GetDriverData() )
+        return false;
+
+    // signature and size must fit to avoid using
+    // JobSetups from a wrong system
+
+    // initialize versions from jobsetup
+    // those will be overwritten with driver's version
+    DEVMODEW const * pDevModeW = nullptr;
+    LONG dmSpecVersion = -1;
+    LONG dmDriverVersion = -1;
+    SalDriverData const * pSalDriverData = reinterpret_cast<SalDriverData 
const *>(pSetupData->GetDriverData());
+    BYTE const * pDriverData = reinterpret_cast<BYTE const *>(pSalDriverData) 
+ pSalDriverData->mnDriverOffset;
+    pDevModeW = reinterpret_cast<DEVMODEW const *>(pDriverData);
+
+    LONG nSysJobSize = -1;
+    if( pPrinter && pDevModeW )
     {
-        // signature and size must fit to avoid using
-        // JobSetups from a wrong system
-
-        // initialize versions from jobsetup
-        // those will be overwritten with driver's version
-        DEVMODEW const * pDevModeW = nullptr;
-        LONG dmSpecVersion = -1;
-        LONG dmDriverVersion = -1;
-        SalDriverData const * pSalDriverData = reinterpret_cast<SalDriverData 
const *>(pSetupData->GetDriverData());
-        BYTE const * pDriverData = reinterpret_cast<BYTE const 
*>(pSalDriverData) + pSalDriverData->mnDriverOffset;
-        pDevModeW = reinterpret_cast<DEVMODEW const *>(pDriverData);
-
-        LONG nSysJobSize = -1;
-        if( pPrinter && pDevModeW )
-        {
-            // just too many driver crashes in that area -> check the 
dmSpecVersion and dmDriverVersion fields always !!!
-            // this prevents using the jobsetup between different Windows 
versions (eg from XP to 9x) but we
-            // can avoid potential driver crashes as their jobsetups are often 
not compatible
-            // #110800#, #111151#, #112381#, #i16580#, #i14173# and perhaps 
#112375#
-            HANDLE hPrn;
-            LPWSTR pPrinterNameW = 
const_cast<LPWSTR>(o3tl::toW(pPrinter->maDeviceName.getStr()));
-            if ( !OpenPrinterW( pPrinterNameW, &hPrn, nullptr ) )
-                return false;
-
-            // #131642# hPrn==HGDI_ERROR even though OpenPrinter() succeeded!
-            if( hPrn == HGDI_ERROR )
-                return false;
-
-            nSysJobSize = DocumentPropertiesW( nullptr, hPrn,
-                                               pPrinterNameW,
-                                               nullptr, nullptr, 0 );
-
-            if( nSysJobSize < 0 )
-            {
-                ClosePrinter( hPrn );
-                return false;
-            }
-            DEVMODEW *pBuffer = static_cast<DEVMODEW*>(_alloca( nSysJobSize ));
-            LONG nRet = DocumentPropertiesW( nullptr, hPrn,
-                                        pPrinterNameW,
-                                        pBuffer, nullptr, DM_OUT_BUFFER );
-            if( nRet < 0 )
-            {
-                ClosePrinter( hPrn );
-                return false;
-            }
+        // just too many driver crashes in that area -> check the 
dmSpecVersion and dmDriverVersion fields always !!!
+        // this prevents using the jobsetup between different Windows versions 
(eg from XP to 9x) but we
+        // can avoid potential driver crashes as their jobsetups are often not 
compatible
+        // #110800#, #111151#, #112381#, #i16580#, #i14173# and perhaps 
#112375#
+        HANDLE hPrn;
+        LPWSTR pPrinterNameW = 
const_cast<LPWSTR>(o3tl::toW(pPrinter->maDeviceName.getStr()));
+        if ( !OpenPrinterW( pPrinterNameW, &hPrn, nullptr ) )
+            return false;
 
-            // the spec version differs between the windows platforms, ie 
98,NT,2000/XP
-            // this allows us to throw away printer settings from other 
platforms that might crash a buggy driver
-            // we check the driver version as well
-            dmSpecVersion = pBuffer->dmSpecVersion;
-            dmDriverVersion = pBuffer->dmDriverVersion;
+        // #131642# hPrn==HGDI_ERROR even though OpenPrinter() succeeded!
+        if( hPrn == HGDI_ERROR )
+            return false;
 
-            ClosePrinter( hPrn );
-        }
-        SalDriverData const * pSetupDriverData = 
reinterpret_cast<SalDriverData const *>(pSetupData->GetDriverData());
-        if ( (pSetupData->GetSystem() == JOBSETUP_SYSTEM_WINDOWS) &&
-             (pPrinter && pPrinter->maDriverName == pSetupData->GetDriver()) &&
-             (pSetupData->GetDriverDataLen() > sizeof( SalDriverData )) &&
-             static_cast<tools::Long>(pSetupData->GetDriverDataLen() - 
pSetupDriverData->mnDriverOffset) == nSysJobSize &&
-             pSetupDriverData->mnSysSignature == SAL_DRIVERDATA_SYSSIGN )
+        nSysJobSize = DocumentPropertiesW( nullptr, hPrn,
+                                           pPrinterNameW,
+                                           nullptr, nullptr, 0 );
+
+        if( nSysJobSize < 0 )
         {
-            if( pDevModeW &&
-                (dmSpecVersion == pDevModeW->dmSpecVersion) &&
-                (dmDriverVersion == pDevModeW->dmDriverVersion) )
-                return true;
+            ClosePrinter( hPrn );
+            return false;
         }
-        if ( bDelete )
+        DEVMODEW *pBuffer = static_cast<DEVMODEW*>(_alloca( nSysJobSize ));
+        LONG nRet = DocumentPropertiesW( nullptr, hPrn,
+                                    pPrinterNameW,
+                                    pBuffer, nullptr, DM_OUT_BUFFER );
+        if( nRet < 0 )
         {
-            pSetupData->SetDriverData( nullptr, 0 );
+            ClosePrinter( hPrn );
+            return false;
         }
+
+        // the spec version differs between the windows platforms, ie 
98,NT,2000/XP
+        // this allows us to throw away printer settings from other platforms 
that might crash a buggy driver
+        // we check the driver version as well
+        dmSpecVersion = pBuffer->dmSpecVersion;
+        dmDriverVersion = pBuffer->dmDriverVersion;
+
+        ClosePrinter( hPrn );
+    }
+    SalDriverData const * pSetupDriverData = reinterpret_cast<SalDriverData 
const *>(pSetupData->GetDriverData());
+    if ( (pSetupData->GetSystem() == JOBSETUP_SYSTEM_WINDOWS) &&
+         (pPrinter && pPrinter->maDriverName == pSetupData->GetDriver()) &&
+         (pSetupData->GetDriverDataLen() > sizeof( SalDriverData )) &&
+         static_cast<tools::Long>(pSetupData->GetDriverDataLen() - 
pSetupDriverData->mnDriverOffset) == nSysJobSize &&
+         pSetupDriverData->mnSysSignature == SAL_DRIVERDATA_SYSSIGN )
+    {
+        if( pDevModeW &&
+            (dmSpecVersion == pDevModeW->dmSpecVersion) &&
+            (dmDriverVersion == pDevModeW->dmDriverVersion) )
+            return true;
+    }
+    if ( bDelete )
+    {
+        pSetupData->SetDriverData( nullptr, 0 );
     }
 
     return false;
@@ -1201,17 +1201,17 @@ OUString WinSalInfoPrinter::GetPaperBinName( const 
ImplJobSetup* pSetupData, sal
 sal_uInt16 WinSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup* 
pSetupData, sal_uInt16 nPaperSource )
 {
     DWORD nBins = ImplDeviceCaps( this, DC_BINNAMES, nullptr, pSetupData );
+    if (nBins == GDI_ERROR)
+        return 0xffff;
+
+    auto pBuffer = std::make_unique<sal_uInt16[]>(nBins);
+    nBins = ImplDeviceCaps( this, DC_BINS, 
reinterpret_cast<BYTE*>(pBuffer.get()), pSetupData );
     if (nBins != GDI_ERROR)
     {
-        auto pBuffer = std::make_unique<sal_uInt16[]>(nBins);
-        nBins = ImplDeviceCaps( this, DC_BINS, 
reinterpret_cast<BYTE*>(pBuffer.get()), pSetupData );
-        if (nBins != GDI_ERROR)
+        for (DWORD nBin = 0; nBin < nBins; ++nBin)
         {
-            for (DWORD nBin = 0; nBin < nBins; ++nBin)
-            {
-                if (nPaperSource == *(pBuffer.get() + nBin))
-                    return nBin;
-            }
+            if (nPaperSource == *(pBuffer.get() + nBin))
+                return nBin;
         }
     }
     return 0xffff;
@@ -1220,14 +1220,14 @@ sal_uInt16 WinSalInfoPrinter::GetPaperBinBySourceIndex( 
const ImplJobSetup* pSet
 sal_uInt16  WinSalInfoPrinter::GetSourceIndexByPaperBin(const ImplJobSetup* 
pSetupData, sal_uInt16 nPaperBin)
 {
     DWORD nBins = ImplDeviceCaps( this, DC_BINNAMES, nullptr, pSetupData );
-    if (nBins != GDI_ERROR)
+    if (nBins == GDI_ERROR)
+        return 0;
+
+    auto pBuffer = std::make_unique<sal_uInt16[]>(nBins);
+    nBins = ImplDeviceCaps( this, DC_BINS, 
reinterpret_cast<BYTE*>(pBuffer.get()), pSetupData );
+    if (nBins != GDI_ERROR && nBins > nPaperBin)
     {
-        auto pBuffer = std::make_unique<sal_uInt16[]>(nBins);
-        nBins = ImplDeviceCaps( this, DC_BINS, 
reinterpret_cast<BYTE*>(pBuffer.get()), pSetupData );
-        if (nBins != GDI_ERROR && nBins > nPaperBin)
-        {
-            return *(pBuffer.get() + nPaperBin);
-        }
+        return *(pBuffer.get() + nPaperBin);
     }
     return 0;
 }
@@ -1337,27 +1337,23 @@ static BOOL CALLBACK SalPrintAbortProc( HDC hPrnDC, int 
/* nError */ )
 
 static DEVMODEW const * ImplSalSetCopies( DEVMODEW const * pDevMode, 
sal_uInt32 nCopies, bool bCollate )
 {
-    if ( pDevMode && (nCopies > 1) )
-    {
-        if ( nCopies > 32765 )
-            nCopies = 32765;
-        sal_uLong nDevSize = pDevMode->dmSize+pDevMode->dmDriverExtra;
-        LPDEVMODEW pNewDevMode = static_cast<LPDEVMODEW>(std::malloc( nDevSize 
));
-        assert(pNewDevMode); // Don't handle OOM conditions
-        memcpy( pNewDevMode, pDevMode, nDevSize );
-        pNewDevMode->dmFields |= DM_COPIES;
-        pNewDevMode->dmCopies  = 
static_cast<short>(static_cast<sal_uInt16>(nCopies));
-        pNewDevMode->dmFields |= DM_COLLATE;
-        if ( bCollate )
-            pNewDevMode->dmCollate = DMCOLLATE_TRUE;
-        else
-            pNewDevMode->dmCollate = DMCOLLATE_FALSE;
-        return pNewDevMode;
-    }
-    else
-    {
+    if ( !pDevMode || (nCopies <= 1) )
         return pDevMode;
-    }
+
+    if ( nCopies > 32765 )
+        nCopies = 32765;
+    sal_uLong nDevSize = pDevMode->dmSize+pDevMode->dmDriverExtra;
+    LPDEVMODEW pNewDevMode = static_cast<LPDEVMODEW>(std::malloc( nDevSize ));
+    assert(pNewDevMode); // Don't handle OOM conditions
+    memcpy( pNewDevMode, pDevMode, nDevSize );
+    pNewDevMode->dmFields |= DM_COPIES;
+    pNewDevMode->dmCopies  = 
static_cast<short>(static_cast<sal_uInt16>(nCopies));
+    pNewDevMode->dmFields |= DM_COLLATE;
+    if ( bCollate )
+        pNewDevMode->dmCollate = DMCOLLATE_TRUE;
+    else
+        pNewDevMode->dmCollate = DMCOLLATE_FALSE;
+    return pNewDevMode;
 }
 
 
@@ -1552,23 +1548,23 @@ void WinSalPrinter::DoEndDoc(HDC hDC)
 bool WinSalPrinter::EndJob()
 {
     HDC hDC = mhDC;
-    if (isValid())
-    {
-        mxGraphics.reset();
+    if (!isValid())
+        return true;
 
-        // #i54419# Windows fax printer brings up a dialog in EndDoc
-        // which text previously copied in soffice process can be
-        // pasted to -> deadlock due to mutex not released.
-        // it should be safe to release the yield mutex over the EndDoc
-        // call, however the real solution is supposed to be the threading
-        // framework yet to come.
-        {
-            SolarMutexReleaser aReleaser;
-            DoEndDoc( hDC );
-        }
-        DeleteDC( hDC );
-        mhDC = nullptr;
+    mxGraphics.reset();
+
+    // #i54419# Windows fax printer brings up a dialog in EndDoc
+    // which text previously copied in soffice process can be
+    // pasted to -> deadlock due to mutex not released.
+    // it should be safe to release the yield mutex over the EndDoc
+    // call, however the real solution is supposed to be the threading
+    // framework yet to come.
+    {
+        SolarMutexReleaser aReleaser;
+        DoEndDoc( hDC );
     }
+    DeleteDC( hDC );
+    mhDC = nullptr;
 
     return true;
 }
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 6f5538140a2e..d5bbc048da43 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -139,9 +139,7 @@ WinFontInstance::~WinFontInstance()
         ::DeleteFont(m_hFont);
 
     if (m_hVerticalFont)
-    {
         ::DeleteFont(m_hVerticalFont);
-    }
 }
 
 float WinFontInstance::getHScale() const
@@ -156,28 +154,28 @@ void WinFontInstance::ImplInitHbFont(hb_font_t* 
/*pHbFont*/)
 {
     assert(m_pGraphics);
     // Calculate the AverageWidthFactor, see LogicalFontInstance::GetScale().
-    if (GetFontSelectPattern().mnWidth)
-    {
-        double nUPEM = GetFontFace()->UnitsPerEm();
+    if (!GetFontSelectPattern().mnWidth)
+        return;
 
-        LOGFONTW aLogFont;
-        GetObjectW(m_hFont, sizeof(LOGFONTW), &aLogFont);
+    double nUPEM = GetFontFace()->UnitsPerEm();
 
-        // Set the height (font size) to EM to minimize rounding errors.
-        aLogFont.lfHeight = -nUPEM;
-        // Set width to the default to get the original value in the metrics.
-        aLogFont.lfWidth = 0;
+    LOGFONTW aLogFont;
+    GetObjectW(m_hFont, sizeof(LOGFONTW), &aLogFont);
 
-        TEXTMETRICW aFontMetric;
-        {
-            // Get the font metrics.
-            HDC hDC = m_pGraphics->getHDC();
-            ScopedSelectedHFONT hFont(hDC, CreateFontIndirectW(&aLogFont));
-            GetTextMetricsW(hDC, &aFontMetric);
-        }
+    // Set the height (font size) to EM to minimize rounding errors.
+    aLogFont.lfHeight = -nUPEM;
+    // Set width to the default to get the original value in the metrics.
+    aLogFont.lfWidth = 0;
 
-        SetAverageWidthFactor(nUPEM / aFontMetric.tmAveCharWidth);
+    TEXTMETRICW aFontMetric;
+    {
+        // Get the font metrics.
+        HDC hDC = m_pGraphics->getHDC();
+        ScopedSelectedHFONT hFont(hDC, CreateFontIndirectW(&aLogFont));
+        GetTextMetricsW(hDC, &aFontMetric);
     }
+
+    SetAverageWidthFactor(nUPEM / aFontMetric.tmAveCharWidth);
 }
 
 void WinFontInstance::SetGraphics(WinSalGraphics* pGraphics)
commit 4cb750372980ba3a572dfb980c59878d3b341d0e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Feb 4 09:25:47 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Feb 4 10:42:52 2025 +0100

    remove some windows95 code
    
    which we have not supported for a very long time
    
    Change-Id: I09bcd3a567c6b4d6c93666f4a4bcb3f632ef43a7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181083
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index d210dd22bb68..9231daf09ae1 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -376,6 +376,4 @@ int     ImplIsSysColorEntry( Color nColor );
 void    ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern&,
             const vcl::font::PhysicalFontFace*, LOGFONTW&, bool bAntiAliased);
 
-#define MAX_64KSALPOINTS    ((((sal_uInt16)0xFFFF)-8)/sizeof(POINTS))
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 8889e43f09d4..2f731d98f6b3 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -908,17 +908,10 @@ void WinSalGraphicsImpl::invert( sal_uInt32 nPoints, 
const Point* pPtAry, SalInv
     for (sal_uInt32 i=0; i<nPoints; ++i)
         pWinPtAry[i] = POINT { static_cast<LONG>(pPtAry[i].getX()), 
static_cast<LONG>(pPtAry[i].getY()) };
 
-    // for Windows 95 and its maximum number of points
     if ( nSalFlags & SalInvert::TrackFrame )
-    {
-        if ( !Polyline( mrParent.getHDC(), pWinPtAry.get(), 
static_cast<int>(nPoints) ) && (nPoints > MAX_64KSALPOINTS) )
-            Polyline( mrParent.getHDC(), pWinPtAry.get(), MAX_64KSALPOINTS );
-    }
+        Polyline( mrParent.getHDC(), pWinPtAry.get(), 
static_cast<int>(nPoints) );
     else
-    {
-        if ( !Polygon( mrParent.getHDC(), pWinPtAry.get(), 
static_cast<int>(nPoints) ) && (nPoints > MAX_64KSALPOINTS) )
-            Polygon( mrParent.getHDC(), pWinPtAry.get(), MAX_64KSALPOINTS );
-    }
+        Polygon( mrParent.getHDC(), pWinPtAry.get(), static_cast<int>(nPoints) 
);
 
     SetROP2( mrParent.getHDC(), nOldROP );
     SelectPen( mrParent.getHDC(), hOldPen );
@@ -1612,9 +1605,7 @@ void WinSalGraphicsImpl::drawPolyLine( sal_uInt32 
nPoints, const Point* pPtAry )
     for (sal_uInt32 i=0; i<nPoints; ++i)
         pWinPtAry[i] = POINT { static_cast<LONG>(pPtAry[i].getX()), 
static_cast<LONG>(pPtAry[i].getY()) };
 
-    // for Windows 95 and its maximum number of points
-    if ( !Polyline( mrParent.getHDC(), pWinPtAry.get(), 
static_cast<int>(nPoints) ) && (nPoints > MAX_64KSALPOINTS) )
-        Polyline( mrParent.getHDC(), pWinPtAry.get(), MAX_64KSALPOINTS );
+    Polyline( mrParent.getHDC(), pWinPtAry.get(), static_cast<int>(nPoints) );
 
     // Polyline seems to uses LineTo, which doesn't paint the last pixel (see 
87eb8f8ee)
     if ( !mrParent.isPrinter() )
@@ -1627,9 +1618,7 @@ void WinSalGraphicsImpl::drawPolygon( sal_uInt32 nPoints, 
const Point* pPtAry )
     for (sal_uInt32 i=0; i<nPoints; ++i)
         pWinPtAry[i] = POINT { static_cast<LONG>(pPtAry[i].getX()), 
static_cast<LONG>(pPtAry[i].getY()) };
 
-    // for Windows 95 and its maximum number of points
-    if ( !Polygon( mrParent.getHDC(), pWinPtAry.get(), 
static_cast<int>(nPoints) ) && (nPoints > MAX_64KSALPOINTS) )
-        Polygon( mrParent.getHDC(), pWinPtAry.get(), MAX_64KSALPOINTS );
+    Polygon( mrParent.getHDC(), pWinPtAry.get(), static_cast<int>(nPoints) );
 }
 
 void WinSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* 
pPoints,
@@ -1670,25 +1659,7 @@ void WinSalGraphicsImpl::drawPolyPolygon( sal_uInt32 
nPoly, const sal_uInt32* pP
         n += nPoints;
     }
 
-    if ( !PolyPolygon( mrParent.getHDC(), pWinPointAryAry, 
reinterpret_cast<int*>(pWinPointAry), static_cast<UINT>(nPoly) ) &&
-         (nPolyPolyPoints > MAX_64KSALPOINTS) )
-    {
-        nPolyPolyPoints  = 0;
-        nPoly = 0;
-        do
-        {
-            nPolyPolyPoints += pWinPointAry[static_cast<UINT>(nPoly)];
-            nPoly++;
-        }
-        while ( nPolyPolyPoints < MAX_64KSALPOINTS );
-        nPoly--;
-        if ( pWinPointAry[static_cast<UINT>(nPoly)] > MAX_64KSALPOINTS )
-            pWinPointAry[static_cast<UINT>(nPoly)] = MAX_64KSALPOINTS;
-        if ( nPoly == 1 )
-            Polygon( mrParent.getHDC(), pWinPointAryAry, *pWinPointAry );
-        else
-            PolyPolygon( mrParent.getHDC(), pWinPointAryAry, 
reinterpret_cast<int*>(pWinPointAry), nPoly );
-    }
+    PolyPolygon( mrParent.getHDC(), pWinPointAryAry, 
reinterpret_cast<int*>(pWinPointAry), static_cast<UINT>(nPoly) );
 
     if ( pWinPointAry != aWinPointAry )
         delete [] pWinPointAry;

Reply via email to