xref: /trunk/main/ucb/source/core/cmdenv.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_ucb.hxx"
26 
27 #include "cppuhelper/factory.hxx"
28 #include "com/sun/star/lang/IllegalArgumentException.hpp"
29 
30 #include "cmdenv.hxx"
31 
32 /**************************************************************************
33                                 TODO
34  **************************************************************************
35 
36  *************************************************************************/
37 using namespace com::sun::star;
38 using namespace ucb_cmdenv;
39 
40 //=========================================================================
41 //=========================================================================
42 //
43 // UcbCommandEnvironment Implementation.
44 //
45 //=========================================================================
46 //=========================================================================
47 
UcbCommandEnvironment(const uno::Reference<lang::XMultiServiceFactory> &)48 UcbCommandEnvironment::UcbCommandEnvironment(
49     const uno::Reference< lang::XMultiServiceFactory >& /*xSMgr*/ )
50 //: m_xSMgr( xSMgr )
51 {
52 }
53 
54 //=========================================================================
55 // virtual
~UcbCommandEnvironment()56 UcbCommandEnvironment::~UcbCommandEnvironment()
57 {
58 }
59 
60 //=========================================================================
61 //
62 // XInitialization methods.
63 //
64 //=========================================================================
65 
66 // virtual
initialize(const uno::Sequence<uno::Any> & aArguments)67 void SAL_CALL UcbCommandEnvironment::initialize(
68         const uno::Sequence< uno::Any >& aArguments )
69 {
70     if ( ( aArguments.getLength() < 2 ) ||
71          !( aArguments[ 0 ] >>= m_xIH ) ||
72          !( aArguments[ 1 ] >>= m_xPH ))
73         throw lang::IllegalArgumentException();
74 }
75 
76 //=========================================================================
77 //
78 // XServiceInfo methods.
79 //
80 //=========================================================================
81 
82 // virtual
getImplementationName()83 ::rtl::OUString SAL_CALL UcbCommandEnvironment::getImplementationName()
84 {
85     return getImplementationName_Static();
86 }
87 
88 //=========================================================================
89 // virtual
90 sal_Bool SAL_CALL
supportsService(const::rtl::OUString & ServiceName)91 UcbCommandEnvironment::supportsService( const ::rtl::OUString& ServiceName )
92 {
93     uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
94     const rtl::OUString * pArray = aSNL.getConstArray();
95     for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
96     {
97         if ( pArray[ i ] == ServiceName )
98             return sal_True;
99     }
100     return sal_False;
101 }
102 
103 //=========================================================================
104 // virtual
105 uno::Sequence< ::rtl::OUString > SAL_CALL
getSupportedServiceNames()106 UcbCommandEnvironment::getSupportedServiceNames()
107 {
108     return getSupportedServiceNames_Static();
109 }
110 
111 //=========================================================================
112 // static
getImplementationName_Static()113 rtl::OUString UcbCommandEnvironment::getImplementationName_Static()
114 {
115     return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
116         "com.sun.star.comp.ucb.CommandEnvironment" ) );
117 }
118 
119 //=========================================================================
120 // static
121 uno::Sequence< rtl::OUString >
getSupportedServiceNames_Static()122 UcbCommandEnvironment::getSupportedServiceNames_Static()
123 {
124     uno::Sequence< rtl::OUString > aSNS( 1 );
125     aSNS.getArray()[ 0 ]
126         = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
127             "com.sun.star.ucb.CommandEnvironment" ) );
128     return aSNS;
129 }
130 
131 //=========================================================================
132 //
133 // XCommandInfo methods.
134 //
135 //=========================================================================
136 
137 // virtual
138 uno::Reference< task::XInteractionHandler > SAL_CALL
getInteractionHandler()139 UcbCommandEnvironment::getInteractionHandler()
140 {
141     return m_xIH;
142 }
143 
144 //=========================================================================
145 // virtual
146 uno::Reference< ucb::XProgressHandler > SAL_CALL
getProgressHandler()147 UcbCommandEnvironment::getProgressHandler()
148 {
149     return m_xPH;
150 }
151 
152 //=========================================================================
153 //
154 // Service factory implementation.
155 //
156 //=========================================================================
157 
158 static uno::Reference< uno::XInterface > SAL_CALL
UcbCommandEnvironment_CreateInstance(const uno::Reference<lang::XMultiServiceFactory> & rSMgr)159 UcbCommandEnvironment_CreateInstance(
160     const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
161 {
162     lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
163         new UcbCommandEnvironment( rSMgr ) );
164     return uno::Reference< uno::XInterface >::query( pX );
165 }
166 
167 //=========================================================================
168 // static
169 uno::Reference< lang::XSingleServiceFactory >
createServiceFactory(const uno::Reference<lang::XMultiServiceFactory> & rxServiceMgr)170 UcbCommandEnvironment::createServiceFactory(
171     const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
172 {
173     return uno::Reference< lang::XSingleServiceFactory >(
174             cppu::createSingleFactory(
175                 rxServiceMgr,
176                 UcbCommandEnvironment::getImplementationName_Static(),
177                 UcbCommandEnvironment_CreateInstance,
178                 UcbCommandEnvironment::getSupportedServiceNames_Static() ) );
179 }
180