xref: /trunk/main/ucb/source/core/cmdenv.cxx (revision 79aad27f)
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     throw( uno::Exception,
70            uno::RuntimeException )
71 {
72     if ( ( aArguments.getLength() < 2 ) ||
73          !( aArguments[ 0 ] >>= m_xIH ) ||
74          !( aArguments[ 1 ] >>= m_xPH ))
75         throw lang::IllegalArgumentException();
76 }
77 
78 //=========================================================================
79 //
80 // XServiceInfo methods.
81 //
82 //=========================================================================
83 
84 // virtual
getImplementationName()85 ::rtl::OUString SAL_CALL UcbCommandEnvironment::getImplementationName()
86     throw ( uno::RuntimeException )
87 {
88     return getImplementationName_Static();
89 }
90 
91 //=========================================================================
92 // virtual
93 sal_Bool SAL_CALL
supportsService(const::rtl::OUString & ServiceName)94 UcbCommandEnvironment::supportsService( const ::rtl::OUString& ServiceName )
95     throw ( uno::RuntimeException )
96 {
97     uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
98     const rtl::OUString * pArray = aSNL.getConstArray();
99     for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
100     {
101         if ( pArray[ i ] == ServiceName )
102             return sal_True;
103     }
104     return sal_False;
105 }
106 
107 //=========================================================================
108 // virtual
109 uno::Sequence< ::rtl::OUString > SAL_CALL
getSupportedServiceNames()110 UcbCommandEnvironment::getSupportedServiceNames()
111     throw ( uno::RuntimeException )
112 {
113     return getSupportedServiceNames_Static();
114 }
115 
116 //=========================================================================
117 // static
getImplementationName_Static()118 rtl::OUString UcbCommandEnvironment::getImplementationName_Static()
119 {
120     return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
121         "com.sun.star.comp.ucb.CommandEnvironment" ) );
122 }
123 
124 //=========================================================================
125 // static
126 uno::Sequence< rtl::OUString >
getSupportedServiceNames_Static()127 UcbCommandEnvironment::getSupportedServiceNames_Static()
128 {
129     uno::Sequence< rtl::OUString > aSNS( 1 );
130     aSNS.getArray()[ 0 ]
131         = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
132             "com.sun.star.ucb.CommandEnvironment" ) );
133     return aSNS;
134 }
135 
136 //=========================================================================
137 //
138 // XCommandInfo methods.
139 //
140 //=========================================================================
141 
142 // virtual
143 uno::Reference< task::XInteractionHandler > SAL_CALL
getInteractionHandler()144 UcbCommandEnvironment::getInteractionHandler()
145     throw ( uno::RuntimeException )
146 {
147     return m_xIH;
148 }
149 
150 //=========================================================================
151 // virtual
152 uno::Reference< ucb::XProgressHandler > SAL_CALL
getProgressHandler()153 UcbCommandEnvironment::getProgressHandler()
154     throw ( uno::RuntimeException )
155 {
156     return m_xPH;
157 }
158 
159 //=========================================================================
160 //
161 // Service factory implementation.
162 //
163 //=========================================================================
164 
165 static uno::Reference< uno::XInterface > SAL_CALL
UcbCommandEnvironment_CreateInstance(const uno::Reference<lang::XMultiServiceFactory> & rSMgr)166 UcbCommandEnvironment_CreateInstance(
167     const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
168     throw( uno::Exception )
169 {
170     lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
171         new UcbCommandEnvironment( rSMgr ) );
172     return uno::Reference< uno::XInterface >::query( pX );
173 }
174 
175 //=========================================================================
176 // static
177 uno::Reference< lang::XSingleServiceFactory >
createServiceFactory(const uno::Reference<lang::XMultiServiceFactory> & rxServiceMgr)178 UcbCommandEnvironment::createServiceFactory(
179     const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
180 {
181     return uno::Reference< lang::XSingleServiceFactory >(
182             cppu::createSingleFactory(
183                 rxServiceMgr,
184                 UcbCommandEnvironment::getImplementationName_Static(),
185                 UcbCommandEnvironment_CreateInstance,
186                 UcbCommandEnvironment::getSupportedServiceNames_Static() ) );
187 }
188