diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-06-06 10:52:35 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-06-11 12:48:48 +0200 |
commit | e17c56bfc7930d3c14c3ff4cfd59828e8dcc0229 (patch) | |
tree | ec27fbffbe482aea2e90e98a7dd269092d43fdf1 /include/svx | |
parent | 4c179c1e62778274e7604b3317300f6df809cd80 (diff) |
annot: new Annotation sdr object, replacing annotation tags
Previously the annotations are shown as annotation (smart) tags,
which just mark in the document the existence of an annotation at
a certain position. For PDF support the annotations can be more
complex, so they can show many forms of vector graphic, ink,
bitmaps, text boxes,... and for this a normal tag is not enough.
This change moves the annotations from simple tag to use the sdr
objects, so any SdrObject can be created as an annotation. The
previous tag annotations are using SdrObject (actually SdrRect)
subclass AnnotationObject and the code that previouslly worked
with the tag annotations has been adapted.
The (PDFium based) PDF import has been changed to use subclasses
of the SdrObjects for the PDF annotations.
Change-Id: I4746b85b5b679499e470987e61ed356397e56bf9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168485
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include/svx')
-rw-r--r-- | include/svx/annotation/Annotation.hxx | 35 | ||||
-rw-r--r-- | include/svx/annotation/AnnotationObject.hxx | 57 | ||||
-rw-r--r-- | include/svx/svdobjkind.hxx | 1 |
3 files changed, 89 insertions, 4 deletions
diff --git a/include/svx/annotation/Annotation.hxx b/include/svx/annotation/Annotation.hxx index be378d6a61de..4001d97f406f 100644 --- a/include/svx/annotation/Annotation.hxx +++ b/include/svx/annotation/Annotation.hxx @@ -41,6 +41,34 @@ SVXCORE_DLLPUBLIC void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell* pViewShell, Annotation& rAnnotation); SVXCORE_DLLPUBLIC void LOKCommentNotifyAll(CommentNotificationType nType, Annotation& rAnnotation); +enum class AnnotationType +{ + None, + Square, + Polygon, + Circle, + Ink, + Highlight, + Line, + FreeText, +}; + +struct CreationInfo +{ + AnnotationType meType = AnnotationType::None; + + std::vector<basegfx::B2DPolygon> maPolygons; + basegfx::B2DRectangle maRectangle; + + float mnWidth = 0.0f; + + bool mbFillColor = false; + Color maFillColor = COL_TRANSPARENT; + + bool mbColor = false; + Color maColor = COL_TRANSPARENT; +}; + struct SVXCORE_DLLPUBLIC AnnotationData { css::geometry::RealPoint2D m_Position; @@ -73,7 +101,7 @@ protected: css::util::DateTime m_DateTime; rtl::Reference<sdr::annotation::TextApiObject> m_TextRange; - bool m_bIsFreeText = false; + CreationInfo maCreationInfo; std::unique_ptr<SdrUndoAction> createUndoAnnotation(); @@ -125,9 +153,8 @@ public: sal_uInt32 GetId() const { return m_nId; } - void setIsFreeText(bool value) { m_bIsFreeText = value; } - - bool isFreeText() const { return m_bIsFreeText; } + CreationInfo const& getCreationInfo() { return maCreationInfo; } + void setCreationInfo(CreationInfo const& rCreationInfo) { maCreationInfo = rCreationInfo; } }; typedef std::vector<rtl::Reference<Annotation>> AnnotationVector; diff --git a/include/svx/annotation/AnnotationObject.hxx b/include/svx/annotation/AnnotationObject.hxx new file mode 100644 index 000000000000..d46f4e7c3150 --- /dev/null +++ b/include/svx/annotation/AnnotationObject.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 <svx/svxdllapi.h> + +#include <svx/annotation/Annotation.hxx> +#include <svx/svdorect.hxx> + +namespace sdr::annotation +{ +struct SVXCORE_DLLPUBLIC AnnotationViewData +{ + sal_Int32 nIndex = -1; + sal_uInt16 nAuthorIndex = 0; +}; + +class SVXCORE_DLLPUBLIC AnnotationObject final : public SdrRectObj +{ +private: + virtual ~AnnotationObject() override; + + sdr::annotation::AnnotationViewData maViewData; + +public: + AnnotationObject(SdrModel& rSdrModel); + AnnotationObject(SdrModel& rSdrModel, AnnotationObject const& rSource); + AnnotationObject(SdrModel& rSdrModel, tools::Rectangle const& rRectangle, + sdr::annotation::AnnotationViewData const& aAnnotationViewData); + + rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override; + + SdrObjKind GetObjIdentifier() const override; + OUString TakeObjNameSingul() const override; + OUString TakeObjNamePlural() const override; + + void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; + + void ApplyAnnotationName(); + + bool HasTextEdit() const override; + + bool hasSpecialDrag() const override { return true; } + + bool beginSpecialDrag(SdrDragStat& /*rDrag*/) const override { return false; } +}; + +} // end sdr::annotation + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/svdobjkind.hxx b/include/svx/svdobjkind.hxx index d25eba0a0027..1517bbeba4aa 100644 --- a/include/svx/svdobjkind.hxx +++ b/include/svx/svdobjkind.hxx @@ -53,6 +53,7 @@ enum class SdrObjKind : sal_uInt16 CustomShape = 33, /// custom shape Media = 34, /// media shape Table = 35, /// table + Annotation = 36, /// annotation object OLE2Applet = 100, OLE2Plugin = 101, |