svtools/source/brwbox/brwbox2.cxx | 20 ++++++-------------- svtools/source/control/ctrlbox.cxx | 6 ++---- svtools/source/control/ruler.cxx | 3 +-- svtools/source/control/scriptedtext.cxx | 8 ++------ svtools/source/control/tabbar.cxx | 3 +-- svtools/source/control/valueset.cxx | 4 +--- svtools/source/misc/embedhlp.cxx | 8 ++------ 7 files changed, 15 insertions(+), 37 deletions(-)
New commits: commit f70e18ab72b695cb237e51c281f1e421ce202f4c Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Aug 16 23:37:51 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Aug 17 08:32:18 2025 +0200 Use OutputDevice::ScopedPush in svtools Change-Id: I2fd9ec24012af0d3dcaa61e0d32b4143a4437a4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189805 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx index 11ed24ba0d0f..1984dc2290de 100644 --- a/svtools/source/brwbox/brwbox2.cxx +++ b/svtools/source/brwbox/brwbox2.cxx @@ -610,10 +610,9 @@ void BrowseBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle } else { - rRenderContext.Push(vcl::PushFlags::FILLCOLOR); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::FILLCOLOR); rRenderContext.SetFillColor(COL_BLACK); rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0), Size(pCol->Width(), GetTitleHeight() - 1))); - rRenderContext.Pop(); } // skip column @@ -625,24 +624,22 @@ void BrowseBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle { const StyleSettings &rSettings = rRenderContext.GetSettings().GetStyleSettings(); Color aColFace(rSettings.GetFaceColor()); - rRenderContext.Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR); rRenderContext.SetFillColor(aColFace); rRenderContext.SetLineColor(aColFace); rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0), Point(rRect.Right(), GetTitleHeight() - 2 ))); - rRenderContext.Pop(); } if (m_nActualCornerWidth) { const StyleSettings &rSettings = rRenderContext.GetSettings().GetStyleSettings(); Color aColFace(rSettings.GetFaceColor()); - rRenderContext.Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR); rRenderContext.SetFillColor(aColFace); rRenderContext.SetLineColor(aColFace); rRenderContext.DrawRect(tools::Rectangle(Point(GetOutputSizePixel().Width() - m_nActualCornerWidth, aHScroll->GetPosPixel().Y()), Size(m_nActualCornerWidth, m_nCornerHeight))); - rRenderContext.Pop(); } } @@ -660,7 +657,7 @@ void BrowseBox::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlag // the 'normal' painting uses always the data window as device to output to, so we have to calc the new font // relative to the data wins current settings - pDev->Push(); + auto popIt = pDev->ScopedPush(); pDev->SetMapMode(); pDev->SetFont( aFont ); if (nFlags & SystemTextColorFlags::Mono) @@ -744,15 +741,13 @@ void BrowseBox::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlag pFirstCol->Title(), !IsEnabled()); aButtonFrame.Draw( *pDev ); - pDev->Push( vcl::PushFlags::LINECOLOR ); + auto popIt2 = pDev->ScopedPush(vcl::PushFlags::LINECOLOR); pDev->SetLineColor( COL_BLACK ); pDev->DrawLine( Point( aRealPos.X(), aRealPos.Y() + nTitleHeight-1 ), Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) ); pDev->DrawLine( Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() ), Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) ); - - pDev->Pop(); } aRealPos.AdjustY(aHeaderSize.Height() ); @@ -787,8 +782,6 @@ void BrowseBox::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlag if ( pBar ) pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() ); } - - pDev->Pop(); } void BrowseBox::ImplPaintData(OutputDevice& _rOut, const tools::Rectangle& _rRect, bool _bForeignDevice) @@ -952,7 +945,7 @@ void BrowseBox::ImplPaintData(OutputDevice& _rOut, const tools::Rectangle& _rRec { // draw horizontal delimitation lines _rOut.SetClipRegion(); - _rOut.Push( vcl::PushFlags::LINECOLOR ); + auto popIt = _rOut.ScopedPush(vcl::PushFlags::LINECOLOR); _rOut.SetLineColor( aDelimiterLineColor ); tools::Long nY = aPos.Y() + nDataRowHeight - 1; if (nY <= aOverallAreaBRPos.Y()) @@ -961,7 +954,6 @@ void BrowseBox::ImplPaintData(OutputDevice& _rOut, const tools::Rectangle& _rRec ? std::min(tools::Long(aPos.X() - 1), aOverallAreaBRPos.X()) : aOverallAreaBRPos.X(), nY ) ); - _rOut.Pop(); } } diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 9434121ce65f..554d8114cc2c 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -605,7 +605,7 @@ IMPL_LINK_NOARG(FontNameBox, UpdateHdl, Timer*, void) static void DrawPreview(const FontMetric& rFontMetric, const Point& rTopLeft, OutputDevice& rDevice, bool bSelected) { - rDevice.Push(vcl::PushFlags::TEXTCOLOR); + auto popIt = rDevice.ScopedPush(vcl::PushFlags::TEXTCOLOR); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); if (bSelected) @@ -780,7 +780,6 @@ static void DrawPreview(const FontMetric& rFontMetric, const Point& rTopLeft, Ou } rDevice.SetFont(aOldFont); - rDevice.Pop(); } OutputDevice& FontNameBox::CachePreview(size_t nIndex, Point* pTopLeft, @@ -1648,14 +1647,13 @@ void SvtLineListBox::UpdatePreview() Image aImage(m_xLineSet->GetItemImage(m_xLineSet->GetSelectedItemId())); m_xControl->set_label(u""_ustr); const auto nPos = (aVirDev->GetOutputSizePixel().Height() - aImage.GetSizePixel().Height()) / 2; - aVirDev->Push(vcl::PushFlags::MAPMODE); + auto popIt = aVirDev->ScopedPush(vcl::PushFlags::MAPMODE); aVirDev->SetMapMode(MapMode(MapUnit::MapPixel)); const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); aVirDev->SetBackground(rSettings.GetFieldColor()); aVirDev->Erase(); aVirDev->DrawImage(Point(0, nPos), aImage); m_xControl->set_image(aVirDev.get()); - aVirDev->Pop(); } } diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index 5808cfe1e559..ebd4b1908dc5 100644 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -2705,12 +2705,11 @@ void Ruler::DrawTab(vcl::RenderContext& rRenderContext, const Color &rFillColor, Point aPos(rPos); sal_uInt16 nTabStyle = nStyle & (RULER_TAB_STYLE | RULER_TAB_RTL); - rRenderContext.Push(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); rRenderContext.SetLineColor(); rRenderContext.SetFillColor(rFillColor); ImplCenterTabPos(aPos, nTabStyle); ImplDrawRulerTab(rRenderContext, aPos, nTabStyle, nStyle); - rRenderContext.Pop(); } void Ruler::SetTextRTL(bool bRTL) diff --git a/svtools/source/control/scriptedtext.cxx b/svtools/source/control/scriptedtext.cxx index e47924687bab..cfffd9cb5ca8 100644 --- a/svtools/source/control/scriptedtext.cxx +++ b/svtools/source/control/scriptedtext.cxx @@ -104,7 +104,7 @@ void SvtScriptedTextHelper_Impl::CalculateSizes() { maTextSize.setWidth(0); maTextSize.setHeight(0); - mrOutDevice.Push(vcl::PushFlags::FONT | vcl::PushFlags::TEXTCOLOR); + auto popIt = mrOutDevice.ScopedPush(vcl::PushFlags::FONT | vcl::PushFlags::TEXTCOLOR); // calculate text portion widths and total width maWidthVec.clear(); @@ -143,8 +143,6 @@ void SvtScriptedTextHelper_Impl::CalculateSizes() maTextSize.setHeight( std::max( maTextSize.Height(), mrOutDevice.GetTextHeight() ) ); SetOutDevFont( i18n::ScriptType::COMPLEX ); maTextSize.setHeight( std::max( maTextSize.Height(), mrOutDevice.GetTextHeight() ) ); - - mrOutDevice.Pop(); } void SvtScriptedTextHelper_Impl::CalculateBreaks( const uno::Reference< i18n::XBreakIterator >& _xBreakIter ) @@ -246,7 +244,7 @@ void SvtScriptedTextHelper_Impl::DrawText( const Point& _rPos ) DBG_ASSERT( maPosVec.size() - 1 == maScriptVec.size(), "SvtScriptedTextHelper_Impl::DrawText - invalid std::vectors" ); DBG_ASSERT( maScriptVec.size() == maWidthVec.size(), "SvtScriptedTextHelper_Impl::DrawText - invalid std::vectors" ); - mrOutDevice.Push(vcl::PushFlags::FONT | vcl::PushFlags::TEXTCOLOR); + auto popIt = mrOutDevice.ScopedPush(vcl::PushFlags::FONT | vcl::PushFlags::TEXTCOLOR); Point aCurrPos( _rPos ); sal_Int32 nThisPos = maPosVec[ 0 ]; @@ -270,8 +268,6 @@ void SvtScriptedTextHelper_Impl::DrawText( const Point& _rPos ) aCurrPos.AdjustX(mrOutDevice.GetTextHeight() / 5 ); // add 20% of font height as portion spacing nThisPos = nNextPos; } - - mrOutDevice.Pop(); } diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index f11b4cd91f4c..ace2641b6f60 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -1158,7 +1158,7 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); ImplGetColors(rStyleSettings, aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor); - rRenderContext.Push(vcl::PushFlags::FONT | vcl::PushFlags::CLIPREGION); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::FONT | vcl::PushFlags::CLIPREGION); rRenderContext.SetClipRegion(vcl::Region(GetPageArea())); // select font @@ -1263,7 +1263,6 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r if (!pItem) pItem = pCurItem; } - rRenderContext.Pop(); } void TabBar::Resize() diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index a0fac8e50a36..8d7edca7de00 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1517,7 +1517,7 @@ void ValueSet::ImplDrawItemText(vcl::RenderContext& rRenderContext, const OUStri tools::Long nTxtWidth = rRenderContext.GetTextWidth(rText); tools::Long nTxtOffset = mnTextOffset; - rRenderContext.Push(vcl::PushFlags::TEXTCOLOR); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::TEXTCOLOR); // delete rectangle and show text const bool bFlat(GetStyle() & WB_FLATVALUESET); @@ -1529,8 +1529,6 @@ void ValueSet::ImplDrawItemText(vcl::RenderContext& rRenderContext, const OUStri // overwrite already rendered text rRenderContext.Erase(tools::Rectangle(Point(0, nTxtOffset), Point(aWinSize.Width(), aWinSize.Height()))); rRenderContext.DrawText(Point((aWinSize.Width() - nTxtWidth) / 2, nTxtOffset + (NAME_OFFSET / 2)), rText); - - rRenderContext.Pop(); } void ValueSet::StyleUpdated() diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index ef3584d03f54..f988a6abd1b6 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -722,7 +722,7 @@ void EmbeddedObjectRef::DrawPaintReplacement( const tools::Rectangle &rRect, con aFnt.SetWeight( WEIGHT_BOLD ); aFnt.SetFamily( FAMILY_SWISS ); - pOut->Push(); + auto popIt = pOut->ScopedPush(); pOut->SetBackground(); pOut->SetFont( aFnt ); @@ -791,7 +791,6 @@ void EmbeddedObjectRef::DrawPaintReplacement( const tools::Rectangle &rRect, con pOut->IntersectClipRegion( rRect ); aPt += rRect.TopLeft(); pOut->DrawText( aPt, rText ); - pOut->Pop(); } void EmbeddedObjectRef::DrawShading( const tools::Rectangle &rRect, OutputDevice *pOut ) @@ -800,7 +799,7 @@ void EmbeddedObjectRef::DrawShading( const tools::Rectangle &rRect, OutputDevice if( pMtf && pMtf->IsRecord() ) return; - pOut->Push(); + auto popIt = pOut->ScopedPush(); pOut->SetLineColor( COL_BLACK ); Size aPixSize = pOut->LogicToPixel( rRect.GetSize() ); @@ -822,9 +821,6 @@ void EmbeddedObjectRef::DrawShading( const tools::Rectangle &rRect, OutputDevice pOut->DrawLine( pOut->PixelToLogic( a1 ), pOut->PixelToLogic( a2 ) ); } - - pOut->Pop(); - } bool EmbeddedObjectRef::TryRunningState( const uno::Reference < embed::XEmbeddedObject >& xEmbObj )