LibreOffice Module sd (master) 1
Annotation.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23#include <sal/types.h>
24#include <memory>
25
26#include <com/sun/star/office/XAnnotation.hpp>
30
31#include "sdpage.hxx"
32#include "textapi.hxx"
33#include "sddllapi.h"
34
36#include <tools/color.hxx>
37
38class SdrUndoAction;
39
40namespace com::sun::star::office {
41 class XAnnotation;
42}
43
44namespace com::sun::star::uno { template <typename > class Reference; }
45
46class SfxViewShell;
47
48namespace sd {
49
51
52void createAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation, SdPage* pPage );
53
54std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bInsert );
55
56void CreateChangeUndo(const css::uno::Reference< css::office::XAnnotation >& xAnnotation);
57
58sal_uInt32 getAnnotationId(const css::uno::Reference <css::office::XAnnotation>& xAnnotation);
59
60const SdPage* getAnnotationPage(const css::uno::Reference<css::office::XAnnotation>& xAnnotation);
61
63 css::uno::Reference<css::office::XAnnotation> const & rxAnnotation);
64
66 css::uno::Reference<css::office::XAnnotation> const & rxAnnotation);
67
69{
73 std::vector<basegfx::B2DPolygon> maPolygons;
74};
75
76class Annotation final : private ::cppu::BaseMutex,
77 public ::cppu::WeakComponentImplHelper<css::office::XAnnotation>,
78 public ::cppu::PropertySetMixin<css::office::XAnnotation>
79{
80public:
81 explicit Annotation( const css::uno::Reference<css::uno::XComponentContext>& context, SdPage* pPage );
82 Annotation(const Annotation&) = delete;
83 Annotation& operator=(const Annotation&) = delete;
84
85 static sal_uInt32 m_nLastId;
86
87 SdPage* GetPage() const { return mpPage; }
88 SdrModel* GetModel() { return (mpPage != nullptr) ? &mpPage->getSdrModelFromSdrPage() : nullptr; }
89 sal_uInt32 GetId() const { return m_nId; }
90
91 // XInterface:
92 virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) override;
93 virtual void SAL_CALL acquire() noexcept override { ::cppu::WeakComponentImplHelper<css::office::XAnnotation>::acquire(); }
94 virtual void SAL_CALL release() noexcept override { ::cppu::WeakComponentImplHelper<css::office::XAnnotation>::release(); }
95
96 // css::beans::XPropertySet:
97 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
98 virtual void SAL_CALL setPropertyValue(const OUString & aPropertyName, const css::uno::Any & aValue) override;
99 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString & PropertyName) override;
100 virtual void SAL_CALL addPropertyChangeListener(const OUString & aPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener> & xListener) override;
101 virtual void SAL_CALL removePropertyChangeListener(const OUString & aPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener> & aListener) override;
102 virtual void SAL_CALL addVetoableChangeListener(const OUString & PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener> & aListener) override;
103 virtual void SAL_CALL removeVetoableChangeListener(const OUString & PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener> & aListener) override;
104
105 // css::office::XAnnotation:
106 virtual css::uno::Any SAL_CALL getAnchor() override;
107 virtual css::geometry::RealPoint2D SAL_CALL getPosition() override;
108 virtual void SAL_CALL setPosition(const css::geometry::RealPoint2D & the_value) override;
109 virtual css::geometry::RealSize2D SAL_CALL getSize() override;
110 virtual void SAL_CALL setSize(const css::geometry::RealSize2D& _size) override;
111 virtual OUString SAL_CALL getAuthor() override;
112 virtual void SAL_CALL setAuthor(const OUString & the_value) override;
113 virtual OUString SAL_CALL getInitials() override;
114 virtual void SAL_CALL setInitials(const OUString & the_value) override;
115 virtual css::util::DateTime SAL_CALL getDateTime() override;
116 virtual void SAL_CALL setDateTime(const css::util::DateTime & the_value) override;
117 virtual css::uno::Reference<css::text::XText> SAL_CALL getTextRange() override;
118
119 void createChangeUndo();
120
122 {
123 m_pCustomAnnotationMarker = std::make_unique<CustomAnnotationMarker>();
124 }
125
127 {
129 }
130
132 {
133 return bool(m_pCustomAnnotationMarker);
134 }
135
136 void setIsFreeText(bool value) { m_bIsFreeText = value; }
137
138 bool isFreeText() const { return m_bIsFreeText; }
139
140private:
141 // destructor is private and will be called indirectly by the release call virtual ~Annotation() {}
142
143 // override WeakComponentImplHelperBase::disposing()
144 // This function is called upon disposing the component,
145 // if your component needs special work when it becomes
146 // disposed, do it here.
147 virtual void SAL_CALL disposing() override;
148
149 sal_uInt32 m_nId;
151 css::geometry::RealPoint2D m_Position;
152 css::geometry::RealSize2D m_Size;
153 OUString m_Author;
154 OUString m_Initials;
155 css::util::DateTime m_DateTime;
157
158 std::unique_ptr<CustomAnnotationMarker> m_pCustomAnnotationMarker;
160};
161
162}
163
164/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrModel & getSdrModelFromSdrPage() const
css::geometry::RealPoint2D m_Position
Definition: Annotation.hxx:151
SdrModel * GetModel()
Definition: Annotation.hxx:88
Annotation & operator=(const Annotation &)=delete
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: Annotation.cxx:150
virtual void SAL_CALL disposing() override
Definition: Annotation.cxx:134
virtual void SAL_CALL setPosition(const css::geometry::RealPoint2D &the_value) override
Definition: Annotation.cxx:204
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: Annotation.cxx:155
SdPage * mpPage
Definition: Annotation.hxx:150
Annotation(const css::uno::Reference< css::uno::XComponentContext > &context, SdPage *pPage)
virtual void SAL_CALL setSize(const css::geometry::RealSize2D &_size) override
Definition: Annotation.cxx:221
void createCustomAnnotationMarker()
Definition: Annotation.hxx:121
sal_uInt32 GetId() const
Definition: Annotation.hxx:89
virtual css::geometry::RealSize2D SAL_CALL getSize() override
Definition: Annotation.cxx:215
SdPage * GetPage() const
Definition: Annotation.hxx:87
css::util::DateTime m_DateTime
Definition: Annotation.hxx:155
void createChangeUndo()
Definition: Annotation.cxx:279
bool isFreeText() const
Definition: Annotation.hxx:138
CustomAnnotationMarker & getCustomAnnotationMarker()
Definition: Annotation.hxx:126
virtual void SAL_CALL setAuthor(const OUString &the_value) override
Definition: Annotation.cxx:237
virtual void SAL_CALL setDateTime(const css::util::DateTime &the_value) override
Definition: Annotation.cxx:269
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &type) override
Definition: Annotation.cxx:144
bool hasCustomAnnotationMarker() const
Definition: Annotation.hxx:131
Annotation(const Annotation &)=delete
rtl::Reference< TextApiObject > m_TextRange
Definition: Annotation.hxx:156
virtual css::uno::Reference< css::text::XText > SAL_CALL getTextRange() override
Definition: Annotation.cxx:296
OUString m_Initials
Definition: Annotation.hxx:154
virtual void SAL_CALL release() noexcept override
Definition: Annotation.hxx:94
virtual OUString SAL_CALL getInitials() override
Definition: Annotation.cxx:247
std::unique_ptr< CustomAnnotationMarker > m_pCustomAnnotationMarker
Definition: Annotation.hxx:158
sal_uInt32 m_nId
Definition: Annotation.hxx:149
virtual css::util::DateTime SAL_CALL getDateTime() override
Definition: Annotation.cxx:263
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: Annotation.cxx:160
OUString m_Author
Definition: Annotation.hxx:153
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: Annotation.cxx:175
virtual css::uno::Any SAL_CALL getAnchor() override
Definition: Annotation.cxx:185
css::geometry::RealSize2D m_Size
Definition: Annotation.hxx:152
virtual css::geometry::RealPoint2D SAL_CALL getPosition() override
Definition: Annotation.cxx:198
virtual OUString SAL_CALL getAuthor() override
Definition: Annotation.cxx:231
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: Annotation.cxx:165
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: Annotation.cxx:170
static sal_uInt32 m_nLastId
Definition: Annotation.hxx:85
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: Annotation.cxx:180
virtual void SAL_CALL acquire() noexcept override
Definition: Annotation.hxx:93
virtual void SAL_CALL setInitials(const OUString &the_value) override
Definition: Annotation.cxx:253
void setIsFreeText(bool value)
Definition: Annotation.hxx:136
Any value
Reference
sal_uInt32 getAnnotationId(const uno::Reference< office::XAnnotation > &xAnnotation)
Definition: Annotation.cxx:326
void createAnnotation(uno::Reference< office::XAnnotation > &xAnnotation, SdPage *pPage)
Definition: Annotation.cxx:111
void LOKCommentNotifyAll(CommentNotificationType nType, uno::Reference< office::XAnnotation > const &rxAnnotation)
Definition: Annotation.cxx:387
const SdPage * getAnnotationPage(const uno::Reference< office::XAnnotation > &xAnnotation)
Definition: Annotation.cxx:335
void CreateChangeUndo(const uno::Reference< office::XAnnotation > &xAnnotation)
Definition: Annotation.cxx:319
std::unique_ptr< SdrUndoAction > CreateUndoInsertOrRemoveAnnotation(const uno::Reference< office::XAnnotation > &xAnnotation, bool bInsert)
Definition: Annotation.cxx:306
void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell *pViewShell, uno::Reference< office::XAnnotation > const &rxAnnotation)
Definition: Annotation.cxx:377
CommentNotificationType
Definition: Annotation.hxx:50
#define SD_DLLPUBLIC
Definition: sddllapi.h:27
std::vector< basegfx::B2DPolygon > maPolygons
Definition: Annotation.hxx:73