1*c82f2877SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*c82f2877SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*c82f2877SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*c82f2877SAndrew Rist * distributed with this work for additional information 6*c82f2877SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*c82f2877SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*c82f2877SAndrew Rist * "License"); you may not use this file except in compliance 9*c82f2877SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*c82f2877SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*c82f2877SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*c82f2877SAndrew Rist * software distributed under the License is distributed on an 15*c82f2877SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*c82f2877SAndrew Rist * KIND, either express or implied. See the License for the 17*c82f2877SAndrew Rist * specific language governing permissions and limitations 18*c82f2877SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*c82f2877SAndrew Rist *************************************************************/ 21*c82f2877SAndrew Rist 22*c82f2877SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_comphelper.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "comphelper/serviceinfohelper.hxx" 28cdf0e10cSrcweir #include <stdarg.h> 29cdf0e10cSrcweir 30cdf0e10cSrcweir // ##################################################################### 31cdf0e10cSrcweir 32cdf0e10cSrcweir namespace comphelper 33cdf0e10cSrcweir { 34cdf0e10cSrcweir 35cdf0e10cSrcweir /** returns an empty UString(). most times sufficient */ 36cdf0e10cSrcweir ::rtl::OUString SAL_CALL ServiceInfoHelper::getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) 37cdf0e10cSrcweir { 38cdf0e10cSrcweir return ::rtl::OUString(); 39cdf0e10cSrcweir } 40cdf0e10cSrcweir 41cdf0e10cSrcweir /** the base implementation iterates over the service names from <code>getSupportedServiceNames</code> */ 42cdf0e10cSrcweir sal_Bool SAL_CALL ServiceInfoHelper::supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException) 43cdf0e10cSrcweir { 44cdf0e10cSrcweir return supportsService( ServiceName, getSupportedServiceNames() ); 45cdf0e10cSrcweir } 46cdf0e10cSrcweir 47cdf0e10cSrcweir sal_Bool SAL_CALL ServiceInfoHelper::supportsService( const ::rtl::OUString& ServiceName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& SupportedServices ) throw() 48cdf0e10cSrcweir { 49cdf0e10cSrcweir const ::rtl::OUString * pArray = SupportedServices.getConstArray(); 50cdf0e10cSrcweir for( sal_Int32 i = 0; i < SupportedServices.getLength(); i++ ) 51cdf0e10cSrcweir if( pArray[i] == ServiceName ) 52cdf0e10cSrcweir return sal_True; 53cdf0e10cSrcweir return sal_False; 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir /** the base implementation has no supported services */ 57cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > ServiceInfoHelper::getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq(0); 60cdf0e10cSrcweir return aSeq; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir /** this method concatenates the given sequences and returns the result 64cdf0e10cSrcweir */ 65cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > ServiceInfoHelper::concatSequences( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rSeq1, 66cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rSeq2 ) throw() 67cdf0e10cSrcweir { 68cdf0e10cSrcweir const sal_Int32 nLen1 = rSeq1.getLength(); 69cdf0e10cSrcweir const sal_Int32 nLen2 = rSeq2.getLength(); 70cdf0e10cSrcweir 71cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq( nLen1 + nLen2 ); 72cdf0e10cSrcweir 73cdf0e10cSrcweir ::rtl::OUString* pStrings = aSeq.getArray(); 74cdf0e10cSrcweir 75cdf0e10cSrcweir sal_Int32 nIdx; 76cdf0e10cSrcweir const ::rtl::OUString* pStringSrc = rSeq1.getConstArray(); 77cdf0e10cSrcweir for( nIdx = 0; nIdx < nLen1; nIdx++ ) 78cdf0e10cSrcweir *pStrings++ = *pStringSrc++; 79cdf0e10cSrcweir 80cdf0e10cSrcweir pStringSrc = rSeq2.getConstArray(); 81cdf0e10cSrcweir for( nIdx = 0; nIdx < nLen2; nIdx++ ) 82cdf0e10cSrcweir *pStrings++ = *pStringSrc++; 83cdf0e10cSrcweir 84cdf0e10cSrcweir return aSeq; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir /** this method adds a variable number of char pointer to a given Sequence 88cdf0e10cSrcweir */ 89cdf0e10cSrcweir void ServiceInfoHelper::addToSequence( ::com::sun::star::uno::Sequence< ::rtl::OUString >& rSeq, sal_uInt16 nServices, /* char * */ ... ) throw() 90cdf0e10cSrcweir { 91cdf0e10cSrcweir sal_uInt32 nCount = rSeq.getLength(); 92cdf0e10cSrcweir 93cdf0e10cSrcweir rSeq.realloc( nCount + nServices ); 94cdf0e10cSrcweir rtl::OUString* pStrings = rSeq.getArray(); 95cdf0e10cSrcweir 96cdf0e10cSrcweir va_list marker; 97cdf0e10cSrcweir va_start( marker, nServices ); 98cdf0e10cSrcweir for( sal_uInt16 i = 0 ; i < nServices; i++ ) 99cdf0e10cSrcweir pStrings[nCount++] = rtl::OUString::createFromAscii(va_arg( marker, char*)); 100cdf0e10cSrcweir va_end( marker ); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir 106