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 <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"
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.)
45 class MyListener
: public cppu::WeakImplHelper2
< css::task::XJob
,
46 css::lang::XServiceInfo
>
49 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xSMGR
;
51 MyListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
52 virtual ~MyListener();
55 virtual css::uno::Any SAL_CALL
execute(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
)
56 throw (css::lang::IllegalArgumentException
,
58 css::uno::RuntimeException
);
61 virtual ::rtl::OUString SAL_CALL
getImplementationName()
62 throw (css::uno::RuntimeException
);
64 virtual sal_Bool SAL_CALL
supportsService(const ::rtl::OUString
& sServiceName
)
65 throw (css::uno::RuntimeException
);
67 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
68 throw (css::uno::RuntimeException
);
72 static css::uno::Reference
< css::uno::XInterface
> st_createInstance(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
75 class CalcListener
: public cppu::WeakImplHelper1
< css::document::XEventListener
>
78 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
82 CalcListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
> &rxMSF
)
86 virtual ~CalcListener()
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 class WriterListener
: public cppu::WeakImplHelper1
< css::document::XEventListener
>
99 css::uno::Reference
< css::lang::XMultiServiceFactory
> mxMSF
;
102 WriterListener(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rxMSF
);
104 virtual ~WriterListener()
107 // document.XEventListener
108 virtual void SAL_CALL
notifyEvent(const css::document::EventObject
& aEvent
)
109 throw (css::uno::RuntimeException
);
110 virtual void SAL_CALL
disposing(const css::lang::EventObject
& aEvent
)
111 throw (css::uno::RuntimeException
);
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */