use more OutputDevice::Push/Pop (tdf#164799 related)

So we save/restore the fill colors properly

Change-Id: I9613587d76785905346b341e24b5491188d095d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180929
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2025-01-30 09:55:02 +02:00
parent 94eb08183a
commit 7cd00ca413
9 changed files with 24 additions and 57 deletions

View File

@ -133,8 +133,7 @@ void ImageControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
bool bFlat = (GetBorderStyle() == WindowBorderStyle::MONO);
tools::Rectangle aRect(Point(0,0), pBorderWindow->GetOutputSizePixel());
Color oldLineCol = pBorderWindow->GetOutDev()->GetLineColor();
Color oldFillCol = pBorderWindow->GetOutDev()->GetFillColor();
pBorderWindow->GetOutDev()->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
pBorderWindow->GetOutDev()->SetFillColor();
pBorderWindow->GetOutDev()->SetLineColor(bFlat ? COL_WHITE : COL_BLACK);
pBorderWindow->GetOutDev()->DrawRect(aRect);
@ -144,9 +143,7 @@ void ImageControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
aRect.AdjustBottom( -1 );
pBorderWindow->GetOutDev()->SetLineColor(bFlat ? COL_BLACK : COL_WHITE);
pBorderWindow->GetOutDev()->DrawRect(aRect);
pBorderWindow->GetOutDev()->SetLineColor(oldLineCol);
pBorderWindow->GetOutDev()->SetFillColor(oldFillCol);
pBorderWindow->GetOutDev()->Pop();
}
void ImageControl::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags )

View File

@ -938,14 +938,14 @@ void SvxIconChoiceCtrl_Impl::LoseFocus()
void SvxIconChoiceCtrl_Impl::PaintEmphasis(const tools::Rectangle& rTextRect,
vcl::RenderContext& rRenderContext)
{
Color aOldFillColor(rRenderContext.GetFillColor());
rRenderContext.Push(vcl::PushFlags::FILLCOLOR);
const Color& rFillColor = rRenderContext.GetFont().GetFillColor();
rRenderContext.SetFillColor(rFillColor);
// draw text rectangle
if (rFillColor != COL_TRANSPARENT)
rRenderContext.DrawRect(rTextRect);
rRenderContext.SetFillColor(aOldFillColor);
rRenderContext.Pop();
}

View File

@ -2007,11 +2007,11 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, tools:
const TextPaM aTextEnd(nPara, nIndex + 1);
if ((aTextStart < *pSelEnd) && (aTextEnd > *pSelStart))
{
const Color aOldColor = pOutDev->GetFillColor();
pOutDev->Push(vcl::PushFlags::FILLCOLOR);
pOutDev->SetFillColor(
rStyleSettings.GetHighlightColor());
pOutDev->DrawRect(aTabArea);
pOutDev->SetFillColor(aOldColor);
pOutDev->Pop();
}
else
{

View File

@ -954,8 +954,9 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas
if(!aFillPolyPolygon.count())
return;
maVDev->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
const Color aOldLineColor(maVDev->GetLineColor());
const Color aOldFillColor(maVDev->GetFillColor());
maVDev->SetLineColor();
maVDev->SetFillColor(aOldLineColor);
@ -965,8 +966,7 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas
ImplWritePolyPolygonRecord(tools::PolyPolygon( tools::Polygon(rB2DPolygon) ));
}
maVDev->SetLineColor(aOldLineColor);
maVDev->SetFillColor(aOldFillColor);
maVDev->Pop();
}
void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )

View File

@ -895,9 +895,7 @@ void OutputDevice::ImplDrawEmphasisMark( tools::Long nBaseX, tools::Long nX, too
void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
{
Color aOldLineColor = GetLineColor();
Color aOldFillColor = GetFillColor();
bool bOldMap = mbMap;
Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR | vcl::PushFlags::MAPMODE);
GDIMetaFile* pOldMetaFile = mpMetaFile;
mpMetaFile = nullptr;
EnableMapMode( false );
@ -981,9 +979,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
}
}
SetLineColor( aOldLineColor );
SetFillColor( aOldFillColor );
EnableMapMode( bOldMap );
Pop();
mpMetaFile = pOldMetaFile;
}

View File

@ -107,8 +107,8 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
Point aEntryPos(nX, nY);
const Color aBackupTextColor(rRenderContext.GetTextColor());
const vcl::Font aBackupFont(rRenderContext.GetFont());
rRenderContext.Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR
| vcl::PushFlags::FONT);
const Color aBackupColor = rRenderContext.GetFillColor();
const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
@ -119,7 +119,6 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
const SvViewDataEntry* pViewDataEntry = GetViewDataEntry(&rEntry);
bool bCurFontIsSel = false;
if (pViewDataEntry->IsHighlighted())
{
vcl::Font aHighlightFont(rRenderContext.GetFont());
@ -129,7 +128,6 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
// set font color to highlight
rRenderContext.SetTextColor(aHighlightTextColor);
rRenderContext.SetFont(aHighlightFont);
bCurFontIsSel = true;
}
bool bFillColorSet = false;
@ -223,11 +221,7 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
rItem.Paint(aEntryPos, *this, rRenderContext, pViewDataEntry, rEntry);
}
if (bCurFontIsSel)
{
rRenderContext.SetTextColor(aBackupTextColor);
rRenderContext.SetFont(aBackupFont);
}
rRenderContext.Pop();
}
css::uno::Reference<css::accessibility::XAccessible> IconView::CreateAccessible()

View File

@ -770,9 +770,7 @@ void DecorationView::DrawSymbol( const tools::Rectangle& rRect, SymbolType eType
{
const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
const tools::Rectangle aRect = mpOutDev->LogicToPixel( rRect );
const Color aOldLineColor = mpOutDev->GetLineColor();
const Color aOldFillColor = mpOutDev->GetFillColor();
const bool bOldMapMode = mpOutDev->IsMapModeEnabled();
mpOutDev->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR | vcl::PushFlags::MAPMODE);
Color nColor(rColor);
mpOutDev->EnableMapMode( false );
@ -803,9 +801,7 @@ void DecorationView::DrawSymbol( const tools::Rectangle& rRect, SymbolType eType
ImplDrawSymbol( mpOutDev, aRect, eType );
// Restore previous settings
mpOutDev->SetLineColor( aOldLineColor );
mpOutDev->SetFillColor( aOldFillColor );
mpOutDev->EnableMapMode( bOldMapMode );
mpOutDev->Pop();
}
void DecorationView::DrawFrame( const tools::Rectangle& rRect,
@ -873,11 +869,9 @@ tools::Rectangle DecorationView::DrawFrame( const tools::Rectangle& rRect, DrawF
ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle, nFlags );
else
{
Color aOldLineColor = mpOutDev->GetLineColor();
Color aOldFillColor = mpOutDev->GetFillColor();
mpOutDev->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle, nFlags );
mpOutDev->SetLineColor( aOldLineColor );
mpOutDev->SetFillColor( aOldFillColor );
mpOutDev->Pop();
}
}
@ -898,11 +892,9 @@ tools::Rectangle DecorationView::DrawButton( const tools::Rectangle& rRect, Draw
const bool bOldMap = mpOutDev->IsMapModeEnabled();
mpOutDev->EnableMapMode( false );
const Color aOldLineColor = mpOutDev->GetLineColor();
const Color aOldFillColor = mpOutDev->GetFillColor();
mpOutDev->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
ImplDrawButton( mpOutDev, aRect, nStyle );
mpOutDev->SetLineColor( aOldLineColor );
mpOutDev->SetFillColor( aOldFillColor );
mpOutDev->Pop();
// keep border free, although it is used at default representation
aRect.AdjustLeft( 1 );

View File

@ -2368,10 +2368,7 @@ static void ImplDrawMoreIndicator(vcl::RenderContext& rRenderContext, const tool
static void ImplDrawDropdownArrow(vcl::RenderContext& rRenderContext, const tools::Rectangle& rDropDownRect, bool bSetColor, bool bRotate )
{
bool bLineColor = rRenderContext.IsLineColor();
bool bFillColor = rRenderContext.IsFillColor();
Color aOldFillColor = rRenderContext.GetFillColor();
Color aOldLineColor = rRenderContext.GetLineColor();
rRenderContext.Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
rRenderContext.SetLineColor();
if ( bSetColor )
@ -2409,14 +2406,7 @@ static void ImplDrawDropdownArrow(vcl::RenderContext& rRenderContext, const tool
rRenderContext.DrawPolygon( aPoly );
rRenderContext.SetAntialiasing(aaflags);
if( bFillColor )
rRenderContext.SetFillColor(aOldFillColor);
else
rRenderContext.SetFillColor();
if( bLineColor )
rRenderContext.SetLineColor(aOldLineColor);
else
rRenderContext.SetLineColor();
rRenderContext.Pop();
}
void ToolBox::ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight)

View File

@ -3511,8 +3511,7 @@ void Window::DrawSelectionBackground( const tools::Rectangle& rRect,
}
tools::Rectangle aRect( rRect );
Color oldFillCol = GetOutDev()->GetFillColor();
Color oldLineCol = GetOutDev()->GetLineColor();
GetOutDev()->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
if( bDrawBorder )
GetOutDev()->SetLineColor( bDark ? COL_WHITE : ( bBright ? COL_BLACK : aSelectionBorderCol ) );
@ -3586,8 +3585,7 @@ void Window::DrawSelectionBackground( const tools::Rectangle& rRect,
GetOutDev()->DrawTransparent( aPolyPoly, nPercent );
}
GetOutDev()->SetFillColor( oldFillCol );
GetOutDev()->SetLineColor( oldLineCol );
GetOutDev()->Pop();
}
bool Window::IsScrollable() const