include/svx/annotation/ObjectAnnotationData.hxx |   26 ++++++++++
 include/svx/svdobj.hxx                          |    9 +++
 svx/source/svdraw/svdobj.cxx                    |   58 +++++++++++++++---------
 3 files changed, 72 insertions(+), 21 deletions(-)

New commits:
commit d051319a8f057b7938cc2c047829eed20fbd9a9a
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Jun 5 17:23:22 2024 +0900
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Jun 17 09:26:35 2024 +0200

    annot: prepare SdrObject to represent an annotation
    
    Adds the ObjectAnnotationData class that is available in every
    SdrObject, so it is possible to mark an object to represent an
    annotation. Such objects will be treated differently when saving
    the objects to files, printing, exporting to PDF.
    
    Change-Id: Iabcc2166ea20cbeac6d2ada7120700a4e8b19303
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168428
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 4cd2737d829e8a3413ad3d60a17dded4dcc8938c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168572
    Tested-by: Miklos Vajna <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/include/svx/annotation/ObjectAnnotationData.hxx 
b/include/svx/annotation/ObjectAnnotationData.hxx
new file mode 100644
index 000000000000..44776638e64f
--- /dev/null
+++ b/include/svx/annotation/ObjectAnnotationData.hxx
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <svx/svxdllapi.h>
+#include <svx/annotation/Annotation.hxx>
+
+namespace sdr::annotation
+{
+/** Contains the annotation data for a SdrObject */
+class ObjectAnnotationData
+{
+public:
+    bool mbIsAnnotation : 1 = false;
+    rtl::Reference<sdr::annotation::Annotation> mxAnnotation;
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 396c09e8cd94..95442d0123e5 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -86,7 +86,7 @@ namespace basegfx
 namespace sdr { class ObjectUser; }
 namespace sdr::properties { class BaseProperties; }
 namespace sdr::contact { class ViewContact; }
-
+namespace sdr::annotation { class ObjectAnnotationData; }
 namespace com::sun::star::drawing { class XShape; }
 namespace svx::diagram { class IDiagramHelper; }
 
@@ -379,6 +379,11 @@ public:
     virtual void SetDecorative(bool isDecorative);
     virtual bool IsDecorative() const;
 
+    // Object representing an annotation
+    bool isAnnotationObject() const;
+    void setAsAnnotationObject(bool bSetAnnotation);
+    std::unique_ptr<sdr::annotation::ObjectAnnotationData>& 
getAnnotationData();
+
     // for group objects
     bool IsGroupObject() const;
     virtual SdrObjList* GetSubList() const;
@@ -915,6 +920,8 @@ protected:
     // #i25616#
     bool                        mbSupportTextIndentingOnLineWidthChange : 1;
 
+    std::unique_ptr<sdr::annotation::ObjectAnnotationData> mpAnnotationData;
+
     virtual ~SdrObject() override;
 
     virtual std::unique_ptr<sdr::properties::BaseProperties> 
CreateObjectSpecificProperties() = 0;
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index b23e18a6a4d3..1b180f19bdec 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -57,6 +57,7 @@
 #include <sdr/contact/objectcontactofobjlistpainter.hxx>
 #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
 #include <sdr/properties/emptyproperties.hxx>
+#include <svx/annotation/ObjectAnnotationData.hxx>
 #include <svx/sdrhittesthelper.hxx>
 #include <svx/sdrobjectuser.hxx>
 #include <svx/sdrobjectfilter.hxx>
@@ -341,16 +342,17 @@ void impRemoveIncarnatedSdrObjectToSdrModel(SdrObject& 
rSdrObject, SdrModel& rSd
 #endif
 
 SdrObject::SdrObject(SdrModel& rSdrModel)
-:   mpFillGeometryDefiningShape(nullptr)
-    ,mrSdrModelFromSdrObject(rSdrModel)
-    ,m_pUserCall(nullptr)
-    ,mpImpl(new Impl)
-    ,mpParentOfSdrObject(nullptr)
-    ,m_nOrdNum(0)
-    ,mnNavigationPosition(SAL_MAX_UINT32)
-    ,mnLayerID(0)
-    ,mpSvxShape( nullptr )
-    ,mbDoNotInsertIntoPageAutomatically(false)
+    : mpFillGeometryDefiningShape(nullptr)
+    , mrSdrModelFromSdrObject(rSdrModel)
+    , m_pUserCall(nullptr)
+    , mpAnnotationData(new sdr::annotation::ObjectAnnotationData)
+    , mpImpl(new Impl)
+    , mpParentOfSdrObject(nullptr)
+    , m_nOrdNum(0)
+    , mnNavigationPosition(SAL_MAX_UINT32)
+    , mnLayerID(0)
+    , mpSvxShape( nullptr )
+    , mbDoNotInsertIntoPageAutomatically(false)
 {
     m_bVirtObj         =false;
     m_bSnapRectDirty   =true;
@@ -379,16 +381,17 @@ SdrObject::SdrObject(SdrModel& rSdrModel)
 }
 
 SdrObject::SdrObject(SdrModel& rSdrModel, SdrObject const & rSource)
-:   mpFillGeometryDefiningShape(nullptr)
-    ,mrSdrModelFromSdrObject(rSdrModel)
-    ,m_pUserCall(nullptr)
-    ,mpImpl(new Impl)
-    ,mpParentOfSdrObject(nullptr)
-    ,m_nOrdNum(0)
-    ,mnNavigationPosition(SAL_MAX_UINT32)
-    ,mnLayerID(0)
-    ,mpSvxShape( nullptr )
-    ,mbDoNotInsertIntoPageAutomatically(false)
+    : mpFillGeometryDefiningShape(nullptr)
+    , mrSdrModelFromSdrObject(rSdrModel)
+    , m_pUserCall(nullptr)
+    , mpAnnotationData(new sdr::annotation::ObjectAnnotationData)
+    , mpImpl(new Impl)
+    , mpParentOfSdrObject(nullptr)
+    , m_nOrdNum(0)
+    , mnNavigationPosition(SAL_MAX_UINT32)
+    , mnLayerID(0)
+    , mpSvxShape( nullptr )
+    , mbDoNotInsertIntoPageAutomatically(false)
 {
     m_bVirtObj         =false;
     m_bSnapRectDirty   =true;
@@ -895,6 +898,21 @@ bool SdrObject::IsDecorative() const
     return m_pPlusData == nullptr ? false : m_pPlusData->isDecorative;
 }
 
+bool SdrObject::isAnnotationObject() const
+{
+    return mpAnnotationData->mbIsAnnotation;
+}
+
+void SdrObject::setAsAnnotationObject(bool bSetAnnotation)
+{
+    mpAnnotationData->mbIsAnnotation = bSetAnnotation;
+}
+
+std::unique_ptr<sdr::annotation::ObjectAnnotationData>& 
SdrObject::getAnnotationData()
+{
+    return mpAnnotationData;
+}
+
 sal_uInt32 SdrObject::GetOrdNum() const
 {
     if (SdrObjList* pParentList = getParentSdrObjListFromSdrObject())

Reply via email to