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 INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYLISTENER_H
21 #define INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYLISTENER_H
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/task/XJob.hpp>
26 #include <com/sun/star/document/XEventListener.hpp>
27 #include <cppuhelper/implbase1.hxx>
28 #include <cppuhelper/implbase2.hxx>
30 #define MYLISTENER_IMPLEMENTATIONNAME "vnd.My.impl.NewDocListener"
31 #define MYLISTENER_SERVICENAME "vnd.My.NewDocListener"
34 * Registriert sich in der Office Konfiguration als Job.
35 * Dieser wird dann für alle neu geöffneten Dokumente automatisch
36 * gerufen. Man bekommt eine Reference auf das geöffnete Dokument
37 * überreicht und kann dann prüfen, ob es ein unterstütztes Format
38 * hat. (Wir interessieren uns ja schließlich nur für Writer/Calc Dokumente.)
43 class MyListener
: public cppu::WeakImplHelper2
< css::task::XJob
,
44 css::lang::XServiceInfo
>
47 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xSMGR
;
49 MyListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
50 virtual ~MyListener();
53 virtual css::uno::Any SAL_CALL
execute(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
)
54 throw (css::lang::IllegalArgumentException
,
56 css::uno::RuntimeException
);
59 virtual ::rtl::OUString SAL_CALL
getImplementationName()
60 throw (css::uno::RuntimeException
);
62 virtual sal_Bool SAL_CALL
supportsService(const ::rtl::OUString
& sServiceName
)
63 throw (css::uno::RuntimeException
);
65 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
66 throw (css::uno::RuntimeException
);
70 static css::uno::Reference
< css::uno::XInterface
> st_createInstance(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
73 class CalcListener
: public cppu::WeakImplHelper1
< css::document::XEventListener
>
76 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
80 CalcListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
> &rxMSF
)
84 virtual ~CalcListener()
87 // document.XEventListener
88 virtual void SAL_CALL
notifyEvent(const css::document::EventObject
& aEvent
)
89 throw (css::uno::RuntimeException
);
90 virtual void SAL_CALL
disposing(const css::lang::EventObject
& aEvent
)
91 throw (css::uno::RuntimeException
);
94 class WriterListener
: public cppu::WeakImplHelper1
< css::document::XEventListener
>
97 css::uno::Reference
< css::lang::XMultiServiceFactory
> mxMSF
;
100 WriterListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rxMSF
);
102 virtual ~WriterListener()
105 // document.XEventListener
106 virtual void SAL_CALL
notifyEvent(const css::document::EventObject
& aEvent
)
107 throw (css::uno::RuntimeException
);
108 virtual void SAL_CALL
disposing(const css::lang::EventObject
& aEvent
)
109 throw (css::uno::RuntimeException
);
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */