[Libreoffice-commits] core.git: comphelper/source include/comphelper

Noel Grandin noel.grandin at collabora.co.uk
Tue Jan 17 06:52:22 UTC 2017


 comphelper/source/property/MasterPropertySet.cxx |   39 +++++++++++------------
 include/comphelper/MasterPropertySet.hxx         |    6 +--
 2 files changed, 22 insertions(+), 23 deletions(-)

New commits:
commit f5e9c29136079b596e68f888e74e524605c12713
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 16 10:52:28 2017 +0200

    use rtl::Reference in MasterPropertySet
    
    no need to store a raw and a smart pointer
    
    Change-Id: Ic6b0b716812ec1dca3111f2162379c11389e963a

diff --git a/comphelper/source/property/MasterPropertySet.cxx b/comphelper/source/property/MasterPropertySet.cxx
index 32f3284..f1c74d7 100644
--- a/comphelper/source/property/MasterPropertySet.cxx
+++ b/comphelper/source/property/MasterPropertySet.cxx
@@ -65,8 +65,7 @@ SlaveData::SlaveData ( ChainablePropertySet *pSlave)
 
 MasterPropertySet::MasterPropertySet( comphelper::MasterPropertySetInfo* pInfo, comphelper::SolarMutex* pMutex )
     throw()
-: mpInfo ( pInfo )
-, mpMutex ( pMutex )
+: mpMutex ( pMutex )
 , mnLastId ( 0 )
 , mxInfo ( pInfo )
 {
@@ -83,14 +82,14 @@ MasterPropertySet::~MasterPropertySet()
 Reference< XPropertySetInfo > SAL_CALL MasterPropertySet::getPropertySetInfo(  )
     throw(RuntimeException, std::exception)
 {
-    return mxInfo;
+    return mxInfo.get();
 }
 
 void MasterPropertySet::registerSlave ( ChainablePropertySet *pNewSet )
     throw()
 {
     maSlaveMap [ ++mnLastId ] = new SlaveData ( pNewSet );
-    mpInfo->add ( pNewSet->mxInfo->maMap, mnLastId );
+    mxInfo->add ( pNewSet->mxInfo->maMap, mnLastId );
 }
 
 void SAL_CALL MasterPropertySet::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
@@ -101,9 +100,9 @@ void SAL_CALL MasterPropertySet::setPropertyValue( const OUString& rPropertyName
     if (mpMutex)
         xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
 
-    PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
+    PropertyDataHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
 
-    if( aIter == mpInfo->maMap.end())
+    if( aIter == mxInfo->maMap.end())
         throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
 
     if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
@@ -135,9 +134,9 @@ Any SAL_CALL MasterPropertySet::getPropertyValue( const OUString& rPropertyName
     if (mpMutex)
         xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
 
-    PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
+    PropertyDataHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
 
-    if( aIter == mpInfo->maMap.end())
+    if( aIter == mxInfo->maMap.end())
         throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
 
     Any aAny;
@@ -207,7 +206,7 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >&
 
         const Any * pAny = aValues.getConstArray();
         const OUString * pString = aPropertyNames.getConstArray();
-        PropertyDataHash::const_iterator aEnd = mpInfo->maMap.end(), aIter;
+        PropertyDataHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
 
         //!! have a unique_ptr to an array of OGuards in order to have the
         //!! allocated memory properly freed (exception safe!).
@@ -218,7 +217,7 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >&
 
         for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
         {
-            aIter = mpInfo->maMap.find ( *pString );
+            aIter = mxInfo->maMap.find ( *pString );
             if ( aIter == aEnd )
                 throw RuntimeException( *pString, static_cast< XPropertySet* >( this ) );
 
@@ -270,7 +269,7 @@ Sequence< Any > SAL_CALL MasterPropertySet::getPropertyValues( const Sequence< O
 
         Any * pAny = aValues.getArray();
         const OUString * pString = aPropertyNames.getConstArray();
-        PropertyDataHash::const_iterator aEnd = mpInfo->maMap.end(), aIter;
+        PropertyDataHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
 
         //!! have an unique_ptr to an array of OGuards in order to have the
         //!! allocated memory properly freed (exception safe!).
@@ -281,7 +280,7 @@ Sequence< Any > SAL_CALL MasterPropertySet::getPropertyValues( const Sequence< O
 
         for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
         {
-            aIter = mpInfo->maMap.find ( *pString );
+            aIter = mxInfo->maMap.find ( *pString );
             if ( aIter == aEnd )
                 throw RuntimeException( *pString, static_cast< XPropertySet* >( this ) );
 
@@ -338,8 +337,8 @@ void SAL_CALL MasterPropertySet::firePropertiesChangeEvent( const Sequence< OUSt
 PropertyState SAL_CALL MasterPropertySet::getPropertyState( const OUString& PropertyName )
     throw(UnknownPropertyException, RuntimeException, std::exception)
 {
-    PropertyDataHash::const_iterator aIter =  mpInfo->maMap.find( PropertyName );
-    if( aIter == mpInfo->maMap.end())
+    PropertyDataHash::const_iterator aIter =  mxInfo->maMap.find( PropertyName );
+    if( aIter == mxInfo->maMap.end())
         throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
 
     PropertyState aState(PropertyState_AMBIGUOUS_VALUE);
@@ -381,12 +380,12 @@ Sequence< PropertyState > SAL_CALL MasterPropertySet::getPropertyStates( const S
     {
         PropertyState * pState = aStates.getArray();
         const OUString * pString = rPropertyNames.getConstArray();
-        PropertyDataHash::const_iterator aEnd = mpInfo->maMap.end(), aIter;
+        PropertyDataHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
         _preGetPropertyState();
 
         for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pState )
         {
-            aIter = mpInfo->maMap.find ( *pString );
+            aIter = mxInfo->maMap.find ( *pString );
             if ( aIter == aEnd )
                 throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) );
 
@@ -419,9 +418,9 @@ Sequence< PropertyState > SAL_CALL MasterPropertySet::getPropertyStates( const S
 void SAL_CALL MasterPropertySet::setPropertyToDefault( const OUString& rPropertyName )
     throw(UnknownPropertyException, RuntimeException, std::exception)
 {
-    PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
+    PropertyDataHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
 
-    if( aIter == mpInfo->maMap.end())
+    if( aIter == mxInfo->maMap.end())
         throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
     _setPropertyToDefault( *((*aIter).second->mpInfo) );
 }
@@ -429,9 +428,9 @@ void SAL_CALL MasterPropertySet::setPropertyToDefault( const OUString& rProperty
 Any SAL_CALL MasterPropertySet::getPropertyDefault( const OUString& rPropertyName )
     throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
 {
-    PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
+    PropertyDataHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
 
-    if( aIter == mpInfo->maMap.end())
+    if( aIter == mxInfo->maMap.end())
         throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
     return _getPropertyDefault( *((*aIter).second->mpInfo) );
 }
diff --git a/include/comphelper/MasterPropertySet.hxx b/include/comphelper/MasterPropertySet.hxx
index b01edf3..37182a9 100644
--- a/include/comphelper/MasterPropertySet.hxx
+++ b/include/comphelper/MasterPropertySet.hxx
@@ -25,6 +25,7 @@
 #include <comphelper/PropertyInfoHash.hxx>
 #include <comphelper/comphelperdllapi.h>
 #include <comphelper/solarmutex.hxx>
+#include <rtl/ref.hxx>
 #include <map>
 
 namespace comphelper
@@ -60,11 +61,10 @@ namespace comphelper
                               public css::beans::XMultiPropertySet
     {
     protected:
-        MasterPropertySetInfo *mpInfo;
         SolarMutex* mpMutex;
         sal_uInt8 mnLastId;
-        std::map < sal_uInt8, comphelper::SlaveData* >       maSlaveMap;
-        css::uno::Reference < css::beans::XPropertySetInfo > mxInfo;
+        std::map< sal_uInt8, comphelper::SlaveData* >  maSlaveMap;
+        rtl::Reference< MasterPropertySetInfo >        mxInfo;
 
         virtual void _preSetValues ()
             throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException ) = 0;


More information about the Libreoffice-commits mailing list