drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 18 ++------ drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 9 +--- drawinglayer/source/processor2d/vclprocessor2d.cxx | 3 - editeng/source/editeng/impedit.cxx | 7 --- editeng/source/editeng/impedit2.cxx | 4 - editeng/source/editeng/impedit3.cxx | 27 ++++--------- 6 files changed, 22 insertions(+), 46 deletions(-)
New commits: commit 9cb201471899a498874023b0c3bb031edb02417c Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Aug 16 23:23:14 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Aug 16 22:36:58 2025 +0200 Use OutputDevice::ScopedPush in drawinglayer Change-Id: I4d8ce3ffe50eb572da6582a9939d0c658cf93131 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189797 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 7d654a3e419a..89a4aa5d74a6 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -1767,7 +1767,8 @@ void VclMetafileProcessor2D::processPolygonStrokePrimitive2D( } else { - mpOutputDevice->Push(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); + auto popIt + = mpOutputDevice->ScopedPush(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); // support SvtGraphicStroke MetaCommentAction std::unique_ptr<SvtGraphicStroke> pSvtGraphicStroke = impTryToCreateSvtGraphicStroke( @@ -1880,8 +1881,6 @@ void VclMetafileProcessor2D::processPolygonStrokePrimitive2D( } impEndSvtGraphicStroke(pSvtGraphicStroke.get()); - - mpOutputDevice->Pop(); } } @@ -2349,7 +2348,7 @@ void VclMetafileProcessor2D::processPolyPolygonGradientPrimitive2D( void VclMetafileProcessor2D::processPolyPolygonColorPrimitive2D( const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate) { - mpOutputDevice->Push(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); + auto popIt = mpOutputDevice->ScopedPush(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points @@ -2365,8 +2364,6 @@ void VclMetafileProcessor2D::processPolyPolygonColorPrimitive2D( mpOutputDevice->SetLineColor(); mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); - - mpOutputDevice->Pop(); } void VclMetafileProcessor2D::processMaskPrimitive2D( @@ -2410,16 +2407,13 @@ void VclMetafileProcessor2D::processMaskPrimitive2D( // set VCL clip region; subdivide before conversion to tools polygon. Subdivision necessary (!) // Removed subdivision and fixed in vcl::Region::ImplPolyPolyRegionToBandRegionFunc() in VCL where // the ClipRegion is built from the Polygon. An AdaptiveSubdivide on the source polygon was missing there - mpOutputDevice->Push(vcl::PushFlags::CLIPREGION); + auto popIt = mpOutputDevice->ScopedPush(vcl::PushFlags::CLIPREGION); mpOutputDevice->SetClipRegion(vcl::Region(maClipPolyPolygon)); // recursively paint content // #i121267# Only need to process sub-content when clip polygon is *not* empty. // If it is empty, the clip is empty and there can be nothing inside. process(rMaskCandidate.getChildren()); - - // restore VCL clip region - mpOutputDevice->Pop(); } // restore to rescued clip polygon @@ -2435,7 +2429,7 @@ void VclMetafileProcessor2D::processMaskPrimitive2D( void VclMetafileProcessor2D::processUnifiedTransparencePrimitive2D( const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate) { - mpOutputDevice->Push(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); + auto popIt = mpOutputDevice->ScopedPush(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); // for metafile: Need to examine what the pure vcl version is doing here actually // - uses DrawTransparent with metafile for content and a gradient // - uses DrawTransparent for single PolyPolygons directly. Can be detected by @@ -2538,8 +2532,6 @@ void VclMetafileProcessor2D::processUnifiedTransparencePrimitive2D( } } } - - mpOutputDevice->Pop(); } void VclMetafileProcessor2D::processTransparencePrimitive2D( diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 8dce98808e0a..9e4be16ef399 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -879,7 +879,7 @@ void VclPixelProcessor2D::processInvertPrimitive2D(const primitive2d::BasePrimit // invert primitive (currently only used for HighContrast fallback for selection in SW and SC). // (Not true, also used at least for the drawing of dragged column and row boundaries in SC.) // Set OutDev to XOR and switch AA off (XOR does not work with AA) - mpOutputDevice->Push(); + auto popIt = mpOutputDevice->ScopedPush(); mpOutputDevice->SetRasterOp(RasterOp::Xor); const AntialiasingFlags nAntiAliasing(mpOutputDevice->GetAntialiasing()); mpOutputDevice->SetAntialiasing(nAntiAliasing & ~AntialiasingFlags::Enable); @@ -888,7 +888,6 @@ void VclPixelProcessor2D::processInvertPrimitive2D(const primitive2d::BasePrimit process(rCandidate); // restore OutDev - mpOutputDevice->Pop(); mpOutputDevice->SetAntialiasing(nAntiAliasing); } @@ -1048,10 +1047,9 @@ void VclPixelProcessor2D::processFillGradientPrimitive2D( std::floor(aFullRange.getMinX()), std::floor(aFullRange.getMinY()), std::ceil(aFullRange.getMaxX()), std::ceil(aFullRange.getMaxY())); - mpOutputDevice->Push(vcl::PushFlags::CLIPREGION); + auto popIt = mpOutputDevice->ScopedPush(vcl::PushFlags::CLIPREGION); mpOutputDevice->IntersectClipRegion(aOutputRectangle); mpOutputDevice->DrawGradient(aFullRectangle, aGradient); - mpOutputDevice->Pop(); } void VclPixelProcessor2D::processPatternFillPrimitive2D( @@ -1079,7 +1077,7 @@ void VclPixelProcessor2D::processPatternFillPrimitive2D( // Unless smooth edges are needed, simply use clipping. if (basegfx::utils::isRectangle(aMask) || !getViewInformation2D().getUseAntiAliasing()) { - mpOutputDevice->Push(vcl::PushFlags::CLIPREGION); + auto popIt = mpOutputDevice->ScopedPush(vcl::PushFlags::CLIPREGION); mpOutputDevice->IntersectClipRegion(vcl::Region(aMask)); Wallpaper aWallpaper(aTileImage); aWallpaper.SetColor(COL_TRANSPARENT); @@ -1087,7 +1085,6 @@ void VclPixelProcessor2D::processPatternFillPrimitive2D( tools::Rectangle aPaperRect(aPaperPt, aTileImage.GetSizePixel()); aWallpaper.SetRect(aPaperRect); mpOutputDevice->DrawWallpaper(aMaskRect, aWallpaper); - mpOutputDevice->Pop(); return; } diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 4d13286c1280..fd491119029c 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -919,10 +919,9 @@ void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive // Unless smooth edges are needed, simply use clipping. if (basegfx::utils::isRectangle(aMask) || !getViewInformation2D().getUseAntiAliasing()) { - mpOutputDevice->Push(vcl::PushFlags::CLIPREGION); + auto popIt = mpOutputDevice->ScopedPush(vcl::PushFlags::CLIPREGION); mpOutputDevice->IntersectClipRegion(vcl::Region(aMask)); process(rMaskCandidate.getChildren()); - mpOutputDevice->Pop(); return; } commit e44019c78e5ea060c77560255bcf5f7b6d602840 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Aug 16 23:20:00 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Aug 16 22:36:49 2025 +0200 Use OutputDevice::ScopedPush in editeng Change-Id: If4bb074e53246bf01e2e40d7d2ebb93e8813754d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189796 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 31e8008e093a..e93b0c565322 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -353,7 +353,7 @@ void ImpEditView::lokSelectionCallback(const std::optional<tools::PolyPolygon> & } else if (mpViewShell) { - mpOutputWindow->GetOutDev()->Push(vcl::PushFlags::MAPMODE); + auto popIt = mpOutputWindow->GetOutDev()->ScopedPush(vcl::PushFlags::MAPMODE); if (mpOutputWindow->GetMapMode().GetMapUnit() == MapUnit::MapTwip) { // Find the parent that is not right @@ -446,8 +446,6 @@ void ImpEditView::lokSelectionCallback(const std::optional<tools::PolyPolygon> & mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle); mpViewShell->NotifyOtherViews(LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection"_ostr, sRectangle); } - - mpOutputWindow->GetOutDev()->Pop(); } } @@ -730,12 +728,11 @@ void ImpEditView::ImplDrawHighlightRect( OutputDevice& rTarget, const Point& rDo } else { - rTarget.Push(vcl::PushFlags::LINECOLOR|vcl::PushFlags::FILLCOLOR|vcl::PushFlags::RASTEROP); + auto popIt = rTarget.ScopedPush(vcl::PushFlags::LINECOLOR|vcl::PushFlags::FILLCOLOR|vcl::PushFlags::RASTEROP); rTarget.SetLineColor(); rTarget.SetFillColor(COL_BLACK); rTarget.SetRasterOp(RasterOp::Invert); rTarget.DrawRect(aRect); - rTarget.Pop(); } } } diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index d63bcc0fb934..1d60a91d2134 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3499,7 +3499,7 @@ sal_uInt32 ImpEditEngine::CalcLineWidth(ParaPortion const& rPortion, EditLine co // #114278# Saving both layout mode and language (since I'm // potentially changing both) - GetRefDevice()->Push( vcl::PushFlags::TEXTLAYOUTMODE|vcl::PushFlags::TEXTLANGUAGE ); + auto popIt = GetRefDevice()->ScopedPush(vcl::PushFlags::TEXTLAYOUTMODE | vcl::PushFlags::TEXTLANGUAGE); ImplInitLayoutMode(*GetRefDevice(), nPara, -1); @@ -3542,8 +3542,6 @@ sal_uInt32 ImpEditEngine::CalcLineWidth(ParaPortion const& rPortion, EditLine co nPos = nPos + rTextPortion.GetLen(); } - GetRefDevice()->Pop(); - return nWidth; } diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 235d962427ad..a366c53d9ee4 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -743,7 +743,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY, bool bI } // Saving both layout mode and language (since I'm potentially changing both) - GetRefDevice()->Push( vcl::PushFlags::TEXTLAYOUTMODE|vcl::PushFlags::TEXTLANGUAGE ); + auto popIt = GetRefDevice()->ScopedPush(vcl::PushFlags::TEXTLAYOUTMODE | vcl::PushFlags::TEXTLANGUAGE); ImplInitLayoutMode(*GetRefDevice(), nPara, -1); @@ -1811,8 +1811,6 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY, bool bI bool bHeightChanged = FinishCreateLines(rParaPortion); - GetRefDevice()->Pop(); - return bHeightChanged; } @@ -2533,11 +2531,10 @@ sal_Int32 ImpEditEngine::SplitTextPortion(ParaPortion& rParaPortion, sal_Int32 n SvxFont aTmpFont = rParaPortion.GetNode()->GetCharAttribs().GetDefFont(); SeekCursor(rParaPortion.GetNode(), nTxtPortionStart + 1, aTmpFont); aTmpFont.SetPhysFont(*GetRefDevice()); - GetRefDevice()->Push( vcl::PushFlags::TEXTLANGUAGE ); + auto popIt = GetRefDevice()->ScopedPush(vcl::PushFlags::TEXTLANGUAGE); ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage()); Size aSz = aTmpFont.QuickGetTextSize( GetRefDevice(), rParaPortion.GetNode()->GetString(), nTxtPortionStart, pTextPortion->GetLen(), nullptr ); - GetRefDevice()->Pop(); pTextPortion->GetExtraInfos()->nOrgWidth = aSz.Width(); } } @@ -3605,7 +3602,7 @@ void ImpEditEngine::StripAllPortions( OutputDevice& rOutDev, tools::Rectangle aC // #114278# Saving both layout mode and language (since I'm // potentially changing both) - rOutDev.Push( vcl::PushFlags::TEXTLAYOUTMODE|vcl::PushFlags::TEXTLANGUAGE ); + auto popIt = rOutDev.ScopedPush(vcl::PushFlags::TEXTLAYOUTMODE | vcl::PushFlags::TEXTLANGUAGE); ImplInitLayoutMode(rOutDev, nParaPortion, nIndex); ImplInitDigitMode(rOutDev, aTmpFont.GetLanguage()); @@ -3665,16 +3662,14 @@ void ImpEditEngine::StripAllPortions( OutputDevice& rOutDev, tools::Rectangle aC adjustXDirectionAware(aBottomRightRectPos, 2 * nHalfBlankWidth); adjustYDirectionAware(aBottomRightRectPos, pLine->GetHeight()); - rOutDev.Push( vcl::PushFlags::FILLCOLOR ); - rOutDev.Push( vcl::PushFlags::LINECOLOR ); - rOutDev.SetFillColor( COL_LIGHTGRAY ); - rOutDev.SetLineColor( COL_LIGHTGRAY ); - - const tools::Rectangle aBackRect( aTopLeftRectPos, aBottomRightRectPos ); - rOutDev.DrawRect( aBackRect ); + { + auto popIt2 = rOutDev.ScopedPush(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR); + rOutDev.SetFillColor( COL_LIGHTGRAY ); + rOutDev.SetLineColor( COL_LIGHTGRAY ); - rOutDev.Pop(); - rOutDev.Pop(); + const tools::Rectangle aBackRect( aTopLeftRectPos, aBottomRightRectPos ); + rOutDev.DrawRect( aBackRect ); + } if ( 0x200B == cChar ) { @@ -3903,8 +3898,6 @@ void ImpEditEngine::StripAllPortions( OutputDevice& rOutDev, tools::Rectangle aC { bEndOfParagraphWritten = true; } - - rOutDev.Pop(); } break; case PortionKind::TAB: