Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <comphelper/MasterPropertySetInfo.hxx>
21 :
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;
33 :
34 0 : MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo const * pMap )
35 : {
36 0 : for ( ; !pMap->maName.isEmpty(); ++pMap )
37 : {
38 : SAL_WARN_IF(
39 : maMap.find(pMap->maName) != maMap.end(),
40 : "comphelper", "Duplicate property name \"" << pMap->maName << "\"");
41 0 : maMap[pMap->maName] = new PropertyData ( 0, pMap );
42 : }
43 0 : }
44 :
45 0 : MasterPropertySetInfo::~MasterPropertySetInfo()
46 0 : throw()
47 : {
48 0 : PropertyDataHash::iterator aEnd = maMap.end(), aIter = maMap.begin();
49 0 : while (aIter != aEnd )
50 : {
51 0 : delete (*aIter).second;
52 0 : ++aIter;
53 : }
54 0 : }
55 :
56 0 : void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId )
57 : {
58 0 : if( maProperties.getLength() )
59 0 : maProperties.realloc( 0 );
60 0 : PropertyInfoHash::iterator aIter = rHash.begin(), aEnd = rHash.end();
61 :
62 0 : while ( aIter != aEnd )
63 : {
64 : SAL_WARN_IF(
65 : maMap.find(aIter->first) != maMap.end(),
66 : "comphelper", "Duplicate property name \"" << aIter->first << "\"");
67 0 : maMap[(*aIter).first] = new PropertyData ( nMapId, (*aIter).second );
68 0 : ++aIter;
69 : }
70 0 : }
71 :
72 0 : Sequence< ::Property > SAL_CALL MasterPropertySetInfo::getProperties()
73 : throw(::com::sun::star::uno::RuntimeException, std::exception)
74 : {
75 0 : sal_Int32 nSize = maMap.size();
76 0 : if( maProperties.getLength() != nSize )
77 : {
78 0 : maProperties.realloc ( nSize );
79 0 : Property* pProperties = maProperties.getArray();
80 :
81 0 : for (PropertyDataHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()) ; aIter != aEnd; ++aIter, ++pProperties)
82 : {
83 0 : PropertyInfo const * pInfo = (*aIter).second->mpInfo;
84 :
85 0 : pProperties->Name = pInfo->maName;
86 0 : pProperties->Handle = pInfo->mnHandle;
87 0 : pProperties->Type = pInfo->maType;
88 0 : pProperties->Attributes = pInfo->mnAttributes;
89 : }
90 : }
91 0 : return maProperties;
92 : }
93 :
94 0 : Property SAL_CALL MasterPropertySetInfo::getPropertyByName( const OUString& rName )
95 : throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
96 : {
97 0 : PropertyDataHash::iterator aIter = maMap.find( rName );
98 :
99 0 : if ( maMap.end() == aIter )
100 0 : throw UnknownPropertyException( rName, *this );
101 :
102 0 : PropertyInfo const *pInfo = (*aIter).second->mpInfo;
103 0 : Property aProperty;
104 0 : aProperty.Name = pInfo->maName;
105 0 : aProperty.Handle = pInfo->mnHandle;
106 0 : aProperty.Type = pInfo->maType;
107 :
108 0 : aProperty.Attributes = pInfo->mnAttributes;
109 0 : return aProperty;
110 : }
111 :
112 0 : sal_Bool SAL_CALL MasterPropertySetInfo::hasPropertyByName( const OUString& rName )
113 : throw(::com::sun::star::uno::RuntimeException, std::exception)
114 : {
115 0 : return maMap.find ( rName ) != maMap.end();
116 : }
117 :
118 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|