svx/source/sdr/overlay/overlayselection.cxx | 41 +++++++++++++--------------- 1 file changed, 20 insertions(+), 21 deletions(-)
New commits: commit 84af307af8bebfc81d4173d4574c3b72efd4c253 Author: Rafael Lima <rafael.palma.l...@gmail.com> AuthorDate: Thu Jun 27 21:28:18 2024 +0200 Commit: Rafael Lima <rafael.palma.l...@gmail.com> CommitDate: Wed Jul 10 19:11:50 2024 +0200 tdf#161817 Fix Autofill overlay when zoom is low Prior to this patch, the calculation of the offset to draw the outline was incorrect, which caused the two lines of the outline to overlap. This patch fixes this issue and makes the outline work at any zoom level. Change-Id: I95d0b240a53beda872cdf6f0e7d75b48966217d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169665 Reviewed-by: Rafael Lima <rafael.palma.l...@gmail.com> Tested-by: Jenkins (cherry picked from commit 7383298e141dcc3df23c8c849513b7782b0785e2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170113 diff --git a/svx/source/sdr/overlay/overlayselection.cxx b/svx/source/sdr/overlay/overlayselection.cxx index bd00e8a7f5df..78a1421943d5 100644 --- a/svx/source/sdr/overlay/overlayselection.cxx +++ b/svx/source/sdr/overlay/overlayselection.cxx @@ -33,30 +33,22 @@ #include <officecfg/Office/Common.hxx> #include <o3tl/sorted_vector.hxx> #include <map> +#include <tools/fract.hxx> namespace sdr::overlay { // combine ranges geometrically to a single, ORed polygon - static basegfx::B2DPolyPolygon impCombineRangesToPolyPolygon(const std::vector< basegfx::B2DRange >& rRanges, bool bOffset) + static basegfx::B2DPolyPolygon impCombineRangesToPolyPolygon(const std::vector< basegfx::B2DRange >& rRanges, bool bOffset, double fOffset) { - // Determines the offset in twips. - // The offset is only needed if the contrast outline is drawn - sal_Int32 nOffset(0); - if (bOffset) - { - Size aSize(1, 1); - aSize = o3tl::convert(aSize, o3tl::Length::px, o3tl::Length::twip); - nOffset = aSize.getWidth(); - } - const sal_uInt32 nCount(rRanges.size()); basegfx::B2DPolyPolygon aRetval; for(sal_uInt32 a(0); a < nCount; a++) { basegfx::B2DRange aRange(rRanges[a]); - aRange.grow(nOffset); + if (bOffset) + aRange.grow(fOffset); const basegfx::B2DPolygon aDiscretePolygon(basegfx::utils::createPolygonFromRect(aRange)); if(0 == a) @@ -172,15 +164,7 @@ namespace sdr::overlay if(mbBorder) { - // External outline using themed color - basegfx::B2DPolyPolygon aPolyPolygon(impCombineRangesToPolyPolygon(getRanges(), mbContrastOutline)); - const drawinglayer::primitive2d::Primitive2DReference aSelectionOutline( - new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D( - std::move(aPolyPolygon), - aRGBColor)); - - // add both to result - aRetval = drawinglayer::primitive2d::Primitive2DContainer {aUnifiedTransparence, aSelectionOutline}; + aRetval = drawinglayer::primitive2d::Primitive2DContainer {aUnifiedTransparence}; // tdf#161204 Outline with white color to provide contrast if (mbContrastOutline) @@ -192,6 +176,21 @@ namespace sdr::overlay basegfx::BColor(1.0, 1.0, 1.0))); aRetval.append(drawinglayer::primitive2d::Primitive2DContainer{aContrastSelectionOutline}); } + + // Offset to be applied to the external outline + double fOffset(0); + if (getOverlayManager()) + fOffset = getOverlayManager()->getOutputDevice().PixelToLogic(Size(1, 1)).getWidth(); + + // External outline using themed color + basegfx::B2DPolyPolygon aPolyPolygon(impCombineRangesToPolyPolygon(getRanges(), mbContrastOutline, fOffset)); + const drawinglayer::primitive2d::Primitive2DReference aSelectionOutline( + new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D( + std::move(aPolyPolygon), + aRGBColor)); + + // Add to result + aRetval.append(drawinglayer::primitive2d::Primitive2DContainer {aSelectionOutline}); } else {