bump product version to 5.0.4.1
[LibreOffice.git] / comphelper / source / property / MasterPropertySetInfo.cxx
blob43f0dccdb6280f39e372360b3ff9a22ca49eb2af
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>
21 #include <sal/log.hxx>
23 using ::comphelper::PropertyInfo;
24 using ::comphelper::MasterPropertySetInfo;
25 using ::com::sun::star::uno::Any;
26 using ::com::sun::star::uno::Type;
27 using ::com::sun::star::uno::Sequence;
28 using ::com::sun::star::uno::Reference;
29 using ::com::sun::star::uno::XInterface;
30 using ::com::sun::star::uno::RuntimeException;
31 using ::com::sun::star::beans::Property;
32 using ::com::sun::star::beans::XPropertySetInfo;
33 using ::com::sun::star::beans::UnknownPropertyException;
35 MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo const * pMap )
37 for ( ; !pMap->maName.isEmpty(); ++pMap )
39 SAL_WARN_IF(
40 maMap.find(pMap->maName) != maMap.end(),
41 "comphelper", "Duplicate property name \"" << pMap->maName << "\"");
42 maMap[pMap->maName] = new PropertyData ( 0, pMap );
46 MasterPropertySetInfo::~MasterPropertySetInfo()
47 throw()
49 PropertyDataHash::iterator aEnd = maMap.end(), aIter = maMap.begin();
50 while (aIter != aEnd )
52 delete (*aIter).second;
53 ++aIter;
57 void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId )
59 if( maProperties.getLength() )
60 maProperties.realloc( 0 );
61 PropertyInfoHash::iterator aIter = rHash.begin(), aEnd = rHash.end();
63 while ( aIter != aEnd )
65 SAL_WARN_IF(
66 maMap.find(aIter->first) != maMap.end(),
67 "comphelper", "Duplicate property name \"" << aIter->first << "\"");
68 maMap[(*aIter).first] = new PropertyData ( nMapId, (*aIter).second );
69 ++aIter;
73 Sequence< ::Property > SAL_CALL MasterPropertySetInfo::getProperties()
74 throw(::com::sun::star::uno::RuntimeException, std::exception)
76 sal_Int32 nSize = maMap.size();
77 if( maProperties.getLength() != nSize )
79 maProperties.realloc ( nSize );
80 Property* pProperties = maProperties.getArray();
82 for (PropertyDataHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()) ; aIter != aEnd; ++aIter, ++pProperties)
84 PropertyInfo const * pInfo = (*aIter).second->mpInfo;
86 pProperties->Name = pInfo->maName;
87 pProperties->Handle = pInfo->mnHandle;
88 pProperties->Type = pInfo->maType;
89 pProperties->Attributes = pInfo->mnAttributes;
92 return maProperties;
95 Property SAL_CALL MasterPropertySetInfo::getPropertyByName( const OUString& rName )
96 throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
98 PropertyDataHash::iterator aIter = maMap.find( rName );
100 if ( maMap.end() == aIter )
101 throw UnknownPropertyException( rName, *this );
103 PropertyInfo const *pInfo = (*aIter).second->mpInfo;
104 Property aProperty;
105 aProperty.Name = pInfo->maName;
106 aProperty.Handle = pInfo->mnHandle;
107 aProperty.Type = pInfo->maType;
109 aProperty.Attributes = pInfo->mnAttributes;
110 return aProperty;
113 sal_Bool SAL_CALL MasterPropertySetInfo::hasPropertyByName( const OUString& rName )
114 throw(::com::sun::star::uno::RuntimeException, std::exception)
116 return maMap.find ( rName ) != maMap.end();
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */