tdf#125181 maxY is 50000 in prstGeom for star24 and star32
[LibreOffice.git] / comphelper / source / property / propertysetinfo.cxx
bloba77a32799c7d6b1382b386c1213fe28292f70674
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 .
21 #include <comphelper/propertysetinfo.hxx>
22 #include <comphelper/sequence.hxx>
23 #include <vector>
26 using namespace ::comphelper;
27 using namespace ::com::sun::star;
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::beans;
30 using namespace ::com::sun::star::lang;
32 namespace comphelper
34 class PropertyMapImpl final
36 public:
37 PropertyMapImpl() throw();
39 void add(PropertyMapEntry const * pMap) throw();
40 void remove( const OUString& aName ) throw();
42 std::vector< Property > const & getProperties() throw();
44 const PropertyMap& getPropertyMap() const throw() { return maPropertyMap;}
46 /// @throws UnknownPropertyException
47 Property getPropertyByName( const OUString& aName );
48 bool hasPropertyByName( const OUString& aName ) throw();
50 private:
51 PropertyMap maPropertyMap;
52 std::vector< Property > maProperties;
56 PropertyMapImpl::PropertyMapImpl() throw()
60 void PropertyMapImpl::add(PropertyMapEntry const * pMap) throw()
62 while (!pMap->maName.isEmpty())
64 // check for duplicates
65 assert(maPropertyMap.find(pMap->maName) == maPropertyMap.end());
67 maPropertyMap[pMap->maName] = pMap;
69 maProperties.clear();
71 pMap = &pMap[1];
75 void PropertyMapImpl::remove( const OUString& aName ) throw()
77 maPropertyMap.erase( aName );
79 maProperties.clear();
82 std::vector< Property > const & PropertyMapImpl::getProperties() throw()
84 // maybe we have to generate the properties after
85 // a change in the property map or at first call
86 // to getProperties
87 if( maProperties.size() != maPropertyMap.size() )
89 maProperties.resize( maPropertyMap.size() );
90 auto propIter = maProperties.begin();
92 for( const auto& rProperty : maPropertyMap )
94 PropertyMapEntry const * pEntry = rProperty.second;
96 propIter->Name = pEntry->maName;
97 propIter->Handle = pEntry->mnHandle;
98 propIter->Type = pEntry->maType;
99 propIter->Attributes = pEntry->mnAttributes;
101 ++propIter;
105 return maProperties;
109 Property PropertyMapImpl::getPropertyByName( const OUString& aName )
111 PropertyMap::iterator aIter = maPropertyMap.find( aName );
113 if( maPropertyMap.end() == aIter )
114 throw UnknownPropertyException( aName );
116 PropertyMapEntry const * pEntry = (*aIter).second;
118 return Property( aName, pEntry->mnHandle, pEntry->maType, pEntry->mnAttributes );
121 bool PropertyMapImpl::hasPropertyByName( const OUString& aName ) throw()
123 return maPropertyMap.find( aName ) != maPropertyMap.end();
127 PropertySetInfo::PropertySetInfo() throw()
128 : mpImpl(new PropertyMapImpl)
132 PropertySetInfo::PropertySetInfo( PropertyMapEntry const * pMap ) throw()
133 : mpImpl(new PropertyMapImpl)
135 mpImpl->add( pMap );
138 PropertySetInfo::PropertySetInfo(uno::Sequence<beans::Property> const& rProps) throw()
139 : mpImpl(new PropertyMapImpl)
141 PropertyMapEntry * pEntries(new PropertyMapEntry[rProps.getLength() + 1]);
142 PropertyMapEntry * pEntry(&pEntries[0]);
143 for (auto const& it : rProps)
145 pEntry->maName = it.Name;
146 pEntry->mnHandle = it.Handle;
147 pEntry->maType = it.Type;
148 pEntry->mnAttributes = it.Attributes;
149 pEntry->mnMemberId = 0;
150 ++pEntry;
152 pEntry->maName = OUString();
153 mpImpl->add(pEntries);
156 PropertySetInfo::~PropertySetInfo() throw()
160 void PropertySetInfo::add( PropertyMapEntry const * pMap ) throw()
162 mpImpl->add( pMap );
165 void PropertySetInfo::remove( const OUString& aName ) throw()
167 mpImpl->remove( aName );
170 Sequence< css::beans::Property > SAL_CALL PropertySetInfo::getProperties()
172 return comphelper::containerToSequence(mpImpl->getProperties());
175 Property SAL_CALL PropertySetInfo::getPropertyByName( const OUString& aName )
177 return mpImpl->getPropertyByName( aName );
180 sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName( const OUString& Name )
182 return mpImpl->hasPropertyByName( Name );
185 const PropertyMap& PropertySetInfo::getPropertyMap() const throw()
187 return mpImpl->getPropertyMap();
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */