1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_stoc.hxx" 26 #include "base.hxx" 27 28 #include "registry/reader.hxx" 29 #include "registry/version.h" 30 31 namespace stoc_rdbtdp 32 { 33 34 //__________________________________________________________________________________________________ 35 CompoundTypeDescriptionImpl::~CompoundTypeDescriptionImpl() 36 { 37 delete _pMembers; 38 delete _pMemberNames; 39 g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); 40 } 41 42 // XTypeDescription 43 //__________________________________________________________________________________________________ 44 TypeClass CompoundTypeDescriptionImpl::getTypeClass() 45 throw(::com::sun::star::uno::RuntimeException) 46 { 47 return _eTypeClass; 48 } 49 //__________________________________________________________________________________________________ 50 OUString CompoundTypeDescriptionImpl::getName() 51 throw(::com::sun::star::uno::RuntimeException) 52 { 53 return _aName; 54 } 55 56 // XCompoundTypeDescription 57 //__________________________________________________________________________________________________ 58 Reference< XTypeDescription > CompoundTypeDescriptionImpl::getBaseType() 59 throw(::com::sun::star::uno::RuntimeException) 60 { 61 if (!_xBaseTD.is() && _aBaseType.getLength()) 62 { 63 try 64 { 65 Reference< XTypeDescription > xBaseTD; 66 if (_xTDMgr->getByHierarchicalName( _aBaseType ) >>= xBaseTD) 67 { 68 MutexGuard aGuard( getMutex() ); 69 if (! _xBaseTD.is()) 70 _xBaseTD = xBaseTD; 71 return _xBaseTD; 72 } 73 } 74 catch (NoSuchElementException &) 75 { 76 } 77 // never try again, if no base td was found 78 _aBaseType = OUString(); 79 } 80 return _xBaseTD; 81 } 82 //__________________________________________________________________________________________________ 83 84 namespace { 85 86 class TypeParameter: public WeakImplHelper1< XTypeDescription > { 87 public: 88 explicit TypeParameter(OUString const & name): m_name(name) {} 89 90 virtual TypeClass SAL_CALL getTypeClass() throw (RuntimeException) 91 { return TypeClass_UNKNOWN; } 92 93 virtual OUString SAL_CALL getName() throw (RuntimeException) 94 { return m_name; } 95 96 private: 97 OUString m_name; 98 }; 99 100 } 101 102 Sequence< Reference< XTypeDescription > > CompoundTypeDescriptionImpl::getMemberTypes() 103 throw(::com::sun::star::uno::RuntimeException) 104 { 105 if (! _pMembers) 106 { 107 typereg::Reader aReader( 108 _aBytes.getConstArray(), _aBytes.getLength(), false, 109 TYPEREG_VERSION_1); 110 111 sal_uInt16 nFields = aReader.getFieldCount(); 112 Sequence< Reference< XTypeDescription > > * pTempMembers = 113 new Sequence< Reference< XTypeDescription > >( nFields ); 114 Reference< XTypeDescription > * pMembers = pTempMembers->getArray(); 115 116 while (nFields--) 117 { 118 if ((aReader.getFieldFlags(nFields) & RT_ACCESS_PARAMETERIZED_TYPE) 119 != 0) 120 { 121 pMembers[nFields] = new TypeParameter( 122 aReader.getFieldTypeName(nFields)); 123 } else { 124 try { 125 _xTDMgr->getByHierarchicalName( 126 aReader.getFieldTypeName(nFields).replace('/', '.')) 127 >>= pMembers[nFields]; 128 } catch (NoSuchElementException &) {} 129 OSL_ENSURE( 130 pMembers[nFields].is(), "### compound member unknown!"); 131 } 132 } 133 134 ClearableMutexGuard aGuard( getMutex() ); 135 if (_pMembers) 136 { 137 aGuard.clear(); 138 delete pTempMembers; 139 } 140 else 141 { 142 _pMembers = pTempMembers; 143 } 144 } 145 146 return *_pMembers; 147 } 148 //__________________________________________________________________________________________________ 149 Sequence< OUString > CompoundTypeDescriptionImpl::getMemberNames() 150 throw(::com::sun::star::uno::RuntimeException) 151 { 152 if (! _pMemberNames) 153 { 154 typereg::Reader aReader( 155 _aBytes.getConstArray(), _aBytes.getLength(), false, 156 TYPEREG_VERSION_1); 157 158 sal_uInt16 nFields = aReader.getFieldCount(); 159 Sequence< OUString > * pTempMemberNames = new Sequence< OUString >( nFields ); 160 OUString * pMemberNames = pTempMemberNames->getArray(); 161 162 while (nFields--) 163 { 164 pMemberNames[nFields] = aReader.getFieldName( nFields ); 165 } 166 167 ClearableMutexGuard aGuard( getMutex() ); 168 if (_pMemberNames) 169 { 170 aGuard.clear(); 171 delete pTempMemberNames; 172 } 173 else 174 { 175 _pMemberNames = pTempMemberNames; 176 } 177 } 178 return *_pMemberNames; 179 } 180 181 } 182 183 184