1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <com/sun/star/document/XEventListener.hpp>
24 #include <rtl/ustring.hxx>
26 #include <comphelper/compbase.hxx>
28 #include "annotationtag.hxx"
30 namespace com::sun::star::drawing
{ class XDrawView
; }
31 namespace com::sun::star::office
{ class XAnnotationAccess
; }
32 namespace com::sun::star::office
{ class XAnnotation
; }
45 class EventMultiplexerEvent
;
48 typedef comphelper::WeakComponentImplHelper
<
49 css::document::XEventListener
50 > AnnotationManagerImplBase
;
52 class AnnotationManagerImpl
: public AnnotationManagerImplBase
55 explicit AnnotationManagerImpl( ViewShellBase
& rViewShellBase
);
59 // WeakComponentImplHelper
60 virtual void disposing (std::unique_lock
<std::mutex
>&) override
;
63 virtual void SAL_CALL
notifyEvent( const css::document::EventObject
& Event
) override
;
64 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
66 void ExecuteAnnotation (SfxRequest
const & rRequest
);
67 void GetAnnotationState (SfxItemSet
& rItemSet
);
69 void ExecuteInsertAnnotation(SfxRequest
const & rReq
);
70 void ExecuteDeleteAnnotation(SfxRequest
const & rReq
);
71 void ExecuteEditAnnotation(SfxRequest
const & rReq
);
72 void ExecuteReplyToAnnotation(SfxRequest
const & rReq
);
74 void SelectNextAnnotation(bool bForward
);
76 void SelectAnnotation( const css::uno::Reference
< css::office::XAnnotation
>& xAnnotation
, bool bEdit
= false );
77 void GetSelectedAnnotation( css::uno::Reference
< css::office::XAnnotation
>& xAnnotation
);
79 void InsertAnnotation(const OUString
& rText
);
80 void DeleteAnnotation( const css::uno::Reference
< css::office::XAnnotation
>& xAnnotation
);
81 void DeleteAnnotationsByAuthor( std::u16string_view sAuthor
);
82 void DeleteAllAnnotations();
84 void ExecuteAnnotationTagContextMenu(const css::uno::Reference
<css::office::XAnnotation
>& xAnnotation
, weld::Widget
* pParent
, const ::tools::Rectangle
& rContextRect
);
86 static Color
GetColorDark(sal_uInt16 aAuthorIndex
);
87 static Color
GetColorLight(sal_uInt16 aAuthorIndex
);
88 static Color
GetColor(sal_uInt16 aAuthorIndex
);
91 void onTagSelected( AnnotationTag
const & rTag
);
92 void onTagDeselected( AnnotationTag
const & rTag
);
94 void onSelectionChanged();
97 void removeListener();
99 void invalidateSlots();
101 DECL_LINK(EventMultiplexerListener
, tools::EventMultiplexerEvent
&, void);
102 DECL_LINK(UpdateTagsHdl
, void *, void);
104 void UpdateTags(bool bSynchron
= false);
108 SdPage
* GetNextPage( SdPage
const * pPage
, bool bForward
);
110 SdPage
* GetCurrentPage();
112 SdDrawDocument
* GetDoc() { return mpDoc
; }
114 void ShowAnnotations(bool bShow
);
117 ViewShellBase
& mrBase
;
118 SdDrawDocument
* mpDoc
;
120 std::vector
< rtl::Reference
< AnnotationTag
> > maTagVector
;
122 css::uno::Reference
< css::drawing::XDrawView
> mxView
;
123 css::uno::Reference
< css::office::XAnnotationAccess
> mxCurrentPage
;
124 css::uno::Reference
< css::office::XAnnotation
> mxSelectedAnnotation
;
126 bool mbShowAnnotations
;
127 ImplSVEvent
* mnUpdateTagsEvent
;
130 css::uno::Reference
<css::office::XAnnotation
> GetAnnotationById(sal_uInt32 nAnnotationId
);
133 OUString
getAnnotationDateTimeString( const css::uno::Reference
< css::office::XAnnotation
>& xAnnotation
);
135 SfxItemPool
* GetAnnotationPool();
137 css::util::DateTime
getCurrentDateTime();
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */