Update ooo320-m1
[ooovba.git] / odk / examples / cpp / complextoolbarcontrols / MyListener.h
blobd1a9c22cb6cebcac35b659532d04dea5947c5c07
1 #ifndef _MyListener_HXX
2 #define _MyListener_HXX
4 #include <com/sun/star/uno/Reference.h>
5 #include <com/sun/star/lang/XServiceInfo.hpp>
6 #include <com/sun/star/task/XJob.hpp>
7 #include <com/sun/star/document/XEventListener.hpp>
8 #include <cppuhelper/implbase1.hxx>
9 #include <cppuhelper/implbase2.hxx>
11 #define MYLISTENER_IMPLEMENTATIONNAME "vnd.My.impl.NewDocListener"
12 #define MYLISTENER_SERVICENAME "vnd.My.NewDocListener"
14 namespace css = ::com::sun::star;
16 /*---------------------------------------------------
17 * Registriert sich in der Office Konfiguration als Job.
18 * Dieser wird dann für alle neu geöffneten Dokumente automatisch
19 * gerufen. Man bekommt eine Reference auf das geöffnete Dokument
20 * überreicht und kann dann prüfen, ob es ein unterstütztes Format
21 * hat. (Wir interessieren uns ja schließlich nur für Writer/Calc Dokumente.)
23 * @see CalcListener
24 * @see WriterListener
26 class MyListener : public cppu::WeakImplHelper2< css::task::XJob ,
27 css::lang::XServiceInfo >
29 private:
30 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
32 public:
33 MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
34 virtual ~MyListener();
36 // XJob
37 virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
38 throw (css::lang::IllegalArgumentException,
39 css::uno::Exception,
40 css::uno::RuntimeException);
42 // XServiceInfo
43 virtual ::rtl::OUString SAL_CALL getImplementationName()
44 throw (css::uno::RuntimeException);
46 virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& sServiceName)
47 throw (css::uno::RuntimeException);
49 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
50 throw (css::uno::RuntimeException);
52 public:
54 static css::uno::Reference< css::uno::XInterface > st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
57 class CalcListener : public cppu::WeakImplHelper1< css::document::XEventListener >
59 private:
60 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
63 public:
64 CalcListener(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxMSF)
65 : mxMSF( rxMSF )
68 virtual ~CalcListener()
71 // document.XEventListener
72 virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
73 throw (css::uno::RuntimeException);
74 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
75 throw (css::uno::RuntimeException);
78 class WriterListener : public cppu::WeakImplHelper1< css::document::XEventListener >
80 private:
81 css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
83 public:
84 WriterListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& rxMSF);
86 virtual ~WriterListener()
89 // document.XEventListener
90 virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
91 throw (css::uno::RuntimeException);
92 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
93 throw (css::uno::RuntimeException);
96 #endif // _MyListener_HXX