include/svx/annotation/Annotation.hxx     |   57 ++++++++++++++++++++++++++++++
 sd/inc/Annotation.hxx                     |   18 ++-------
 sd/source/core/annotations/Annotation.cxx |    8 +---
 svx/Library_svxcore.mk                    |    1 
 svx/source/annotation/Annotation.cxx      |   18 +++++++++
 5 files changed, 82 insertions(+), 20 deletions(-)

New commits:
commit a938ed2be520426ce7949c4fd30a6e7e31d7c279
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Apr 18 14:54:52 2024 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Thu Apr 25 07:17:51 2024 +0200

    annot: added Annotation impl. to svx, moved some thing from sd
    
    This is an attempt to move the sd::Annotation to the common code
    in the svx module. This will need to be done in multiple steps so
    the first one is to introduce sdr::annotation::Annotation class in
    svx module, which is derived by sd::Annotation. Non-problematic
    functionality and members are also moved to the svx Annotation.
    
    Change-Id: Id20466b3780514ab63a9df8923b879098870ebb6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166492
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/include/svx/annotation/Annotation.hxx 
b/include/svx/annotation/Annotation.hxx
new file mode 100644
index 000000000000..13881a58d070
--- /dev/null
+++ b/include/svx/annotation/Annotation.hxx
@@ -0,0 +1,57 @@
+/* -*- 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 <com/sun/star/geometry/RealPoint2D.hpp>
+#include <com/sun/star/geometry/RealSize2D.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+
+#include <svx/svdpage.hxx>
+#include <svx/svxdllapi.h>
+
+namespace sdr::annotation
+{
+class SVXCORE_DLLPUBLIC Annotation
+{
+private:
+    static sal_uInt32 m_nLastId;
+    static sal_uInt32 nextID() { return m_nLastId++; }
+
+protected:
+    SdrPage* mpSdrPage;
+    sal_uInt32 m_nId;
+
+    css::geometry::RealPoint2D m_Position;
+    css::geometry::RealSize2D m_Size;
+    OUString m_Author;
+    OUString m_Initials;
+    css::util::DateTime m_DateTime;
+    bool m_bIsFreeText = false;
+
+public:
+    Annotation(SdrPage* pPage)
+        : mpSdrPage(pPage)
+        , m_nId(nextID())
+    {
+    }
+
+    SdrModel* GetModel()
+    {
+        return mpSdrPage != nullptr ? &mpSdrPage->getSdrModelFromSdrPage() : 
nullptr;
+    }
+
+    sal_uInt32 GetId() const { return m_nId; }
+};
+
+//typedef std::vector<rtl::Reference<Annotation>> AnnotationVector;
+
+} // namespace sdr::annotation
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/inc/Annotation.hxx b/sd/inc/Annotation.hxx
index 965cbded3719..558271dbc04e 100644
--- a/sd/inc/Annotation.hxx
+++ b/sd/inc/Annotation.hxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/office/XAnnotation.hpp>
 #include <comphelper/compbase.hxx>
 #include <cppuhelper/propertysetmixin.hxx>
+#include <svx/annotation/Annotation.hxx>
 
 #include "sdpage.hxx"
 #include "textapi.hxx"
@@ -67,19 +68,16 @@ struct SD_DLLPUBLIC CustomAnnotationMarker
 };
 
 class SAL_DLLPUBLIC_RTTI Annotation final :
-                   public 
::comphelper::WeakComponentImplHelper<css::office::XAnnotation>,
-                   public ::cppu::PropertySetMixin<css::office::XAnnotation>
+                    public sdr::annotation::Annotation,
+                    public 
::comphelper::WeakComponentImplHelper<css::office::XAnnotation>,
+                     public ::cppu::PropertySetMixin<css::office::XAnnotation>
 {
 public:
     explicit Annotation( const 
css::uno::Reference<css::uno::XComponentContext>& context, SdPage* pPage );
     Annotation(const Annotation&) = delete;
     Annotation& operator=(const Annotation&) = delete;
 
-    static sal_uInt32 m_nLastId;
-
     SdPage* GetPage() const { return mpPage; }
-    SdrModel* GetModel() { return (mpPage != nullptr) ? 
&mpPage->getSdrModelFromSdrPage() : nullptr; }
-    sal_uInt32 GetId() const { return m_nId; }
 
     // XInterface:
     virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) 
override;
@@ -141,17 +139,9 @@ private:
 
     void createChangeUndoImpl(std::unique_lock<std::mutex>& g);
 
-    sal_uInt32 m_nId;
     SdPage* mpPage;
-    css::geometry::RealPoint2D m_Position;
-    css::geometry::RealSize2D m_Size;
-    OUString m_Author;
-    OUString m_Initials;
-    css::util::DateTime m_DateTime;
     rtl::Reference<TextApiObject> m_TextRange;
-
     std::unique_ptr<CustomAnnotationMarker> m_pCustomAnnotationMarker;
-    bool m_bIsFreeText;
 };
 
 }
diff --git a/sd/source/core/annotations/Annotation.cxx 
b/sd/source/core/annotations/Annotation.cxx
index fee7312bcca2..b3938002b87c 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -115,14 +115,10 @@ void createAnnotation(rtl::Reference<Annotation>& 
xAnnotation, SdPage* pPage )
     pPage->addAnnotation(xAnnotation, -1);
 }
 
-sal_uInt32 Annotation::m_nLastId = 1;
-
 Annotation::Annotation(const uno::Reference<uno::XComponentContext>& context, 
SdPage* pPage)
-    : ::cppu::PropertySetMixin<office::XAnnotation>(context, 
IMPLEMENTS_PROPERTY_SET,
-                                                    uno::Sequence<OUString>())
-    , m_nId(m_nLastId++)
+    : sdr::annotation::Annotation(pPage)
+    , ::cppu::PropertySetMixin<office::XAnnotation>(context, 
IMPLEMENTS_PROPERTY_SET, uno::Sequence<OUString>())
     , mpPage(pPage)
-    , m_bIsFreeText(false)
 {
 }
 
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 40fad5ea6b4f..1b1e6f5c2cf1 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -106,6 +106,7 @@ $(eval $(call 
gb_Library_use_system_darwin_frameworks,svxcore,\
 endif
 
 $(eval $(call gb_Library_add_exception_objects,svxcore,\
+    svx/source/annotation/Annotation \
     svx/source/core/extedit \
     svx/source/core/graphichelper \
     svx/source/core/extendedprimitive2dxmldump \
diff --git a/svx/source/annotation/Annotation.cxx 
b/svx/source/annotation/Annotation.cxx
new file mode 100644
index 000000000000..df6e2175cef6
--- /dev/null
+++ b/svx/source/annotation/Annotation.cxx
@@ -0,0 +1,18 @@
+/* -*- 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/.
+ */
+
+#include <svx/annotation/Annotation.hxx>
+
+namespace sdr::annotation
+{
+sal_uInt32 Annotation::m_nLastId = 1;
+
+} // namespace sdr::annotation
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to