1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c45d927aSAndrew Rist  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c45d927aSAndrew Rist  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19*c45d927aSAndrew Rist  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SD_ANNOTATIONMANAGER_IMPL_HXX
25cdf0e10cSrcweir #define _SD_ANNOTATIONMANAGER_IMPL_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/document/XEventListener.hpp>
28cdf0e10cSrcweir #include <com/sun/star/office/XAnnotationAccess.hpp>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <rtl/ustring.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
33cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "ViewShellBase.hxx"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include "annotationtag.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class SfxRequest;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace sd
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 
44cdf0e10cSrcweir typedef std::vector< rtl::Reference< AnnotationTag > > AnnotationTagVector;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir namespace tools {
47cdf0e10cSrcweir class EventMultiplexerEvent;
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1 <
51cdf0e10cSrcweir     com::sun::star::document::XEventListener
52cdf0e10cSrcweir     > AnnotationManagerImplBase;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir class AnnotationManagerImpl : private ::cppu::BaseMutex, public AnnotationManagerImplBase
55cdf0e10cSrcweir {
56cdf0e10cSrcweir public:
57cdf0e10cSrcweir     AnnotationManagerImpl( ViewShellBase& rViewShellBase );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     void init();
60cdf0e10cSrcweir 
61cdf0e10cSrcweir     // WeakComponentImplHelper1
62cdf0e10cSrcweir     virtual void SAL_CALL disposing ();
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     // XEventListener
65cdf0e10cSrcweir     virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
66cdf0e10cSrcweir     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     //
69cdf0e10cSrcweir     void ExecuteAnnotation (SfxRequest& rRequest);
70cdf0e10cSrcweir     void GetAnnotationState (SfxItemSet& rItemSet);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     void ExecuteInsertAnnotation(SfxRequest& rReq);
73cdf0e10cSrcweir     void ExecuteDeleteAnnotation(SfxRequest& rReq);
74cdf0e10cSrcweir     void ExecuteReplyToAnnotation(SfxRequest& rReq);
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     void SelectNextAnnotation(bool bForeward);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     void SelectAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, bool bEdit = sal_False );
79cdf0e10cSrcweir     void GetSelectedAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     void InsertAnnotation();
82cdf0e10cSrcweir     void DeleteAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation );
83cdf0e10cSrcweir     void DeleteAnnotationsByAuthor( const rtl::OUString& sAuthor );
84cdf0e10cSrcweir     void DeleteAllAnnotations();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     void ExecuteAnnotationContextMenu( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, ::Window* pParent, const Rectangle& rContextRect, bool bButtonMenu = false );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     Color GetColorDark(sal_uInt16 aAuthorIndex);
89cdf0e10cSrcweir     Color GetColorLight(sal_uInt16 aAuthorIndex);
90cdf0e10cSrcweir     Color GetColor(sal_uInt16 aAuthorIndex);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	// callbacks
94cdf0e10cSrcweir     void onTagSelected(	AnnotationTag& rTag );
95cdf0e10cSrcweir     void onTagDeselected( AnnotationTag& rTag );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	void onSelectionChanged();
98cdf0e10cSrcweir #if 0
99cdf0e10cSrcweir     rtl::OUString GetHelpText( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation );
100cdf0e10cSrcweir #endif
101cdf0e10cSrcweir 	void addListener();
102cdf0e10cSrcweir 	void removeListener();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     void invalidateSlots();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     DECL_LINK(EventMultiplexerListener, tools::EventMultiplexerEvent*);
107cdf0e10cSrcweir     DECL_LINK(UpdateTagsHdl, void *);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     void UpdateTags(bool bSynchron = false);
110cdf0e10cSrcweir     void CreateTags();
111cdf0e10cSrcweir 	void DisposeTags();
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     SdPage* GetNextPage( SdPage* pPage, bool bForeward );
114cdf0e10cSrcweir     SdPage* GetFirstPage();
115cdf0e10cSrcweir     SdPage* GetLastPage();
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     SdPage* GetCurrentPage();
118cdf0e10cSrcweir 
GetDoc()119cdf0e10cSrcweir     SdDrawDocument* GetDoc() { return mpDoc; }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     void ShowAnnotations(bool bShow);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir private:
124cdf0e10cSrcweir 	ViewShellBase& mrBase;
125cdf0e10cSrcweir     SdDrawDocument* mpDoc;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	AnnotationTagVector	maTagVector;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawView > mxView;
130cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotationAccess > mxCurrentPage;
131cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > mxSelectedAnnotation;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     bool mbShowAnnotations;
134cdf0e10cSrcweir     sal_uLong mnUpdateTagsEvent;
135cdf0e10cSrcweir     Font maFont;
136cdf0e10cSrcweir };
137cdf0e10cSrcweir 
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir #endif // _SD_ANNOTATIONMANAGER_IMPL_HXX
141