include/svx/svdmrkv.hxx | 2 + svx/source/svdraw/svdmrkv.cxx | 43 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-)
New commits: commit 016cd3860171f622d2a2475cf79c8463bebd58b2 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Fri Jun 7 19:23:11 2024 +0900 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Jun 18 11:24:12 2024 +0200 annot: add custom selection overlay for the annotation object Make annotation objects selection similar like it was with the old annotationg tags. Change-Id: I0623ddf56274dc996ed9dd16096256e03ad65270 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168652 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Miklos Vajna <[email protected]> diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx index 6421b51b0dba..9f95f300ccd8 100644 --- a/include/svx/svdmrkv.hxx +++ b/include/svx/svdmrkv.hxx @@ -85,6 +85,7 @@ enum class ImpGetDescriptionOptions }; class ImplMarkingOverlay; +class MarkingSelectionOverlay; class MarkingSubSelectionOverlay; class SVXCORE_DLLPUBLIC SdrMarkView : public SdrSnapView @@ -96,6 +97,7 @@ class SVXCORE_DLLPUBLIC SdrMarkView : public SdrSnapView std::unique_ptr<ImplMarkingOverlay> mpMarkPointsOverlay; std::unique_ptr<ImplMarkingOverlay> mpMarkGluePointsOverlay; + std::unique_ptr<MarkingSelectionOverlay> mpMarkingSelectionOverlay; std::unique_ptr<MarkingSubSelectionOverlay> mpMarkingSubSelectionOverlay; protected: diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 38e13d8e3857..3339191f9fb7 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -40,6 +40,7 @@ #include <svx/scene3d.hxx> #include <svx/svdovirt.hxx> #include <sdr/overlay/overlayrollingrectangle.hxx> +#include <svx/sdr/overlay/overlaypolypolygon.hxx> #include <svx/sdr/contact/displayinfo.hxx> #include <svx/sdr/contact/objectcontact.hxx> #include <svx/sdr/overlay/overlaymanager.hxx> @@ -53,6 +54,7 @@ #include <vcl/uitest/eventdescription.hxx> #include <vcl/window.hxx> #include <o3tl/string_view.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> @@ -134,6 +136,31 @@ void ImplMarkingOverlay::SetSecondPosition(const basegfx::B2DPoint& rNewPosition } } +class MarkingSelectionOverlay +{ + sdr::overlay::OverlayObjectList maObjects; +public: + MarkingSelectionOverlay(const SdrPaintView& rView, basegfx::B2DRectangle const& rSelection) + { + if (comphelper::LibreOfficeKit::isActive()) + return; // We do client-side object manipulation with the Kit API + + for (sal_uInt32 a(0); a < rView.PaintWindowCount(); a++) + { + SdrPaintWindow* pPaintWindow = rView.GetPaintWindow(a); + const rtl::Reference<sdr::overlay::OverlayManager>& xTargetOverlay = pPaintWindow->GetOverlayManager(); + + if (xTargetOverlay.is()) + { + basegfx::B2DPolyPolygon aPolyPoly(basegfx::utils::createPolygonFromRect(rSelection)); + auto pNew = std::make_unique<sdr::overlay::OverlayPolyPolygon>(aPolyPoly, COL_GRAY, 0, COL_TRANSPARENT); + xTargetOverlay->add(*pNew); + maObjects.append(std::move(pNew)); + } + } + } +}; + class MarkingSubSelectionOverlay { sdr::overlay::OverlayObjectList maObjects; @@ -1244,6 +1271,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell) SdrObject* pSaveObj = nullptr; mpMarkingSubSelectionOverlay.reset(); + mpMarkingSelectionOverlay.reset(); if(pSaveOldFocusHdl && pSaveOldFocusHdl->GetObj() @@ -1308,12 +1336,23 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell) } } + tools::Rectangle aRect(GetMarkedObjRect()); + + if (mpMarkedObj && mpMarkedObj->GetObjIdentifier() == SdrObjKind::Annotation) + { + basegfx::B2DRectangle aB2DRect(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()); + mpMarkingSelectionOverlay = std::make_unique<MarkingSelectionOverlay>(*this, aB2DRect); + + return; + + } + SfxViewShell* pViewShell = GetSfxViewShell(); // check if text edit or ole is active and handles need to be suppressed. This may be the case // when a single object is selected // Using a strict return statement is okay here; no handles means *no* handles. - if(mpMarkedObj) + if (mpMarkedObj) { // formerly #i33755#: If TextEdit is active the EditEngine will directly paint // to the window, so suppress Overlay and handles completely; a text frame for @@ -1346,8 +1385,6 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell) } } - tools::Rectangle aRect(GetMarkedObjRect()); - if (bFrmHdl) { if(!aRect.IsEmpty())
