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 EVENT_TESTLISTENER_HXX 25 #define EVENT_TESTLISTENER_HXX 26 27 #include <sal/types.h> 28 29 #include <com/sun/star/uno/Reference.h> 30 #include <com/sun/star/uno/Sequence.h> 31 32 #include <com/sun/star/uno/XInterface.hpp> 33 #include <com/sun/star/uno/Exception.hpp> 34 #include <com/sun/star/lang/XServiceInfo.hpp> 35 #include <com/sun/star/lang/XInitialization.hpp> 36 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 37 #include <com/sun/star/xml/dom/events/XEventTarget.hpp> 38 #include <com/sun/star/xml/dom/events/XEventListener.hpp> 39 #include <com/sun/star/xml/dom/events/XEvent.hpp> 40 41 #include <cppuhelper/implbase3.hxx> 42 43 44 using ::rtl::OUString; 45 using namespace com::sun::star::uno; 46 using namespace com::sun::star::xml::dom; 47 using namespace com::sun::star::xml::dom::events; 48 49 namespace DOM { namespace events 50 { 51 52 typedef ::cppu::WeakImplHelper3 53 < ::com::sun::star::xml::dom::events::XEventListener 54 , ::com::sun::star::lang::XInitialization 55 , ::com::sun::star::lang::XServiceInfo 56 > CTestListener_Base; 57 58 class CTestListener 59 : public CTestListener_Base 60 { 61 62 private: 63 Reference< ::com::sun::star::lang::XMultiServiceFactory > m_factory; 64 Reference <XEventTarget> m_target; 65 OUString m_type; 66 sal_Bool m_capture; 67 OUString m_name; 68 69 public: 70 71 // static helpers for service info and component management 72 static const char* aImplementationName; 73 static const char* aSupportedServiceNames[]; 74 static OUString _getImplementationName(); 75 static Sequence< OUString > _getSupportedServiceNames(); 76 static Reference< XInterface > _getInstance( 77 const Reference< ::com::sun::star::lang::XMultiServiceFactory >& 78 rSMgr); 79 CTestListener(const Reference<::com::sun::star::lang::XMultiServiceFactory> & rSMgr)80 CTestListener( 81 const Reference< ::com::sun::star::lang::XMultiServiceFactory >& 82 rSMgr) 83 : m_factory(rSMgr){}; 84 85 virtual ~CTestListener(); 86 87 // XServiceInfo 88 virtual OUString SAL_CALL getImplementationName() 89 throw (RuntimeException); 90 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) 91 throw (RuntimeException); 92 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames () 93 throw (RuntimeException); 94 95 96 // XEventListener 97 virtual void SAL_CALL initialize(const Sequence< Any >& args) throw (RuntimeException); 98 99 virtual void SAL_CALL handleEvent(const Reference< XEvent >& evt) throw (RuntimeException); 100 101 102 }; 103 }} 104 105 #endif 106