summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-08-09 18:35:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-10 12:17:36 +0200
commitd5c8684c05e33e87033d595c98fb50acd42d56a8 (patch)
tree8f52500cf8da0afd936eccf6b0884fc78859059b /comphelper
parent51d8845959c75f8c8a3795e7601f947841d0fa60 (diff)
flatten PropertySetInfo a little
Change-Id: I46bc0dc2da9b52d5a2cb1e415328ab1f13a96ff3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120216 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/property/propertysetinfo.cxx137
1 files changed, 43 insertions, 94 deletions
diff --git a/comphelper/source/property/propertysetinfo.cxx b/comphelper/source/property/propertysetinfo.cxx
index fd68b529392a..f21afe3951cd 100644
--- a/comphelper/source/property/propertysetinfo.cxx
+++ b/comphelper/source/property/propertysetinfo.cxx
@@ -29,35 +29,26 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
-namespace comphelper
+void PropertySetInfo::addImpl(PropertyMapEntry const * pMap) noexcept
{
-class PropertyMapImpl final
-{
-public:
- PropertyMapImpl() noexcept;
-
- void add(PropertyMapEntry const * pMap) noexcept;
- void remove( const OUString& aName ) noexcept;
-
- std::vector< Property > const & getProperties() noexcept;
+ while (!pMap->maName.isEmpty())
+ {
+ // check for duplicates
+ assert(maPropertyMap.find(pMap->maName) == maPropertyMap.end());
- const PropertyMap& getPropertyMap() const noexcept { return maPropertyMap;}
+ maPropertyMap[pMap->maName] = pMap;
- /// @throws UnknownPropertyException
- Property getPropertyByName( const OUString& aName );
- bool hasPropertyByName( const OUString& aName ) noexcept;
+ maProperties.clear();
-private:
- PropertyMap maPropertyMap;
- std::vector< Property > maProperties;
-};
+ ++pMap;
+ }
}
-PropertyMapImpl::PropertyMapImpl() noexcept
+PropertySetInfo::PropertySetInfo() noexcept
{
}
-void PropertyMapImpl::add(PropertyMapEntry const * pMap) noexcept
+PropertySetInfo::PropertySetInfo( PropertyMapEntry const * pMap ) noexcept
{
while (!pMap->maName.isEmpty())
{
@@ -66,20 +57,44 @@ void PropertyMapImpl::add(PropertyMapEntry const * pMap) noexcept
maPropertyMap[pMap->maName] = pMap;
- maProperties.clear();
+ ++pMap;
+ }
+}
- pMap = &pMap[1];
+PropertySetInfo::PropertySetInfo(uno::Sequence<beans::Property> const& rProps) noexcept
+{
+ PropertyMapEntry * pEntries(new PropertyMapEntry[rProps.getLength() + 1]);
+ PropertyMapEntry * pEntry(&pEntries[0]);
+ for (auto const& it : rProps)
+ {
+ pEntry->maName = it.Name;
+ pEntry->mnHandle = it.Handle;
+ pEntry->maType = it.Type;
+ pEntry->mnAttributes = it.Attributes;
+ pEntry->mnMemberId = 0;
+ ++pEntry;
}
+ pEntry->maName = OUString();
+
+ addImpl(pEntries);
+}
+
+PropertySetInfo::~PropertySetInfo() noexcept
+{
}
-void PropertyMapImpl::remove( const OUString& aName ) noexcept
+void PropertySetInfo::add( PropertyMapEntry const * pMap ) noexcept
{
- maPropertyMap.erase( aName );
+ addImpl( pMap );
+}
+void PropertySetInfo::remove( const OUString& aName ) noexcept
+{
+ maPropertyMap.erase( aName );
maProperties.clear();
}
-std::vector< Property > const & PropertyMapImpl::getProperties() noexcept
+Sequence< css::beans::Property > SAL_CALL PropertySetInfo::getProperties()
{
// maybe we have to generate the properties after
// a change in the property map or at first call
@@ -101,12 +116,10 @@ std::vector< Property > const & PropertyMapImpl::getProperties() noexcept
++propIter;
}
}
-
- return maProperties;
+ return comphelper::containerToSequence(maProperties);
}
-
-Property PropertyMapImpl::getPropertyByName( const OUString& aName )
+Property SAL_CALL PropertySetInfo::getPropertyByName( const OUString& aName )
{
PropertyMap::iterator aIter = maPropertyMap.find( aName );
@@ -118,73 +131,9 @@ Property PropertyMapImpl::getPropertyByName( const OUString& aName )
return Property( aName, pEntry->mnHandle, pEntry->maType, pEntry->mnAttributes );
}
-bool PropertyMapImpl::hasPropertyByName( const OUString& aName ) noexcept
+sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName( const OUString& aName )
{
return maPropertyMap.find( aName ) != maPropertyMap.end();
}
-
-PropertySetInfo::PropertySetInfo() noexcept
- : mpImpl(new PropertyMapImpl)
-{
-}
-
-PropertySetInfo::PropertySetInfo( PropertyMapEntry const * pMap ) noexcept
- : mpImpl(new PropertyMapImpl)
-{
- mpImpl->add( pMap );
-}
-
-PropertySetInfo::PropertySetInfo(uno::Sequence<beans::Property> const& rProps) noexcept
- : mpImpl(new PropertyMapImpl)
-{
- PropertyMapEntry * pEntries(new PropertyMapEntry[rProps.getLength() + 1]);
- PropertyMapEntry * pEntry(&pEntries[0]);
- for (auto const& it : rProps)
- {
- pEntry->maName = it.Name;
- pEntry->mnHandle = it.Handle;
- pEntry->maType = it.Type;
- pEntry->mnAttributes = it.Attributes;
- pEntry->mnMemberId = 0;
- ++pEntry;
- }
- pEntry->maName = OUString();
- mpImpl->add(pEntries);
-}
-
-PropertySetInfo::~PropertySetInfo() noexcept
-{
-}
-
-void PropertySetInfo::add( PropertyMapEntry const * pMap ) noexcept
-{
- mpImpl->add( pMap );
-}
-
-void PropertySetInfo::remove( const OUString& aName ) noexcept
-{
- mpImpl->remove( aName );
-}
-
-Sequence< css::beans::Property > SAL_CALL PropertySetInfo::getProperties()
-{
- return comphelper::containerToSequence(mpImpl->getProperties());
-}
-
-Property SAL_CALL PropertySetInfo::getPropertyByName( const OUString& aName )
-{
- return mpImpl->getPropertyByName( aName );
-}
-
-sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName( const OUString& Name )
-{
- return mpImpl->hasPropertyByName( Name );
-}
-
-const PropertyMap& PropertySetInfo::getPropertyMap() const noexcept
-{
- return mpImpl->getPropertyMap();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */