CWS-TOOLING: integrate CWS os146
[LibreOffice.git] / comphelper / source / misc / serviceinfohelper.cxx
blobf2f9da278a06c3f53d460d041b7d676e9a231189
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoprov.cxx,v $
10 * $Revision: 1.72.92.1 $
12 * This file is part of OpenOffice.org.
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.
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).
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.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_comphelper.hxx"
34 #include "comphelper/serviceinfohelper.hxx"
35 #include <stdarg.h>
37 // #####################################################################
39 namespace comphelper
42 /** returns an empty UString(). most times sufficient */
43 ::rtl::OUString SAL_CALL ServiceInfoHelper::getImplementationName() throw( ::com::sun::star::uno::RuntimeException )
45 return ::rtl::OUString();
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)
51 return supportsService( ServiceName, getSupportedServiceNames() );
54 sal_Bool SAL_CALL ServiceInfoHelper::supportsService( const ::rtl::OUString& ServiceName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& SupportedServices ) throw()
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;
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 )
66 ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq(0);
67 return aSeq;
70 /** this method concatenates the given sequences and returns the result
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()
75 const sal_Int32 nLen1 = rSeq1.getLength();
76 const sal_Int32 nLen2 = rSeq2.getLength();
78 ::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq( nLen1 + nLen2 );
80 ::rtl::OUString* pStrings = aSeq.getArray();
82 sal_Int32 nIdx;
83 const ::rtl::OUString* pStringSrc = rSeq1.getConstArray();
84 for( nIdx = 0; nIdx < nLen1; nIdx++ )
85 *pStrings++ = *pStringSrc++;
87 pStringSrc = rSeq2.getConstArray();
88 for( nIdx = 0; nIdx < nLen2; nIdx++ )
89 *pStrings++ = *pStringSrc++;
91 return aSeq;
94 /** this method adds a variable number of char pointer to a given Sequence
96 void ServiceInfoHelper::addToSequence( ::com::sun::star::uno::Sequence< ::rtl::OUString >& rSeq, sal_uInt16 nServices, /* char * */ ... ) throw()
98 sal_uInt32 nCount = rSeq.getLength();
100 rSeq.realloc( nCount + nServices );
101 rtl::OUString* pStrings = rSeq.getArray();
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 );