1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2008 by Sun Microsystems, Inc. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * $RCSfile: unoprov.cxx,v $ 10*cdf0e10cSrcweir * $Revision: 1.72.92.1 $ 11*cdf0e10cSrcweir * 12*cdf0e10cSrcweir * This file is part of OpenOffice.org. 13*cdf0e10cSrcweir * 14*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 15*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 16*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 17*cdf0e10cSrcweir * 18*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 19*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 20*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 22*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 23*cdf0e10cSrcweir * 24*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 25*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 26*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 27*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 28*cdf0e10cSrcweir * 29*cdf0e10cSrcweir ************************************************************************/ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 32*cdf0e10cSrcweir #include "precompiled_comphelper.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include "comphelper/serviceinfohelper.hxx" 35*cdf0e10cSrcweir #include <stdarg.h> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir // ##################################################################### 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir namespace comphelper 40*cdf0e10cSrcweir { 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir /** returns an empty UString(). most times sufficient */ 43*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ServiceInfoHelper::getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir return ::rtl::OUString(); 46*cdf0e10cSrcweir } 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir /** the base implementation iterates over the service names from <code>getSupportedServiceNames</code> */ 49*cdf0e10cSrcweir sal_Bool SAL_CALL ServiceInfoHelper::supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException) 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir return supportsService( ServiceName, getSupportedServiceNames() ); 52*cdf0e10cSrcweir } 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir sal_Bool SAL_CALL ServiceInfoHelper::supportsService( const ::rtl::OUString& ServiceName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& SupportedServices ) throw() 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir const ::rtl::OUString * pArray = SupportedServices.getConstArray(); 57*cdf0e10cSrcweir for( sal_Int32 i = 0; i < SupportedServices.getLength(); i++ ) 58*cdf0e10cSrcweir if( pArray[i] == ServiceName ) 59*cdf0e10cSrcweir return sal_True; 60*cdf0e10cSrcweir return sal_False; 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir /** the base implementation has no supported services */ 64*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > ServiceInfoHelper::getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq(0); 67*cdf0e10cSrcweir return aSeq; 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir /** this method concatenates the given sequences and returns the result 71*cdf0e10cSrcweir */ 72*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > ServiceInfoHelper::concatSequences( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rSeq1, 73*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rSeq2 ) throw() 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir const sal_Int32 nLen1 = rSeq1.getLength(); 76*cdf0e10cSrcweir const sal_Int32 nLen2 = rSeq2.getLength(); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq( nLen1 + nLen2 ); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir ::rtl::OUString* pStrings = aSeq.getArray(); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir sal_Int32 nIdx; 83*cdf0e10cSrcweir const ::rtl::OUString* pStringSrc = rSeq1.getConstArray(); 84*cdf0e10cSrcweir for( nIdx = 0; nIdx < nLen1; nIdx++ ) 85*cdf0e10cSrcweir *pStrings++ = *pStringSrc++; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir pStringSrc = rSeq2.getConstArray(); 88*cdf0e10cSrcweir for( nIdx = 0; nIdx < nLen2; nIdx++ ) 89*cdf0e10cSrcweir *pStrings++ = *pStringSrc++; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir return aSeq; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir /** this method adds a variable number of char pointer to a given Sequence 95*cdf0e10cSrcweir */ 96*cdf0e10cSrcweir void ServiceInfoHelper::addToSequence( ::com::sun::star::uno::Sequence< ::rtl::OUString >& rSeq, sal_uInt16 nServices, /* char * */ ... ) throw() 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir sal_uInt32 nCount = rSeq.getLength(); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir rSeq.realloc( nCount + nServices ); 101*cdf0e10cSrcweir rtl::OUString* pStrings = rSeq.getArray(); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir va_list marker; 104*cdf0e10cSrcweir va_start( marker, nServices ); 105*cdf0e10cSrcweir for( sal_uInt16 i = 0 ; i < nServices; i++ ) 106*cdf0e10cSrcweir pStrings[nCount++] = rtl::OUString::createFromAscii(va_arg( marker, char*)); 107*cdf0e10cSrcweir va_end( marker ); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir 113