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()
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)
......
......@@ -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:
......
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