[Libreoffice-commits] core.git: cppuhelper/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 17 19:08:04 UTC 2020


 cppuhelper/source/component_context.cxx |   56 +--
 cppuhelper/source/implbase.cxx          |  141 ++++----
 cppuhelper/source/propertysetmixin.cxx  |  223 ++++++-------
 cppuhelper/source/propshlp.cxx          |  531 ++++++++++++++++----------------
 cppuhelper/source/tdmgr.cxx             |   54 +--
 5 files changed, 504 insertions(+), 501 deletions(-)

New commits:
commit 23dad0aa083996b5086f6da868a001499bdc8a40
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Apr 17 15:08:40 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Apr 17 21:07:27 2020 +0200

    loplugin:flatten in cppuhelper
    
    Change-Id: I814a109b7822d7a6cd23b5aa4220d496a4da2fb8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92425
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx
index 6d70b7817fa7..739be2800631 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -492,38 +492,38 @@ ComponentContext::ComponentContext(
         }
     }
 
-    if (!m_xSMgr.is() && m_xDelegate.is())
+    if (!(!m_xSMgr.is() && m_xDelegate.is()))
+        return;
+
+    // wrap delegate's smgr XPropertySet into new smgr
+    Reference< lang::XMultiComponentFactory > xMgr( m_xDelegate->getServiceManager() );
+    if (!xMgr.is())
+        return;
+
+    osl_atomic_increment( &m_refCount );
+    try
     {
-        // wrap delegate's smgr XPropertySet into new smgr
-        Reference< lang::XMultiComponentFactory > xMgr( m_xDelegate->getServiceManager() );
-        if (xMgr.is())
+        // create new smgr based on delegate's one
+        m_xSMgr.set(
+            xMgr->createInstanceWithContext(
+                "com.sun.star.comp.stoc.OServiceManagerWrapper", xDelegate ),
+            UNO_QUERY );
+        // patch DefaultContext property of new one
+        Reference< beans::XPropertySet > xProps( m_xSMgr, UNO_QUERY );
+        OSL_ASSERT( xProps.is() );
+        if (xProps.is())
         {
-            osl_atomic_increment( &m_refCount );
-            try
-            {
-                // create new smgr based on delegate's one
-                m_xSMgr.set(
-                    xMgr->createInstanceWithContext(
-                        "com.sun.star.comp.stoc.OServiceManagerWrapper", xDelegate ),
-                    UNO_QUERY );
-                // patch DefaultContext property of new one
-                Reference< beans::XPropertySet > xProps( m_xSMgr, UNO_QUERY );
-                OSL_ASSERT( xProps.is() );
-                if (xProps.is())
-                {
-                    Reference< XComponentContext > xThis( this );
-                    xProps->setPropertyValue( "DefaultContext", Any( xThis ) );
-                }
-            }
-            catch (...)
-            {
-                osl_atomic_decrement( &m_refCount );
-                throw;
-            }
-            osl_atomic_decrement( &m_refCount );
-            OSL_ASSERT( m_xSMgr.is() );
+            Reference< XComponentContext > xThis( this );
+            xProps->setPropertyValue( "DefaultContext", Any( xThis ) );
         }
     }
+    catch (...)
+    {
+        osl_atomic_decrement( &m_refCount );
+        throw;
+    }
+    osl_atomic_decrement( &m_refCount );
+    OSL_ASSERT( m_xSMgr.is() );
 }
 
 
diff --git a/cppuhelper/source/implbase.cxx b/cppuhelper/source/implbase.cxx
index 554520ac8196..1f00accecb27 100644
--- a/cppuhelper/source/implbase.cxx
+++ b/cppuhelper/source/implbase.cxx
@@ -67,64 +67,65 @@ void WeakComponentImplHelperBase::acquire()
 void WeakComponentImplHelperBase::release()
     throw ()
 {
-    if (osl_atomic_decrement( &m_refCount ) == 0) {
-        // ensure no other references are created, via the weak connection point, from now on
-        disposeWeakConnectionPoint();
-        // restore reference count:
-        osl_atomic_increment( &m_refCount );
-        if (! rBHelper.bDisposed) {
-            try {
-                dispose();
-            }
-            catch (RuntimeException const& exc) { // don't break throw ()
-                SAL_WARN( "cppuhelper", exc );
-            }
-            OSL_ASSERT( rBHelper.bDisposed );
+    if (osl_atomic_decrement( &m_refCount ) != 0)
+        return;
+
+    // ensure no other references are created, via the weak connection point, from now on
+    disposeWeakConnectionPoint();
+    // restore reference count:
+    osl_atomic_increment( &m_refCount );
+    if (! rBHelper.bDisposed) {
+        try {
+            dispose();
+        }
+        catch (RuntimeException const& exc) { // don't break throw ()
+            SAL_WARN( "cppuhelper", exc );
         }
-        OWeakObject::release();
+        OSL_ASSERT( rBHelper.bDisposed );
     }
+    OWeakObject::release();
 }
 
 void WeakComponentImplHelperBase::dispose()
 {
     ClearableMutexGuard aGuard( rBHelper.rMutex );
-    if (!rBHelper.bDisposed && !rBHelper.bInDispose)
+    if (rBHelper.bDisposed || rBHelper.bInDispose)
+        return;
+
+    rBHelper.bInDispose = true;
+    aGuard.clear();
+    try
     {
-        rBHelper.bInDispose = true;
-        aGuard.clear();
+        // side effect: keeping a reference to this
+        lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
         try
         {
-            // side effect: keeping a reference to this
-            lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
-            try
-            {
-                rBHelper.aLC.disposeAndClear( aEvt );
-                disposing();
-            }
-            catch (...)
-            {
-                MutexGuard aGuard2( rBHelper.rMutex );
-                // bDisposed and bInDispose must be set in this order:
-                rBHelper.bDisposed = true;
-                rBHelper.bInDispose = false;
-                throw;
-            }
+            rBHelper.aLC.disposeAndClear( aEvt );
+            disposing();
+        }
+        catch (...)
+        {
             MutexGuard aGuard2( rBHelper.rMutex );
             // bDisposed and bInDispose must be set in this order:
             rBHelper.bDisposed = true;
             rBHelper.bInDispose = false;
-        }
-        catch (RuntimeException &)
-        {
             throw;
         }
-        catch (Exception & exc)
-        {
-            css::uno::Any anyEx = cppu::getCaughtException();
-            throw lang::WrappedTargetRuntimeException(
-                "unexpected UNO exception caught: " + exc.Message,
-                nullptr, anyEx );
-        }
+        MutexGuard aGuard2( rBHelper.rMutex );
+        // bDisposed and bInDispose must be set in this order:
+        rBHelper.bDisposed = true;
+        rBHelper.bInDispose = false;
+    }
+    catch (RuntimeException &)
+    {
+        throw;
+    }
+    catch (Exception & exc)
+    {
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw lang::WrappedTargetRuntimeException(
+            "unexpected UNO exception caught: " + exc.Message,
+            nullptr, anyEx );
     }
 }
 
@@ -214,43 +215,43 @@ void WeakAggComponentImplHelperBase::release()
 void WeakAggComponentImplHelperBase::dispose()
 {
     ClearableMutexGuard aGuard( rBHelper.rMutex );
-    if (!rBHelper.bDisposed && !rBHelper.bInDispose)
+    if (rBHelper.bDisposed || rBHelper.bInDispose)
+        return;
+
+    rBHelper.bInDispose = true;
+    aGuard.clear();
+    try
     {
-        rBHelper.bInDispose = true;
-        aGuard.clear();
+        // side effect: keeping a reference to this
+        lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
         try
         {
-            // side effect: keeping a reference to this
-            lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
-            try
-            {
-                rBHelper.aLC.disposeAndClear( aEvt );
-                disposing();
-            }
-            catch (...)
-            {
-                MutexGuard aGuard2( rBHelper.rMutex );
-                // bDisposed and bInDispose must be set in this order:
-                rBHelper.bDisposed = true;
-                rBHelper.bInDispose = false;
-                throw;
-            }
+            rBHelper.aLC.disposeAndClear( aEvt );
+            disposing();
+        }
+        catch (...)
+        {
             MutexGuard aGuard2( rBHelper.rMutex );
             // bDisposed and bInDispose must be set in this order:
             rBHelper.bDisposed = true;
             rBHelper.bInDispose = false;
-        }
-        catch (RuntimeException &)
-        {
             throw;
         }
-        catch (Exception & exc)
-        {
-            css::uno::Any anyEx = cppu::getCaughtException();
-            throw lang::WrappedTargetRuntimeException(
-                "unexpected UNO exception caught: " + exc.Message,
-                nullptr, anyEx );
-        }
+        MutexGuard aGuard2( rBHelper.rMutex );
+        // bDisposed and bInDispose must be set in this order:
+        rBHelper.bDisposed = true;
+        rBHelper.bInDispose = false;
+    }
+    catch (RuntimeException &)
+    {
+        throw;
+    }
+    catch (Exception & exc)
+    {
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw lang::WrappedTargetRuntimeException(
+            "unexpected UNO exception caught: " + exc.Message,
+            nullptr, anyEx );
     }
 }
 
diff --git a/cppuhelper/source/propertysetmixin.cxx b/cppuhelper/source/propertysetmixin.cxx
index a37185e76686..899567e85686 100644
--- a/cppuhelper/source/propertysetmixin.cxx
+++ b/cppuhelper/source/propertysetmixin.cxx
@@ -134,127 +134,128 @@ void Data::initProperties(
 {
     css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > ifc(
         resolveTypedefs(type), css::uno::UNO_QUERY_THROW);
-    if (seen->insert(ifc->getName()).second) {
-        css::uno::Sequence<
-        css::uno::Reference< css::reflection::XTypeDescription > > bases(
-            ifc->getBaseTypes());
-        for (sal_Int32 i = 0; i < bases.getLength(); ++i) {
-            initProperties(bases[i], absentOptional, handleNames, seen);
-        }
-        css::uno::Sequence<
-        css::uno::Reference<
-        css::reflection::XInterfaceMemberTypeDescription > > members(
-            ifc->getMembers());
-        OUString const * absentBegin = absentOptional.getConstArray();
-        OUString const * absentEnd =
-            absentBegin + absentOptional.getLength();
-        for (sal_Int32 i = 0; i < members.getLength(); ++i) {
-            if (members[i]->getTypeClass()
-                == css::uno::TypeClass_INTERFACE_ATTRIBUTE)
-            {
-                css::uno::Reference<
-                css::reflection::XInterfaceAttributeTypeDescription2 > attr(
-                    members[i], css::uno::UNO_QUERY_THROW);
-                sal_Int16 attrAttribs = 0;
-                if (attr->isBound()) {
-                    attrAttribs |= css::beans::PropertyAttribute::BOUND;
+    if (!seen->insert(ifc->getName()).second)
+        return;
+
+    css::uno::Sequence<
+    css::uno::Reference< css::reflection::XTypeDescription > > bases(
+        ifc->getBaseTypes());
+    for (sal_Int32 i = 0; i < bases.getLength(); ++i) {
+        initProperties(bases[i], absentOptional, handleNames, seen);
+    }
+    css::uno::Sequence<
+    css::uno::Reference<
+    css::reflection::XInterfaceMemberTypeDescription > > members(
+        ifc->getMembers());
+    OUString const * absentBegin = absentOptional.getConstArray();
+    OUString const * absentEnd =
+        absentBegin + absentOptional.getLength();
+    for (sal_Int32 i = 0; i < members.getLength(); ++i) {
+        if (members[i]->getTypeClass()
+            == css::uno::TypeClass_INTERFACE_ATTRIBUTE)
+        {
+            css::uno::Reference<
+            css::reflection::XInterfaceAttributeTypeDescription2 > attr(
+                members[i], css::uno::UNO_QUERY_THROW);
+            sal_Int16 attrAttribs = 0;
+            if (attr->isBound()) {
+                attrAttribs |= css::beans::PropertyAttribute::BOUND;
+            }
+            bool bSetUnknown = false;
+            if (attr->isReadOnly()) {
+                attrAttribs |= css::beans::PropertyAttribute::READONLY;
+                bSetUnknown = true;
+            }
+            css::uno::Sequence<
+            css::uno::Reference<
+            css::reflection::XCompoundTypeDescription > > excs(
+                attr->getGetExceptions());
+            bool bGetUnknown = false;
+            //XXX  Special interpretation of getter/setter exceptions only
+            // works if the specified exceptions are of the exact type, not
+            // of a supertype:
+            for (sal_Int32 j = 0; j < excs.getLength(); ++j) {
+                if ( excs[j]->getName() == "com.sun.star.beans.UnknownPropertyException" )
+                {
+                    bGetUnknown = true;
+                    break;
                 }
-                bool bSetUnknown = false;
-                if (attr->isReadOnly()) {
-                    attrAttribs |= css::beans::PropertyAttribute::READONLY;
+            }
+            excs = attr->getSetExceptions();
+            for (sal_Int32 j = 0; j < excs.getLength(); ++j) {
+                if ( excs[j]->getName() == "com.sun.star.beans.UnknownPropertyException" )
+                {
                     bSetUnknown = true;
+                } else if ( excs[j]->getName() == "com.sun.star.beans.PropertyVetoException" )
+                {
+                    attrAttribs
+                        |= css::beans::PropertyAttribute::CONSTRAINED;
                 }
-                css::uno::Sequence<
-                css::uno::Reference<
-                css::reflection::XCompoundTypeDescription > > excs(
-                    attr->getGetExceptions());
-                bool bGetUnknown = false;
-                //XXX  Special interpretation of getter/setter exceptions only
-                // works if the specified exceptions are of the exact type, not
-                // of a supertype:
-                for (sal_Int32 j = 0; j < excs.getLength(); ++j) {
-                    if ( excs[j]->getName() == "com.sun.star.beans.UnknownPropertyException" )
-                    {
-                        bGetUnknown = true;
-                        break;
-                    }
-                }
-                excs = attr->getSetExceptions();
-                for (sal_Int32 j = 0; j < excs.getLength(); ++j) {
-                    if ( excs[j]->getName() == "com.sun.star.beans.UnknownPropertyException" )
-                    {
-                        bSetUnknown = true;
-                    } else if ( excs[j]->getName() == "com.sun.star.beans.PropertyVetoException" )
-                    {
-                        attrAttribs
-                            |= css::beans::PropertyAttribute::CONSTRAINED;
-                    }
-                }
-                if (bGetUnknown && bSetUnknown) {
-                    attrAttribs |= css::beans::PropertyAttribute::OPTIONAL;
-                }
-                css::uno::Reference< css::reflection::XTypeDescription > t(
-                    attr->getType());
-                for (;;)
+            }
+            if (bGetUnknown && bSetUnknown) {
+                attrAttribs |= css::beans::PropertyAttribute::OPTIONAL;
+            }
+            css::uno::Reference< css::reflection::XTypeDescription > t(
+                attr->getType());
+            for (;;)
+            {
+                t = resolveTypedefs(t);
+                sal_Int16 n;
+                if (t->getName().startsWith(
+                        "com.sun.star.beans.Ambiguous<"))
                 {
-                    t = resolveTypedefs(t);
-                    sal_Int16 n;
-                    if (t->getName().startsWith(
-                            "com.sun.star.beans.Ambiguous<"))
-                    {
-                        n = css::beans::PropertyAttribute::MAYBEAMBIGUOUS;
-                    } else if (t->getName().startsWith(
-                                   "com.sun.star.beans.Defaulted<"))
-                    {
-                        n = css::beans::PropertyAttribute::MAYBEDEFAULT;
-                    } else if (t->getName().startsWith(
-                                   "com.sun.star.beans.Optional<"))
-                    {
-                        n = css::beans::PropertyAttribute::MAYBEVOID;
-                    } else {
-                        break;
-                    }
-                    if ((attrAttribs & n) != 0) {
-                        break;
-                    }
-                    attrAttribs |= n;
-                    css::uno::Sequence<
-                    css::uno::Reference< css::reflection::XTypeDescription > >
-                        args(
-                            css::uno::Reference<
-                            css::reflection::XStructTypeDescription >(
-                                t, css::uno::UNO_QUERY_THROW)->
-                            getTypeArguments());
-                    if (args.getLength() != 1) {
-                        throw css::uno::RuntimeException(
-                            "inconsistent UNO type registry");
-                    }
-                    t = args[0];
+                    n = css::beans::PropertyAttribute::MAYBEAMBIGUOUS;
+                } else if (t->getName().startsWith(
+                               "com.sun.star.beans.Defaulted<"))
+                {
+                    n = css::beans::PropertyAttribute::MAYBEDEFAULT;
+                } else if (t->getName().startsWith(
+                               "com.sun.star.beans.Optional<"))
+                {
+                    n = css::beans::PropertyAttribute::MAYBEVOID;
+                } else {
+                    break;
                 }
-                std::vector< OUString >::size_type handles
-                    = handleNames->size();
-                if (handles > SAL_MAX_INT32) {
-                    throw css::uno::RuntimeException(
-                        "interface type has too many attributes");
+                if ((attrAttribs & n) != 0) {
+                    break;
                 }
-                OUString name(members[i]->getMemberName());
-                if (!properties.emplace(
-                            name,
-                            PropertyData(
-                                css::beans::Property(
-                                    name, static_cast< sal_Int32 >(handles),
-                                    css::uno::Type(
-                                        t->getTypeClass(), t->getName()),
-                                    attrAttribs),
-                                (std::find(absentBegin, absentEnd, name)
-                                 == absentEnd))).
-                    second)
-                {
+                attrAttribs |= n;
+                css::uno::Sequence<
+                css::uno::Reference< css::reflection::XTypeDescription > >
+                    args(
+                        css::uno::Reference<
+                        css::reflection::XStructTypeDescription >(
+                            t, css::uno::UNO_QUERY_THROW)->
+                        getTypeArguments());
+                if (args.getLength() != 1) {
                     throw css::uno::RuntimeException(
                         "inconsistent UNO type registry");
                 }
-                handleNames->push_back(name);
+                t = args[0];
+            }
+            std::vector< OUString >::size_type handles
+                = handleNames->size();
+            if (handles > SAL_MAX_INT32) {
+                throw css::uno::RuntimeException(
+                    "interface type has too many attributes");
+            }
+            OUString name(members[i]->getMemberName());
+            if (!properties.emplace(
+                        name,
+                        PropertyData(
+                            css::beans::Property(
+                                name, static_cast< sal_Int32 >(handles),
+                                css::uno::Type(
+                                    t->getTypeClass(), t->getName()),
+                                attrAttribs),
+                            (std::find(absentBegin, absentEnd, name)
+                             == absentEnd))).
+                second)
+            {
+                throw css::uno::RuntimeException(
+                    "inconsistent UNO type registry");
             }
+            handleNames->push_back(name);
         }
     }
 }
diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx
index cdde8d4ff92f..3af4cda49bb7 100644
--- a/cppuhelper/source/propshlp.cxx
+++ b/cppuhelper/source/propshlp.cxx
@@ -284,40 +284,40 @@ void OPropertySetHelper::addPropertyChangeListener(
     MutexGuard aGuard( rBHelper.rMutex );
     OSL_ENSURE( !rBHelper.bInDispose, "do not addPropertyChangeListener in the dispose call" );
     OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" );
-    if( !rBHelper.bInDispose && !rBHelper.bDisposed )
-    {
-        // only add listeners if you are not disposed
-        // a listener with no name means all properties
-        if( !rPropertyName.isEmpty() )
-        {
-            // get the map table
-            IPropertyArrayHelper & rPH = getInfoHelper();
-            // map the name to the handle
-            sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
-            if( nHandle == -1 ) {
-                // property not known throw exception
-                throw  UnknownPropertyException(rPropertyName);
-            }
+    if( rBHelper.bInDispose || rBHelper.bDisposed )
+        return;
 
-            sal_Int16 nAttributes;
-            rPH.fillPropertyMembersByHandle( nullptr, &nAttributes, nHandle );
-            if( !(nAttributes & css::beans::PropertyAttribute::BOUND) )
-            {
-                OSL_FAIL( "add listener to an unbound property" );
-                // silent ignore this
-                return;
-            }
-            // add the change listener to the helper container
+    // only add listeners if you are not disposed
+    // a listener with no name means all properties
+    if( !rPropertyName.isEmpty() )
+    {
+        // get the map table
+        IPropertyArrayHelper & rPH = getInfoHelper();
+        // map the name to the handle
+        sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+        if( nHandle == -1 ) {
+            // property not known throw exception
+            throw  UnknownPropertyException(rPropertyName);
+        }
 
-            aBoundLC.addInterface( nHandle, rxListener );
+        sal_Int16 nAttributes;
+        rPH.fillPropertyMembersByHandle( nullptr, &nAttributes, nHandle );
+        if( !(nAttributes & css::beans::PropertyAttribute::BOUND) )
+        {
+            OSL_FAIL( "add listener to an unbound property" );
+            // silent ignore this
+            return;
         }
-        else
-            // add the change listener to the helper container
-            rBHelper.aLC.addInterface(
-                            getPropertyTypeIdentifier(  ),
-                            rxListener
-                                     );
+        // add the change listener to the helper container
+
+        aBoundLC.addInterface( nHandle, rxListener );
     }
+    else
+        // add the change listener to the helper container
+        rBHelper.aLC.addInterface(
+                        getPropertyTypeIdentifier(  ),
+                        rxListener
+                                 );
 }
 
 
@@ -329,26 +329,26 @@ void OPropertySetHelper::removePropertyChangeListener(
     MutexGuard aGuard( rBHelper.rMutex );
     OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" );
     // all listeners are automatically released in a dispose call
-    if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+    if( rBHelper.bInDispose || rBHelper.bDisposed )
+        return;
+
+    if( !rPropertyName.isEmpty() )
     {
-        if( !rPropertyName.isEmpty() )
-        {
-            // get the map table
-            IPropertyArrayHelper & rPH = getInfoHelper();
-            // map the name to the handle
-            sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
-            if( nHandle == -1 )
-                // property not known throw exception
-                throw UnknownPropertyException(rPropertyName);
-            aBoundLC.removeInterface( nHandle, rxListener );
-        }
-        else {
-            // remove the change listener to the helper container
-            rBHelper.aLC.removeInterface(
-                            getPropertyTypeIdentifier(  ),
-                            rxListener
-                                        );
-        }
+        // get the map table
+        IPropertyArrayHelper & rPH = getInfoHelper();
+        // map the name to the handle
+        sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+        if( nHandle == -1 )
+            // property not known throw exception
+            throw UnknownPropertyException(rPropertyName);
+        aBoundLC.removeInterface( nHandle, rxListener );
+    }
+    else {
+        // remove the change listener to the helper container
+        rBHelper.aLC.removeInterface(
+                        getPropertyTypeIdentifier(  ),
+                        rxListener
+                                    );
     }
 }
 
@@ -360,39 +360,39 @@ void OPropertySetHelper::addVetoableChangeListener(
     MutexGuard aGuard( rBHelper.rMutex );
     OSL_ENSURE( !rBHelper.bInDispose, "do not addVetoableChangeListener in the dispose call" );
     OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" );
-    if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+    if( rBHelper.bInDispose || rBHelper.bDisposed )
+        return;
+
+    // only add listeners if you are not disposed
+    // a listener with no name means all properties
+    if( !rPropertyName.isEmpty() )
     {
-        // only add listeners if you are not disposed
-        // a listener with no name means all properties
-        if( !rPropertyName.isEmpty() )
-        {
-            // get the map table
-            IPropertyArrayHelper & rPH = getInfoHelper();
-            // map the name to the handle
-            sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
-            if( nHandle == -1 ) {
-                // property not known throw exception
-                throw UnknownPropertyException(rPropertyName);
-            }
+        // get the map table
+        IPropertyArrayHelper & rPH = getInfoHelper();
+        // map the name to the handle
+        sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+        if( nHandle == -1 ) {
+            // property not known throw exception
+            throw UnknownPropertyException(rPropertyName);
+        }
 
-            sal_Int16 nAttributes;
-            rPH.fillPropertyMembersByHandle( nullptr, &nAttributes, nHandle );
-            if( !(nAttributes & PropertyAttribute::CONSTRAINED) )
-            {
-                OSL_FAIL( "addVetoableChangeListener, and property is not constrained" );
-                // silent ignore this
-                return;
-            }
-            // add the vetoable listener to the helper container
-            aVetoableLC.addInterface( nHandle, rxListener );
+        sal_Int16 nAttributes;
+        rPH.fillPropertyMembersByHandle( nullptr, &nAttributes, nHandle );
+        if( !(nAttributes & PropertyAttribute::CONSTRAINED) )
+        {
+            OSL_FAIL( "addVetoableChangeListener, and property is not constrained" );
+            // silent ignore this
+            return;
         }
-        else
-            // add the vetoable listener to the helper container
-            rBHelper.aLC.addInterface(
-                                getVetoableTypeIdentifier(  ),
-                                rxListener
-                                     );
+        // add the vetoable listener to the helper container
+        aVetoableLC.addInterface( nHandle, rxListener );
     }
+    else
+        // add the vetoable listener to the helper container
+        rBHelper.aLC.addInterface(
+                            getVetoableTypeIdentifier(  ),
+                            rxListener
+                                 );
 }
 
 // XPropertySet
@@ -403,28 +403,28 @@ void OPropertySetHelper::removeVetoableChangeListener(
     MutexGuard aGuard( rBHelper.rMutex );
     OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" );
     // all listeners are automatically released in a dispose call
-    if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+    if( rBHelper.bInDispose || rBHelper.bDisposed )
+        return;
+
+    if( !rPropertyName.isEmpty() )
     {
-        if( !rPropertyName.isEmpty() )
-        {
-            // get the map table
-            IPropertyArrayHelper & rPH = getInfoHelper();
-            // map the name to the handle
-            sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
-            if( nHandle == -1 ) {
-                // property not known throw exception
-                throw UnknownPropertyException(rPropertyName);
-            }
-            // remove the vetoable listener to the helper container
-            aVetoableLC.removeInterface( nHandle, rxListener );
+        // get the map table
+        IPropertyArrayHelper & rPH = getInfoHelper();
+        // map the name to the handle
+        sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+        if( nHandle == -1 ) {
+            // property not known throw exception
+            throw UnknownPropertyException(rPropertyName);
         }
-        else
-            // add the vetoable listener to the helper container
-            rBHelper.aLC.removeInterface(
-                                getVetoableTypeIdentifier( ),
-                                rxListener
-                                        );
+        // remove the vetoable listener to the helper container
+        aVetoableLC.removeInterface( nHandle, rxListener );
     }
+    else
+        // add the vetoable listener to the helper container
+        rBHelper.aLC.removeInterface(
+                            getVetoableTypeIdentifier( ),
+                            rxListener
+                                    );
 }
 
 void OPropertySetHelper::setDependentFastPropertyValue( sal_Int32 i_handle, const css::uno::Any& i_value )
@@ -502,44 +502,44 @@ void OPropertySetHelper::setFastPropertyValue( sal_Int32 nHandle, const Any& rVa
         bChanged = convertFastPropertyValue( aConvertedVal, aOldVal, nHandle, rValue );
         // release guard to fire events
     }
-    if( bChanged )
+    if( !bChanged )
+        return;
+
+    // Is it a constrained property?
+    if( nAttributes & PropertyAttribute::CONSTRAINED )
+    {
+        // In aValue is the converted rValue
+        // fire a constrained event
+        // second parameter NULL means constrained
+        fire( &nHandle, &rValue, &aOldVal, 1, true );
+    }
+
     {
-        // Is it a constrained property?
-        if( nAttributes & PropertyAttribute::CONSTRAINED )
+        MutexGuard aGuard( rBHelper.rMutex );
+        try
         {
-            // In aValue is the converted rValue
-            // fire a constrained event
-            // second parameter NULL means constrained
-            fire( &nHandle, &rValue, &aOldVal, 1, true );
+            // set the property to the new value
+            setFastPropertyValue_NoBroadcast( nHandle, aConvertedVal );
         }
-
+        catch (const css::beans::UnknownPropertyException& )   { throw;    /* allowed to leave */ }
+        catch (const css::beans::PropertyVetoException& )      { throw;    /* allowed to leave */ }
+        catch (const css::lang::IllegalArgumentException& )    { throw;    /* allowed to leave */ }
+        catch (const css::lang::WrappedTargetException& )      { throw;    /* allowed to leave */ }
+        catch (const css::uno::RuntimeException& )             { throw;    /* allowed to leave */ }
+        catch (const css::uno::Exception& e )
         {
-            MutexGuard aGuard( rBHelper.rMutex );
-            try
-            {
-                // set the property to the new value
-                setFastPropertyValue_NoBroadcast( nHandle, aConvertedVal );
-            }
-            catch (const css::beans::UnknownPropertyException& )   { throw;    /* allowed to leave */ }
-            catch (const css::beans::PropertyVetoException& )      { throw;    /* allowed to leave */ }
-            catch (const css::lang::IllegalArgumentException& )    { throw;    /* allowed to leave */ }
-            catch (const css::lang::WrappedTargetException& )      { throw;    /* allowed to leave */ }
-            catch (const css::uno::RuntimeException& )             { throw;    /* allowed to leave */ }
-            catch (const css::uno::Exception& e )
-            {
-                // not allowed to leave this method
-                css::lang::WrappedTargetException aWrap;
-                aWrap.Context = static_cast< css::beans::XPropertySet* >( this );
-                aWrap.TargetException <<= e;
+            // not allowed to leave this method
+            css::lang::WrappedTargetException aWrap;
+            aWrap.Context = static_cast< css::beans::XPropertySet* >( this );
+            aWrap.TargetException <<= e;
 
-                throw aWrap;
-            }
-
-            // release guard to fire events
+            throw aWrap;
         }
-        // file a change event, if the value changed
-        impl_fireAll( &nHandle, &rValue, &aOldVal, 1 );
+
+        // release guard to fire events
     }
+    // file a change event, if the value changed
+    impl_fireAll( &nHandle, &rValue, &aOldVal, 1 );
 }
 
 // XFastPropertySet
@@ -613,184 +613,185 @@ void OPropertySetHelper::fire
     }
 
     // Only fire, if one or more properties changed
-    if( nHandles )
+    if( !nHandles )
+        return;
+
+    // create the event sequence of all changed properties
+    Sequence< PropertyChangeEvent > aEvts( nHandles );
+    PropertyChangeEvent * pEvts = aEvts.getArray();
+    Reference < XInterface > xSource( static_cast<XPropertySet *>(this), UNO_QUERY );
+    sal_Int32 i;
+    sal_Int32 nChangesLen = 0;
+    // Loop over all changed properties to fill the event struct
+    for( i = 0; i < nHandles; i++ )
     {
-        // create the event sequence of all changed properties
-        Sequence< PropertyChangeEvent > aEvts( nHandles );
-        PropertyChangeEvent * pEvts = aEvts.getArray();
-        Reference < XInterface > xSource( static_cast<XPropertySet *>(this), UNO_QUERY );
-        sal_Int32 i;
-        sal_Int32 nChangesLen = 0;
-        // Loop over all changed properties to fill the event struct
-        for( i = 0; i < nHandles; i++ )
+        // Vetoable fire and constrained attribute set or
+        // Change fire and Changed and bound attribute set
+        IPropertyArrayHelper & rInfo = getInfoHelper();
+        sal_Int16   nAttributes;
+        OUString aPropName;
+        rInfo.fillPropertyMembersByHandle( &aPropName, &nAttributes, pnHandles[i] );
+
+        if(
+           (bVetoable && (nAttributes & PropertyAttribute::CONSTRAINED)) ||
+           (!bVetoable && (nAttributes & PropertyAttribute::BOUND))
+          )
         {
-            // Vetoable fire and constrained attribute set or
-            // Change fire and Changed and bound attribute set
-            IPropertyArrayHelper & rInfo = getInfoHelper();
-            sal_Int16   nAttributes;
-            OUString aPropName;
-            rInfo.fillPropertyMembersByHandle( &aPropName, &nAttributes, pnHandles[i] );
-
-            if(
-               (bVetoable && (nAttributes & PropertyAttribute::CONSTRAINED)) ||
-               (!bVetoable && (nAttributes & PropertyAttribute::BOUND))
-              )
-            {
-                pEvts[nChangesLen].Source = xSource;
-                pEvts[nChangesLen].PropertyName = aPropName;
-                pEvts[nChangesLen].PropertyHandle = pnHandles[i];
-                pEvts[nChangesLen].OldValue = pOldValues[i];
-                pEvts[nChangesLen].NewValue = pNewValues[i];
-                nChangesLen++;
-            }
+            pEvts[nChangesLen].Source = xSource;
+            pEvts[nChangesLen].PropertyName = aPropName;
+            pEvts[nChangesLen].PropertyHandle = pnHandles[i];
+            pEvts[nChangesLen].OldValue = pOldValues[i];
+            pEvts[nChangesLen].NewValue = pNewValues[i];
+            nChangesLen++;
         }
+    }
 
-        bool bIgnoreRuntimeExceptionsWhileFiring =
-                m_pReserved->m_bIgnoreRuntimeExceptionsWhileFiring;
+    bool bIgnoreRuntimeExceptionsWhileFiring =
+            m_pReserved->m_bIgnoreRuntimeExceptionsWhileFiring;
 
-        // fire the events for all changed properties
-        for( i = 0; i < nChangesLen; i++ )
+    // fire the events for all changed properties
+    for( i = 0; i < nChangesLen; i++ )
+    {
+        // get the listener container for the property name
+        OInterfaceContainerHelper * pLC;
+        if( bVetoable ) // fire change Events?
+            pLC = aVetoableLC.getContainer( pEvts[i].PropertyHandle );
+        else
+            pLC = aBoundLC.getContainer( pEvts[i].PropertyHandle );
+        if( pLC )
         {
-            // get the listener container for the property name
-            OInterfaceContainerHelper * pLC;
-            if( bVetoable ) // fire change Events?
-                pLC = aVetoableLC.getContainer( pEvts[i].PropertyHandle );
-            else
-                pLC = aBoundLC.getContainer( pEvts[i].PropertyHandle );
-            if( pLC )
+            // Iterate over all listeners and send events
+            OInterfaceIteratorHelper aIt( *pLC);
+            while( aIt.hasMoreElements() )
             {
-                // Iterate over all listeners and send events
-                OInterfaceIteratorHelper aIt( *pLC);
-                while( aIt.hasMoreElements() )
+                XInterface * pL = aIt.next();
+                try
                 {
-                    XInterface * pL = aIt.next();
                     try
                     {
-                        try
+                        if( bVetoable ) // fire change Events?
                         {
-                            if( bVetoable ) // fire change Events?
-                            {
-                                static_cast<XVetoableChangeListener *>(pL)->vetoableChange(
-                                    pEvts[i] );
-                            }
-                            else
-                            {
-                                static_cast<XPropertyChangeListener *>(pL)->propertyChange(
-                                    pEvts[i] );
-                            }
+                            static_cast<XVetoableChangeListener *>(pL)->vetoableChange(
+                                pEvts[i] );
                         }
-                        catch (DisposedException & exc)
+                        else
                         {
-                            OSL_ENSURE( exc.Context.is(),
-                                        "DisposedException without Context!" );
-                            if (exc.Context == pL)
-                                aIt.remove();
-                            else
-                                throw;
+                            static_cast<XPropertyChangeListener *>(pL)->propertyChange(
+                                pEvts[i] );
                         }
                     }
-                    catch (RuntimeException & exc)
+                    catch (DisposedException & exc)
                     {
-                        SAL_INFO("cppuhelper", "caught RuntimeException while firing listeners: " << exc);
-                        if (! bIgnoreRuntimeExceptionsWhileFiring)
+                        OSL_ENSURE( exc.Context.is(),
+                                    "DisposedException without Context!" );
+                        if (exc.Context == pL)
+                            aIt.remove();
+                        else
                             throw;
                     }
                 }
+                catch (RuntimeException & exc)
+                {
+                    SAL_INFO("cppuhelper", "caught RuntimeException while firing listeners: " << exc);
+                    if (! bIgnoreRuntimeExceptionsWhileFiring)
+                        throw;
+                }
             }
-            // broadcast to all listeners with "" property name
-            if( bVetoable ){
-                // fire change Events?
-                pLC = rBHelper.aLC.getContainer(
-                            getVetoableTypeIdentifier()
-                                                );
-            }
-            else {
-                pLC = rBHelper.aLC.getContainer(
-                            getPropertyTypeIdentifier(  )
-                                                );
-            }
-            if( pLC )
+        }
+        // broadcast to all listeners with "" property name
+        if( bVetoable ){
+            // fire change Events?
+            pLC = rBHelper.aLC.getContainer(
+                        getVetoableTypeIdentifier()
+                                            );
+        }
+        else {
+            pLC = rBHelper.aLC.getContainer(
+                        getPropertyTypeIdentifier(  )
+                                            );
+        }
+        if( pLC )
+        {
+            // Iterate over all listeners and send events.
+            OInterfaceIteratorHelper aIt( *pLC);
+            while( aIt.hasMoreElements() )
             {
-                // Iterate over all listeners and send events.
-                OInterfaceIteratorHelper aIt( *pLC);
-                while( aIt.hasMoreElements() )
+                XInterface * pL = aIt.next();
+                try
                 {
-                    XInterface * pL = aIt.next();
                     try
                     {
-                        try
+                        if( bVetoable ) // fire change Events?
                         {
-                            if( bVetoable ) // fire change Events?
-                            {
-                                static_cast<XVetoableChangeListener *>(pL)->vetoableChange(
-                                    pEvts[i] );
-                            }
-                            else
-                            {
-                                static_cast<XPropertyChangeListener *>(pL)->propertyChange(
-                                    pEvts[i] );
-                            }
+                            static_cast<XVetoableChangeListener *>(pL)->vetoableChange(
+                                pEvts[i] );
                         }
-                        catch (DisposedException & exc)
+                        else
                         {
-                            OSL_ENSURE( exc.Context.is(),
-                                        "DisposedException without Context!" );
-                            if (exc.Context == pL)
-                                aIt.remove();
-                            else
-                                throw;
+                            static_cast<XPropertyChangeListener *>(pL)->propertyChange(
+                                pEvts[i] );
                         }
                     }
-                    catch (RuntimeException & exc)
+                    catch (DisposedException & exc)
                     {
-                        SAL_INFO("cppuhelper", "caught RuntimeException while firing listeners: " << exc);
-                        if (! bIgnoreRuntimeExceptionsWhileFiring)
+                        OSL_ENSURE( exc.Context.is(),
+                                    "DisposedException without Context!" );
+                        if (exc.Context == pL)
+                            aIt.remove();
+                        else
                             throw;
                     }
                 }
+                catch (RuntimeException & exc)
+                {
+                    SAL_INFO("cppuhelper", "caught RuntimeException while firing listeners: " << exc);
+                    if (! bIgnoreRuntimeExceptionsWhileFiring)
+                        throw;
+                }
             }
         }
+    }
+
+    // reduce array to changed properties
+    aEvts.realloc( nChangesLen );
 
-        // reduce array to changed properties
-        aEvts.realloc( nChangesLen );
+    if( bVetoable )
+        return;
+
+    auto pCont = rBHelper.aLC.getContainer(getPropertiesTypeIdentifier());
+    if (!pCont)
+        return;
 
-        if( !bVetoable )
+    // Here is a Bug, unbound properties are also fired
+    OInterfaceIteratorHelper aIt( *pCont );
+    while( aIt.hasMoreElements() )
+    {
+        XPropertiesChangeListener * pL =
+            static_cast<XPropertiesChangeListener *>(aIt.next());
+        try
         {
-            if (auto pCont = rBHelper.aLC.getContainer(getPropertiesTypeIdentifier()))
+            try
             {
-                // Here is a Bug, unbound properties are also fired
-                OInterfaceIteratorHelper aIt( *pCont );
-                while( aIt.hasMoreElements() )
-                {
-                    XPropertiesChangeListener * pL =
-                        static_cast<XPropertiesChangeListener *>(aIt.next());
-                    try
-                    {
-                        try
-                        {
-                            // fire the whole event sequence to the
-                            // XPropertiesChangeListener's
-                            pL->propertiesChange( aEvts );
-                        }
-                        catch (DisposedException & exc)
-                        {
-                            OSL_ENSURE( exc.Context.is(),
-                                        "DisposedException without Context!" );
-                            if (exc.Context == pL)
-                                aIt.remove();
-                            else
-                                throw;
-                        }
-                    }
-                    catch (RuntimeException & exc)
-                    {
-                        SAL_INFO("cppuhelper", "caught RuntimeException while firing listeners: " << exc);
-                        if (! bIgnoreRuntimeExceptionsWhileFiring)
-                            throw;
-                    }
-                }
+                // fire the whole event sequence to the
+                // XPropertiesChangeListener's
+                pL->propertiesChange( aEvts );
+            }
+            catch (DisposedException & exc)
+            {
+                OSL_ENSURE( exc.Context.is(),
+                            "DisposedException without Context!" );
+                if (exc.Context == pL)
+                    aIt.remove();
+                else
+                    throw;
             }
         }
+        catch (RuntimeException & exc)
+        {
+            SAL_INFO("cppuhelper", "caught RuntimeException while firing listeners: " << exc);
+            if (! bIgnoreRuntimeExceptionsWhileFiring)
+                throw;
+        }
     }
 }
 
diff --git a/cppuhelper/source/tdmgr.cxx b/cppuhelper/source/tdmgr.cxx
index 99229644fa7c..e11b6d6077f3 100644
--- a/cppuhelper/source/tdmgr.cxx
+++ b/cppuhelper/source/tdmgr.cxx
@@ -567,37 +567,37 @@ static void typelib_callback(
     void * pContext, typelib_TypeDescription ** ppRet, rtl_uString * pTypeName )
 {
     OSL_ENSURE( pContext && ppRet && pTypeName, "### null ptr!" );
-    if (ppRet)
+    if (!ppRet)
+        return;
+
+    if (*ppRet)
     {
-        if (*ppRet)
-        {
-            ::typelib_typedescription_release( *ppRet );
-            *ppRet = nullptr;
-        }
-        if (pContext && pTypeName)
+        ::typelib_typedescription_release( *ppRet );
+        *ppRet = nullptr;
+    }
+    if (!(pContext && pTypeName))
+        return;
+
+    Reference< container::XHierarchicalNameAccess > access(
+        static_cast< container::XHierarchicalNameAccess * >(
+            pContext));
+    try
+    {
+        OUString const & rTypeName = OUString::unacquired( &pTypeName );
+        Reference< XTypeDescription > xTD;
+        if (access->getByHierarchicalName(rTypeName ) >>= xTD)
         {
-            Reference< container::XHierarchicalNameAccess > access(
-                static_cast< container::XHierarchicalNameAccess * >(
-                    pContext));
-            try
-            {
-                OUString const & rTypeName = OUString::unacquired( &pTypeName );
-                Reference< XTypeDescription > xTD;
-                if (access->getByHierarchicalName(rTypeName ) >>= xTD)
-                {
-                    *ppRet = createCTD( access, xTD );
-                }
-            }
-            catch (const container::NoSuchElementException & exc)
-            {
-                SAL_INFO("cppuhelper", "typelibrary type not available: " << exc );
-            }
-            catch (const Exception & exc)
-            {
-                SAL_INFO("cppuhelper", exc );
-            }
+            *ppRet = createCTD( access, xTD );
         }
     }
+    catch (const container::NoSuchElementException & exc)
+    {
+        SAL_INFO("cppuhelper", "typelibrary type not available: " << exc );
+    }
+    catch (const Exception & exc)
+    {
+        SAL_INFO("cppuhelper", exc );
+    }
 }
 }
 


More information about the Libreoffice-commits mailing list