From 93e819418070deb2750a918a1c3ea52376558d21 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 13 Aug 2012 16:03:17 +0200 Subject: fdo#53439 SwPageFrm::PaintBorderAndShadow fix painting at small zoom Change-Id: I235895caaf95225148e61d96f4c3b14bf9f5542e (cherry picked from commit c5b9c197d70a0fb7d75bcedf2d70e6320175e846) Signed-off-by: Ivan Timofeev --- sw/source/core/layout/paintfrm.cxx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index ad81f20c0343..74936a192829 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -5677,13 +5677,24 @@ sal_Bool SwPageFrm::IsLeftShadowNeeded() const } } +enum PaintArea {LEFT, RIGHT, TOP, BOTTOM}; + /// Wrapper around pOut->DrawBitmapEx. -void lcl_paintBitmapExToRect(OutputDevice *pOut, Point aPoint, BitmapEx& rBitmapEx) +void lcl_paintBitmapExToRect(OutputDevice *pOut, Point aPoint, BitmapEx& rBitmapEx, PaintArea eArea) { // The problem is that if we get called multiple times and the color is // partly transparent, then the result will get darker and darker. To avoid // this, always paint the background color before doing the real paint. Rectangle aRect(aPoint, rBitmapEx.GetSizePixel()); + + switch (eArea) + { + case LEFT: aRect.Left() = aRect.Right() - 1; break; + case RIGHT: aRect.Right() = aRect.Left() + 1; break; + case TOP: aRect.Top() = aRect.Bottom() - 1; break; + case BOTTOM: aRect.Bottom() = aRect.Top() + 1; break; + } + pOut->SetFillColor( SwViewOption::GetAppBackgroundColor()); pOut->SetLineColor(); pOut->DrawRect(pOut->PixelToLogic(aRect)); @@ -5795,7 +5806,7 @@ void lcl_paintBitmapExToRect(OutputDevice *pOut, Point aPoint, BitmapEx& rBitmap aPageTopRightShadow ); BitmapEx aPageRightShadow = aPageRightShadowBase; aPageRightShadow.Scale( 1, aPagePxRect.Height() - 2 * (mnShadowPxWidth - 1) ); - lcl_paintBitmapExToRect(pOut, Point( aPaintRect.Right() + mnShadowPxWidth, aPagePxRect.Top() + mnShadowPxWidth - 1), aPageRightShadow ); + lcl_paintBitmapExToRect(pOut, Point( aPaintRect.Right() + mnShadowPxWidth, aPagePxRect.Top() + mnShadowPxWidth - 1), aPageRightShadow, RIGHT ); } // Left shadows and corners @@ -5807,15 +5818,15 @@ void lcl_paintBitmapExToRect(OutputDevice *pOut, Point aPoint, BitmapEx& rBitmap pOut->DrawBitmapEx( pOut->PixelToLogic( Point( lLeft, aPagePxRect.Top() - mnShadowPxWidth ) ), aPageTopLeftShadow ); BitmapEx aPageLeftShadow = aPageLeftShadowBase; aPageLeftShadow.Scale( 1, aPagePxRect.Height() - 2 * (mnShadowPxWidth - 1) ); - lcl_paintBitmapExToRect(pOut, Point( lLeft, aPagePxRect.Top() + mnShadowPxWidth - 1), aPageLeftShadow); + lcl_paintBitmapExToRect(pOut, Point( lLeft, aPagePxRect.Top() + mnShadowPxWidth - 1), aPageLeftShadow, LEFT); } BitmapEx aPageBottomShadow = aPageBottomShadowBase; aPageBottomShadow.Scale( aPaintRect.Width(), 1 ); - lcl_paintBitmapExToRect(pOut, Point( aPaintRect.Left(), aPagePxRect.Bottom() + 1 ), aPageBottomShadow); + lcl_paintBitmapExToRect(pOut, Point( aPaintRect.Left(), aPagePxRect.Bottom() + 1 ), aPageBottomShadow, BOTTOM); BitmapEx aPageTopShadow = aPageTopShadowBase; aPageTopShadow.Scale( aPaintRect.Width(), 1 ); - lcl_paintBitmapExToRect(pOut, Point( aPaintRect.Left(), aPagePxRect.Top() - mnShadowPxWidth ), aPageTopShadow ); + lcl_paintBitmapExToRect(pOut, Point( aPaintRect.Left(), aPagePxRect.Top() - mnShadowPxWidth ), aPageTopShadow, TOP); } //mod #i6193# paint sidebar for notes -- cgit v1.2.3