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