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 _INTERCEPT_HXX_ 25 #define _INTERCEPT_HXX_ 26 27 #include <osl/mutex.hxx> 28 #include <cppuhelper/implbase3.hxx> 29 #include <cppuhelper/interfacecontainer.hxx> 30 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> 31 #include <com/sun/star/frame/XInterceptorInfo.hpp> 32 #include <com/sun/star/frame/XDispatch.hpp> 33 34 35 class StatusChangeListenerContainer; 36 class DocumentHolder; 37 38 class Interceptor : public ::cppu::WeakImplHelper3< ::com::sun::star::frame::XDispatchProviderInterceptor, 39 ::com::sun::star::frame::XInterceptorInfo, 40 ::com::sun::star::frame::XDispatch> 41 { 42 public: 43 44 Interceptor( DocumentHolder* pDocHolder ); 45 ~Interceptor(); 46 47 void DisconnectDocHolder(); 48 // overwritten to release the statuslistener. 49 50 // XComponent 51 virtual void SAL_CALL 52 addEventListener( 53 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener ) 54 throw( com::sun::star::uno::RuntimeException ); 55 56 virtual void SAL_CALL 57 removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener ) 58 throw( com::sun::star::uno::RuntimeException ); 59 60 //XDispatch 61 virtual void SAL_CALL 62 dispatch( 63 const ::com::sun::star::util::URL& URL, 64 const ::com::sun::star::uno::Sequence< 65 ::com::sun::star::beans::PropertyValue >& Arguments ) 66 throw (::com::sun::star::uno::RuntimeException); 67 68 virtual void SAL_CALL 69 addStatusListener( 70 const ::com::sun::star::uno::Reference< 71 ::com::sun::star::frame::XStatusListener >& Control, 72 const ::com::sun::star::util::URL& URL ) 73 throw ( 74 ::com::sun::star::uno::RuntimeException 75 ); 76 77 virtual void SAL_CALL 78 removeStatusListener( 79 const ::com::sun::star::uno::Reference< 80 ::com::sun::star::frame::XStatusListener >& Control, 81 const ::com::sun::star::util::URL& URL ) 82 throw ( 83 ::com::sun::star::uno::RuntimeException 84 ); 85 86 //XInterceptorInfo 87 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > 88 SAL_CALL getInterceptedURLs( ) 89 throw ( 90 ::com::sun::star::uno::RuntimeException 91 ); 92 93 //XDispatchProvider ( inherited by XDispatchProviderInterceptor ) 94 virtual ::com::sun::star::uno::Reference< 95 ::com::sun::star::frame::XDispatch > SAL_CALL 96 queryDispatch( 97 const ::com::sun::star::util::URL& URL, 98 const ::rtl::OUString& TargetFrameName, 99 sal_Int32 SearchFlags ) 100 throw ( 101 ::com::sun::star::uno::RuntimeException 102 ); 103 104 virtual ::com::sun::star::uno::Sequence< 105 ::com::sun::star::uno::Reference< 106 ::com::sun::star::frame::XDispatch > > SAL_CALL 107 queryDispatches( 108 const ::com::sun::star::uno::Sequence< 109 ::com::sun::star::frame::DispatchDescriptor >& Requests ) 110 throw ( 111 ::com::sun::star::uno::RuntimeException 112 ); 113 114 115 //XDispatchProviderInterceptor 116 virtual ::com::sun::star::uno::Reference< 117 ::com::sun::star::frame::XDispatchProvider > SAL_CALL 118 getSlaveDispatchProvider( ) 119 throw ( 120 ::com::sun::star::uno::RuntimeException 121 ); 122 123 virtual void SAL_CALL 124 setSlaveDispatchProvider( 125 const ::com::sun::star::uno::Reference< 126 ::com::sun::star::frame::XDispatchProvider >& NewDispatchProvider ) 127 throw ( 128 ::com::sun::star::uno::RuntimeException 129 ); 130 131 virtual ::com::sun::star::uno::Reference< 132 ::com::sun::star::frame::XDispatchProvider > SAL_CALL 133 getMasterDispatchProvider( ) 134 throw ( 135 ::com::sun::star::uno::RuntimeException 136 ); 137 138 virtual void SAL_CALL 139 setMasterDispatchProvider( 140 const ::com::sun::star::uno::Reference< 141 ::com::sun::star::frame::XDispatchProvider >& NewSupplier ) 142 throw ( 143 ::com::sun::star::uno::RuntimeException 144 ); 145 146 147 private: 148 149 osl::Mutex m_aMutex; 150 151 DocumentHolder* m_pDocHolder; 152 153 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xSlaveDispatchProvider; 154 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xMasterDispatchProvider; 155 156 static ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aInterceptedURL; 157 158 cppu::OInterfaceContainerHelper* m_pDisposeEventListeners; 159 StatusChangeListenerContainer* m_pStatCL; 160 }; 161 162 #endif 163 164