Line data Source code
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 : #ifndef INCLUDED_SD_SOURCE_UI_ANNOTATIONS_ANNOTATIONMANAGERIMPL_HXX
21 : #define INCLUDED_SD_SOURCE_UI_ANNOTATIONS_ANNOTATIONMANAGERIMPL_HXX
22 :
23 : #include <com/sun/star/document/XEventListener.hpp>
24 : #include <com/sun/star/office/XAnnotationAccess.hpp>
25 :
26 : #include <rtl/ustring.hxx>
27 :
28 : #include <cppuhelper/basemutex.hxx>
29 : #include <cppuhelper/compbase1.hxx>
30 :
31 : #include "ViewShellBase.hxx"
32 :
33 : #include "annotationtag.hxx"
34 :
35 : class SfxRequest;
36 :
37 : namespace sd
38 : {
39 :
40 : typedef std::vector< rtl::Reference< AnnotationTag > > AnnotationTagVector;
41 :
42 : namespace tools {
43 : class EventMultiplexerEvent;
44 : }
45 :
46 : typedef ::cppu::WeakComponentImplHelper1 <
47 : com::sun::star::document::XEventListener
48 : > AnnotationManagerImplBase;
49 :
50 266 : class AnnotationManagerImpl : private ::cppu::BaseMutex, public AnnotationManagerImplBase
51 : {
52 : public:
53 : AnnotationManagerImpl( ViewShellBase& rViewShellBase );
54 :
55 : void init();
56 :
57 : // WeakComponentImplHelper1
58 : virtual void SAL_CALL disposing () SAL_OVERRIDE;
59 :
60 : // XEventListener
61 : virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
62 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
63 :
64 : void ExecuteAnnotation (SfxRequest& rRequest);
65 : void GetAnnotationState (SfxItemSet& rItemSet);
66 :
67 : void ExecuteInsertAnnotation(SfxRequest& rReq);
68 : void ExecuteDeleteAnnotation(SfxRequest& rReq);
69 : void ExecuteReplyToAnnotation(SfxRequest& rReq);
70 :
71 : void SelectNextAnnotation(bool bForeward);
72 :
73 : void SelectAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, bool bEdit = false );
74 : void GetSelectedAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation );
75 :
76 : void InsertAnnotation();
77 : void DeleteAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation );
78 : void DeleteAnnotationsByAuthor( const OUString& sAuthor );
79 : void DeleteAllAnnotations();
80 :
81 : void ExecuteAnnotationContextMenu( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, vcl::Window* pParent, const Rectangle& rContextRect, bool bButtonMenu = false );
82 :
83 : static Color GetColorDark(sal_uInt16 aAuthorIndex);
84 : static Color GetColorLight(sal_uInt16 aAuthorIndex);
85 : static Color GetColor(sal_uInt16 aAuthorIndex);
86 :
87 : // callbacks
88 : void onTagSelected( AnnotationTag& rTag );
89 : void onTagDeselected( AnnotationTag& rTag );
90 :
91 : void onSelectionChanged();
92 :
93 : void addListener();
94 : void removeListener();
95 :
96 : void invalidateSlots();
97 :
98 : DECL_LINK(EventMultiplexerListener, tools::EventMultiplexerEvent*);
99 : DECL_LINK(UpdateTagsHdl, void *);
100 :
101 : void UpdateTags(bool bSynchron = false);
102 : void CreateTags();
103 : void DisposeTags();
104 :
105 : SdPage* GetNextPage( SdPage* pPage, bool bForeward );
106 : SdPage* GetFirstPage();
107 : SdPage* GetLastPage();
108 :
109 : SdPage* GetCurrentPage();
110 :
111 0 : SdDrawDocument* GetDoc() { return mpDoc; }
112 :
113 : void ShowAnnotations(bool bShow);
114 :
115 : private:
116 : ViewShellBase& mrBase;
117 : SdDrawDocument* mpDoc;
118 :
119 : AnnotationTagVector maTagVector;
120 :
121 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawView > mxView;
122 : ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotationAccess > mxCurrentPage;
123 : ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > mxSelectedAnnotation;
124 :
125 : bool mbShowAnnotations;
126 : ImplSVEvent * mnUpdateTagsEvent;
127 : vcl::Font maFont;
128 : };
129 :
130 : OUString getAnnotationDateTimeString( const css::uno::Reference< css::office::XAnnotation >& xAnnotation );
131 :
132 : SfxItemPool* GetAnnotationPool();
133 :
134 : com::sun::star::util::DateTime getCurrentDateTime();
135 :
136 : }
137 :
138 : #endif // INCLUDED_SD_SOURCE_UI_ANNOTATIONS_ANNOTATIONMANAGERIMPL_HXX
139 :
140 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|