include/svx/sdr/overlay/overlayselection.hxx | 4 +- sc/source/ui/view/gridwin.cxx | 16 ++++----- svx/source/sdr/overlay/overlayselection.cxx | 44 ++++++++++++++++----------- 3 files changed, 38 insertions(+), 26 deletions(-)
New commits: commit ef744cd5719335e9f98fbc0996c6bb32d072475e Author: Rafael Lima <rafael.palma.l...@gmail.com> AuthorDate: Thu Jun 20 19:48:19 2024 +0200 Commit: Rafael Lima <rafael.palma.l...@gmail.com> CommitDate: Tue Jun 25 22:49:15 2024 +0200 tdf#161658 Limit new selection overlay to Calc only Previous patches [1] and [2] introduced a contrast white line to the selection overlay that was supposed to affect only Calc, but it ended up affecting other areas of LO, such as the star math editor as well as Writer. This patch makes sure the changes only affect cell selection in Calc. [1] dc243f0122ba656d2630e93bebfb84a2bfe4042a [2] 3c0db898092c2cf6148c01f6c561acc199d484f5 Change-Id: Ie910120e4b71c55ad8c00a905e1204e291a711f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169292 Reviewed-by: Rafael Lima <rafael.palma.l...@gmail.com> Tested-by: Jenkins (cherry picked from commit c3e80cbaaa62d1150860cc5281dfc784dbbde8af) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169440 diff --git a/include/svx/sdr/overlay/overlayselection.hxx b/include/svx/sdr/overlay/overlayselection.hxx index d456ac6bf11b..b83322acbf61 100644 --- a/include/svx/sdr/overlay/overlayselection.hxx +++ b/include/svx/sdr/overlay/overlayselection.hxx @@ -48,6 +48,7 @@ namespace sdr::overlay sal_uInt16 mnLastTransparence; bool mbBorder : 1; + bool mbContrastOutline : 1; // geometry creation for OverlayObject, can use local *Last* values virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence() override; @@ -57,7 +58,8 @@ namespace sdr::overlay OverlayType eType, const Color& rColor, std::vector< basegfx::B2DRange >&& rRanges, - bool bBorder); + bool bBorder, + bool bContrastOutline = false); virtual ~OverlaySelection() override; // data read access diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 5d298458cb75..9c9ed3f474ae 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -6703,7 +6703,7 @@ void ScGridWindow::UpdateCursorOverlay() sdr::overlay::OverlayType::Solid, aCursorColor, std::move(aRanges), - false)); + false, false)); xOverlayManager->add(*pOverlay); mpOOCursors.reset(new sdr::overlay::OverlayObjectList); @@ -6792,7 +6792,7 @@ void ScGridWindow::UpdateSelectionOverlay() sdr::overlay::OverlayType::Transparent, aHighlight, std::move(aRanges), - true)); + true, true)); xOverlayManager->add(*pOverlay); mpOOSelection.reset(new sdr::overlay::OverlayObjectList); @@ -6861,7 +6861,7 @@ void ScGridWindow::UpdateHighlightOverlay() sdr::overlay::OverlayType::Transparent, aHighlightColor, std::move(aRanges), - false)); + false, false)); xOverlayManager->add(*pOverlay); mpOOHighlight.reset(new sdr::overlay::OverlayObjectList); @@ -6975,7 +6975,7 @@ void ScGridWindow::UpdateAutoFillOverlay() sdr::overlay::OverlayType::Solid, aHandleColor, std::move(aRanges), - false)); + false, false)); xOverlayManager->add(*pOverlay); mpOOAutoFill.reset(new sdr::overlay::OverlayObjectList); @@ -7121,7 +7121,7 @@ void ScGridWindow::UpdateDragRectOverlay() sdr::overlay::OverlayType::Invert, COL_BLACK, std::move(aRanges), - false)); + false, false)); xOverlayManager->add(*pOverlay); mpOODragRect.reset(new sdr::overlay::OverlayObjectList); @@ -7197,7 +7197,7 @@ void ScGridWindow::UpdateHeaderOverlay() sdr::overlay::OverlayType::Invert, COL_BLACK, std::move(aRanges), - false)); + false, false)); xOverlayManager->add(*pOverlay); mpOOHeader.reset(new sdr::overlay::OverlayObjectList); @@ -7267,7 +7267,7 @@ void ScGridWindow::UpdateShrinkOverlay() sdr::overlay::OverlayType::Invert, COL_BLACK, std::move(aRanges), - false)); + false, false)); xOverlayManager->add(*pOverlay); mpOOShrink.reset(new sdr::overlay::OverlayObjectList); @@ -7332,7 +7332,7 @@ void ScGridWindow::UpdateSparklineGroupOverlay() std::unique_ptr<sdr::overlay::OverlayObject> pOverlay(new sdr::overlay::OverlaySelection( sdr::overlay::OverlayType::Transparent, - aColor, std::move(aRanges), true)); + aColor, std::move(aRanges), true, false)); xOverlayManager->add(*pOverlay); mpOOSparklineGroup->append(std::move(pOverlay)); diff --git a/svx/source/sdr/overlay/overlayselection.cxx b/svx/source/sdr/overlay/overlayselection.cxx index 700aa1915c75..bd00e8a7f5df 100644 --- a/svx/source/sdr/overlay/overlayselection.cxx +++ b/svx/source/sdr/overlay/overlayselection.cxx @@ -38,12 +38,17 @@ namespace sdr::overlay { // combine ranges geometrically to a single, ORed polygon - static basegfx::B2DPolyPolygon impCombineRangesToPolyPolygon(const std::vector< basegfx::B2DRange >& rRanges) + static basegfx::B2DPolyPolygon impCombineRangesToPolyPolygon(const std::vector< basegfx::B2DRange >& rRanges, bool bOffset) { - // Determines the offset in twips - Size aSize(1, 1); - aSize = o3tl::convert(aSize, o3tl::Length::px, o3tl::Length::twip); - const sal_Int32 nOffset = aSize.getWidth(); + // 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; @@ -168,22 +173,25 @@ namespace sdr::overlay if(mbBorder) { // External outline using themed color - basegfx::B2DPolyPolygon aPolyPolygon(impCombineRangesToPolyPolygon(getRanges())); + basegfx::B2DPolyPolygon aPolyPolygon(impCombineRangesToPolyPolygon(getRanges(), mbContrastOutline)); const drawinglayer::primitive2d::Primitive2DReference aSelectionOutline( new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D( std::move(aPolyPolygon), aRGBColor)); - // tdf#161204 Outline with white color to provide contrast - basegfx::B2DPolyPolygon aContrastPolyPolygon(impCombineRangesToContrastPolyPolygon(getRanges())); - const drawinglayer::primitive2d::Primitive2DReference aContrastSelectionOutline( - new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D( - std::move(aContrastPolyPolygon), - basegfx::BColor(1.0, 1.0, 1.0))); - // add both to result - aRetval = drawinglayer::primitive2d::Primitive2DContainer { aUnifiedTransparence, aSelectionOutline }; - aRetval.append(drawinglayer::primitive2d::Primitive2DContainer{aUnifiedTransparence, aContrastSelectionOutline}); + aRetval = drawinglayer::primitive2d::Primitive2DContainer {aUnifiedTransparence, aSelectionOutline}; + + // tdf#161204 Outline with white color to provide contrast + if (mbContrastOutline) + { + basegfx::B2DPolyPolygon aContrastPolyPolygon(impCombineRangesToContrastPolyPolygon(getRanges())); + const drawinglayer::primitive2d::Primitive2DReference aContrastSelectionOutline( + new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D( + std::move(aContrastPolyPolygon), + basegfx::BColor(1.0, 1.0, 1.0))); + aRetval.append(drawinglayer::primitive2d::Primitive2DContainer{aContrastSelectionOutline}); + } } else { @@ -200,13 +208,15 @@ namespace sdr::overlay OverlayType eType, const Color& rColor, std::vector< basegfx::B2DRange >&& rRanges, - bool bBorder) + bool bBorder, + bool bContrastOutline) : OverlayObject(rColor), meOverlayType(eType), maRanges(std::move(rRanges)), maLastOverlayType(eType), mnLastTransparence(0), - mbBorder(bBorder) + mbBorder(bBorder), + mbContrastOutline(bContrastOutline) { // no AA for selection overlays allowAntiAliase(false);