/src/libreoffice/comphelper/source/property/MasterPropertySetInfo.cxx
Line | Count | Source |
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 | | #include <sal/log.hxx> |
22 | | |
23 | | using ::comphelper::PropertyInfo; |
24 | | using ::comphelper::MasterPropertySetInfo; |
25 | | using ::com::sun::star::uno::Sequence; |
26 | | using ::com::sun::star::beans::Property; |
27 | | using ::com::sun::star::beans::UnknownPropertyException; |
28 | | |
29 | | MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo const * pMap ) |
30 | 22.4k | { |
31 | 2.46M | for ( ; !pMap->maName.isEmpty(); ++pMap ) |
32 | 2.44M | { |
33 | 2.44M | SAL_WARN_IF( |
34 | 2.44M | maMap.contains(pMap->maName), |
35 | 2.44M | "comphelper", "Duplicate property name \"" << pMap->maName << "\""); |
36 | 2.44M | maMap[pMap->maName] = new PropertyData ( 0, pMap ); |
37 | 2.44M | } |
38 | 22.4k | } |
39 | | |
40 | | MasterPropertySetInfo::~MasterPropertySetInfo() |
41 | | noexcept |
42 | 22.4k | { |
43 | 22.4k | for( const auto& rObj : maMap ) |
44 | 2.82M | delete rObj.second; |
45 | 22.4k | } |
46 | | |
47 | | void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId ) |
48 | 22.4k | { |
49 | 22.4k | if( maProperties.hasElements() ) |
50 | 0 | maProperties.realloc( 0 ); |
51 | | |
52 | 22.4k | for( const auto& rObj : rHash ) |
53 | 381k | { |
54 | 381k | SAL_WARN_IF( |
55 | 381k | maMap.contains(rObj.first), |
56 | 381k | "comphelper", "Duplicate property name \"" << rObj.first << "\""); |
57 | 381k | maMap[rObj.first] = new PropertyData ( nMapId, rObj.second ); |
58 | 381k | } |
59 | 22.4k | } |
60 | | |
61 | | Sequence< ::Property > SAL_CALL MasterPropertySetInfo::getProperties() |
62 | 0 | { |
63 | 0 | sal_Int32 nSize = maMap.size(); |
64 | 0 | if( maProperties.getLength() != nSize ) |
65 | 0 | { |
66 | 0 | maProperties.realloc ( nSize ); |
67 | 0 | Property* pProperties = maProperties.getArray(); |
68 | |
|
69 | 0 | for (auto const& elem : maMap) |
70 | 0 | { |
71 | 0 | PropertyInfo const * pInfo = elem.second->mpInfo; |
72 | |
|
73 | 0 | pProperties->Name = pInfo->maName; |
74 | 0 | pProperties->Handle = pInfo->mnHandle; |
75 | 0 | pProperties->Type = pInfo->maType; |
76 | 0 | pProperties->Attributes = pInfo->mnAttributes; |
77 | 0 | ++pProperties; |
78 | 0 | } |
79 | 0 | } |
80 | 0 | return maProperties; |
81 | 0 | } |
82 | | |
83 | | Property SAL_CALL MasterPropertySetInfo::getPropertyByName( const OUString& rName ) |
84 | 0 | { |
85 | 0 | PropertyDataHash::iterator aIter = maMap.find( rName ); |
86 | |
|
87 | 0 | if ( maMap.end() == aIter ) |
88 | 0 | throw UnknownPropertyException( rName, *this ); |
89 | | |
90 | 0 | PropertyInfo const *pInfo = (*aIter).second->mpInfo; |
91 | 0 | Property aProperty; |
92 | 0 | aProperty.Name = pInfo->maName; |
93 | 0 | aProperty.Handle = pInfo->mnHandle; |
94 | 0 | aProperty.Type = pInfo->maType; |
95 | |
|
96 | 0 | aProperty.Attributes = pInfo->mnAttributes; |
97 | 0 | return aProperty; |
98 | 0 | } |
99 | | |
100 | | sal_Bool SAL_CALL MasterPropertySetInfo::hasPropertyByName( const OUString& rName ) |
101 | 29.1k | { |
102 | 29.1k | return maMap.contains( rName ); |
103 | 29.1k | } |
104 | | |
105 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |