bump product version to 5.0.4.1
[LibreOffice.git] / comphelper / source / property / ChainablePropertySetInfo.cxx
blob4f7868dfa3cb20fd819591d59bb019d3c3dcd1b8
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/ChainablePropertySetInfo.hxx>
21 #include <sal/log.hxx>
23 using ::comphelper::PropertyInfo;
24 using ::comphelper::ChainablePropertySetInfo;
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 ChainablePropertySetInfo::ChainablePropertySetInfo( 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] = pMap;
46 ChainablePropertySetInfo::~ChainablePropertySetInfo()
47 throw()
51 void ChainablePropertySetInfo::remove( const OUString& aName )
53 maMap.erase ( aName );
54 if ( maProperties.getLength() )
55 maProperties.realloc( 0 );
58 Sequence< ::Property > SAL_CALL ChainablePropertySetInfo::getProperties()
59 throw(::com::sun::star::uno::RuntimeException, std::exception)
61 sal_Int32 nSize = maMap.size();
62 if( maProperties.getLength() != nSize )
64 maProperties.realloc ( nSize );
65 Property* pProperties = maProperties.getArray();
67 for (PropertyInfoHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()); aIter != aEnd; ++aIter, ++pProperties)
69 PropertyInfo const * pInfo = (*aIter).second;
71 pProperties->Name = pInfo->maName;
72 pProperties->Handle = pInfo->mnHandle;
73 pProperties->Type = pInfo->maType;
74 pProperties->Attributes = pInfo->mnAttributes;
77 return maProperties;
80 Property SAL_CALL ChainablePropertySetInfo::getPropertyByName( const OUString& rName )
81 throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
83 PropertyInfoHash::iterator aIter = maMap.find( rName );
85 if ( maMap.end() == aIter )
86 throw UnknownPropertyException( rName, *this );
88 PropertyInfo const *pInfo = (*aIter).second;
89 Property aProperty;
90 aProperty.Name = pInfo->maName;
91 aProperty.Handle = pInfo->mnHandle;
92 aProperty.Type = pInfo->maType;
93 aProperty.Attributes = pInfo->mnAttributes;
94 return aProperty;
97 sal_Bool SAL_CALL ChainablePropertySetInfo::hasPropertyByName( const OUString& rName )
98 throw(::com::sun::star::uno::RuntimeException, std::exception)
100 return maMap.find ( rName ) != maMap.end();
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */