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: tdenum.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"
35 #include "registry/reader.hxx"
36 #include "registry/version.h"
41 //__________________________________________________________________________________________________
42 EnumTypeDescriptionImpl::~EnumTypeDescriptionImpl()
46 g_moduleCount
.modCnt
.release( &g_moduleCount
.modCnt
);
50 //__________________________________________________________________________________________________
51 TypeClass
EnumTypeDescriptionImpl::getTypeClass()
52 throw(::com::sun::star::uno::RuntimeException
)
54 return TypeClass_ENUM
;
56 //__________________________________________________________________________________________________
57 OUString
EnumTypeDescriptionImpl::getName()
58 throw(::com::sun::star::uno::RuntimeException
)
63 // XEnumTypeDescription
64 //__________________________________________________________________________________________________
65 sal_Int32
EnumTypeDescriptionImpl::getDefaultEnumValue()
66 throw(::com::sun::star::uno::RuntimeException
)
68 return _nDefaultValue
;
70 //__________________________________________________________________________________________________
71 Sequence
< OUString
> EnumTypeDescriptionImpl::getEnumNames()
72 throw(::com::sun::star::uno::RuntimeException
)
76 typereg::Reader
aReader(
77 _aBytes
.getConstArray(), _aBytes
.getLength(), false,
80 sal_uInt16 nFields
= aReader
.getFieldCount();
81 Sequence
< OUString
> * pTempEnumNames
= new Sequence
< OUString
>( nFields
);
82 OUString
* pEnumNames
= pTempEnumNames
->getArray();
86 pEnumNames
[nFields
] = aReader
.getFieldName( nFields
);
89 ClearableMutexGuard
aGuard( getMutex() );
93 delete pTempEnumNames
;
97 _pEnumNames
= pTempEnumNames
;
102 //__________________________________________________________________________________________________
103 Sequence
< sal_Int32
> EnumTypeDescriptionImpl::getEnumValues()
104 throw(::com::sun::star::uno::RuntimeException
)
108 typereg::Reader
aReader(
109 _aBytes
.getConstArray(), _aBytes
.getLength(), false,
112 sal_uInt16 nFields
= aReader
.getFieldCount();
113 Sequence
< sal_Int32
> * pTempEnumValues
= new Sequence
< sal_Int32
>( nFields
);
114 sal_Int32
* pEnumValues
= pTempEnumValues
->getArray();
118 pEnumValues
[nFields
] = getRTValueAsInt32(
119 aReader
.getFieldValue( nFields
) );
122 ClearableMutexGuard
aGuard( getMutex() );
126 delete pTempEnumValues
;
130 _pEnumValues
= pTempEnumValues
;
133 return *_pEnumValues
;