1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _MyListener_HXX
21 #define _MyListener_HXX
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/task/XJob.hpp>
25 #include <com/sun/star/document/XEventListener.hpp>
26 #include <cppuhelper/implbase1.hxx>
27 #include <cppuhelper/implbase2.hxx>
29 #define MYLISTENER_IMPLEMENTATIONNAME "vnd.My.impl.NewDocListener"
30 #define MYLISTENER_SERVICENAME "vnd.My.NewDocListener"
32 /*---------------------------------------------------
33 * Registriert sich in der Office Konfiguration als Job.
34 * Dieser wird dann für alle neu geöffneten Dokumente automatisch
35 * gerufen. Man bekommt eine Reference auf das geöffnete Dokument
36 * überreicht und kann dann prüfen, ob es ein unterstütztes Format
37 * hat. (Wir interessieren uns ja schließlich nur für Writer/Calc Dokumente.)
42 class MyListener
: public cppu::WeakImplHelper2
< css::task::XJob
,
43 css::lang::XServiceInfo
>
46 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xSMGR
;
48 MyListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
49 virtual ~MyListener();
52 virtual css::uno::Any SAL_CALL
execute(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
)
53 throw (css::lang::IllegalArgumentException
,
55 css::uno::RuntimeException
);
58 virtual ::rtl::OUString SAL_CALL
getImplementationName()
59 throw (css::uno::RuntimeException
);
61 virtual sal_Bool SAL_CALL
supportsService(const ::rtl::OUString
& sServiceName
)
62 throw (css::uno::RuntimeException
);
64 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
65 throw (css::uno::RuntimeException
);
69 static css::uno::Reference
< css::uno::XInterface
> st_createInstance(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
72 class CalcListener
: public cppu::WeakImplHelper1
< css::document::XEventListener
>
75 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
79 CalcListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
> &rxMSF
)
83 virtual ~CalcListener()
86 // document.XEventListener
87 virtual void SAL_CALL
notifyEvent(const css::document::EventObject
& aEvent
)
88 throw (css::uno::RuntimeException
);
89 virtual void SAL_CALL
disposing(const css::lang::EventObject
& aEvent
)
90 throw (css::uno::RuntimeException
);
93 class WriterListener
: public cppu::WeakImplHelper1
< css::document::XEventListener
>
96 css::uno::Reference
< css::lang::XMultiServiceFactory
> mxMSF
;
99 WriterListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rxMSF
);
101 virtual ~WriterListener()
104 // document.XEventListener
105 virtual void SAL_CALL
notifyEvent(const css::document::EventObject
& aEvent
)
106 throw (css::uno::RuntimeException
);
107 virtual void SAL_CALL
disposing(const css::lang::EventObject
& aEvent
)
108 throw (css::uno::RuntimeException
);
111 #endif // _MyListener_HXX
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */