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