1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MyJob.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include <osl/diagnose.h>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <com/sun/star/beans/NamedValue.hpp>
38 #include <com/sun/star/document/XEventBroadcaster.hpp>
41 using com::sun::star::uno::Sequence
;
42 using com::sun::star::uno::Reference
;
43 using com::sun::star::uno::Any
;
44 using com::sun::star::uno::UNO_QUERY
;
45 using com::sun::star::uno::XInterface
;
46 using com::sun::star::uno::Exception
;
47 using com::sun::star::uno::RuntimeException
;
48 using com::sun::star::lang::IllegalArgumentException
;
49 using com::sun::star::lang::XMultiServiceFactory
;
50 using com::sun::star::beans::NamedValue
;
51 using com::sun::star::document::XEventBroadcaster
;
53 Any SAL_CALL
MyJob::execute( const Sequence
< NamedValue
>& aArguments
)
54 throw ( IllegalArgumentException
, Exception
, RuntimeException
)
56 Reference
< XEventBroadcaster
> xBrd( mxMSF
->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.GlobalEventBroadcaster") ), UNO_QUERY
);
57 Reference
< com::sun::star::document::XEventListener
> xLstner( mxMSF
->createInstance(
58 ::rtl::OUString::createFromAscii("com.sun.star.comp.Office.MyListener" ) ), UNO_QUERY
);
60 xBrd
->addEventListener( xLstner
);
64 OUString
MyJob_getImplementationName ()
65 throw (RuntimeException
)
67 return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Office.MyJob" ) );
70 #define SERVICE_NAME "com.sun.star.task.Job"
72 sal_Bool SAL_CALL
MyJob_supportsService( const OUString
& ServiceName
)
73 throw (RuntimeException
)
75 return ServiceName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME
) );
78 Sequence
< OUString
> SAL_CALL
MyJob_getSupportedServiceNames( )
79 throw (RuntimeException
)
81 Sequence
< OUString
> aRet(1);
82 OUString
* pArray
= aRet
.getArray();
83 pArray
[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME
) );
89 Reference
< XInterface
> SAL_CALL
MyJob_createInstance( const Reference
< XMultiServiceFactory
> & rSMgr
)
92 return (cppu::OWeakObject
*) new MyJob( rSMgr
);
96 OUString SAL_CALL
MyJob::getImplementationName( )
97 throw (RuntimeException
)
99 return MyJob_getImplementationName();
102 sal_Bool SAL_CALL
MyJob::supportsService( const OUString
& rServiceName
)
103 throw (RuntimeException
)
105 return MyJob_supportsService( rServiceName
);
108 Sequence
< OUString
> SAL_CALL
MyJob::getSupportedServiceNames( )
109 throw (RuntimeException
)
111 return MyJob_getSupportedServiceNames();