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

Arkadiy Illarionov (via logerrit) logerrit at kemper.freedesktop.org
Sat Jun 29 11:23:04 UTC 2019


 ucbhelper/source/provider/providerhelper.cxx |  208 ++++++++++++---------------
 1 file changed, 97 insertions(+), 111 deletions(-)

New commits:
commit 195b11b4eed1cabc6090b926901bd17c8c8c9dbd
Author:     Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sat Jun 29 13:19:51 2019 +0300
Commit:     Arkadiy Illarionov <qarkai at gmail.com>
CommitDate: Sat Jun 29 13:22:10 2019 +0200

    Flatten ContentProviderImplHelper
    
    Change-Id: I0461ccfb2d9a9750b91863d9dee29cc5515201dc
    Reviewed-on: https://gerrit.libreoffice.org/74868
    Tested-by: Jenkins
    Reviewed-by: Arkadiy Illarionov <qarkai at gmail.com>

diff --git a/ucbhelper/source/provider/providerhelper.cxx b/ucbhelper/source/provider/providerhelper.cxx
index e4b6d4dab704..52935962f9be 100644
--- a/ucbhelper/source/provider/providerhelper.cxx
+++ b/ucbhelper/source/provider/providerhelper.cxx
@@ -280,47 +280,43 @@ bool ContentProviderImplHelper::renameAdditionalPropertySet(
         // Get propertyset registry.
         getAdditionalPropertySetRegistry();
 
-        if ( m_pImpl->m_xPropertySetRegistry.is() )
+        if ( !m_pImpl->m_xPropertySetRegistry.is() )
+            return false;
+
+        uno::Reference< container::XNameAccess > xNameAccess(
+            m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
+        if ( !xNameAccess.is() )
+            return false;
+
+        uno::Sequence< OUString > aKeys
+            = xNameAccess->getElementNames();
+        if ( aKeys.hasElements() )
         {
-            uno::Reference< container::XNameAccess > xNameAccess(
-                m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
-            if ( xNameAccess.is() )
+            OUString aOldKeyWithSlash = rOldKey;
+            OUString aOldKeyWithoutSlash;
+            if ( !aOldKeyWithSlash.endsWith("/") )
             {
-                uno::Sequence< OUString > aKeys
-                    = xNameAccess->getElementNames();
-                if ( aKeys.hasElements() )
+                aOldKeyWithSlash += "/";
+                aOldKeyWithoutSlash = rOldKey;
+            }
+            else if ( !rOldKey.isEmpty() )
+                aOldKeyWithoutSlash
+                    = rOldKey.copy( 0, rOldKey.getLength() - 1 );
+
+            for ( const OUString& rKey : aKeys )
+            {
+                if ( rKey.startsWith( aOldKeyWithSlash )
+                     || rKey == aOldKeyWithoutSlash )
                 {
-                    OUString aOldKeyWithSlash = rOldKey;
-                    OUString aOldKeyWithoutSlash;
-                    if ( !aOldKeyWithSlash.endsWith("/") )
-                    {
-                        aOldKeyWithSlash += "/";
-                        aOldKeyWithoutSlash = rOldKey;
-                    }
-                    else if ( !rOldKey.isEmpty() )
-                        aOldKeyWithoutSlash
-                            = rOldKey.copy( 0, rOldKey.getLength() - 1 );
-
-                    for ( const OUString& rKey : aKeys )
-                    {
-                        if ( rKey.startsWith( aOldKeyWithSlash )
-                             || rKey == aOldKeyWithoutSlash )
-                        {
-                            OUString aNewKey
-                                = rKey.replaceAt(
-                                    0, rOldKey.getLength(), rNewKey );
-                            if ( !renameAdditionalPropertySet(
-                                    rKey, aNewKey, false ) )
-                                return false;
-                        }
-                    }
+                    OUString aNewKey
+                        = rKey.replaceAt(
+                            0, rOldKey.getLength(), rNewKey );
+                    if ( !renameAdditionalPropertySet(
+                            rKey, aNewKey, false ) )
+                        return false;
                 }
             }
-            else
-                return false;
         }
-        else
-            return false;
     }
     else
     {
@@ -332,13 +328,11 @@ bool ContentProviderImplHelper::renameAdditionalPropertySet(
             // Rename property set.
             uno::Reference< container::XNamed > xNamed(
                 xOldSet, uno::UNO_QUERY );
-            if ( xNamed.is() )
-            {
-                // ??? throws no exceptions and has no return value ???
-                xNamed->setName( rNewKey );
-            }
-            else
+            if ( !xNamed.is() )
                 return false;
+
+            // ??? throws no exceptions and has no return value ???
+            xNamed->setName( rNewKey );
         }
     }
     return true;
@@ -359,47 +353,43 @@ bool ContentProviderImplHelper::copyAdditionalPropertySet(
         // Get propertyset registry.
         getAdditionalPropertySetRegistry();
 
-        if ( m_pImpl->m_xPropertySetRegistry.is() )
+        if ( !m_pImpl->m_xPropertySetRegistry.is() )
+            return false;
+
+        uno::Reference< container::XNameAccess > xNameAccess(
+            m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
+        if ( !xNameAccess.is() )
+            return false;
+
+        uno::Sequence< OUString > aKeys
+            = xNameAccess->getElementNames();
+        if ( aKeys.hasElements() )
         {
-            uno::Reference< container::XNameAccess > xNameAccess(
-                m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
-            if ( xNameAccess.is() )
+            OUString aSrcKeyWithSlash = rSourceKey;
+            OUString aSrcKeyWithoutSlash;
+            if ( !aSrcKeyWithSlash.endsWith("/") )
             {
-                uno::Sequence< OUString > aKeys
-                    = xNameAccess->getElementNames();
-                if ( aKeys.hasElements() )
+                aSrcKeyWithSlash += "/";
+                aSrcKeyWithoutSlash = rSourceKey;
+            }
+            else if ( !rSourceKey.isEmpty() )
+                aSrcKeyWithoutSlash = rSourceKey.copy(
+                    0, rSourceKey.getLength() - 1 );
+
+            for ( const OUString& rKey : aKeys )
+            {
+                if ( rKey.startsWith(aSrcKeyWithSlash )
+                     || rKey == aSrcKeyWithoutSlash )
                 {
-                    OUString aSrcKeyWithSlash = rSourceKey;
-                    OUString aSrcKeyWithoutSlash;
-                    if ( !aSrcKeyWithSlash.endsWith("/") )
-                    {
-                        aSrcKeyWithSlash += "/";
-                        aSrcKeyWithoutSlash = rSourceKey;
-                    }
-                    else if ( !rSourceKey.isEmpty() )
-                        aSrcKeyWithoutSlash = rSourceKey.copy(
-                            0, rSourceKey.getLength() - 1 );
-
-                    for ( const OUString& rKey : aKeys )
-                    {
-                        if ( rKey.startsWith(aSrcKeyWithSlash )
-                             || rKey == aSrcKeyWithoutSlash )
-                        {
-                            OUString aNewKey
-                                = rKey.replaceAt(
-                                    0, rSourceKey.getLength(), rTargetKey );
-                            if ( !copyAdditionalPropertySet(
-                                    rKey, aNewKey, false ) )
-                                return false;
-                        }
-                    }
+                    OUString aNewKey
+                        = rKey.replaceAt(
+                            0, rSourceKey.getLength(), rTargetKey );
+                    if ( !copyAdditionalPropertySet(
+                            rKey, aNewKey, false ) )
+                        return false;
                 }
             }
-            else
-                return false;
         }
-        else
-            return false;
     }
     else
     {
@@ -483,54 +473,50 @@ bool ContentProviderImplHelper::removeAdditionalPropertySet(
         // Get propertyset registry.
         getAdditionalPropertySetRegistry();
 
-        if ( m_pImpl->m_xPropertySetRegistry.is() )
+        if ( !m_pImpl->m_xPropertySetRegistry.is() )
+            return false;
+
+        uno::Reference< container::XNameAccess > xNameAccess(
+            m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
+        if ( !xNameAccess.is() )
+            return false;
+
+        uno::Sequence< OUString > aKeys
+            = xNameAccess->getElementNames();
+        if ( aKeys.hasElements() )
         {
-            uno::Reference< container::XNameAccess > xNameAccess(
-                m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
-            if ( xNameAccess.is() )
+            OUString aKeyWithSlash = rKey;
+            OUString aKeyWithoutSlash;
+            if ( !aKeyWithSlash.endsWith("/") )
             {
-                uno::Sequence< OUString > aKeys
-                    = xNameAccess->getElementNames();
-                if ( aKeys.hasElements() )
+                aKeyWithSlash += "/";
+                aKeyWithoutSlash = rKey;
+            }
+            else if ( !rKey.isEmpty() )
+                aKeyWithoutSlash
+                    = rKey.copy( 0, rKey.getLength() - 1 );
+
+            for ( const OUString& rCurrKey : aKeys )
+            {
+                if ( rCurrKey.startsWith(aKeyWithSlash )
+                     || rCurrKey == aKeyWithoutSlash )
                 {
-                    OUString aKeyWithSlash = rKey;
-                    OUString aKeyWithoutSlash;
-                    if ( !aKeyWithSlash.endsWith("/") )
-                    {
-                        aKeyWithSlash += "/";
-                        aKeyWithoutSlash = rKey;
-                    }
-                    else if ( !rKey.isEmpty() )
-                        aKeyWithoutSlash
-                            = rKey.copy( 0, rKey.getLength() - 1 );
-
-                    for ( const OUString& rCurrKey : aKeys )
-                    {
-                        if ( rCurrKey.startsWith(aKeyWithSlash )
-                             || rCurrKey == aKeyWithoutSlash )
-                        {
-                            if ( !removeAdditionalPropertySet(
-                                     rCurrKey, false ) )
-                                return false;
-                        }
-                    }
+                    if ( !removeAdditionalPropertySet(
+                             rCurrKey, false ) )
+                        return false;
                 }
             }
-            else
-                return false;
         }
-        else
-            return false;
     }
     else
     {
         // Get propertyset registry.
         getAdditionalPropertySetRegistry();
 
-        if ( m_pImpl->m_xPropertySetRegistry.is() )
-            m_pImpl->m_xPropertySetRegistry->removePropertySet( rKey );
-        else
+        if ( !m_pImpl->m_xPropertySetRegistry.is() )
             return false;
+
+        m_pImpl->m_xPropertySetRegistry->removePropertySet( rKey );
     }
     return true;
 }


More information about the Libreoffice-commits mailing list