summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-09-11 22:26:44 +0200
committerMichael Stahl <mstahl@redhat.com>2015-09-11 22:31:53 +0200
commit03be785efe589dda77cad28782fbf51ab4049f46 (patch)
treec807f245e5349c66737ae729a1a9d4776e883c45
parentee9a98966a4c1388dcf47757eeaa380d47f6a6a2 (diff)
framework: yet another WeakImplHelper<XPropertySetInfo> dupcliate
There's a very similar comphelper::PropertySetInfo, unfortunately with an additional mnMemberId on its properties, so convert a little... Change-Id: I2a5fc0bb0ff6d680d546192b9d09afee6348f218
-rw-r--r--comphelper/source/property/propertysetinfo.cxx18
-rw-r--r--framework/source/fwi/uielement/constitemcontainer.cxx74
-rw-r--r--include/comphelper/propertysetinfo.hxx1
3 files changed, 22 insertions, 71 deletions
diff --git a/comphelper/source/property/propertysetinfo.cxx b/comphelper/source/property/propertysetinfo.cxx
index 4791b3cb73d7..90985f24854b 100644
--- a/comphelper/source/property/propertysetinfo.cxx
+++ b/comphelper/source/property/propertysetinfo.cxx
@@ -143,6 +143,24 @@ PropertySetInfo::PropertySetInfo( PropertyMapEntry const * pMap ) throw()
mpMap->add( pMap );
}
+PropertySetInfo::PropertySetInfo(uno::Sequence<beans::Property> const& rProps) throw()
+ : mpMap(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();
+ mpMap->add(pEntries);
+}
+
PropertySetInfo::~PropertySetInfo() throw()
{
delete mpMap;
diff --git a/framework/source/fwi/uielement/constitemcontainer.cxx b/framework/source/fwi/uielement/constitemcontainer.cxx
index cea61f6a81f0..d2a4b07f3c90 100644
--- a/framework/source/fwi/uielement/constitemcontainer.cxx
+++ b/framework/source/fwi/uielement/constitemcontainer.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <cppuhelper/implbase.hxx>
+#include <comphelper/propertysetinfo.hxx>
#include <comphelper/servicehelper.hxx>
using namespace cppu;
@@ -41,76 +42,6 @@ const char PROPNAME_UINAME[] = "UIName";
namespace framework
{
-/**
- * The class which implements the PropertySetInfo interface.
- */
-extern "C"
-{
-static int SAL_CALL compare_OUString_Property_Impl( const void *arg1, const void *arg2 )
-{
- return static_cast<OUString const *>(arg1)->compareTo( static_cast<Property const *>(arg2)->Name );
-}
-}
-
-class OPropertySetHelperInfo_Impl
- : public WeakImplHelper< ::com::sun::star::beans::XPropertySetInfo >
-{
- Sequence < Property > aInfos;
-
-public:
- OPropertySetHelperInfo_Impl( IPropertyArrayHelper & rHelper_ );
-
- // XPropertySetInfo-Methoden
- virtual Sequence< Property > SAL_CALL getProperties() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual Property SAL_CALL getPropertyByName(const OUString& PropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& PropertyName) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-};
-
-/**
- * Create an object that implements XPropertySetInfo IPropertyArrayHelper.
- */
-OPropertySetHelperInfo_Impl::OPropertySetHelperInfo_Impl(
- IPropertyArrayHelper & rHelper_ )
- :aInfos( rHelper_.getProperties() )
-{
-}
-
-/**
- * Return the sequence of properties, which are provided through the constructor.
- */
-Sequence< Property > OPropertySetHelperInfo_Impl::getProperties() throw(::com::sun::star::uno::RuntimeException, std::exception)
-{
- return aInfos;
-}
-
-/**
- * Return the sequence of properties, which are provided through the constructor.
- */
-Property OPropertySetHelperInfo_Impl::getPropertyByName( const OUString & PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
-{
- Property * pR;
- pR = static_cast<Property *>(bsearch( &PropertyName, aInfos.getConstArray(), aInfos.getLength(),
- sizeof( Property ),
- compare_OUString_Property_Impl ));
- if( !pR ) {
- throw UnknownPropertyException();
- }
-
- return *pR;
-}
-
-/**
- * Return the sequence of properties, which are provided through the constructor.
- */
-sal_Bool OPropertySetHelperInfo_Impl::hasPropertyByName( const OUString & PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
-{
- Property * pR;
- pR = static_cast<Property *>(bsearch( &PropertyName, aInfos.getConstArray(), aInfos.getLength(),
- sizeof( Property ),
- compare_OUString_Property_Impl ));
- return pR != NULL;
-}
-
ConstItemContainer::ConstItemContainer()
{
}
@@ -409,7 +340,8 @@ const com::sun::star::uno::Sequence< com::sun::star::beans::Property > ConstItem
Reference < XPropertySetInfo > ConstItemContainer::createPropertySetInfo(
IPropertyArrayHelper & rProperties )
{
- return static_cast< XPropertySetInfo * >( new OPropertySetHelperInfo_Impl( rProperties ) );
+ return static_cast<XPropertySetInfo *>(
+ new ::comphelper::PropertySetInfo(rProperties.getProperties()));
}
} // namespace framework
diff --git a/include/comphelper/propertysetinfo.hxx b/include/comphelper/propertysetinfo.hxx
index e554282c9d52..e81a43e54632 100644
--- a/include/comphelper/propertysetinfo.hxx
+++ b/include/comphelper/propertysetinfo.hxx
@@ -54,6 +54,7 @@ private:
public:
PropertySetInfo() throw();
PropertySetInfo( PropertyMapEntry const * pMap ) throw();
+ PropertySetInfo(css::uno::Sequence<css::beans::Property> const &) throw();
virtual ~PropertySetInfo() throw();
/** returns a stl map with all PropertyMapEntry pointer.<p>