Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / odk / examples / cpp / complextoolbarcontrols / MyJob.cxx
blob656eb6942a81cdecf0ff3d20f1e200f4062657b9
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 .
21 #include "MyJob.h"
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/beans/NamedValue.hpp>
25 #include <com/sun/star/document/XEventBroadcaster.hpp>
26 #include <cppuhelper/supportsservice.hxx>
28 using rtl::OUString;
29 using com::sun::star::uno::Sequence;
30 using com::sun::star::uno::Reference;
31 using com::sun::star::uno::Any;
32 using com::sun::star::uno::UNO_QUERY;
33 using com::sun::star::uno::XInterface;
34 using com::sun::star::uno::Exception;
35 using com::sun::star::uno::RuntimeException;
36 using com::sun::star::lang::IllegalArgumentException;
37 using com::sun::star::lang::XMultiServiceFactory;
38 using com::sun::star::beans::NamedValue;
39 using com::sun::star::document::XEventBroadcaster;
41 Any SAL_CALL MyJob::execute( const Sequence< NamedValue >& aArguments )
42 throw ( IllegalArgumentException, Exception, RuntimeException )
44 Reference < XEventBroadcaster > xBrd( mxMSF->createInstance(
45 "com.sun.star.frame.GlobalEventBroadcaster" ), UNO_QUERY );
46 Reference < com::sun::star::document::XEventListener > xLstner( mxMSF->createInstance(
47 "com.sun.star.comp.Office.MyListener" ), UNO_QUERY );
48 if ( xBrd.is() )
49 xBrd->addEventListener( xLstner );
50 return Any();
53 OUString MyJob_getImplementationName ()
54 throw (RuntimeException)
56 return OUString( "com.sun.star.comp.Office.MyJob" );
59 #define SERVICE_NAME "com.sun.star.task.Job"
61 Sequence< OUString > SAL_CALL MyJob_getSupportedServiceNames( )
62 throw (RuntimeException)
64 Sequence < OUString > aRet(1);
65 OUString* pArray = aRet.getArray();
66 pArray[0] = OUString( SERVICE_NAME );
67 return aRet;
70 #undef SERVICE_NAME
72 Reference< XInterface > SAL_CALL MyJob_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
73 throw( Exception )
75 return (cppu::OWeakObject*) new MyJob( rSMgr );
78 // XServiceInfo
79 OUString SAL_CALL MyJob::getImplementationName( )
80 throw (RuntimeException)
82 return MyJob_getImplementationName();
85 sal_Bool SAL_CALL MyJob::supportsService( const OUString& rServiceName )
86 throw (RuntimeException)
88 return cppu::supportsService(this, rServiceName);
91 Sequence< OUString > SAL_CALL MyJob::getSupportedServiceNames( )
92 throw (RuntimeException)
94 return MyJob_getSupportedServiceNames();
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */