Revert "improve empty tools::Rectangle (width)"

This reverts commit a46a257794f1f53b294735fc876c394be23a3811.

Too many issues, I'm going to try landing this in smaller pieces to make it easier to fix regressions

Change-Id: Ie5e8979838017af86c119c887b580385ba068d54
Reviewed-on: https://gerrit.libreoffice.org/73859
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index bbcf171..ec3e10c 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2921,8 +2921,6 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, tools::Rectangle aClipRect, Po
{
    if ( !GetUpdateMode() && !bStripOnly )
        return;
    if ( aClipRect.IsEmpty() )
        return;

    if ( !IsFormatted() )
        FormatDoc();
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index d84d359..0d9a81e 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -24,7 +24,6 @@
#include <limits.h>
#include <algorithm>
#include <ostream>
#include <cassert>

class SvStream;
namespace rtl
@@ -387,12 +386,12 @@ public:
                        Rectangle( const Point& rLT, const Size& rSize );

    long                Left() const    { return nLeft;   }
    long                Right() const   { assert(!mbWidthEmpty); return nRight;  }
    long                Right() const   { return nRight;  }
    long                Top() const     { return nTop;    }
    long                Bottom() const  { return nBottom; }

    void                SetLeft(long v)    { nLeft = v;   }
    void                SetRight(long v)   { nRight = v; mbWidthEmpty = false; }
    void                SetRight(long v)   { nRight = v;  }
    void                SetTop(long v)     { nTop = v;    }
    void                SetBottom(long v)  { nBottom = v; }

@@ -410,17 +409,7 @@ public:
    inline void         Move( long nHorzMoveDelta, long nVertMoveDelta );
    void                Move( Size const & s ) { Move(s.Width(), s.Height()); }
    long                AdjustLeft( long nHorzMoveDelta ) { nLeft += nHorzMoveDelta; return nLeft; }
    long                AdjustRight( long nHorzMoveDelta )
    {
        if (mbWidthEmpty)
        {
            mbWidthEmpty = false;
            nRight = nLeft + nHorzMoveDelta - 1;
        }
        else
            nRight += nHorzMoveDelta;
        return nRight;
    }
    long                AdjustRight( long nHorzMoveDelta ) { nRight += nHorzMoveDelta; return nRight; }
    long                AdjustTop( long nVertMoveDelta ) { nTop += nVertMoveDelta; return nTop; }
    long                AdjustBottom( long nVertMoveDelta ) { nBottom += nVertMoveDelta; return nBottom; }
    inline void         SetPos( const Point& rPoint );
@@ -443,11 +432,11 @@ public:
    bool                IsInside( const tools::Rectangle& rRect ) const;
    bool                IsOver( const tools::Rectangle& rRect ) const;

    void                SetEmpty() { nRight = 0; nBottom = RECT_EMPTY; mbWidthEmpty = true; }
    void                SetWidthEmpty() { nRight = 0; mbWidthEmpty = true; }
    void                SetEmpty() { nRight = nBottom = RECT_EMPTY; }
    void                SetWidthEmpty() { nRight = RECT_EMPTY; }
    void                SetHeightEmpty() { nBottom = RECT_EMPTY; }
    inline bool         IsEmpty() const;
    bool                IsWidthEmpty() const { return mbWidthEmpty; }
    bool                IsWidthEmpty() const { return nRight == RECT_EMPTY; }
    bool                IsHeightEmpty() const { return nBottom == RECT_EMPTY; }

    inline bool         operator == ( const tools::Rectangle& rRect ) const;
@@ -466,19 +455,14 @@ public:
    long                getX() const { return nLeft; }
    long                getY() const { return nTop; }
    /// Returns the difference between right and left, assuming the range includes one end, but not the other.
    long                getWidth() const { return mbWidthEmpty ? 0 : nRight - nLeft; }
    long                getWidth() const { return nRight - nLeft; }
    /// Returns the difference between bottom and top, assuming the range includes one end, but not the other.
    long                getHeight() const { return nBottom - nTop; }
    /// Set the left edge of the rectangle to x, preserving the width
    void                setX( long x )
    {
        if (!mbWidthEmpty)
            nRight += x - nLeft;
        nLeft = x;
    }
    void                setX( long x ) { nRight  += x - nLeft; nLeft = x; }
    /// Set the top edge of the rectangle to y, preserving the height
    void                setY( long y ) { nBottom += y - nTop;  nTop  = y; }
    void                setWidth( long n ) { nRight = nLeft + n; mbWidthEmpty = false; }
    void                setWidth( long n ) { nRight = nLeft + n; }
    void                setHeight( long n ) { nBottom = nTop + n; }
    /// Returns the string representation of the rectangle, format is "x, y, width, height".
    rtl::OString        toString() const;
@@ -497,7 +481,6 @@ public:
    void                SaturatingSetY(long y);

private:
    bool                mbWidthEmpty : 1;
    long                nLeft;
    long                nTop;
    long                nRight;
@@ -508,9 +491,7 @@ private:
inline tools::Rectangle::Rectangle()
{
    nLeft = nTop = 0;
    nRight = 0;
    nBottom = RECT_EMPTY;
    mbWidthEmpty = true;
    nRight = nBottom = RECT_EMPTY;
}

inline tools::Rectangle::Rectangle( const Point& rLT, const Point& rRB )
@@ -519,7 +500,6 @@ inline tools::Rectangle::Rectangle( const Point& rLT, const Point& rRB )
    nTop    = rLT.Y();
    nRight  = rRB.X();
    nBottom = rRB.Y();
    mbWidthEmpty = false;
}

inline tools::Rectangle::Rectangle( long _nLeft,  long _nTop,
@@ -529,30 +509,26 @@ inline tools::Rectangle::Rectangle( long _nLeft,  long _nTop,
    nTop    = _nTop;
    nRight  = _nRight;
    nBottom = _nBottom;
    mbWidthEmpty = false;
}

inline tools::Rectangle::Rectangle( long _nLeft,  long _nTop )
{
    nLeft   = _nLeft;
    nTop    = _nTop;
    nRight  =  0;
    nBottom = RECT_EMPTY;
    mbWidthEmpty = true;
    nRight = nBottom = RECT_EMPTY;
}

inline tools::Rectangle::Rectangle( const Point& rLT, const Size& rSize )
{
    nLeft   = rLT.X();
    nTop    = rLT.Y();
    nRight  = rSize.Width()  ? nLeft+(rSize.Width()-1) : 0;
    nRight  = rSize.Width()  ? nLeft+(rSize.Width()-1) : RECT_EMPTY;
    nBottom = rSize.Height() ? nTop+(rSize.Height()-1) : RECT_EMPTY;
    mbWidthEmpty  = rSize.Width() == 0;
}

inline bool tools::Rectangle::IsEmpty() const
{
    return mbWidthEmpty || (nBottom == RECT_EMPTY);
    return (nRight == RECT_EMPTY) || (nBottom == RECT_EMPTY);
}

inline Point tools::Rectangle::TopLeft() const
@@ -562,7 +538,7 @@ inline Point tools::Rectangle::TopLeft() const

inline Point tools::Rectangle::TopRight() const
{
    return Point( mbWidthEmpty ? nLeft : nRight, nTop );
    return Point( (nRight == RECT_EMPTY) ? nLeft : nRight, nTop );
}

inline Point tools::Rectangle::BottomLeft() const
@@ -572,7 +548,7 @@ inline Point tools::Rectangle::BottomLeft() const

inline Point tools::Rectangle::BottomRight() const
{
    return Point( mbWidthEmpty ? nLeft : nRight,
    return Point( (nRight  == RECT_EMPTY) ? nLeft : nRight,
                  (nBottom == RECT_EMPTY) ? nTop  : nBottom );
}

@@ -622,7 +598,7 @@ inline void tools::Rectangle::Move( long nHorzMove, long nVertMove )
{
    nLeft += nHorzMove;
    nTop  += nVertMove;
    if ( !mbWidthEmpty )
    if ( nRight != RECT_EMPTY )
        nRight += nHorzMove;
    if ( nBottom != RECT_EMPTY )
        nBottom += nVertMove;
@@ -630,7 +606,7 @@ inline void tools::Rectangle::Move( long nHorzMove, long nVertMove )

inline void tools::Rectangle::SetPos( const Point& rPoint )
{
    if ( !mbWidthEmpty )
    if ( nRight != RECT_EMPTY )
        nRight += rPoint.X() - nLeft;
    if ( nBottom != RECT_EMPTY )
        nBottom += rPoint.Y() - nTop;
@@ -641,7 +617,7 @@ inline void tools::Rectangle::SetPos( const Point& rPoint )
inline long tools::Rectangle::GetWidth() const
{
    long n;
    if ( mbWidthEmpty )
    if ( nRight == RECT_EMPTY )
        n = 0;
    else
    {
@@ -694,20 +670,22 @@ inline bool tools::Rectangle::operator == ( const tools::Rectangle& rRect ) cons
    return (nLeft   == rRect.nLeft   ) &&
           (nTop    == rRect.nTop    ) &&
           (nRight  == rRect.nRight  ) &&
           (nBottom == rRect.nBottom ) &&
           (mbWidthEmpty == rRect.mbWidthEmpty);
           (nBottom == rRect.nBottom );
}

inline bool tools::Rectangle::operator != ( const tools::Rectangle& rRect ) const
{
    return !(operator==(rRect));
    return (nLeft   != rRect.nLeft   ) ||
           (nTop    != rRect.nTop    ) ||
           (nRight  != rRect.nRight  ) ||
           (nBottom != rRect.nBottom );
}

inline tools::Rectangle& tools::Rectangle::operator +=( const Point& rPt )
{
    nLeft += rPt.X();
    nTop  += rPt.Y();
    if ( !mbWidthEmpty )
    if ( nRight != RECT_EMPTY )
        nRight += rPt.X();
    if ( nBottom != RECT_EMPTY )
        nBottom += rPt.Y();
@@ -718,7 +696,7 @@ inline tools::Rectangle& tools::Rectangle::operator -= ( const Point& rPt )
{
    nLeft -= rPt.X();
    nTop  -= rPt.Y();
    if ( !mbWidthEmpty )
    if ( nRight != RECT_EMPTY )
        nRight -= rPt.X();
    if ( nBottom != RECT_EMPTY )
        nBottom -= rPt.Y();
@@ -748,13 +726,7 @@ inline void tools::Rectangle::expand(long nExpandBy)
{
    nLeft   -= nExpandBy;
    nTop    -= nExpandBy;
    if (mbWidthEmpty)
    {
        nRight  = nLeft + nExpandBy - 1;
        mbWidthEmpty = false;
    }
    else
        nRight  += nExpandBy;
    nRight  += nExpandBy;
    nBottom += nExpandBy;
}

@@ -762,8 +734,7 @@ inline void tools::Rectangle::shrink(long nShrinkBy)
{
    nLeft   += nShrinkBy;
    nTop    += nShrinkBy;
    if (!mbWidthEmpty)
        nRight  -= nShrinkBy;
    nRight  -= nShrinkBy;
    nBottom -= nShrinkBy;
}

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 0b17e43..e043cfc 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -6001,43 +6001,40 @@ void ScGridWindow::UpdateCursorOverlay()
            long nSizeYPix;
            pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );

            if (nSizeXPix>1 && nSizeYPix>1)
            {
                if (bLayoutRTL)
                    aScrPos.AdjustX( -(nSizeXPix - 2) );       // move instead of mirroring
            if (bLayoutRTL)
                aScrPos.AdjustX( -(nSizeXPix - 2) );       // move instead of mirroring

                // show the cursor as 4 (thin) rectangles
                tools::Rectangle aRect(aScrPos, Size(nSizeXPix - 1, nSizeYPix - 1));
            // show the cursor as 4 (thin) rectangles
            tools::Rectangle aRect(aScrPos, Size(nSizeXPix - 1, nSizeYPix - 1));

                float fScaleFactor = GetDPIScaleFactor();
            float fScaleFactor = GetDPIScaleFactor();

                long aCursorWidth = 1 * fScaleFactor;
            long aCursorWidth = 1 * fScaleFactor;

                tools::Rectangle aLeft = aRect;
                aLeft.AdjustTop( -aCursorWidth );
                aLeft.AdjustBottom(aCursorWidth );
                aLeft.SetRight( aLeft.Left() );
                aLeft.AdjustLeft( -aCursorWidth );
            tools::Rectangle aLeft = aRect;
            aLeft.AdjustTop( -aCursorWidth );
            aLeft.AdjustBottom(aCursorWidth );
            aLeft.SetRight( aLeft.Left() );
            aLeft.AdjustLeft( -aCursorWidth );

                tools::Rectangle aRight = aRect;
                aRight.AdjustTop( -aCursorWidth );
                aRight.AdjustBottom(aCursorWidth );
                aRight.SetLeft( aRight.Right() );
                aRight.AdjustRight(aCursorWidth );
            tools::Rectangle aRight = aRect;
            aRight.AdjustTop( -aCursorWidth );
            aRight.AdjustBottom(aCursorWidth );
            aRight.SetLeft( aRight.Right() );
            aRight.AdjustRight(aCursorWidth );

                tools::Rectangle aTop = aRect;
                aTop.SetBottom( aTop.Top() );
                aTop.AdjustTop( -aCursorWidth );
            tools::Rectangle aTop = aRect;
            aTop.SetBottom( aTop.Top() );
            aTop.AdjustTop( -aCursorWidth );

                tools::Rectangle aBottom = aRect;
                aBottom.SetTop( aBottom.Bottom() );
                aBottom.AdjustBottom(aCursorWidth );
            tools::Rectangle aBottom = aRect;
            aBottom.SetTop( aBottom.Bottom() );
            aBottom.AdjustBottom(aCursorWidth );

                aPixelRects.push_back(aLeft);
                aPixelRects.push_back(aRight);
                aPixelRects.push_back(aTop);
                aPixelRects.push_back(aBottom);
            }
            aPixelRects.push_back(aLeft);
            aPixelRects.push_back(aRight);
            aPixelRects.push_back(aTop);
            aPixelRects.push_back(aBottom);
        }
    }

diff --git a/sd/source/filter/eppt/escherex.cxx b/sd/source/filter/eppt/escherex.cxx
index 4b2adb3..5032c27 100644
--- a/sd/source/filter/eppt/escherex.cxx
+++ b/sd/source/filter/eppt/escherex.cxx
@@ -220,10 +220,9 @@ sal_uInt32 PptEscherEx::EnterGroup( ::tools::Rectangle const * pBoundRect, SvMem
        OpenContainer( ESCHER_SpContainer );
        AddAtom( 16, ESCHER_Spgr, 1 );
        PtReplaceOrInsert( ESCHER_Persist_Grouping_Snap | mnGroupLevel, mpOutStrm->Tell() );
        // FIXME what to do with empty rectangles?
        mpOutStrm ->WriteInt32( aRect.Left() )  // bounding box for the grouped shapes to which they are attached
                   .WriteInt32( aRect.Top() )
                   .WriteInt32( aRect.IsWidthEmpty() ? -32767 : aRect.Right() )
                   .WriteInt32( aRect.Right() )
                   .WriteInt32( aRect.Bottom() );

        nShapeId = GenerateShapeId();
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index a14b163..8ee61e4 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -864,7 +864,7 @@ void TabBar::ImplShowPage( sal_uInt16 nPos )
    auto& pItem = mpImpl->mpItemList[nPos];
    if (nPos < mnFirstPos)
        SetFirstPageId( pItem->mnId );
    else if (!pItem->maRect.IsEmpty() && pItem->maRect.Right() > nWidth)
    else if (pItem->maRect.Right() > nWidth)
    {
        while (pItem->maRect.Right() > nWidth)
        {
@@ -1868,8 +1868,8 @@ void TabBar::SetCurPageId(sal_uInt16 nPageId)
            if (pItem->maRect.IsEmpty())
                ImplFormat();

            while (pItem->maRect.IsEmpty() ||
                   (mbMirrored ? (pItem->maRect.Left() < mnOffX) : (pItem->maRect.Right() > nWidth)))
            while ((mbMirrored ? (pItem->maRect.Left() < mnOffX) : (pItem->maRect.Right() > nWidth)) ||
                    pItem->maRect.IsEmpty())
            {
                sal_uInt16 nNewPos = mnFirstPos + 1;
                // assure at least the actual tabpages are visible as first tabpage
diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx
index 4961d46..3bda11b 100644
--- a/svx/source/sdr/contact/objectcontactofpageview.cxx
+++ b/svx/source/sdr/contact/objectcontactofpageview.cxx
@@ -213,9 +213,6 @@ namespace sdr
                aViewRange.transform(rTargetOutDev.GetInverseViewTransformation());
            }

            if (aViewRange.isEmpty())
                return;

            // update local ViewInformation2D
            const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
                basegfx::B2DHomMatrix(),
diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx
index abaf3f8..6c844c7 100644
--- a/sw/source/core/view/vdraw.cxx
+++ b/sw/source/core/view/vdraw.cxx
@@ -204,7 +204,7 @@ void SwViewShellImp::NotifySizeChg( const Size &rNewSz )
    bool bCheckDrawObjs = false;
    if ( aDocRect != rOldWork )
    {
        if ( !rOldWork.IsEmpty() && (rOldWork.Bottom() > aDocRect.Bottom() || rOldWork.Right() > aDocRect.Right()))
        if ( rOldWork.Bottom() > aDocRect.Bottom() || rOldWork.Right() > aDocRect.Right())
            bCheckDrawObjs = true;
        GetDrawView()->SetWorkArea( aDocRect );
    }
diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
index bebcaa1..2fa7e12 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -316,11 +316,9 @@ void SwView::SetVisArea( const Point &rPt, bool bUpdateScrollbar )

    const long lXDiff = m_aVisArea.Left() - aPt.X();
    const long lYDiff = m_aVisArea.Top()  - aPt.Y();
    tools::Rectangle aNewVisArea(m_aVisArea);
    aNewVisArea.SetPos(aPt);
    aNewVisArea.AdjustRight(-lXDiff);
    aNewVisArea.AdjustBottom(-lYDiff);
    SetVisArea( aNewVisArea, bUpdateScrollbar);
    SetVisArea( tools::Rectangle( aPt,
            Point( m_aVisArea.Right() - lXDiff, m_aVisArea.Bottom() - lYDiff ) ),
            bUpdateScrollbar);
}

void SwView::CheckVisArea()
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 6438405..3593801 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -55,20 +55,11 @@ OString Pair::toString() const
void tools::Rectangle::SetSize( const Size& rSize )
{
    if ( rSize.Width() < 0 )
    {
        nRight  = nLeft + rSize.Width() +1;
        mbWidthEmpty = false;
    }
    else if ( rSize.Width() > 0 )
    {
        nRight  = nLeft + rSize.Width() -1;
        mbWidthEmpty = false;
    }
    else
    {
        nRight = 0;
        mbWidthEmpty = true;
    }
        nRight = RECT_EMPTY;

    if ( rSize.Height() < 0 )
        nBottom  = nTop + rSize.Height() +1;
@@ -81,20 +72,11 @@ void tools::Rectangle::SetSize( const Size& rSize )
void tools::Rectangle::SaturatingSetSize(const Size& rSize)
{
    if (rSize.Width() < 0)
    {
        nRight = o3tl::saturating_add(nLeft, (rSize.Width() + 1));
        mbWidthEmpty = false;
    }
    else if ( rSize.Width() > 0 )
    {
        nRight = o3tl::saturating_add(nLeft, (rSize.Width() - 1));
        mbWidthEmpty = false;
    }
    else
    {
        nRight = 0;
        mbWidthEmpty = true;
    }
        nRight = RECT_EMPTY;

    if ( rSize.Height() < 0 )
        nBottom = o3tl::saturating_add(nTop, (rSize.Height() + 1));
@@ -106,8 +88,7 @@ void tools::Rectangle::SaturatingSetSize(const Size& rSize)

void tools::Rectangle::SaturatingSetX(long x)
{
    if (!mbWidthEmpty)
        nRight = o3tl::saturating_add(nRight, x - nLeft);
    nRight = o3tl::saturating_add(nRight, x - nLeft);
    nLeft = x;
}

@@ -165,7 +146,7 @@ tools::Rectangle& tools::Rectangle::Intersection( const tools::Rectangle& rRect 

void tools::Rectangle::Justify()
{
    if ( (nRight < nLeft) && !mbWidthEmpty )
    if ( (nRight < nLeft) && (nRight != RECT_EMPTY) )
    {
        std::swap(nLeft, nRight);
    }
@@ -225,9 +206,8 @@ SvStream& ReadRectangle( SvStream& rIStream, tools::Rectangle& rRect )

    rRect.nLeft = nTmpL;
    rRect.nTop = nTmpT;
    rRect.nRight = nTmpR == Rectangle::RECT_EMPTY ? 0 : nTmpR;
    rRect.nRight = nTmpR;
    rRect.nBottom = nTmpB;
    rRect.mbWidthEmpty = nTmpR == Rectangle::RECT_EMPTY;

    return rIStream;
}
@@ -236,7 +216,7 @@ SvStream& WriteRectangle( SvStream& rOStream, const tools::Rectangle& rRect )
{
    rOStream.WriteInt32( rRect.nLeft )
            .WriteInt32( rRect.nTop )
            .WriteInt32( rRect.mbWidthEmpty ? Rectangle::RECT_EMPTY : rRect.nRight )
            .WriteInt32( rRect.nRight )
            .WriteInt32( rRect.nBottom );

    return rOStream;
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index 481d7a9..ad1362d 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -1017,8 +1017,6 @@ bool AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa
                                                tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion )

{
    if (rControlRegion.IsEmpty()) // nothing to do
        return false;
    bool toReturn = false;

    tools::Rectangle aCtrlBoundRect( rControlRegion );
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index eeede1a..d5b9eee 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -2123,7 +2123,7 @@ Size TabControl::calculateRequisition() const
        tools::Rectangle aTabRect = pThis->ImplGetTabRect(nPos, aOptimalPageSize.Width(), LONG_MAX);
        if (aTabRect.Bottom() > nTabLabelsBottom)
            nTabLabelsBottom = aTabRect.Bottom();
        if (!aTabRect.IsEmpty() && aTabRect.Right() > nTabLabelsRight)
        if (aTabRect.Right() > nTabLabelsRight)
            nTabLabelsRight = aTabRect.Right();
    }

diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 3f681a0..8c168a8 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -459,7 +459,7 @@ void writeRectangle(tools::XmlWriter& rWriter, tools::Rectangle const& rRectangl
{
    rWriter.attribute("left", rRectangle.Left());
    rWriter.attribute("top", rRectangle.Top());
    rWriter.attribute("right", rRectangle.IsWidthEmpty() ? -32767 : rRectangle.Right());
    rWriter.attribute("right", rRectangle.Right());
    rWriter.attribute("bottom", rRectangle.Bottom());
}

diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx
index 14d341a..6734327 100644
--- a/vcl/source/outdev/rect.cxx
+++ b/vcl/source/outdev/rect.cxx
@@ -376,8 +376,7 @@ BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix )

void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect )
{
    long right = rValidSrcRect.IsEmpty() ? rValidSrcRect.Left() : rValidSrcRect.Right();
    if( ( rTwoRect.mnSrcX < rValidSrcRect.Left() ) || ( rTwoRect.mnSrcX >= right ) ||
    if( ( rTwoRect.mnSrcX < rValidSrcRect.Left() ) || ( rTwoRect.mnSrcX >= rValidSrcRect.Right() ) ||
        ( rTwoRect.mnSrcY < rValidSrcRect.Top() ) || ( rTwoRect.mnSrcY >= rValidSrcRect.Bottom() ) ||
        ( ( rTwoRect.mnSrcX + rTwoRect.mnSrcWidth ) > rValidSrcRect.Right() ) ||
        ( ( rTwoRect.mnSrcY + rTwoRect.mnSrcHeight ) > rValidSrcRect.Bottom() ) )
diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx
index 0038bef..35ef312 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -2769,7 +2769,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render
            {
                rRenderContext.SetFillColor(aBackgroundColor);
                // this case may occur for smaller horizontal resizes
                if (!aRect.IsEmpty() && (aRect.Left() < aRect.Right()))
                if (aRect.Left() < aRect.Right())
                    rRenderContext.DrawRect(aRect);
            }
        }
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx
index 1b49bfb..422a86c 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -1155,9 +1155,6 @@ bool WinSalGraphics::drawNativeControl( ControlType nType,
    bool bOk = false;
    HTHEME hTheme = nullptr;

    if (rControlRegion.IsEmpty()) // nothing to do
           return true;

    tools::Rectangle buttonRect = rControlRegion;
    tools::Rectangle cacheRect = rControlRegion;
    Size keySize = cacheRect.GetSize();