summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Shilin <dshil@fastmail.com>2018-12-08 15:07:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-12-10 05:46:46 +0100
commit7311a88baa8c30eeb61d897f43ac3f5b481ed01f (patch)
tree07c7b8ecc900c7ca41fbf1788e0cf431fbe41af3
parentba17d2e3c1acd571a4faa7e31ef97a2ec71591bd (diff)
tdf#39593 vcl/win/gdi: extract brush updating into method
Change-Id: I569a8e1ce30054b2e01e9f774fe7332fa6874083 Reviewed-on: https://gerrit.libreoffice.org/64802 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--vcl/win/gdi/gdiimpl.cxx44
-rw-r--r--vcl/win/gdi/gdiimpl.hxx1
2 files changed, 21 insertions, 24 deletions
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 8caf2a94317f..72f2f58e524a 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -1428,21 +1428,9 @@ void WinSalGraphicsImpl::ResetPen(HPEN hNewPen)
void WinSalGraphicsImpl::SetFillColor()
{
- // create and select new brush
- HBRUSH hNewBrush = GetStockBrush( NULL_BRUSH );
- HBRUSH hOldBrush = SelectBrush( mrParent.getHDC(), hNewBrush );
-
- // destroy or save old brush
- if ( mhBrush )
- {
- if ( !mbStockBrush )
- DeleteBrush( mhBrush );
- }
- else
- mrParent.mhDefBrush = hOldBrush;
+ ResetBrush(GetStockBrush(NULL_BRUSH));
// set new data
- mhBrush = hNewBrush;
mbBrush = FALSE;
mbStockBrush = TRUE;
}
@@ -1531,23 +1519,31 @@ void WinSalGraphicsImpl::SetFillColor( Color nColor )
bStockBrush = FALSE;
}
- // select new brush
- HBRUSH hOldBrush = SelectBrush( mrParent.getHDC(), hNewBrush );
+ ResetBrush(hNewBrush);
- // destroy or save old brush
- if ( mhBrush )
+ // set new data
+ mnBrushColor = nBrushColor;
+ mbBrush = TRUE;
+ mbStockBrush = bStockBrush;
+}
+
+void WinSalGraphicsImpl::ResetBrush(HBRUSH hNewBrush)
+{
+ HBRUSH hOldBrush = SelectBrush(mrParent.getHDC(), hNewBrush);
+
+ if (mhBrush)
{
- if ( !mbStockBrush )
- DeleteBrush( mhBrush );
+ if (!mbStockBrush)
+ {
+ DeleteBrush(mhBrush);
+ }
}
else
+ {
mrParent.mhDefBrush = hOldBrush;
+ }
- // set new data
- mnBrushColor = nBrushColor;
- mhBrush = hNewBrush;
- mbBrush = TRUE;
- mbStockBrush = bStockBrush;
+ mhBrush = hNewBrush;
}
void WinSalGraphicsImpl::SetXORMode( bool bSet, bool )
diff --git a/vcl/win/gdi/gdiimpl.hxx b/vcl/win/gdi/gdiimpl.hxx
index 040920cb1536..3673b0ca5055 100644
--- a/vcl/win/gdi/gdiimpl.hxx
+++ b/vcl/win/gdi/gdiimpl.hxx
@@ -53,6 +53,7 @@ private:
void drawPixelImpl( long nX, long nY, COLORREF crColor );
void ResetPen(HPEN hNewPen);
+ void ResetBrush(HBRUSH hNewBrush);
public:
explicit WinSalGraphicsImpl(WinSalGraphics& rParent);