1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SD_ANNOTATIONMANAGER_IMPL_HXX
29 #define _SD_ANNOTATIONMANAGER_IMPL_HXX
30 
31 #include <com/sun/star/document/XEventListener.hpp>
32 #include <com/sun/star/office/XAnnotationAccess.hpp>
33 
34 #include <rtl/ustring.hxx>
35 
36 #include <cppuhelper/basemutex.hxx>
37 #include <cppuhelper/compbase1.hxx>
38 
39 #include "ViewShellBase.hxx"
40 
41 #include "annotationtag.hxx"
42 
43 class SfxRequest;
44 
45 namespace sd
46 {
47 
48 typedef std::vector< rtl::Reference< AnnotationTag > > AnnotationTagVector;
49 
50 namespace tools {
51 class EventMultiplexerEvent;
52 }
53 
54 typedef ::cppu::WeakComponentImplHelper1 <
55     com::sun::star::document::XEventListener
56     > AnnotationManagerImplBase;
57 
58 class AnnotationManagerImpl : private ::cppu::BaseMutex, public AnnotationManagerImplBase
59 {
60 public:
61     AnnotationManagerImpl( ViewShellBase& rViewShellBase );
62 
63     void init();
64 
65     // WeakComponentImplHelper1
66     virtual void SAL_CALL disposing ();
67 
68     // XEventListener
69     virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
70     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
71 
72     //
73     void ExecuteAnnotation (SfxRequest& rRequest);
74     void GetAnnotationState (SfxItemSet& rItemSet);
75 
76     void ExecuteInsertAnnotation(SfxRequest& rReq);
77     void ExecuteDeleteAnnotation(SfxRequest& rReq);
78     void ExecuteReplyToAnnotation(SfxRequest& rReq);
79 
80     void SelectNextAnnotation(bool bForeward);
81 
82     void SelectAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, bool bEdit = sal_False );
83     void GetSelectedAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation );
84 
85     void InsertAnnotation();
86     void DeleteAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation );
87     void DeleteAnnotationsByAuthor( const rtl::OUString& sAuthor );
88     void DeleteAllAnnotations();
89 
90     void ExecuteAnnotationContextMenu( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, ::Window* pParent, const Rectangle& rContextRect, bool bButtonMenu = false );
91 
92     Color GetColorDark(sal_uInt16 aAuthorIndex);
93     Color GetColorLight(sal_uInt16 aAuthorIndex);
94     Color GetColor(sal_uInt16 aAuthorIndex);
95 
96 
97 	// callbacks
98     void onTagSelected(	AnnotationTag& rTag );
99     void onTagDeselected( AnnotationTag& rTag );
100 
101 	void onSelectionChanged();
102 #if 0
103     rtl::OUString GetHelpText( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation );
104 #endif
105 	void addListener();
106 	void removeListener();
107 
108     void invalidateSlots();
109 
110     DECL_LINK(EventMultiplexerListener, tools::EventMultiplexerEvent*);
111     DECL_LINK(UpdateTagsHdl, void *);
112 
113     void UpdateTags(bool bSynchron = false);
114     void CreateTags();
115 	void DisposeTags();
116 
117     SdPage* GetNextPage( SdPage* pPage, bool bForeward );
118     SdPage* GetFirstPage();
119     SdPage* GetLastPage();
120 
121     SdPage* GetCurrentPage();
122 
123     SdDrawDocument* GetDoc() { return mpDoc; }
124 
125     void ShowAnnotations(bool bShow);
126 
127 private:
128 	ViewShellBase& mrBase;
129     SdDrawDocument* mpDoc;
130 
131 	AnnotationTagVector	maTagVector;
132 
133 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawView > mxView;
134 	::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotationAccess > mxCurrentPage;
135 	::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > mxSelectedAnnotation;
136 
137     bool mbShowAnnotations;
138     sal_uLong mnUpdateTagsEvent;
139     Font maFont;
140 };
141 
142 }
143 
144 #endif // _SD_ANNOTATIONMANAGER_IMPL_HXX
145