summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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: