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: tdmgr_tdenumeration.cxx,v $
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_stoc.hxx"
33 #include <osl/diagnose.h>
34 #include "tdmgr_common.hxx"
35 #include "tdmgr_tdenumeration.hxx"
37 using namespace com::sun::star
;
39 extern rtl_StandardModuleCount g_moduleCount
;
44 //=========================================================================
45 //=========================================================================
47 // TypeDescriptionEnumerationImpl Implementation.
49 //=========================================================================
50 //=========================================================================
52 TypeDescriptionEnumerationImpl::TypeDescriptionEnumerationImpl(
53 const rtl::OUString
& rModuleName
,
54 const com::sun::star::uno::Sequence
<
55 com::sun::star::uno::TypeClass
> & rTypes
,
56 com::sun::star::reflection::TypeDescriptionSearchDepth eDepth
,
57 const TDEnumerationAccessStack
& rTDEAS
)
58 : m_aModuleName( rModuleName
),
63 ::g_moduleCount
.modCnt
.acquire( &::g_moduleCount
.modCnt
);
66 //=========================================================================
68 TypeDescriptionEnumerationImpl::~TypeDescriptionEnumerationImpl()
70 ::g_moduleCount
.modCnt
.release( &::g_moduleCount
.modCnt
);
73 //=========================================================================
75 // XEnumeration (base of XTypeDescriptionEnumeration) methods
77 //=========================================================================
80 sal_Bool SAL_CALL
TypeDescriptionEnumerationImpl::hasMoreElements()
81 throw ( uno::RuntimeException
)
83 uno::Reference
< reflection::XTypeDescriptionEnumeration
> xEnum
84 = queryCurrentChildEnumeration();
86 return xEnum
->hasMoreElements();
91 //=========================================================================
93 uno::Any SAL_CALL
TypeDescriptionEnumerationImpl::nextElement()
94 throw ( container::NoSuchElementException
,
95 lang::WrappedTargetException
,
96 uno::RuntimeException
)
98 uno::Reference
< reflection::XTypeDescriptionEnumeration
> xEnum
99 = queryCurrentChildEnumeration();
101 return xEnum
->nextElement();
103 throw container::NoSuchElementException(
104 rtl::OUString::createFromAscii(
105 "No further elements in enumeration!" ),
106 static_cast< cppu::OWeakObject
* >( this ) );
109 //=========================================================================
111 // XTypeDescriptionEnumeration methods
113 //=========================================================================
116 uno::Reference
< reflection::XTypeDescription
> SAL_CALL
117 TypeDescriptionEnumerationImpl::nextTypeDescription()
118 throw ( container::NoSuchElementException
,
119 uno::RuntimeException
)
121 uno::Reference
< reflection::XTypeDescriptionEnumeration
> xEnum
122 = queryCurrentChildEnumeration();
124 return xEnum
->nextTypeDescription();
126 throw container::NoSuchElementException(
127 rtl::OUString::createFromAscii(
128 "No further elements in enumeration!" ),
129 static_cast< cppu::OWeakObject
* >( this ) );
132 //=========================================================================
133 uno::Reference
< reflection::XTypeDescriptionEnumeration
>
134 TypeDescriptionEnumerationImpl::queryCurrentChildEnumeration()
136 osl::MutexGuard
aGuard( m_aMutex
);
142 if ( m_xEnum
->hasMoreElements() )
148 // Forget about enumeration without further elements. Try next.
153 // Note: m_xEnum is always null here.
155 if ( m_aChildren
.empty() )
157 // No child enumerations left.
164 m_aChildren
.top()->createTypeDescriptionEnumeration(
165 m_aModuleName
, m_aTypes
, m_eDepth
);
167 catch ( reflection::NoSuchTypeNameException
const & )
169 OSL_ENSURE( sal_False
,
170 "TypeDescriptionEnumerationImpl::queryCurrentChildEnumeration "
171 "- Caught NoSuchTypeNameException!" );
173 catch ( reflection::InvalidTypeNameException
const & )
175 OSL_ENSURE( sal_False
,
176 "TypeDescriptionEnumerationImpl::queryCurrentChildEnumeration "
177 "- Caught InvalidTypeNameException!" );
180 // We're done with this enumeration access in any case (Either
181 // enumeration was successfully created or creation failed for some
189 } // namespace stoc_tdmgr