merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / misc / serviceinfohelper.cxx
blob8a379b01f4e1c029c0488648473a125843c1870a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: serviceinfohelper.cxx,v $
10 * $Revision: 1.5 $
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_configmgr.hxx"
34 #include "serviceinfohelper.hxx"
36 namespace configmgr
38 // ---------------------------------------------------------------------------
40 sal_Int32 ServiceInfoHelper::countServices( ) const
42 if (m_info == 0)
43 return 0;
45 sal_Int32 nCount = 0;
46 if (sal_Char const * const* p= m_info->registeredServiceNames)
48 while (*p != 0)
50 ++nCount;
51 ++p;
54 if (sal_Char const * const* p= m_info->additionalServiceNames)
56 while (*p != 0)
58 ++nCount;
59 ++p;
63 return nCount;
65 // ---------------------------------------------------------------------------
67 rtl::OUString ServiceInfoHelper::getImplementationName( ) const
68 throw(uno::RuntimeException)
70 sal_Char const * p= m_info ? m_info->implementationName : 0;
72 return p ? rtl::OUString::createFromAscii(p) : rtl::OUString();
74 // ---------------------------------------------------------------------------
76 sal_Bool ServiceInfoHelper::supportsService( rtl::OUString const & ServiceName ) const
77 throw(uno::RuntimeException)
79 if (m_info == 0)
80 return false;
82 if (sal_Char const * const* p= m_info->registeredServiceNames)
84 while (*p != 0)
86 if (ServiceName.equalsAscii(*p))
87 return true;
88 ++p;
91 if (sal_Char const * const* p= m_info->additionalServiceNames)
93 while (*p != 0)
95 if (ServiceName.equalsAscii(*p))
96 return true;
97 ++p;
101 return false;
103 // ---------------------------------------------------------------------------
105 uno::Sequence< rtl::OUString > ServiceInfoHelper::getSupportedServiceNames( ) const
106 throw(uno::RuntimeException)
108 sal_Int32 const nCount = countServices();
110 uno::Sequence< rtl::OUString > aServices( nCount );
112 if (nCount)
114 OSL_ASSERT(m_info);
115 sal_Int32 i = 0;
116 if (sal_Char const * const* p= m_info->registeredServiceNames)
118 while (*p != 0)
120 aServices[i++] = rtl::OUString::createFromAscii(*p++);
123 if (sal_Char const * const* p= m_info->additionalServiceNames)
125 while (*p != 0)
127 aServices[i++] = rtl::OUString::createFromAscii(*p++);
130 OSL_ASSERT( i == nCount );
133 return aServices;
135 // ---------------------------------------------------------------------------
136 // ---------------------------------------------------------------------------
138 sal_Int32 ServiceRegistrationHelper::countServices( ) const
140 if (m_info == 0)
141 return 0;
143 sal_Int32 nCount = 0;
144 if (sal_Char const * const* p= m_info->registeredServiceNames)
146 while (*p != 0)
148 ++nCount;
149 ++p;
153 return nCount;
155 // ---------------------------------------------------------------------------
157 rtl::OUString ServiceRegistrationHelper::getImplementationName( ) const
158 throw(uno::RuntimeException)
160 sal_Char const * p= m_info ? m_info->implementationName : 0;
162 return p ? rtl::OUString::createFromAscii(p) : rtl::OUString();
164 // ---------------------------------------------------------------------------
166 uno::Sequence< rtl::OUString > ServiceRegistrationHelper::getRegisteredServiceNames( ) const
167 throw(uno::RuntimeException)
169 sal_Int32 const nCount = countServices();
171 uno::Sequence< rtl::OUString > aServices( nCount );
173 if (nCount)
175 OSL_ASSERT(m_info);
176 sal_Int32 i = 0;
177 if (sal_Char const * const* p= m_info->registeredServiceNames)
179 while (*p != 0)
181 aServices[i++] = rtl::OUString::createFromAscii(*p++);
184 OSL_ASSERT( i == nCount );
187 return aServices;
189 // ---------------------------------------------------------------------------
190 } // namespace config