Kaydet (Commit) 216cbcec authored tarafından Dmitriy Shilin's avatar Dmitriy Shilin Kaydeden (comit) Mike Kaganski

tdf#107792 vcl: simplify SetLineColor()

Change-Id: Ie40ef8f4c0b8fe510ead1e8ad66bce88ee6cb913
Reviewed-on: https://gerrit.libreoffice.org/64842
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 7263d223
...@@ -1361,50 +1361,58 @@ void WinSalGraphicsImpl::SetLineColor() ...@@ -1361,50 +1361,58 @@ void WinSalGraphicsImpl::SetLineColor()
mbStockPen = TRUE; mbStockPen = TRUE;
} }
void WinSalGraphicsImpl::SetLineColor( Color nColor ) void WinSalGraphicsImpl::SetLineColor(Color nColor)
{ {
maLineColor = nColor; COLORREF nPenColor = PALETTERGB(nColor.GetRed(),
COLORREF nPenColor = PALETTERGB( nColor.GetRed(),
nColor.GetGreen(), nColor.GetGreen(),
nColor.GetBlue() ); nColor.GetBlue());
HPEN hNewPen = nullptr; bool bStockPen = false;
bool bStockPen = FALSE;
// search for stock pen (only screen, because printer have problems, HPEN hNewPen = SearchStockPen(nPenColor);
// when we use stock objects) if (hNewPen)
if ( !mrParent.isPrinter() ) bStockPen = true;
{ else
SalData* pSalData = GetSalData(); hNewPen = MakePen(nColor, nPenColor);
for ( sal_uInt16 i = 0; i < pSalData->mnStockPenCount; i++ )
{ ResetPen(hNewPen);
if ( nPenColor == pSalData->maStockPenColorAry[i] )
// set new data
mnPenColor = nPenColor;
maLineColor = nColor;
mbPen = TRUE;
mbStockPen = bStockPen;
}
HPEN WinSalGraphicsImpl::SearchStockPen(COLORREF nPenColor)
{
// Only screen, because printer has problems, when we use stock objects.
if (mrParent.isPrinter())
{ {
hNewPen = pSalData->mhStockPenAry[i]; return nullptr;
bStockPen = TRUE;
break;
}
} }
const SalData* pSalData = GetSalData();
for (sal_uInt16 i = 0; i < pSalData->mnStockPenCount; i++)
{
if (nPenColor == pSalData->maStockPenColorAry[i])
return pSalData->mhStockPenAry[i];
} }
// create new pen return nullptr;
if ( !hNewPen ) }
HPEN WinSalGraphicsImpl::MakePen(Color nColor, COLORREF nPenColor)
{
if (!mrParent.isPrinter())
{ {
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); return CreatePen(PS_SOLID, mrParent.mnPenWidth, nPenColor);
// set new data
mnPenColor = nPenColor;
mbPen = TRUE;
mbStockPen = bStockPen;
} }
void WinSalGraphicsImpl::ResetPen(HPEN hNewPen) void WinSalGraphicsImpl::ResetPen(HPEN hNewPen)
......
...@@ -52,7 +52,10 @@ private: ...@@ -52,7 +52,10 @@ private:
bool tryDrawBitmapGdiPlus(const SalTwoRect& rTR, const SalBitmap& rSrcBitmap); bool tryDrawBitmapGdiPlus(const SalTwoRect& rTR, const SalBitmap& rSrcBitmap);
void drawPixelImpl( long nX, long nY, COLORREF crColor ); void drawPixelImpl( long nX, long nY, COLORREF crColor );
HPEN SearchStockPen(COLORREF nPenColor);
HPEN MakePen(Color nColor, COLORREF nPenColor);
void ResetPen(HPEN hNewPen); void ResetPen(HPEN hNewPen);
void ResetBrush(HBRUSH hNewBrush); void ResetBrush(HBRUSH hNewBrush);
public: public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment