summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorDmitriy Shilin <dshil@fastmail.com>2018-12-09 16:57:23 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-12-11 08:44:58 +0100
commit216cbcec6b0361986593e49837f8420e84032d6f (patch)
tree7160f945ec969083c7fbe0942ee45a7c47a362f0 /vcl
parent7263d223ddf42cc39d10a501159c7b04ef48df96 (diff)
tdf#107792 vcl: simplify SetLineColor()
Change-Id: Ie40ef8f4c0b8fe510ead1e8ad66bce88ee6cb913 Reviewed-on: https://gerrit.libreoffice.org/64842 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/win/gdi/gdiimpl.cxx74
-rw-r--r--vcl/win/gdi/gdiimpl.hxx3
2 files changed, 44 insertions, 33 deletions
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 72f2f58e524a..2200dbda000a 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -1361,50 +1361,58 @@ void WinSalGraphicsImpl::SetLineColor()
mbStockPen = TRUE;
}
-void WinSalGraphicsImpl::SetLineColor( Color nColor )
+void WinSalGraphicsImpl::SetLineColor(Color nColor)
{
+ COLORREF nPenColor = PALETTERGB(nColor.GetRed(),
+ nColor.GetGreen(),
+ nColor.GetBlue());
+ bool bStockPen = false;
+
+ HPEN hNewPen = SearchStockPen(nPenColor);
+ if (hNewPen)
+ bStockPen = true;
+ else
+ hNewPen = MakePen(nColor, nPenColor);
+
+ ResetPen(hNewPen);
+
+ // set new data
+ mnPenColor = nPenColor;
maLineColor = nColor;
- COLORREF nPenColor = PALETTERGB( nColor.GetRed(),
- nColor.GetGreen(),
- nColor.GetBlue() );
- HPEN hNewPen = nullptr;
- bool bStockPen = FALSE;
+ mbPen = TRUE;
+ mbStockPen = bStockPen;
+}
- // search for stock pen (only screen, because printer have problems,
- // when we use stock objects)
- if ( !mrParent.isPrinter() )
+HPEN WinSalGraphicsImpl::SearchStockPen(COLORREF nPenColor)
+{
+ // Only screen, because printer has problems, when we use stock objects.
+ if (mrParent.isPrinter())
{
- SalData* pSalData = GetSalData();
- for ( sal_uInt16 i = 0; i < pSalData->mnStockPenCount; i++ )
- {
- if ( nPenColor == pSalData->maStockPenColorAry[i] )
- {
- hNewPen = pSalData->mhStockPenAry[i];
- bStockPen = TRUE;
- break;
- }
- }
+ return nullptr;
}
- // create new pen
- if ( !hNewPen )
+ const SalData* pSalData = GetSalData();
+
+ for (sal_uInt16 i = 0; i < pSalData->mnStockPenCount; i++)
{
- if ( !mrParent.isPrinter() )
+ if (nPenColor == pSalData->maStockPenColorAry[i])
+ return pSalData->mhStockPenAry[i];
+ }
+
+ return nullptr;
+}
+
+HPEN WinSalGraphicsImpl::MakePen(Color nColor, COLORREF nPenColor)
+{
+ if (!mrParent.isPrinter())
+ {
+ if (GetSalData()->mhDitherPal && ImplIsSysColorEntry(nColor))
{
- if ( GetSalData()->mhDitherPal && ImplIsSysColorEntry( nColor ) )
- nPenColor = PALRGB_TO_RGB( nPenColor );
+ nPenColor = PALRGB_TO_RGB(nPenColor);
}
-
- hNewPen = CreatePen( PS_SOLID, mrParent.mnPenWidth, nPenColor );
- bStockPen = FALSE;
}
- ResetPen(hNewPen);
-
- // set new data
- mnPenColor = nPenColor;
- mbPen = TRUE;
- mbStockPen = bStockPen;
+ return CreatePen(PS_SOLID, mrParent.mnPenWidth, nPenColor);
}
void WinSalGraphicsImpl::ResetPen(HPEN hNewPen)
diff --git a/vcl/win/gdi/gdiimpl.hxx b/vcl/win/gdi/gdiimpl.hxx
index 3673b0ca5055..24c904f9ab54 100644
--- a/vcl/win/gdi/gdiimpl.hxx
+++ b/vcl/win/gdi/gdiimpl.hxx
@@ -52,7 +52,10 @@ private:
bool tryDrawBitmapGdiPlus(const SalTwoRect& rTR, const SalBitmap& rSrcBitmap);
void drawPixelImpl( long nX, long nY, COLORREF crColor );
+ HPEN SearchStockPen(COLORREF nPenColor);
+ HPEN MakePen(Color nColor, COLORREF nPenColor);
void ResetPen(HPEN hNewPen);
+
void ResetBrush(HBRUSH hNewBrush);
public: