include/sfx2/LokControlHandler.hxx | 4 +--- sfx2/source/appl/newhelp.cxx | 4 +--- sfx2/source/control/charwin.cxx | 3 +-- sfx2/source/control/recentdocsview.cxx | 4 +--- sfx2/source/control/thumbnailview.cxx | 4 +--- sfx2/source/dialog/StyleList.cxx | 7 ++----- sfx2/source/doc/SfxRedactionHelper.cxx | 4 +--- sfx2/source/doc/objembed.cxx | 6 +----- sfx2/source/view/lokcharthelper.cxx | 3 +-- sfx2/source/view/lokstarmathhelper.cxx | 4 +--- 10 files changed, 11 insertions(+), 32 deletions(-)
New commits: commit b71be162d53b276a1a8f34157c43e8e7b1b7f475 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Aug 16 23:36:48 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Aug 17 08:18:12 2025 +0200 Use OutputDevice::ScopedPush in sfx2 Change-Id: I7c756f1ce06c5d412a4d00ae2366a4fa6d7393d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189803 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/include/sfx2/LokControlHandler.hxx b/include/sfx2/LokControlHandler.hxx index f404c4cf366d..08a49f6f20d9 100644 --- a/include/sfx2/LokControlHandler.hxx +++ b/include/sfx2/LokControlHandler.hxx @@ -154,7 +154,7 @@ public: // Resizes the virtual device so to contain the entries context rDevice.SetOutputSizePixel(aOutputSize, /*bErase*/ false); - rDevice.Push(vcl::PushFlags::MAPMODE); + auto popIt = rDevice.ScopedPush(vcl::PushFlags::MAPMODE); MapMode aDeviceMapMode(rDevice.GetMapMode()); const Fraction scale = conversionFract(o3tl::Length::px, o3tl::Length::twip); @@ -187,8 +187,6 @@ public: } } } - - rDevice.Pop(); } }; diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 7fb23502f2c6..d50d6ae88308 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -433,7 +433,7 @@ IMPL_LINK(IndexTabPage_Impl, CustomRenderHdl, weld::TreeView::render_args, aPayl bool bSelected = std::get<2>(aPayload); const OUString& rId = std::get<3>(aPayload); - rRenderContext.Push(vcl::PushFlags::TEXTCOLOR); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::TEXTCOLOR); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); if (bSelected) rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor()); @@ -456,8 +456,6 @@ IMPL_LINK(IndexTabPage_Impl, CustomRenderHdl, weld::TreeView::render_args, aPayl } else rRenderContext.DrawText(aPos, aEntry); - - rRenderContext.Pop(); } IMPL_LINK_NOARG(IndexTabPage_Impl, TreeChangeHdl, weld::TreeView&, void) diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx index 7dcde6e7f973..87345d7879f2 100644 --- a/sfx2/source/control/charwin.cxx +++ b/sfx2/source/control/charwin.cxx @@ -51,11 +51,10 @@ void SvxCharView::SetDrawingArea(weld::DrawingArea* pDrawingArea) vcl::Font aFont = rStyleSettings.GetLabelFont(); const Size aFontSize = aFont.GetFontSize(); aFont.SetFontSize(Size(aFontSize.Width() * 2, aFontSize.Height() * 2)); - mxVirDev->Push(PUSH_ALLFONT); + auto popIt = mxVirDev->ScopedPush(PUSH_ALLFONT); weld::SetPointFont(*mxVirDev, aFont); pDrawingArea->set_size_request(mxVirDev->approximate_digit_width() * 2, mxVirDev->GetTextHeight()); - mxVirDev->Pop(); } void SvxCharView::GetFocus() diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx index ac1b89984f5b..e5a012477d68 100644 --- a/sfx2/source/control/recentdocsview.cxx +++ b/sfx2/source/control/recentdocsview.cxx @@ -260,7 +260,7 @@ void RecentDocsView::Paint(vcl::RenderContext& rRenderContext, const tools::Rect } // No recent files to be shown yet. Show a welcome screen. - rRenderContext.Push(vcl::PushFlags::FONT | vcl::PushFlags::TEXTCOLOR); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::FONT | vcl::PushFlags::TEXTCOLOR); SetMessageFont(rRenderContext); rRenderContext.SetTextColor(maTextColor); @@ -281,8 +281,6 @@ void RecentDocsView::Paint(vcl::RenderContext& rRenderContext, const tools::Rect rRenderContext.DrawText(tools::Rectangle(0, nY + 2 * nTextHeight, rSize.Width(), rSize.Height()), maWelcomeLine2, DrawTextFlags::MultiLine | DrawTextFlags::WordBreak | DrawTextFlags::Center); - - rRenderContext.Pop(); } void RecentDocsView::LoseFocus() diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index c2b072e7af0d..94cf4cd8b731 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -950,7 +950,7 @@ void ThumbnailView::SetDrawingArea(weld::DrawingArea* pDrawingArea) void ThumbnailView::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& /*rRect*/) { - rRenderContext.Push(vcl::PushFlags::ALL); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::ALL); rRenderContext.SetTextFillColor(); rRenderContext.SetBackground(maFillColor); @@ -979,8 +979,6 @@ void ThumbnailView::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rec continue; pItem->Paint(pProcessor.get(), mpItemAttrs.get()); } - - rRenderContext.Pop(); } void ThumbnailView::GetFocus() diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx index 7748177ef4af..956095a57730 100644 --- a/sfx2/source/dialog/StyleList.cxx +++ b/sfx2/source/dialog/StyleList.cxx @@ -1783,7 +1783,7 @@ IMPL_LINK(StyleList, CustomRenderHdl, weld::TreeView::render_args, aPayload, voi bool bSelected = std::get<2>(aPayload); const OUString& rId = std::get<3>(aPayload); - rRenderContext.Push(vcl::PushFlags::TEXTCOLOR); + auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::TEXTCOLOR); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); if (bSelected) rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor()); @@ -1803,7 +1803,7 @@ IMPL_LINK(StyleList, CustomRenderHdl, weld::TreeView::render_args, aPayload, voi if (pStyleSheet) { - rRenderContext.Push(vcl::PushFlags::ALL); + auto popIt2 = rRenderContext.ScopedPush(vcl::PushFlags::ALL); // tdf#119919 - show "hidden" styles as disabled to not move children onto root node if (pStyleSheet->IsHidden() && m_bHierarchical) rRenderContext.SetTextColor(rStyleSettings.GetDisableColor()); @@ -1813,15 +1813,12 @@ IMPL_LINK(StyleList, CustomRenderHdl, weld::TreeView::render_args, aPayload, voi pStyleManager->CreateStylePreviewRenderer(rRenderContext, pStyleSheet, nSize)); bSuccess = pStylePreviewRenderer->recalculate() && pStylePreviewRenderer->render(aRect); - rRenderContext.Pop(); } } } if (!bSuccess) rRenderContext.DrawText(aRect, rId, DrawTextFlags::Left | DrawTextFlags::VCenter); - - rRenderContext.Pop(); } // Selection of a template during the Watercan-Status diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx index f7e302fec5d8..8e9b5f69dce2 100644 --- a/sfx2/source/doc/SfxRedactionHelper.cxx +++ b/sfx2/source/doc/SfxRedactionHelper.cxx @@ -431,7 +431,7 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget& rRedactionTarge OutputDevice* pOutputDevice = SfxObjectShell::GetShellFromComponent(xComponent)->GetDocumentRefDev(); - pOutputDevice->Push(::vcl::PushFlags::FONT); + auto popIt = pOutputDevice->ScopedPush(vcl::PushFlags::FONT); MetaAction* pCurrAct; @@ -480,8 +480,6 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget& rRedactionTarge pOutputDevice->SetFont(font); } } - - pOutputDevice->Pop(); } void SfxRedactionHelper::searchImagesInMetaFile( diff --git a/sfx2/source/doc/objembed.cxx b/sfx2/source/doc/objembed.cxx index 1be515a6e704..d57e9e55e9ff 100644 --- a/sfx2/source/doc/objembed.cxx +++ b/sfx2/source/doc/objembed.cxx @@ -175,7 +175,7 @@ void SfxObjectShell::DoDraw_Impl( OutputDevice* pDev, aMapMode.SetOrigin( aDelta ); // Secure the Device settings - pDev->Push(); + auto popIt = pDev->ScopedPush(); vcl::Region aRegion; if( pDev->IsClipRegion() && pDev->GetOutDevType() != OUTDEV_PRINTER ) @@ -202,10 +202,6 @@ void SfxObjectShell::DoDraw_Impl( OutputDevice* pDev, pMtf->Record( pDev ); Draw( pDev, rSetup, nAspect, bOutputForScreen ); - - // Restore Device settings - pDev->Pop(); - } comphelper::EmbeddedObjectContainer& SfxObjectShell::GetEmbeddedObjectContainer() const diff --git a/sfx2/source/view/lokcharthelper.cxx b/sfx2/source/view/lokcharthelper.cxx index 910f9757e59b..484d27dc82b5 100644 --- a/sfx2/source/view/lokcharthelper.cxx +++ b/sfx2/source/view/lokcharthelper.cxx @@ -231,7 +231,7 @@ void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice, // Resizes the virtual device so to contain the entries context rDevice.SetOutputSizePixel(Size(nOutputWidth, nOutputHeight), /*bErase*/false); - rDevice.Push(vcl::PushFlags::MAPMODE); + auto popIt = rDevice.ScopedPush(vcl::PushFlags::MAPMODE); MapMode aMapMode(rDevice.GetMapMode()); // Scaling. Must convert from pixels to twips. We know @@ -257,7 +257,6 @@ void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice, } pViewShell = SfxViewShell::GetNext(*pViewShell); } - rDevice.Pop(); } bool LokChartHelper::postMouseEvent(int nType, int nX, int nY, diff --git a/sfx2/source/view/lokstarmathhelper.cxx b/sfx2/source/view/lokstarmathhelper.cxx index d58d1c1df72b..78f27b9d7732 100644 --- a/sfx2/source/view/lokstarmathhelper.cxx +++ b/sfx2/source/view/lokstarmathhelper.cxx @@ -222,7 +222,7 @@ void LokStarMathHelper::PaintAllInPlaceOnTile(VirtualDevice& rDevice, int nOutpu // Resizes the virtual device to contain the entries context rDevice.SetOutputSizePixel({ nOutputWidth, nOutputHeight }); - rDevice.Push(vcl::PushFlags::MAPMODE); + auto popIt = rDevice.ScopedPush(vcl::PushFlags::MAPMODE); MapMode aMapMode(rDevice.GetMapMode()); // Scaling. Must convert from pixels to twips. We know that VirtualDevices use a DPI of 96. @@ -240,8 +240,6 @@ void LokStarMathHelper::PaintAllInPlaceOnTile(VirtualDevice& rDevice, int nOutpu pViewShell = SfxViewShell::GetNext(*pViewShell)) if (pViewShell->GetDocId() == nDocId && pViewShell->getPart() == nPartForCurView) LokStarMathHelper(pViewShell).PaintTile(rDevice, aTileRect); - - rDevice.Pop(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */