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.)
26 class MyListener
: public cppu::WeakImplHelper2
< css::task::XJob
,
27 css::lang::XServiceInfo
>
30 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xSMGR
;
33 MyListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
34 virtual ~MyListener();
37 virtual css::uno::Any SAL_CALL
execute(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
)
38 throw (css::lang::IllegalArgumentException
,
40 css::uno::RuntimeException
);
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
);
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
>
60 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
64 CalcListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
> &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
>
81 css::uno::Reference
< css::lang::XMultiServiceFactory
> mxMSF
;
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