nss: upgrade to release 3.73
[LibreOffice.git] / sd / inc / Annotation.hxx
blob883512506c780262341004e63384d3169ba551dd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <sal/config.h>
23 #include <sal/types.h>
24 #include <memory>
26 #include <com/sun/star/office/XAnnotation.hpp>
27 #include <cppuhelper/basemutex.hxx>
28 #include <cppuhelper/compbase.hxx>
29 #include <cppuhelper/propertysetmixin.hxx>
31 #include "drawdoc.hxx"
32 #include "sdpage.hxx"
33 #include "textapi.hxx"
34 #include "sddllapi.h"
36 #include <basegfx/polygon/b2dpolygon.hxx>
37 #include <tools/color.hxx>
39 class SdrUndoAction;
41 namespace com::sun::star::office {
42 class XAnnotation;
45 namespace com::sun::star::uno { template <typename > class Reference; }
47 class SfxViewShell;
49 namespace sd {
51 enum class CommentNotificationType { Add, Modify, Remove };
53 void createAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation, SdPage* pPage );
55 std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bInsert );
57 void CreateChangeUndo(const css::uno::Reference< css::office::XAnnotation >& xAnnotation);
59 sal_uInt32 getAnnotationId(const css::uno::Reference <css::office::XAnnotation>& xAnnotation);
61 const SdPage* getAnnotationPage(const css::uno::Reference<css::office::XAnnotation>& xAnnotation);
63 void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell* pViewShell,
64 css::uno::Reference<css::office::XAnnotation> const & rxAnnotation);
66 void LOKCommentNotifyAll(CommentNotificationType nType,
67 css::uno::Reference<css::office::XAnnotation> const & rxAnnotation);
69 struct SD_DLLPUBLIC CustomAnnotationMarker
71 Color maLineColor;
72 Color maFillColor;
73 float mnLineWidth;
74 std::vector<basegfx::B2DPolygon> maPolygons;
77 class SD_DLLPUBLIC Annotation : private ::cppu::BaseMutex,
78 public ::cppu::WeakComponentImplHelper<css::office::XAnnotation>,
79 public ::cppu::PropertySetMixin<css::office::XAnnotation>
81 public:
82 explicit Annotation( const css::uno::Reference<css::uno::XComponentContext>& context, SdPage* pPage );
83 Annotation(const Annotation&) = delete;
84 Annotation& operator=(const Annotation&) = delete;
86 static sal_uInt32 m_nLastId;
88 SdPage* GetPage() const { return mpPage; }
89 SdrModel* GetModel() { return (mpPage != nullptr) ? &mpPage->getSdrModelFromSdrPage() : nullptr; }
90 sal_uInt32 GetId() const { return m_nId; }
92 // XInterface:
93 virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) override;
94 virtual void SAL_CALL acquire() throw () override { ::cppu::WeakComponentImplHelper<css::office::XAnnotation>::acquire(); }
95 virtual void SAL_CALL release() throw () override { ::cppu::WeakComponentImplHelper<css::office::XAnnotation>::release(); }
97 // css::beans::XPropertySet:
98 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
99 virtual void SAL_CALL setPropertyValue(const OUString & aPropertyName, const css::uno::Any & aValue) override;
100 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString & PropertyName) override;
101 virtual void SAL_CALL addPropertyChangeListener(const OUString & aPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener> & xListener) override;
102 virtual void SAL_CALL removePropertyChangeListener(const OUString & aPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener> & aListener) override;
103 virtual void SAL_CALL addVetoableChangeListener(const OUString & PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener> & aListener) override;
104 virtual void SAL_CALL removeVetoableChangeListener(const OUString & PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener> & aListener) override;
106 // css::office::XAnnotation:
107 virtual css::uno::Any SAL_CALL getAnchor() override;
108 virtual css::geometry::RealPoint2D SAL_CALL getPosition() override;
109 virtual void SAL_CALL setPosition(const css::geometry::RealPoint2D & the_value) override;
110 virtual css::geometry::RealSize2D SAL_CALL getSize() override;
111 virtual void SAL_CALL setSize(const css::geometry::RealSize2D& _size) override;
112 virtual OUString SAL_CALL getAuthor() override;
113 virtual void SAL_CALL setAuthor(const OUString & the_value) override;
114 virtual OUString SAL_CALL getInitials() override;
115 virtual void SAL_CALL setInitials(const OUString & the_value) override;
116 virtual css::util::DateTime SAL_CALL getDateTime() override;
117 virtual void SAL_CALL setDateTime(const css::util::DateTime & the_value) override;
118 virtual css::uno::Reference<css::text::XText> SAL_CALL getTextRange() override;
120 void createChangeUndo();
122 void createCustomAnnotationMarker()
124 m_pCustomAnnotationMarker = std::make_unique<CustomAnnotationMarker>();
127 CustomAnnotationMarker& getCustomAnnotationMarker()
129 return *m_pCustomAnnotationMarker;
132 bool hasCustomAnnotationMarker()
134 return bool(m_pCustomAnnotationMarker);
137 private:
138 // destructor is private and will be called indirectly by the release call virtual ~Annotation() {}
140 // override WeakComponentImplHelperBase::disposing()
141 // This function is called upon disposing the component,
142 // if your component needs special work when it becomes
143 // disposed, do it here.
144 virtual void SAL_CALL disposing() override;
146 sal_uInt32 m_nId;
147 SdPage* mpPage;
148 css::geometry::RealPoint2D m_Position;
149 css::geometry::RealSize2D m_Size;
150 OUString m_Author;
151 OUString m_Initials;
152 css::util::DateTime m_DateTime;
153 rtl::Reference<TextApiObject> m_TextRange;
155 std::unique_ptr<CustomAnnotationMarker> m_pCustomAnnotationMarker;
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */