editeng/source/editeng/impedit3.cxx | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
New commits: commit fa7ed3501e1ee47600b41985b7c5b7f60a6a8b29 Author: Armin Le Grand (collabora) <[email protected]> AuthorDate: Thu Oct 23 18:35:55 2025 +0200 Commit: Armin Le Grand <[email protected]> CommitDate: Fri Oct 24 16:26:54 2025 +0200 tdf#167605 take ClipRegion at OutDev into account ImpEditEngine::DrawText_ToPosition has to take into account if a ClipRegion is set at the target OutputDevice when it renders using primitives, this is *not* automatically set or taken over when a PrimitiveProcessor is created for that target. This revealed a problem, see comments in editeng/source/editeng/impedit3.cxx for a detailed description. Change-Id: Ied2cf3f59d57099e616ebe9969c721f796b4b227 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192919 Reviewed-by: Armin Le Grand <[email protected]> Tested-by: Armin Le Grand <[email protected]> diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index e0578028f48a..f8cb6ef3e5bd 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -3328,7 +3328,31 @@ void ImpEditEngine::DrawText_ToPosition( std::move(aContent))}; } - static bool bBlendForTest(false); + drawinglayer::geometry::ViewInformation2D aViewInformation2D; + + if (rOutDev.IsClipRegion()) + { + // tdf#167605 if a ClipRegion is set at the OutDev we have to take care of it for the + // primitive way of rendering. get range and ClipRegion to do checks + const basegfx::B2DRange aContentRange(aContent.getB2DRange(aViewInformation2D)); + const basegfx::B2DPolyPolygon aClipPolyPolygon(rOutDev.GetClipRegion().GetAsB2DPolyPolygon()); + const basegfx::B2DRange aClipRange(aClipPolyPolygon.getB2DRange()); + + if (!aContentRange.overlaps(aClipRange)) + // no overlap, nothing visible, no output neccesary + return; + + if (!aClipRange.isInside(aContentRange)) + { + // not completely inside aClipRange, clipping needed, embed to MaskPrimitive2D + aContent = drawinglayer::primitive2d::Primitive2DContainer{ + new drawinglayer::primitive2d::MaskPrimitive2D( + aClipPolyPolygon, + std::move(aContent))}; + } + } + + static bool bBlendForTest(true); if(bBlendForTest) { aContent = drawinglayer::primitive2d::Primitive2DContainer{ @@ -3338,7 +3362,6 @@ void ImpEditEngine::DrawText_ToPosition( } // create ViewInformation2D based on target OutputDevice - drawinglayer::geometry::ViewInformation2D aViewInformation2D; aViewInformation2D.setViewTransformation(rOutDev.GetViewTransformation()); // create PrimitiveProcessor and render to target
