Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "base.hxx"
21 :
22 : #include "registry/reader.hxx"
23 : #include "registry/version.h"
24 :
25 : namespace stoc_rdbtdp
26 : {
27 :
28 : //__________________________________________________________________________________________________
29 1173 : EnumTypeDescriptionImpl::~EnumTypeDescriptionImpl()
30 : {
31 391 : delete _pEnumNames;
32 391 : delete _pEnumValues;
33 391 : g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
34 782 : }
35 :
36 : // XTypeDescription
37 : //__________________________________________________________________________________________________
38 852 : TypeClass EnumTypeDescriptionImpl::getTypeClass()
39 : throw(::com::sun::star::uno::RuntimeException)
40 : {
41 852 : return TypeClass_ENUM;
42 : }
43 : //__________________________________________________________________________________________________
44 910 : OUString EnumTypeDescriptionImpl::getName()
45 : throw(::com::sun::star::uno::RuntimeException)
46 : {
47 910 : return _aName;
48 : }
49 :
50 : // XEnumTypeDescription
51 : //__________________________________________________________________________________________________
52 386 : sal_Int32 EnumTypeDescriptionImpl::getDefaultEnumValue()
53 : throw(::com::sun::star::uno::RuntimeException)
54 : {
55 386 : return _nDefaultValue;
56 : }
57 : //__________________________________________________________________________________________________
58 386 : Sequence< OUString > EnumTypeDescriptionImpl::getEnumNames()
59 : throw(::com::sun::star::uno::RuntimeException)
60 : {
61 386 : if (! _pEnumNames)
62 : {
63 : typereg::Reader aReader(
64 760 : _aBytes.getConstArray(), _aBytes.getLength(), false,
65 760 : TYPEREG_VERSION_1);
66 :
67 380 : sal_uInt16 nFields = aReader.getFieldCount();
68 380 : Sequence< OUString > * pTempEnumNames = new Sequence< OUString >( nFields );
69 380 : OUString * pEnumNames = pTempEnumNames->getArray();
70 :
71 4606 : while (nFields--)
72 : {
73 3846 : pEnumNames[nFields] = aReader.getFieldName( nFields );
74 : }
75 :
76 380 : ClearableMutexGuard aGuard( getMutex() );
77 380 : if (_pEnumNames)
78 : {
79 0 : aGuard.clear();
80 0 : delete pTempEnumNames;
81 : }
82 : else
83 : {
84 380 : _pEnumNames = pTempEnumNames;
85 380 : }
86 : }
87 386 : return *_pEnumNames;
88 : }
89 : //__________________________________________________________________________________________________
90 386 : Sequence< sal_Int32 > EnumTypeDescriptionImpl::getEnumValues()
91 : throw(::com::sun::star::uno::RuntimeException)
92 : {
93 386 : if (! _pEnumValues)
94 : {
95 : typereg::Reader aReader(
96 760 : _aBytes.getConstArray(), _aBytes.getLength(), false,
97 760 : TYPEREG_VERSION_1);
98 :
99 380 : sal_uInt16 nFields = aReader.getFieldCount();
100 380 : Sequence< sal_Int32 > * pTempEnumValues = new Sequence< sal_Int32 >( nFields );
101 380 : sal_Int32 * pEnumValues = pTempEnumValues->getArray();
102 :
103 4606 : while (nFields--)
104 : {
105 3846 : pEnumValues[nFields] = getRTValueAsInt32(
106 3846 : aReader.getFieldValue( nFields ) );
107 : }
108 :
109 380 : ClearableMutexGuard aGuard( getMutex() );
110 380 : if (_pEnumValues)
111 : {
112 0 : aGuard.clear();
113 0 : delete pTempEnumValues;
114 : }
115 : else
116 : {
117 380 : _pEnumValues = pTempEnumValues;
118 380 : }
119 : }
120 386 : return *_pEnumValues;
121 : }
122 :
123 : }
124 :
125 :
126 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|