Bump version to 4.3-4
[LibreOffice.git] / comphelper / source / property / MasterPropertySetInfo.cxx
blobafbd849eb08d8b06157045a28ec780ee7c82fd5c
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 <comphelper/MasterPropertySetInfo.hxx>
22 using ::comphelper::PropertyInfo;
23 using ::comphelper::MasterPropertySetInfo;
24 using ::com::sun::star::uno::Any;
25 using ::com::sun::star::uno::Type;
26 using ::com::sun::star::uno::Sequence;
27 using ::com::sun::star::uno::Reference;
28 using ::com::sun::star::uno::XInterface;
29 using ::com::sun::star::uno::RuntimeException;
30 using ::com::sun::star::beans::Property;
31 using ::com::sun::star::beans::XPropertySetInfo;
32 using ::com::sun::star::beans::UnknownPropertyException;
34 MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo const * pMap )
36 for ( ; !pMap->maName.isEmpty(); ++pMap )
38 SAL_WARN_IF(
39 maMap.find(pMap->maName) != maMap.end(),
40 "comphelper", "Duplicate property name \"" << pMap->maName << "\"");
41 maMap[pMap->maName] = new PropertyData ( 0, pMap );
45 MasterPropertySetInfo::~MasterPropertySetInfo()
46 throw()
48 PropertyDataHash::iterator aEnd = maMap.end(), aIter = maMap.begin();
49 while (aIter != aEnd )
51 delete (*aIter).second;
52 ++aIter;
56 void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId )
58 if( maProperties.getLength() )
59 maProperties.realloc( 0 );
60 PropertyInfoHash::iterator aIter = rHash.begin(), aEnd = rHash.end();
62 while ( aIter != aEnd )
64 SAL_WARN_IF(
65 maMap.find(aIter->first) != maMap.end(),
66 "comphelper", "Duplicate property name \"" << aIter->first << "\"");
67 maMap[(*aIter).first] = new PropertyData ( nMapId, (*aIter).second );
68 ++aIter;
72 Sequence< ::Property > SAL_CALL MasterPropertySetInfo::getProperties()
73 throw(::com::sun::star::uno::RuntimeException, std::exception)
75 sal_Int32 nSize = maMap.size();
76 if( maProperties.getLength() != nSize )
78 maProperties.realloc ( nSize );
79 Property* pProperties = maProperties.getArray();
81 for (PropertyDataHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()) ; aIter != aEnd; ++aIter, ++pProperties)
83 PropertyInfo const * pInfo = (*aIter).second->mpInfo;
85 pProperties->Name = pInfo->maName;
86 pProperties->Handle = pInfo->mnHandle;
87 pProperties->Type = pInfo->maType;
88 pProperties->Attributes = pInfo->mnAttributes;
91 return maProperties;
94 Property SAL_CALL MasterPropertySetInfo::getPropertyByName( const OUString& rName )
95 throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
97 PropertyDataHash::iterator aIter = maMap.find( rName );
99 if ( maMap.end() == aIter )
100 throw UnknownPropertyException( rName, *this );
102 PropertyInfo const *pInfo = (*aIter).second->mpInfo;
103 Property aProperty;
104 aProperty.Name = pInfo->maName;
105 aProperty.Handle = pInfo->mnHandle;
106 aProperty.Type = pInfo->maType;
108 aProperty.Attributes = pInfo->mnAttributes;
109 return aProperty;
112 sal_Bool SAL_CALL MasterPropertySetInfo::hasPropertyByName( const OUString& rName )
113 throw(::com::sun::star::uno::RuntimeException, std::exception)
115 return maMap.find ( rName ) != maMap.end();
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */