Branch data Line data Source code
1 : : #ifndef INCLUDED_COM_SUN_STAR_UCB_COMMANDENVIRONMENT_HPP
2 : : #define INCLUDED_COM_SUN_STAR_UCB_COMMANDENVIRONMENT_HPP
3 : :
4 : : #include "sal/config.h"
5 : :
6 : : #include "com/sun/star/uno/RuntimeException.hpp"
7 : : #include "com/sun/star/uno/Exception.hpp"
8 : : #include "com/sun/star/uno/DeploymentException.hpp"
9 : : #include "com/sun/star/ucb/XProgressHandler.hpp"
10 : : #include "com/sun/star/uno/XComponentContext.hpp"
11 : : #include "com/sun/star/lang/XMultiComponentFactory.hpp"
12 : : #include "com/sun/star/task/XInteractionHandler.hpp"
13 : : #include "com/sun/star/ucb/XCommandEnvironment.hpp"
14 : : #include "com/sun/star/uno/Any.hxx"
15 : : #include "com/sun/star/uno/Reference.hxx"
16 : : #include "com/sun/star/uno/Sequence.hxx"
17 : : #include "cppu/unotype.hxx"
18 : : #include "rtl/ustring.h"
19 : : #include "rtl/ustring.hxx"
20 : :
21 : : namespace com { namespace sun { namespace star { namespace ucb {
22 : :
23 : : class CommandEnvironment {
24 : : public:
25 : 6 : static ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & the_context, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& InteractionHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XProgressHandler >& ProgressHandler) {
26 [ + - ][ + - ]: 6 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > the_factory(the_context->getServiceManager());
27 [ - + ]: 6 : if (!the_factory.is()) {
28 [ # # ][ # # ]: 0 : throw com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component context fails to supply service manager")), the_context);
29 : : }
30 [ + - ]: 6 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > the_arguments(2);
31 [ + - ][ + - ]: 6 : the_arguments[0] <<= InteractionHandler;
32 [ + - ][ + - ]: 6 : the_arguments[1] <<= ProgressHandler;
33 : 6 : ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > the_instance;
34 : : try {
35 [ + - ][ + - ]: 6 : the_instance = ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >(the_factory->createInstanceWithArgumentsAndContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.CommandEnvironment")), the_arguments, the_context), ::com::sun::star::uno::UNO_QUERY);
[ + - ][ + - ]
[ + - ]
36 : 0 : } catch (::com::sun::star::uno::RuntimeException &) {
37 : 0 : throw;
38 [ # # # ]: 0 : } catch (::com::sun::star::uno::Exception & the_exception) {
39 [ # # # # ]: 0 : throw ::com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component context fails to supply service com.sun.star.ucb.CommandEnvironment of type com.sun.star.ucb.XCommandEnvironment: ")) + the_exception.Message, the_context);
40 : : }
41 [ - + ]: 6 : if (!the_instance.is()) {
42 [ # # ][ # # ]: 0 : throw ::com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component context fails to supply service com.sun.star.ucb.CommandEnvironment of type com.sun.star.ucb.XCommandEnvironment")), the_context);
43 : : }
44 [ + - ]: 6 : return the_instance;
45 : : }
46 : :
47 : : private:
48 : : CommandEnvironment(); // not implemented
49 : : CommandEnvironment(CommandEnvironment &); // not implemented
50 : : ~CommandEnvironment(); // not implemented
51 : : void operator =(CommandEnvironment); // not implemented
52 : : };
53 : :
54 : : } } } }
55 : :
56 : : #endif // INCLUDED_COM_SUN_STAR_UCB_COMMANDENVIRONMENT_HPP
|