Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "cppuhelper/factory.hxx"
22 : #include "com/sun/star/lang/IllegalArgumentException.hpp"
23 :
24 : #include "cmdenv.hxx"
25 :
26 : /**************************************************************************
27 : TODO
28 : **************************************************************************
29 :
30 : *************************************************************************/
31 : using namespace com::sun::star;
32 : using namespace ucb_cmdenv;
33 :
34 : //=========================================================================
35 : //=========================================================================
36 : //
37 : // UcbCommandEnvironment Implementation.
38 : //
39 : //=========================================================================
40 : //=========================================================================
41 :
42 3 : UcbCommandEnvironment::UcbCommandEnvironment(
43 3 : const uno::Reference< lang::XMultiServiceFactory >& /*xSMgr*/ )
44 : //: m_xSMgr( xSMgr )
45 : {
46 3 : }
47 :
48 : //=========================================================================
49 : // virtual
50 6 : UcbCommandEnvironment::~UcbCommandEnvironment()
51 : {
52 6 : }
53 :
54 : //=========================================================================
55 : //
56 : // XInitialization methods.
57 : //
58 : //=========================================================================
59 :
60 : // virtual
61 3 : void SAL_CALL UcbCommandEnvironment::initialize(
62 : const uno::Sequence< uno::Any >& aArguments )
63 : throw( uno::Exception,
64 : uno::RuntimeException )
65 : {
66 9 : if ( ( aArguments.getLength() < 2 ) ||
67 6 : !( aArguments[ 0 ] >>= m_xIH ) ||
68 3 : !( aArguments[ 1 ] >>= m_xPH ))
69 0 : throw lang::IllegalArgumentException();
70 3 : }
71 :
72 : //=========================================================================
73 : //
74 : // XServiceInfo methods.
75 : //
76 : //=========================================================================
77 :
78 : // virtual
79 0 : OUString SAL_CALL UcbCommandEnvironment::getImplementationName()
80 : throw ( uno::RuntimeException )
81 : {
82 0 : return getImplementationName_Static();
83 : }
84 :
85 : //=========================================================================
86 : // virtual
87 : sal_Bool SAL_CALL
88 0 : UcbCommandEnvironment::supportsService( const OUString& ServiceName )
89 : throw ( uno::RuntimeException )
90 : {
91 0 : uno::Sequence< OUString > aSNL = getSupportedServiceNames();
92 0 : const OUString * pArray = aSNL.getConstArray();
93 0 : for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
94 : {
95 0 : if ( pArray[ i ] == ServiceName )
96 0 : return sal_True;
97 : }
98 0 : return sal_False;
99 : }
100 :
101 : //=========================================================================
102 : // virtual
103 : uno::Sequence< OUString > SAL_CALL
104 0 : UcbCommandEnvironment::getSupportedServiceNames()
105 : throw ( uno::RuntimeException )
106 : {
107 0 : return getSupportedServiceNames_Static();
108 : }
109 :
110 : //=========================================================================
111 : // static
112 2 : OUString UcbCommandEnvironment::getImplementationName_Static()
113 : {
114 2 : return OUString( "com.sun.star.comp.ucb.CommandEnvironment" );
115 : }
116 :
117 : //=========================================================================
118 : // static
119 : uno::Sequence< OUString >
120 1 : UcbCommandEnvironment::getSupportedServiceNames_Static()
121 : {
122 1 : uno::Sequence< OUString > aSNS( 1 );
123 1 : aSNS.getArray()[ 0 ] = "com.sun.star.ucb.CommandEnvironment";
124 1 : return aSNS;
125 : }
126 :
127 : //=========================================================================
128 : //
129 : // XCommandInfo methods.
130 : //
131 : //=========================================================================
132 :
133 : // virtual
134 : uno::Reference< task::XInteractionHandler > SAL_CALL
135 2 : UcbCommandEnvironment::getInteractionHandler()
136 : throw ( uno::RuntimeException )
137 : {
138 2 : return m_xIH;
139 : }
140 :
141 : //=========================================================================
142 : // virtual
143 : uno::Reference< ucb::XProgressHandler > SAL_CALL
144 0 : UcbCommandEnvironment::getProgressHandler()
145 : throw ( uno::RuntimeException )
146 : {
147 0 : return m_xPH;
148 : }
149 :
150 : //=========================================================================
151 : //
152 : // Service factory implementation.
153 : //
154 : //=========================================================================
155 :
156 : static uno::Reference< uno::XInterface > SAL_CALL
157 3 : UcbCommandEnvironment_CreateInstance(
158 : const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
159 : throw( uno::Exception )
160 : {
161 : lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
162 3 : new UcbCommandEnvironment( rSMgr ) );
163 3 : return uno::Reference< uno::XInterface >::query( pX );
164 : }
165 :
166 : //=========================================================================
167 : // static
168 : uno::Reference< lang::XSingleServiceFactory >
169 1 : UcbCommandEnvironment::createServiceFactory(
170 : const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
171 : {
172 : return uno::Reference< lang::XSingleServiceFactory >(
173 : cppu::createSingleFactory(
174 : rxServiceMgr,
175 : UcbCommandEnvironment::getImplementationName_Static(),
176 : UcbCommandEnvironment_CreateInstance,
177 1 : UcbCommandEnvironment::getSupportedServiceNames_Static() ) );
178 : }
179 :
180 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|