update dev300-m58
[ooovba.git] / stoc / source / registry_tdprovider / tdenum.cxx
blobb6f6eaaeb5dd0d452e22e349bb16ddb0c868e1d5
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: tdenum.cxx,v $
10 * $Revision: 1.9 $
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 "base.hxx"
35 #include "registry/reader.hxx"
36 #include "registry/version.h"
38 namespace stoc_rdbtdp
41 //__________________________________________________________________________________________________
42 EnumTypeDescriptionImpl::~EnumTypeDescriptionImpl()
44 delete _pEnumNames;
45 delete _pEnumValues;
46 g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
49 // XTypeDescription
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)
60 return _aName;
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)
74 if (! _pEnumNames)
76 typereg::Reader aReader(
77 _aBytes.getConstArray(), _aBytes.getLength(), false,
78 TYPEREG_VERSION_1);
80 sal_uInt16 nFields = aReader.getFieldCount();
81 Sequence< OUString > * pTempEnumNames = new Sequence< OUString >( nFields );
82 OUString * pEnumNames = pTempEnumNames->getArray();
84 while (nFields--)
86 pEnumNames[nFields] = aReader.getFieldName( nFields );
89 ClearableMutexGuard aGuard( getMutex() );
90 if (_pEnumNames)
92 aGuard.clear();
93 delete pTempEnumNames;
95 else
97 _pEnumNames = pTempEnumNames;
100 return *_pEnumNames;
102 //__________________________________________________________________________________________________
103 Sequence< sal_Int32 > EnumTypeDescriptionImpl::getEnumValues()
104 throw(::com::sun::star::uno::RuntimeException)
106 if (! _pEnumValues)
108 typereg::Reader aReader(
109 _aBytes.getConstArray(), _aBytes.getLength(), false,
110 TYPEREG_VERSION_1);
112 sal_uInt16 nFields = aReader.getFieldCount();
113 Sequence< sal_Int32 > * pTempEnumValues = new Sequence< sal_Int32 >( nFields );
114 sal_Int32 * pEnumValues = pTempEnumValues->getArray();
116 while (nFields--)
118 pEnumValues[nFields] = getRTValueAsInt32(
119 aReader.getFieldValue( nFields ) );
122 ClearableMutexGuard aGuard( getMutex() );
123 if (_pEnumValues)
125 aGuard.clear();
126 delete pTempEnumValues;
128 else
130 _pEnumValues = pTempEnumValues;
133 return *_pEnumValues;