summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-04-29 20:33:04 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-04-30 13:16:40 +0200
commit5f89b8cc5521b683a519b93bbc3da739ed0fd795 (patch)
treeebc4e1b148c5916125798e8210db116dd52a4979 /svx
parent29016704108165371da9e2392d6ee28939ca46ce (diff)
extend the selection range so adjacent lines are considered one block
and so we get one border around multiple lines of an editview selection Change-Id: Ic641035da1c7d2b891cd6e6193b524e6b581e76f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114895 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/dialog/weldeditview.cxx31
1 files changed, 30 insertions, 1 deletions
diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx
index d59aab1877a6..6e83d079c722 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -181,8 +181,37 @@ void WeldEditView::DoPaint(vcl::RenderContext& rRenderContext, const tools::Rect
std::vector<basegfx::B2DRange> aLogicRanges;
aLogicRanges.reserve(aLogicRects.size());
+ tools::Long nMinX(LONG_MAX), nMaxX(0), nMinY(LONG_MAX), nMaxY(0);
for (const auto& aRect : aLogicRects)
- aLogicRanges.emplace_back(vcl::unotools::b2DRectangleFromRectangle(aRect));
+ {
+ nMinX = std::min(nMinX, aRect.Left());
+ nMinY = std::min(nMinY, aRect.Top());
+ nMaxX = std::max(nMaxX, aRect.Right());
+ nMaxY = std::max(nMaxY, aRect.Bottom());
+ }
+
+ const Size aLogicPixel(rRenderContext.PixelToLogic(Size(1, 1)));
+ for (const auto& aRect : aLogicRects)
+ {
+ // Extend each range by one pixel so multiple lines touch each
+ // other if adjacent, so the whole set is drawn with a single
+ // border around the lot. But keep the selection within the
+ // original max extents.
+ auto nTop = aRect.Top();
+ if (nTop > nMinY)
+ nTop -= aLogicPixel.Height();
+ auto nBottom = aRect.Bottom();
+ if (nBottom < nMaxY)
+ nBottom += aLogicPixel.Height();
+ auto nLeft = aRect.Left();
+ if (nLeft > nMinX)
+ nLeft -= aLogicPixel.Width();
+ auto nRight = aRect.Right();
+ if (nRight < nMaxX)
+ nRight += aLogicPixel.Width();
+
+ aLogicRanges.emplace_back(nLeft, nTop, nRight, nBottom);
+ }
// get the system's highlight color
const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;