1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_ucb.hxx" 30 31 #include "cppuhelper/factory.hxx" 32 #include "com/sun/star/lang/IllegalArgumentException.hpp" 33 34 #include "cmdenv.hxx" 35 36 /************************************************************************** 37 TODO 38 ************************************************************************** 39 40 *************************************************************************/ 41 using namespace com::sun::star; 42 using namespace ucb_cmdenv; 43 44 //========================================================================= 45 //========================================================================= 46 // 47 // UcbCommandEnvironment Implementation. 48 // 49 //========================================================================= 50 //========================================================================= 51 52 UcbCommandEnvironment::UcbCommandEnvironment( 53 const uno::Reference< lang::XMultiServiceFactory >& /*xSMgr*/ ) 54 //: m_xSMgr( xSMgr ) 55 { 56 } 57 58 //========================================================================= 59 // virtual 60 UcbCommandEnvironment::~UcbCommandEnvironment() 61 { 62 } 63 64 //========================================================================= 65 // 66 // XInitialization methods. 67 // 68 //========================================================================= 69 70 // virtual 71 void SAL_CALL UcbCommandEnvironment::initialize( 72 const uno::Sequence< uno::Any >& aArguments ) 73 throw( uno::Exception, 74 uno::RuntimeException ) 75 { 76 if ( ( aArguments.getLength() < 2 ) || 77 !( aArguments[ 0 ] >>= m_xIH ) || 78 !( aArguments[ 1 ] >>= m_xPH )) 79 throw lang::IllegalArgumentException(); 80 } 81 82 //========================================================================= 83 // 84 // XServiceInfo methods. 85 // 86 //========================================================================= 87 88 // virtual 89 ::rtl::OUString SAL_CALL UcbCommandEnvironment::getImplementationName() 90 throw ( uno::RuntimeException ) 91 { 92 return getImplementationName_Static(); 93 } 94 95 //========================================================================= 96 // virtual 97 sal_Bool SAL_CALL 98 UcbCommandEnvironment::supportsService( const ::rtl::OUString& ServiceName ) 99 throw ( uno::RuntimeException ) 100 { 101 uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames(); 102 const rtl::OUString * pArray = aSNL.getConstArray(); 103 for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) 104 { 105 if ( pArray[ i ] == ServiceName ) 106 return sal_True; 107 } 108 return sal_False; 109 } 110 111 //========================================================================= 112 // virtual 113 uno::Sequence< ::rtl::OUString > SAL_CALL 114 UcbCommandEnvironment::getSupportedServiceNames() 115 throw ( uno::RuntimeException ) 116 { 117 return getSupportedServiceNames_Static(); 118 } 119 120 //========================================================================= 121 // static 122 rtl::OUString UcbCommandEnvironment::getImplementationName_Static() 123 { 124 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 125 "com.sun.star.comp.ucb.CommandEnvironment" ) ); 126 } 127 128 //========================================================================= 129 // static 130 uno::Sequence< rtl::OUString > 131 UcbCommandEnvironment::getSupportedServiceNames_Static() 132 { 133 uno::Sequence< rtl::OUString > aSNS( 1 ); 134 aSNS.getArray()[ 0 ] 135 = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 136 "com.sun.star.ucb.CommandEnvironment" ) ); 137 return aSNS; 138 } 139 140 //========================================================================= 141 // 142 // XCommandInfo methods. 143 // 144 //========================================================================= 145 146 // virtual 147 uno::Reference< task::XInteractionHandler > SAL_CALL 148 UcbCommandEnvironment::getInteractionHandler() 149 throw ( uno::RuntimeException ) 150 { 151 return m_xIH; 152 } 153 154 //========================================================================= 155 // virtual 156 uno::Reference< ucb::XProgressHandler > SAL_CALL 157 UcbCommandEnvironment::getProgressHandler() 158 throw ( uno::RuntimeException ) 159 { 160 return m_xPH; 161 } 162 163 //========================================================================= 164 // 165 // Service factory implementation. 166 // 167 //========================================================================= 168 169 static uno::Reference< uno::XInterface > SAL_CALL 170 UcbCommandEnvironment_CreateInstance( 171 const uno::Reference< lang::XMultiServiceFactory> & rSMgr ) 172 throw( uno::Exception ) 173 { 174 lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >( 175 new UcbCommandEnvironment( rSMgr ) ); 176 return uno::Reference< uno::XInterface >::query( pX ); 177 } 178 179 //========================================================================= 180 // static 181 uno::Reference< lang::XSingleServiceFactory > 182 UcbCommandEnvironment::createServiceFactory( 183 const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr ) 184 { 185 return uno::Reference< lang::XSingleServiceFactory >( 186 cppu::createSingleFactory( 187 rxServiceMgr, 188 UcbCommandEnvironment::getImplementationName_Static(), 189 UcbCommandEnvironment_CreateInstance, 190 UcbCommandEnvironment::getSupportedServiceNames_Static() ) ); 191 } 192