include/svx/svdmrkv.hxx                              |    2 
 svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx |    3 +
 svx/source/svdraw/svdmrkv.cxx                        |   43 +++++++++++++++++--
 3 files changed, 45 insertions(+), 3 deletions(-)

New commits:
commit f55cfda525af718070f6a39de01de738ef660cb3
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Sat Jun 8 21:35:05 2024 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Jun 11 14:44:27 2024 +0200

    annot: don't render objects marked as annotation in PDF export
    
    Objects that are marked as annotation shouldn't be rendered to the
    PDF document. Those should be written to the PDF as annotations
    (if output of annotations is enabled in the PDF export options).
    
    Change-Id: I60650b5a64dc52da6d32d8ac92441e4b21900126
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168574
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Tested-by: Jenkins

diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx 
b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx
index 0cc353a5b65c..fc132946883a 100644
--- a/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx
@@ -89,6 +89,9 @@ bool ViewObjectContactOfSdrObj::isPrimitiveVisible(const 
DisplayInfo& rDisplayIn
         return false;
     }
 
+    if (GetObjectContact().isOutputToPDFFile() && rObject.isAnnotationObject())
+        return false;
+
     // Test for Calc object hiding (for OLE and Graphic it's extra, see there)
     const SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
 
commit 2efd36571f4ec9745354bdda31328673716e48f9
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Fri Jun 7 19:23:11 2024 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Jun 11 14:44:18 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/+/168523
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Tested-by: Jenkins

diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index b4958bb3f7fd..e9e97c4ca5ac 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 d79a899de4c8..6400f9748d91 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;
@@ -1254,6 +1281,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* 
pOtherShell)
     SdrObject* pSaveObj = nullptr;
 
     mpMarkingSubSelectionOverlay.reset();
+    mpMarkingSelectionOverlay.reset();
 
     if(pSaveOldFocusHdl
         && pSaveOldFocusHdl->GetObj()
@@ -1319,12 +1347,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
@@ -1357,8 +1396,6 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* 
pOtherShell)
         }
     }
 
-    tools::Rectangle aRect(GetMarkedObjRect());
-
     if (bFrmHdl)
     {
         if(!aRect.IsEmpty())

Reply via email to