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