Update git submodules
[LibreOffice.git] / odk / examples / cpp / complextoolbarcontrols / MyListener.h
blob203c81e0b7928b53360d4738446b9600fe1ff51f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <sal/config.h>
25 #include <com/sun/star/lang/IllegalArgumentException.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/task/XJob.hpp>
29 #include <com/sun/star/document/XEventListener.hpp>
30 #include <cppuhelper/implbase1.hxx>
31 #include <cppuhelper/implbase2.hxx>
33 #define MYLISTENER_IMPLEMENTATIONNAME "vnd.My.impl.NewDocListener"
34 #define MYLISTENER_SERVICENAME "vnd.My.NewDocListener"
36 /**
37 * Register in the Office configuration as job.
38 * This is called automatically for all new opened documents. You receive
39 * a reference of the opened document and then you can check if it's a
40 * supported format. (We are only interested in Writer/Calc documents.)
42 * @see CalcListener
43 * @see WriterListener
45 class MyListener : public cppu::WeakImplHelper2< css::task::XJob ,
46 css::lang::XServiceInfo >
48 private:
49 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
50 public:
51 MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
52 virtual ~MyListener();
54 // XJob
55 virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments);
57 // XServiceInfo
58 virtual ::rtl::OUString SAL_CALL getImplementationName();
60 virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& sServiceName);
62 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
64 public:
66 static css::uno::Reference< css::uno::XInterface > st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
69 class CalcListener : public cppu::WeakImplHelper1< css::document::XEventListener >
71 private:
72 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
75 public:
76 CalcListener(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxMSF)
77 : mxMSF( rxMSF )
80 virtual ~CalcListener()
83 // document.XEventListener
84 virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent);
85 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent);
88 class WriterListener : public cppu::WeakImplHelper1< css::document::XEventListener >
90 private:
91 css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
93 public:
94 WriterListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& rxMSF);
96 virtual ~WriterListener()
99 // document.XEventListener
100 virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent);
101 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent);
104 #endif
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */