fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / stoc / source / registry_tdprovider / tdenum.cxx
blob65c1ecef1a16cee8537b62b2f2e298f3a5d24e18
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "base.hxx"
22 #include "registry/reader.hxx"
23 #include "registry/version.h"
25 namespace stoc_rdbtdp
28 //__________________________________________________________________________________________________
29 EnumTypeDescriptionImpl::~EnumTypeDescriptionImpl()
31 delete _pEnumNames;
32 delete _pEnumValues;
35 // XTypeDescription
36 //__________________________________________________________________________________________________
37 TypeClass EnumTypeDescriptionImpl::getTypeClass()
38 throw(::com::sun::star::uno::RuntimeException)
40 return TypeClass_ENUM;
42 //__________________________________________________________________________________________________
43 OUString EnumTypeDescriptionImpl::getName()
44 throw(::com::sun::star::uno::RuntimeException)
46 return _aName;
49 // XEnumTypeDescription
50 //__________________________________________________________________________________________________
51 sal_Int32 EnumTypeDescriptionImpl::getDefaultEnumValue()
52 throw(::com::sun::star::uno::RuntimeException)
54 return _nDefaultValue;
56 //__________________________________________________________________________________________________
57 Sequence< OUString > EnumTypeDescriptionImpl::getEnumNames()
58 throw(::com::sun::star::uno::RuntimeException)
60 if (! _pEnumNames)
62 typereg::Reader aReader(
63 _aBytes.getConstArray(), _aBytes.getLength(), false,
64 TYPEREG_VERSION_1);
66 sal_uInt16 nFields = aReader.getFieldCount();
67 Sequence< OUString > * pTempEnumNames = new Sequence< OUString >( nFields );
68 OUString * pEnumNames = pTempEnumNames->getArray();
70 while (nFields--)
72 pEnumNames[nFields] = aReader.getFieldName( nFields );
75 ClearableMutexGuard aGuard( getMutex() );
76 if (_pEnumNames)
78 aGuard.clear();
79 delete pTempEnumNames;
81 else
83 _pEnumNames = pTempEnumNames;
86 return *_pEnumNames;
88 //__________________________________________________________________________________________________
89 Sequence< sal_Int32 > EnumTypeDescriptionImpl::getEnumValues()
90 throw(::com::sun::star::uno::RuntimeException)
92 if (! _pEnumValues)
94 typereg::Reader aReader(
95 _aBytes.getConstArray(), _aBytes.getLength(), false,
96 TYPEREG_VERSION_1);
98 sal_uInt16 nFields = aReader.getFieldCount();
99 Sequence< sal_Int32 > * pTempEnumValues = new Sequence< sal_Int32 >( nFields );
100 sal_Int32 * pEnumValues = pTempEnumValues->getArray();
102 while (nFields--)
104 pEnumValues[nFields] = getRTValueAsInt32(
105 aReader.getFieldValue( nFields ) );
108 ClearableMutexGuard aGuard( getMutex() );
109 if (_pEnumValues)
111 aGuard.clear();
112 delete pTempEnumValues;
114 else
116 _pEnumValues = pTempEnumValues;
119 return *_pEnumValues;
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */