Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / odk / examples / cpp / complextoolbarcontrols / MyJob.cxx
blob3a00c1658e85fcb0027805755e971a874a9ed92e
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>
27 using rtl::OUString;
28 using com::sun::star::uno::Sequence;
29 using com::sun::star::uno::Reference;
30 using com::sun::star::uno::Any;
31 using com::sun::star::uno::UNO_QUERY;
32 using com::sun::star::uno::XInterface;
33 using com::sun::star::uno::Exception;
34 using com::sun::star::uno::RuntimeException;
35 using com::sun::star::lang::IllegalArgumentException;
36 using com::sun::star::lang::XMultiServiceFactory;
37 using com::sun::star::beans::NamedValue;
38 using com::sun::star::document::XEventBroadcaster;
40 Any SAL_CALL MyJob::execute( const Sequence< NamedValue >& aArguments )
41 throw ( IllegalArgumentException, Exception, RuntimeException )
43 Reference < XEventBroadcaster > xBrd( mxMSF->createInstance(
44 "com.sun.star.frame.GlobalEventBroadcaster" ), UNO_QUERY );
45 Reference < com::sun::star::document::XEventListener > xLstner( mxMSF->createInstance(
46 "com.sun.star.comp.Office.MyListener" ), UNO_QUERY );
47 if ( xBrd.is() )
48 xBrd->addEventListener( xLstner );
49 return Any();
52 OUString MyJob_getImplementationName ()
53 throw (RuntimeException)
55 return OUString( "com.sun.star.comp.Office.MyJob" );
58 #define SERVICE_NAME "com.sun.star.task.Job"
60 sal_Bool SAL_CALL MyJob_supportsService( const OUString& ServiceName )
61 throw (RuntimeException)
63 return ServiceName == SERVICE_NAME;
66 Sequence< OUString > SAL_CALL MyJob_getSupportedServiceNames( )
67 throw (RuntimeException)
69 Sequence < OUString > aRet(1);
70 OUString* pArray = aRet.getArray();
71 pArray[0] = OUString( SERVICE_NAME );
72 return aRet;
75 #undef SERVICE_NAME
77 Reference< XInterface > SAL_CALL MyJob_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
78 throw( Exception )
80 return (cppu::OWeakObject*) new MyJob( rSMgr );
83 // XServiceInfo
84 OUString SAL_CALL MyJob::getImplementationName( )
85 throw (RuntimeException)
87 return MyJob_getImplementationName();
90 sal_Bool SAL_CALL MyJob::supportsService( const OUString& rServiceName )
91 throw (RuntimeException)
93 return MyJob_supportsService( rServiceName );
96 Sequence< OUString > SAL_CALL MyJob::getSupportedServiceNames( )
97 throw (RuntimeException)
99 return MyJob_getSupportedServiceNames();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */