summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-09-11 23:42:10 +0200
committerMichael Stahl <mstahl@redhat.com>2015-09-11 23:44:59 +0200
commitb3ee922299cf716a1cf785ade84196dfffb8ea19 (patch)
tree84bcf95a0f979bcb0b7389f2f9991a6ccafc5df4 /basic
parentfb1e645e4a5334e75cc594cf89c0540c6d23b0c6 (diff)
basic: one more WeakImplHelper<XPropertySetInfo> duplicate
This one may be quite busted even since it compares sal_Int32(-1) with USHRT_MAX. Change-Id: I894b382ad499ee49f4616c7704afbb90f0556744
Diffstat (limited to 'basic')
-rw-r--r--basic/source/classes/propacc.cxx101
-rw-r--r--basic/source/inc/propacc.hxx42
2 files changed, 14 insertions, 129 deletions
diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx
index b093e50fcc7e..dac042e7388f 100644
--- a/basic/source/classes/propacc.cxx
+++ b/basic/source/classes/propacc.cxx
@@ -23,6 +23,9 @@
#include <basic/sbstar.hxx>
#include <basic/sbuno.hxx>
#include <sbunoobj.hxx>
+
+#include <comphelper/propertysetinfo.hxx>
+
#include <limits.h>
using com::sun::star::uno::Reference;
@@ -40,14 +43,6 @@ struct SbCompare_UString_PropertyValue_Impl
}
};
-extern "C" int SAL_CALL SbCompare_UString_Property_Impl( const void *arg1, const void *arg2 )
-{
- const OUString *pArg1 = static_cast<OUString const *>(arg1);
- const Property *pArg2 = static_cast<Property const *>(arg2);
- return pArg1->compareTo( pArg2->Name );
-}
-
-
SbPropertyValues::SbPropertyValues()
{
@@ -60,15 +55,22 @@ SbPropertyValues::~SbPropertyValues()
m_xInfo.clear();
}
-
-
Reference< XPropertySetInfo > SbPropertyValues::getPropertySetInfo() throw( RuntimeException, std::exception )
{
// create on demand?
if (!m_xInfo.is())
{
- SbPropertySetInfo *pInfo = new SbPropertySetInfo( m_aPropVals );
- m_xInfo.set(pInfo);
+ uno::Sequence<beans::Property> props(m_aPropVals.size());
+ for (size_t n = 0; n < m_aPropVals.size(); ++n)
+ {
+ Property &rProp = props.getArray()[n];
+ const PropertyValue &rPropVal = m_aPropVals[n];
+ rProp.Name = rPropVal.Name;
+ rProp.Handle = rPropVal.Handle;
+ rProp.Type = cppu::UnoType<void>::get();
+ rProp.Attributes = 0;
+ }
+ m_xInfo.set(new ::comphelper::PropertySetInfo(props));
}
return m_xInfo;
}
@@ -188,81 +190,6 @@ void SbPropertyValues::setPropertyValues(const Sequence< PropertyValue >& rPrope
}
-//PropertySetInfoImpl
-
-PropertySetInfoImpl::PropertySetInfoImpl()
-{
-}
-
-sal_Int32 PropertySetInfoImpl::GetIndex_Impl( const OUString &rPropName ) const
-{
- Property *pP;
- pP = static_cast<Property*>(
- bsearch( &rPropName, _aProps.getConstArray(), _aProps.getLength(),
- sizeof( Property ),
- SbCompare_UString_Property_Impl ));
- return pP ? sal::static_int_cast<sal_Int32>( pP - _aProps.getConstArray() ) : -1;
-}
-
-
-Property PropertySetInfoImpl::getPropertyByName(const OUString& Name) throw( RuntimeException )
-{
- sal_Int32 nIndex = GetIndex_Impl( Name );
- if( USHRT_MAX != nIndex )
- return _aProps.getConstArray()[ nIndex ];
- return Property();
-}
-
-bool PropertySetInfoImpl::hasPropertyByName(const OUString& Name) throw( RuntimeException )
-{
- sal_Int32 nIndex = GetIndex_Impl( Name );
- return USHRT_MAX != nIndex;
-}
-
-
-
-
-SbPropertySetInfo::SbPropertySetInfo( const SbPropertyValueArr_Impl &rPropVals )
-{
- aImpl._aProps.realloc( rPropVals.size() );
- for ( size_t n = 0; n < rPropVals.size(); ++n )
- {
- Property &rProp = aImpl._aProps.getArray()[n];
- const PropertyValue &rPropVal = rPropVals[n];
- rProp.Name = rPropVal.Name;
- rProp.Handle = rPropVal.Handle;
- rProp.Type = cppu::UnoType<void>::get();
- rProp.Attributes = 0;
- }
-}
-
-
-
-SbPropertySetInfo::~SbPropertySetInfo()
-{
-}
-
-
-
-Sequence< Property > SbPropertySetInfo::getProperties() throw( RuntimeException, std::exception )
-{
- return aImpl.getProperties();
-}
-
-Property SbPropertySetInfo::getPropertyByName(const OUString& Name)
- throw( RuntimeException, std::exception )
-{
- return aImpl.getPropertyByName( Name );
-}
-
-sal_Bool SbPropertySetInfo::hasPropertyByName(const OUString& Name)
- throw( RuntimeException, std::exception )
-{
- return aImpl.hasPropertyByName( Name );
-}
-
-
-
void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, bool bWrite )
{
(void)pBasic;
diff --git a/basic/source/inc/propacc.hxx b/basic/source/inc/propacc.hxx
index d10cf79014c4..5bd6d51fe50c 100644
--- a/basic/source/inc/propacc.hxx
+++ b/basic/source/inc/propacc.hxx
@@ -84,48 +84,6 @@ public:
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue >& PropertyValues_) throw (css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
};
-
-
-// AB 20.3.2000 Help Class for XPropertySetInfo implementation
-class PropertySetInfoImpl
-{
- friend class SbPropertySetInfo;
-
- css::uno::Sequence< css::beans::Property > _aProps;
-
- sal_Int32 GetIndex_Impl( const OUString &rPropName ) const;
-
-public:
- PropertySetInfoImpl();
- PropertySetInfoImpl( css::uno::Sequence< css::beans::Property >& rProps );
-
- // XPropertySetInfo
- css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() throw () { return _aProps;}
- css::beans::Property SAL_CALL getPropertyByName(const OUString& Name)
- throw( css::uno::RuntimeException );
- bool SAL_CALL hasPropertyByName(const OUString& Name)
- throw ( css::uno::RuntimeException );
-};
-
-class SbPropertySetInfo: public ::cppu::WeakImplHelper< css::beans::XPropertySetInfo >
-{
- PropertySetInfoImpl aImpl;
-
-public:
- SbPropertySetInfo( const SbPropertyValueArr_Impl &rPropVals );
- virtual ~SbPropertySetInfo();
-
- // XPropertySetInfo
- virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties()
- throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
- virtual css::beans::Property SAL_CALL getPropertyByName(const OUString& Name)
- throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
- virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& Name)
- throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
-};
-
-
-
class StarBASIC;
class SbxArray;