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 0 : UcbCommandEnvironment::UcbCommandEnvironment(
43 0 : const uno::Reference< lang::XMultiServiceFactory >& /*xSMgr*/ )
44 : //: m_xSMgr( xSMgr )
45 : {
46 0 : }
47 :
48 : //=========================================================================
49 : // virtual
50 0 : UcbCommandEnvironment::~UcbCommandEnvironment()
51 : {
52 0 : }
53 :
54 : //=========================================================================
55 : //
56 : // XInitialization methods.
57 : //
58 : //=========================================================================
59 :
60 : // virtual
61 0 : void SAL_CALL UcbCommandEnvironment::initialize(
62 : const uno::Sequence< uno::Any >& aArguments )
63 : throw( uno::Exception,
64 : uno::RuntimeException )
65 : {
66 0 : if ( ( aArguments.getLength() < 2 ) ||
67 0 : !( aArguments[ 0 ] >>= m_xIH ) ||
68 0 : !( aArguments[ 1 ] >>= m_xPH ))
69 0 : throw lang::IllegalArgumentException();
70 0 : }
71 :
72 : //=========================================================================
73 : //
74 : // XServiceInfo methods.
75 : //
76 : //=========================================================================
77 :
78 : // virtual
79 0 : ::rtl::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 ::rtl::OUString& ServiceName )
89 : throw ( uno::RuntimeException )
90 : {
91 0 : uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
92 0 : const rtl::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< ::rtl::OUString > SAL_CALL
104 0 : UcbCommandEnvironment::getSupportedServiceNames()
105 : throw ( uno::RuntimeException )
106 : {
107 0 : return getSupportedServiceNames_Static();
108 : }
109 :
110 : //=========================================================================
111 : // static
112 0 : rtl::OUString UcbCommandEnvironment::getImplementationName_Static()
113 : {
114 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
115 0 : "com.sun.star.comp.ucb.CommandEnvironment" ) );
116 : }
117 :
118 : //=========================================================================
119 : // static
120 : uno::Sequence< rtl::OUString >
121 0 : UcbCommandEnvironment::getSupportedServiceNames_Static()
122 : {
123 0 : uno::Sequence< rtl::OUString > aSNS( 1 );
124 : aSNS.getArray()[ 0 ]
125 : = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
126 0 : "com.sun.star.ucb.CommandEnvironment" ) );
127 0 : return aSNS;
128 : }
129 :
130 : //=========================================================================
131 : //
132 : // XCommandInfo methods.
133 : //
134 : //=========================================================================
135 :
136 : // virtual
137 : uno::Reference< task::XInteractionHandler > SAL_CALL
138 0 : UcbCommandEnvironment::getInteractionHandler()
139 : throw ( uno::RuntimeException )
140 : {
141 0 : return m_xIH;
142 : }
143 :
144 : //=========================================================================
145 : // virtual
146 : uno::Reference< ucb::XProgressHandler > SAL_CALL
147 0 : UcbCommandEnvironment::getProgressHandler()
148 : throw ( uno::RuntimeException )
149 : {
150 0 : return m_xPH;
151 : }
152 :
153 : //=========================================================================
154 : //
155 : // Service factory implementation.
156 : //
157 : //=========================================================================
158 :
159 : static uno::Reference< uno::XInterface > SAL_CALL
160 0 : UcbCommandEnvironment_CreateInstance(
161 : const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
162 : throw( uno::Exception )
163 : {
164 : lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
165 0 : new UcbCommandEnvironment( rSMgr ) );
166 0 : return uno::Reference< uno::XInterface >::query( pX );
167 : }
168 :
169 : //=========================================================================
170 : // static
171 : uno::Reference< lang::XSingleServiceFactory >
172 0 : UcbCommandEnvironment::createServiceFactory(
173 : const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
174 : {
175 : return uno::Reference< lang::XSingleServiceFactory >(
176 : cppu::createSingleFactory(
177 : rxServiceMgr,
178 : UcbCommandEnvironment::getImplementationName_Static(),
179 : UcbCommandEnvironment_CreateInstance,
180 0 : UcbCommandEnvironment::getSupportedServiceNames_Static() ) );
181 : }
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|