unotools/source/config/configitem.cxx        |   22 +--
 unotools/source/config/defaultoptions.cxx    |  130 +++++++++++------------
 unotools/source/config/fontcfg.cxx           |  124 +++++++++++-----------
 unotools/source/config/pathoptions.cxx       |   62 +++++------
 unotools/source/config/securityoptions.cxx   |   74 ++++++-------
 unotools/source/i18n/localedatawrapper.cxx   |   50 ++++-----
 unotools/source/i18n/readwritemutexguard.cxx |   36 +++---
 unotools/source/i18n/textsearch.cxx          |  150 +++++++++++++--------------
 unotools/source/misc/mediadescriptor.cxx     |   32 ++---
 unotools/source/ucbhelper/ucblockbytes.cxx   |   22 +--
 10 files changed, 351 insertions(+), 351 deletions(-)

New commits:
commit f3ff488fd4fb56f178ffbb7b3880dfafdd9d8e9c
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Aug 4 21:29:47 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Aug 5 05:02:29 2020 +0200

    loplugin:flatten in unotools
    
    Change-Id: I2fad16061bca6dc3e57926863e7a3b71947a8ade
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100139
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/unotools/source/config/configitem.cxx 
b/unotools/source/config/configitem.cxx
index a6785079723a..60ded67dc837 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -537,19 +537,19 @@ bool ConfigItem::EnableNotification(const Sequence< 
OUString >& rNames,
 void ConfigItem::RemoveChangesListener()
 {
     Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree();
-    if(xHierarchyAccess.is())
+    if(!xHierarchyAccess.is())
+        return;
+
+    Reference<XChangesNotifier> xChgNot(xHierarchyAccess, UNO_QUERY);
+    if(xChgNot.is() && xChangeLstnr.is())
     {
-        Reference<XChangesNotifier> xChgNot(xHierarchyAccess, UNO_QUERY);
-        if(xChgNot.is() && xChangeLstnr.is())
+        try
+        {
+            xChgNot->removeChangesListener( xChangeLstnr );
+            xChangeLstnr = nullptr;
+        }
+        catch (const Exception&)
         {
-            try
-            {
-                xChgNot->removeChangesListener( xChangeLstnr );
-                xChangeLstnr = nullptr;
-            }
-            catch (const Exception&)
-            {
-            }
         }
     }
 }
diff --git a/unotools/source/config/defaultoptions.cxx 
b/unotools/source/config/defaultoptions.cxx
index de7c5a4b4dfd..72a3cc8ba090 100644
--- a/unotools/source/config/defaultoptions.cxx
+++ b/unotools/source/config/defaultoptions.cxx
@@ -233,89 +233,89 @@ SvtDefaultOptions_Impl::SvtDefaultOptions_Impl() : 
ConfigItem( "Office.Common/Pa
     EnableNotification( aNames );
     const Any* pValues = aValues.getConstArray();
     DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties 
failed" );
-    if ( aValues.getLength() == aNames.getLength() )
-    {
-        SvtPathOptions aPathOpt;
-        OUString aTempStr;
-        OUStringBuffer aFullPathBuf;
+    if ( aValues.getLength() != aNames.getLength() )
+        return;
+
+    SvtPathOptions aPathOpt;
+    OUString aTempStr;
+    OUStringBuffer aFullPathBuf;
 
-        for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+    for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+    {
+        if ( pValues[nProp].hasValue() )
         {
-            if ( pValues[nProp].hasValue() )
+            switch ( pValues[nProp].getValueTypeClass() )
             {
-                switch ( pValues[nProp].getValueTypeClass() )
+                case css::uno::TypeClass_STRING :
                 {
-                    case css::uno::TypeClass_STRING :
+                    // multi paths
+                    if ( pValues[nProp] >>= aTempStr )
+                        aFullPathBuf = aPathOpt.SubstituteVariable( aTempStr );
+                    else
                     {
-                        // multi paths
-                        if ( pValues[nProp] >>= aTempStr )
-                            aFullPathBuf = aPathOpt.SubstituteVariable( 
aTempStr );
-                        else
-                        {
-                            SAL_WARN( "unotools.config", "any operator >>= 
failed" );
-                        }
-                        break;
+                        SAL_WARN( "unotools.config", "any operator >>= failed" 
);
                     }
+                    break;
+                }
 
-                    case css::uno::TypeClass_SEQUENCE :
+                case css::uno::TypeClass_SEQUENCE :
+                {
+                    // single paths
+                    aFullPathBuf.setLength(0);
+                    Sequence < OUString > aList;
+                    if ( pValues[nProp] >>= aList )
                     {
-                        // single paths
-                        aFullPathBuf.setLength(0);
-                        Sequence < OUString > aList;
-                        if ( pValues[nProp] >>= aList )
+                        sal_Int32 nCount = aList.getLength();
+                        for ( sal_Int32 nPosition = 0; nPosition < nCount; 
++nPosition )
                         {
-                            sal_Int32 nCount = aList.getLength();
-                            for ( sal_Int32 nPosition = 0; nPosition < nCount; 
++nPosition )
-                            {
-                                
aFullPathBuf.append(aPathOpt.SubstituteVariable( aList[ nPosition ] ));
-                                if ( nPosition < nCount-1 )
-                                    aFullPathBuf.append(";");
-                            }
+                            aFullPathBuf.append(aPathOpt.SubstituteVariable( 
aList[ nPosition ] ));
+                            if ( nPosition < nCount-1 )
+                                aFullPathBuf.append(";");
                         }
-                        else
-                        {
-                            SAL_WARN( "unotools.config", "any operator >>= 
failed" );
-                        }
-                        break;
                     }
-
-                    default:
+                    else
                     {
-                        SAL_WARN( "unotools.config", "Wrong any type" );
+                        SAL_WARN( "unotools.config", "any operator >>= failed" 
);
                     }
+                    break;
                 }
 
-                auto aFullPath = aFullPathBuf.makeStringAndClear();
-                switch ( nProp )
+                default:
                 {
-                    case DEFAULTPATH_ADDIN:            m_aAddinPath = 
aFullPath;         break;
-                    case DEFAULTPATH_AUTOCORRECT:      m_aAutoCorrectPath = 
aFullPath;   break;
-                    case DEFAULTPATH_AUTOTEXT:         m_aAutoTextPath = 
aFullPath;      break;
-                    case DEFAULTPATH_BACKUP:           m_aBackupPath = 
aFullPath;        break;
-                    case DEFAULTPATH_BASIC:            m_aBasicPath = 
aFullPath;         break;
-                    case DEFAULTPATH_BITMAP:           m_aBitmapPath = 
aFullPath;        break;
-                    case DEFAULTPATH_CONFIG:           m_aConfigPath = 
aFullPath;        break;
-                    case DEFAULTPATH_DICTIONARY:       m_aDictionaryPath = 
aFullPath;    break;
-                    case DEFAULTPATH_FAVORITES:        m_aFavoritesPath = 
aFullPath;     break;
-                    case DEFAULTPATH_FILTER:           m_aFilterPath = 
aFullPath;        break;
-                    case DEFAULTPATH_GALLERY:          m_aGalleryPath = 
aFullPath;       break;
-                    case DEFAULTPATH_GRAPHIC:          m_aGraphicPath = 
aFullPath;       break;
-                    case DEFAULTPATH_HELP:             m_aHelpPath = 
aFullPath;          break;
-                    case DEFAULTPATH_LINGUISTIC:       m_aLinguisticPath = 
aFullPath;    break;
-                    case DEFAULTPATH_MODULE:           m_aModulePath = 
aFullPath;        break;
-                    case DEFAULTPATH_PALETTE:          m_aPalettePath = 
aFullPath;       break;
-                    case DEFAULTPATH_PLUGIN:           m_aPluginPath = 
aFullPath;        break;
-                    case DEFAULTPATH_TEMP:             m_aTempPath = 
aFullPath;          break;
-                    case DEFAULTPATH_TEMPLATE:         m_aTemplatePath = 
aFullPath;      break;
-                    case DEFAULTPATH_USERCONFIG:       m_aUserConfigPath = 
aFullPath;    break;
-                    case DEFAULTPATH_WORK:             m_aWorkPath = 
aFullPath;          break;
-                    case DEFAULTPATH_CLASSIFICATION:   m_aClassificationPath = 
aFullPath;break;
-                    case DEFAULTPATH_USERDICTIONARY:   break;
-
-                    default:
-                        SAL_WARN( "unotools.config", "invalid index to load a 
default path" );
+                    SAL_WARN( "unotools.config", "Wrong any type" );
                 }
             }
+
+            auto aFullPath = aFullPathBuf.makeStringAndClear();
+            switch ( nProp )
+            {
+                case DEFAULTPATH_ADDIN:            m_aAddinPath = aFullPath;   
      break;
+                case DEFAULTPATH_AUTOCORRECT:      m_aAutoCorrectPath = 
aFullPath;   break;
+                case DEFAULTPATH_AUTOTEXT:         m_aAutoTextPath = 
aFullPath;      break;
+                case DEFAULTPATH_BACKUP:           m_aBackupPath = aFullPath;  
      break;
+                case DEFAULTPATH_BASIC:            m_aBasicPath = aFullPath;   
      break;
+                case DEFAULTPATH_BITMAP:           m_aBitmapPath = aFullPath;  
      break;
+                case DEFAULTPATH_CONFIG:           m_aConfigPath = aFullPath;  
      break;
+                case DEFAULTPATH_DICTIONARY:       m_aDictionaryPath = 
aFullPath;    break;
+                case DEFAULTPATH_FAVORITES:        m_aFavoritesPath = 
aFullPath;     break;
+                case DEFAULTPATH_FILTER:           m_aFilterPath = aFullPath;  
      break;
+                case DEFAULTPATH_GALLERY:          m_aGalleryPath = aFullPath; 
      break;
+                case DEFAULTPATH_GRAPHIC:          m_aGraphicPath = aFullPath; 
      break;
+                case DEFAULTPATH_HELP:             m_aHelpPath = aFullPath;    
      break;
+                case DEFAULTPATH_LINGUISTIC:       m_aLinguisticPath = 
aFullPath;    break;
+                case DEFAULTPATH_MODULE:           m_aModulePath = aFullPath;  
      break;
+                case DEFAULTPATH_PALETTE:          m_aPalettePath = aFullPath; 
      break;
+                case DEFAULTPATH_PLUGIN:           m_aPluginPath = aFullPath;  
      break;
+                case DEFAULTPATH_TEMP:             m_aTempPath = aFullPath;    
      break;
+                case DEFAULTPATH_TEMPLATE:         m_aTemplatePath = 
aFullPath;      break;
+                case DEFAULTPATH_USERCONFIG:       m_aUserConfigPath = 
aFullPath;    break;
+                case DEFAULTPATH_WORK:             m_aWorkPath = aFullPath;    
      break;
+                case DEFAULTPATH_CLASSIFICATION:   m_aClassificationPath = 
aFullPath;break;
+                case DEFAULTPATH_USERDICTIONARY:   break;
+
+                default:
+                    SAL_WARN( "unotools.config", "invalid index to load a 
default path" );
+            }
         }
     }
 }
diff --git a/unotools/source/config/fontcfg.cxx 
b/unotools/source/config/fontcfg.cxx
index 9025562f89c0..8f7b4277549b 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -974,72 +974,72 @@ ImplFontAttrs FontSubstConfiguration::getSubstType( const 
css::uno::Reference< X
 void FontSubstConfiguration::readLocaleSubst( const OUString& rBcp47 ) const
 {
     std::unordered_map< OUString, LocaleSubst >::const_iterator it = 
m_aSubst.find( rBcp47 );
-    if( it != m_aSubst.end() )
+    if( it == m_aSubst.end() )
+        return;
+
+    if(  it->second.bConfigRead )
+        return;
+
+    it->second.bConfigRead = true;
+    Reference< XNameAccess > xNode;
+    try
     {
-        if( ! it->second.bConfigRead )
-        {
-            it->second.bConfigRead = true;
-            Reference< XNameAccess > xNode;
-            try
-            {
-                Any aAny = m_xConfigAccess->getByName( 
it->second.aConfigLocaleString );
-                aAny >>= xNode;
-            }
-            catch (const NoSuchElementException&)
-            {
-            }
-            catch (const WrappedTargetException&)
-            {
-            }
-            if( xNode.is() )
-            {
-                const Sequence< OUString > aFonts = xNode->getElementNames();
-                int nFonts = aFonts.getLength();
-                // improve performance, heap fragmentation
-                it->second.aSubstAttributes.reserve( nFonts );
-
-                // strings for subst retrieval, construct only once
-                OUString const aSubstFontsStr     ( "SubstFonts" );
-                OUString const aSubstFontsMSStr   ( "SubstFontsMS" );
-                OUString const aSubstWeightStr    ( "FontWeight" );
-                OUString const aSubstWidthStr     ( "FontWidth" );
-                OUString const aSubstTypeStr      ( "FontType" );
-                for( const OUString& rFontName : aFonts )
-                {
-                    Reference< XNameAccess > xFont;
-                    try
-                    {
-                        Any aAny = xNode->getByName( rFontName );
-                        aAny >>= xFont;
-                    }
-                    catch (const NoSuchElementException&)
-                    {
-                    }
-                    catch (const WrappedTargetException&)
-                    {
-                    }
-                    if( ! xFont.is() )
-                    {
-                        SAL_WARN("unotools.config", "did not get font 
attributes for " << rFontName);
-                        continue;
-                    }
+        Any aAny = m_xConfigAccess->getByName( it->second.aConfigLocaleString 
);
+        aAny >>= xNode;
+    }
+    catch (const NoSuchElementException&)
+    {
+    }
+    catch (const WrappedTargetException&)
+    {
+    }
+    if( !xNode.is() )
+        return;
 
-                    FontNameAttr aAttr;
-                    // read subst attributes from config
-                    aAttr.Name = rFontName;
-                    fillSubstVector( xFont, aSubstFontsStr, 
aAttr.Substitutions );
-                    fillSubstVector( xFont, aSubstFontsMSStr, 
aAttr.MSSubstitutions );
-                    aAttr.Weight = getSubstWeight( xFont, aSubstWeightStr );
-                    aAttr.Width = getSubstWidth( xFont, aSubstWidthStr );
-                    aAttr.Type = getSubstType( xFont, aSubstTypeStr );
-
-                    // finally insert this entry
-                    it->second.aSubstAttributes.push_back( aAttr );
-                }
-                std::sort( it->second.aSubstAttributes.begin(), 
it->second.aSubstAttributes.end(), StrictStringSort() );
-            }
+    const Sequence< OUString > aFonts = xNode->getElementNames();
+    int nFonts = aFonts.getLength();
+    // improve performance, heap fragmentation
+    it->second.aSubstAttributes.reserve( nFonts );
+
+    // strings for subst retrieval, construct only once
+    OUString const aSubstFontsStr     ( "SubstFonts" );
+    OUString const aSubstFontsMSStr   ( "SubstFontsMS" );
+    OUString const aSubstWeightStr    ( "FontWeight" );
+    OUString const aSubstWidthStr     ( "FontWidth" );
+    OUString const aSubstTypeStr      ( "FontType" );
+    for( const OUString& rFontName : aFonts )
+    {
+        Reference< XNameAccess > xFont;
+        try
+        {
+            Any aAny = xNode->getByName( rFontName );
+            aAny >>= xFont;
+        }
+        catch (const NoSuchElementException&)
+        {
         }
+        catch (const WrappedTargetException&)
+        {
+        }
+        if( ! xFont.is() )
+        {
+            SAL_WARN("unotools.config", "did not get font attributes for " << 
rFontName);
+            continue;
+        }
+
+        FontNameAttr aAttr;
+        // read subst attributes from config
+        aAttr.Name = rFontName;
+        fillSubstVector( xFont, aSubstFontsStr, aAttr.Substitutions );
+        fillSubstVector( xFont, aSubstFontsMSStr, aAttr.MSSubstitutions );
+        aAttr.Weight = getSubstWeight( xFont, aSubstWeightStr );
+        aAttr.Width = getSubstWidth( xFont, aSubstWidthStr );
+        aAttr.Type = getSubstType( xFont, aSubstTypeStr );
+
+        // finally insert this entry
+        it->second.aSubstAttributes.push_back( aAttr );
     }
+    std::sort( it->second.aSubstAttributes.begin(), 
it->second.aSubstAttributes.end(), StrictStringSort() );
 }
 
 const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& 
rFontName ) const
diff --git a/unotools/source/config/pathoptions.cxx 
b/unotools/source/config/pathoptions.cxx
index 1896f456a3a8..cb70189aa3dd 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -268,41 +268,41 @@ void SvtPathOptions_Impl::SetPath( SvtPathOptions::Paths 
ePath, const OUString&
 {
     ::osl::MutexGuard aGuard( m_aMutex );
 
-    if ( ePath < SvtPathOptions::PATH_COUNT )
-    {
-        OUString    aResult;
-        OUString    aNewValue;
-        Any         a;
-
-        switch ( ePath )
-        {
-            case SvtPathOptions::PATH_ADDIN:
-            case SvtPathOptions::PATH_FILTER:
-            case SvtPathOptions::PATH_HELP:
-            case SvtPathOptions::PATH_MODULE:
-            case SvtPathOptions::PATH_PLUGIN:
-            case SvtPathOptions::PATH_STORAGE:
-            {
-                // These office paths have to be convert back to UCB-URL's
-                osl::FileBase::getFileURLFromSystemPath( rNewPath, aResult );
-                aNewValue = aResult;
-            }
-            break;
+    if ( ePath >= SvtPathOptions::PATH_COUNT )
+        return;
 
-            default:
-                aNewValue = rNewPath;
-        }
+    OUString    aResult;
+    OUString    aNewValue;
+    Any         a;
 
-        // Resubstitution is done by the service itself using the substitution 
service
-        a <<= aNewValue;
-        try
-        {
-            m_xPathSettings->setFastPropertyValue( m_aMapEnumToPropHandle[ 
static_cast<sal_Int32>(ePath)], a );
-        }
-        catch (const Exception&)
+    switch ( ePath )
+    {
+        case SvtPathOptions::PATH_ADDIN:
+        case SvtPathOptions::PATH_FILTER:
+        case SvtPathOptions::PATH_HELP:
+        case SvtPathOptions::PATH_MODULE:
+        case SvtPathOptions::PATH_PLUGIN:
+        case SvtPathOptions::PATH_STORAGE:
         {
-            TOOLS_WARN_EXCEPTION("unotools.config", "SetPath");
+            // These office paths have to be convert back to UCB-URL's
+            osl::FileBase::getFileURLFromSystemPath( rNewPath, aResult );
+            aNewValue = aResult;
         }
+        break;
+
+        default:
+            aNewValue = rNewPath;
+    }
+
+    // Resubstitution is done by the service itself using the substitution 
service
+    a <<= aNewValue;
+    try
+    {
+        m_xPathSettings->setFastPropertyValue( m_aMapEnumToPropHandle[ 
static_cast<sal_Int32>(ePath)], a );
+    }
+    catch (const Exception&)
+    {
+        TOOLS_WARN_EXCEPTION("unotools.config", "SetPath");
     }
 }
 
diff --git a/unotools/source/config/securityoptions.cxx 
b/unotools/source/config/securityoptions.cxx
index d81517f255a0..36aa85b3ac8c 100644
--- a/unotools/source/config/securityoptions.cxx
+++ b/unotools/source/config/securityoptions.cxx
@@ -412,49 +412,49 @@ void SvtSecurityOptions_Impl::LoadAuthors()
     m_seqTrustedAuthors.realloc( 0 );       // first clear
     const Sequence< OUString > lAuthors = GetNodeNames( 
PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
     sal_Int32               c1 = lAuthors.getLength();
-    if( c1 )
+    if( !c1 )
+        return;
+
+    sal_Int32               c2 = c1 * 3;                // 3 Properties inside 
Struct TrustedAuthor
+    Sequence< OUString >    lAllAuthors( c2 );
+
+    sal_Int32               i2 = 0;
+    OUString                aSep( "/" );
+    for( const auto& rAuthor : lAuthors )
     {
-        sal_Int32               c2 = c1 * 3;                // 3 Properties 
inside Struct TrustedAuthor
-        Sequence< OUString >    lAllAuthors( c2 );
+        lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor 
+ aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
+        ++i2;
+        lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor 
+ aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
+        ++i2;
+        lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor 
+ aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
+        ++i2;
+    }
 
-        sal_Int32               i2 = 0;
-        OUString                aSep( "/" );
-        for( const auto& rAuthor : lAuthors )
-        {
-            lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + 
rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
-            ++i2;
-            lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + 
rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
-            ++i2;
-            lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + 
rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
-            ++i2;
-        }
+    Sequence< Any >         lValues = GetProperties( lAllAuthors );
+    if( lValues.getLength() != c2 )
+        return;
 
-        Sequence< Any >         lValues = GetProperties( lAllAuthors );
-        if( lValues.getLength() == c2 )
+    std::vector< SvtSecurityOptions::Certificate > v;
+    SvtSecurityOptions::Certificate aCert( 3 );
+    i2 = 0;
+    for( sal_Int32 i1 = 0; i1 < c1; ++i1 )
+    {
+        lValues[ i2 ] >>= aCert[ 0 ];
+        ++i2;
+        lValues[ i2 ] >>= aCert[ 1 ];
+        ++i2;
+        lValues[ i2 ] >>= aCert[ 2 ];
+        ++i2;
+        // Filter out TrustedAuthor entries with empty RawData, which
+        // would cause an unexpected std::bad_alloc in
+        // SecurityEnvironment_NssImpl::createCertificateFromAscii and
+        // have been observed in the wild (fdo#55019):
+        if( !aCert[ 2 ].isEmpty() )
         {
-            std::vector< SvtSecurityOptions::Certificate > v;
-            SvtSecurityOptions::Certificate aCert( 3 );
-            i2 = 0;
-            for( sal_Int32 i1 = 0; i1 < c1; ++i1 )
-            {
-                lValues[ i2 ] >>= aCert[ 0 ];
-                ++i2;
-                lValues[ i2 ] >>= aCert[ 1 ];
-                ++i2;
-                lValues[ i2 ] >>= aCert[ 2 ];
-                ++i2;
-                // Filter out TrustedAuthor entries with empty RawData, which
-                // would cause an unexpected std::bad_alloc in
-                // SecurityEnvironment_NssImpl::createCertificateFromAscii and
-                // have been observed in the wild (fdo#55019):
-                if( !aCert[ 2 ].isEmpty() )
-                {
-                    v.push_back( aCert );
-                }
-            }
-            m_seqTrustedAuthors = comphelper::containerToSequence(v);
+            v.push_back( aCert );
         }
     }
+    m_seqTrustedAuthors = comphelper::containerToSequence(v);
 }
 
 sal_Int32 SvtSecurityOptions_Impl::GetHandle( const OUString& rName )
diff --git a/unotools/source/i18n/localedatawrapper.cxx 
b/unotools/source/i18n/localedatawrapper.cxx
index f60b6f3e01b6..c900de4452c5 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -520,19 +520,19 @@ bool LocaleDataWrapper::doesSecondaryCalendarUseEC( const 
OUString& rName ) cons
 
 void LocaleDataWrapper::getDefaultCalendarImpl()
 {
-    if (!xDefaultCalendar)
+    if (xDefaultCalendar)
+        return;
+
+    Sequence< Calendar2 > xCals = getAllCalendars();
+    auto pCal = xCals.begin();
+    if (xCals.getLength() > 1)
     {
-        Sequence< Calendar2 > xCals = getAllCalendars();
-        auto pCal = xCals.begin();
-        if (xCals.getLength() > 1)
-        {
-            pCal = std::find_if(xCals.begin(), xCals.end(),
-                [](const Calendar2& rCal) { return rCal.Default; });
-            if (pCal == xCals.end())
-                pCal = xCals.begin();
-        }
-        xDefaultCalendar = std::make_shared<Calendar2>( *pCal);
+        pCal = std::find_if(xCals.begin(), xCals.end(),
+            [](const Calendar2& rCal) { return rCal.Default; });
+        if (pCal == xCals.end())
+            pCal = xCals.begin();
     }
+    xDefaultCalendar = std::make_shared<Calendar2>( *pCal);
 }
 
 const std::shared_ptr< css::i18n::Calendar2 >& 
LocaleDataWrapper::getDefaultCalendar() const
@@ -1061,21 +1061,21 @@ void LocaleDataWrapper::getDigitGroupingImpl()
         aGrouping.realloc(3);   // room for {3,2,0}
         aGrouping[0] = 0;       // invalidate
     }
-    if (!aGrouping[0])
+    if (aGrouping[0])
+        return;
+
+    i18n::LanguageCountryInfo aLCInfo( getLanguageCountryInfo());
+    if (aLCInfo.Country.equalsIgnoreAsciiCase("IN") || // India
+        aLCInfo.Country.equalsIgnoreAsciiCase("BT") )  // Bhutan
     {
-        i18n::LanguageCountryInfo aLCInfo( getLanguageCountryInfo());
-        if (aLCInfo.Country.equalsIgnoreAsciiCase("IN") || // India
-            aLCInfo.Country.equalsIgnoreAsciiCase("BT") )  // Bhutan
-        {
-            aGrouping[0] = 3;
-            aGrouping[1] = 2;
-            aGrouping[2] = 0;
-        }
-        else
-        {
-            aGrouping[0] = 3;
-            aGrouping[1] = 0;
-        }
+        aGrouping[0] = 3;
+        aGrouping[1] = 2;
+        aGrouping[2] = 0;
+    }
+    else
+    {
+        aGrouping[0] = 3;
+        aGrouping[1] = 0;
     }
 }
 
diff --git a/unotools/source/i18n/readwritemutexguard.cxx 
b/unotools/source/i18n/readwritemutexguard.cxx
index 134f06c35747..48da011b7537 100644
--- a/unotools/source/i18n/readwritemutexguard.cxx
+++ b/unotools/source/i18n/readwritemutexguard.cxx
@@ -81,27 +81,27 @@ void ReadWriteGuard::changeReadToWrite()
 {
     bool bOk = !(nMode & (ReadWriteGuardMode::Write | 
ReadWriteGuardMode::BlockCritical));
     DBG_ASSERT( bOk, "ReadWriteGuard::changeReadToWrite: can't" );
-    if ( bOk )
+    if ( !bOk )
+        return;
+
+    // MUST release read before acquiring write mutex or dead lock would
+    // occur if there was a write in another thread waiting for this read
+    // to complete.
+    rMutex.maMutex.acquire();
+    --rMutex.nReadCount;
+    rMutex.maMutex.release();
+
+    rMutex.maWriteMutex.acquire();
+    nMode |= ReadWriteGuardMode::Write;
+    // wait for any other read to complete
+// TODO: set up a waiting thread instead of a loop
+    bool bWait = true;
+    do
     {
-        // MUST release read before acquiring write mutex or dead lock would
-        // occur if there was a write in another thread waiting for this read
-        // to complete.
         rMutex.maMutex.acquire();
-        --rMutex.nReadCount;
+        bWait = (rMutex.nReadCount != 0);
         rMutex.maMutex.release();
-
-        rMutex.maWriteMutex.acquire();
-        nMode |= ReadWriteGuardMode::Write;
-        // wait for any other read to complete
-// TODO: set up a waiting thread instead of a loop
-        bool bWait = true;
-        do
-        {
-            rMutex.maMutex.acquire();
-            bWait = (rMutex.nReadCount != 0);
-            rMutex.maMutex.release();
-        } while ( bWait );
-    }
+    } while ( bWait );
 }
 
 }   // namespace utl
diff --git a/unotools/source/i18n/textsearch.cxx 
b/unotools/source/i18n/textsearch.cxx
index 42b995f7051c..c55b7a712147 100644
--- a/unotools/source/i18n/textsearch.cxx
+++ b/unotools/source/i18n/textsearch.cxx
@@ -305,95 +305,95 @@ bool TextSearch::SearchBackward( const OUString & rStr, 
sal_Int32* pStart,
 
 void TextSearch::ReplaceBackReferences( OUString& rReplaceStr, const OUString 
&rStr, const SearchResult& rResult ) const
 {
-    if( rResult.subRegExpressions > 0 )
+    if( rResult.subRegExpressions <= 0 )
+        return;
+
+    sal_Unicode sFndChar;
+    sal_Int32 i;
+    OUStringBuffer sBuff(rReplaceStr.getLength()*4);
+    for(i = 0; i < rReplaceStr.getLength(); i++)
     {
-        sal_Unicode sFndChar;
-        sal_Int32 i;
-        OUStringBuffer sBuff(rReplaceStr.getLength()*4);
-        for(i = 0; i < rReplaceStr.getLength(); i++)
+        if( rReplaceStr[i] == '&')
         {
-            if( rReplaceStr[i] == '&')
-            {
-                sal_Int32 nStart = rResult.startOffset[0];
-                sal_Int32 nLength = rResult.endOffset[0] - 
rResult.startOffset[0];
-                sBuff.append(std::u16string_view(rStr).substr(nStart, 
nLength));
-            }
-            else if((i < rReplaceStr.getLength() - 1) && rReplaceStr[i] == '$')
-            {
-                sFndChar = rReplaceStr[ i + 1 ];
-                switch(sFndChar)
-                {   // placeholder for a backward reference?
-                case '0':
-                case '1':
-                case '2':
-                case '3':
-                case '4':
-                case '5':
-                case '6':
-                case '7':
-                case '8':
-                case '9':
+            sal_Int32 nStart = rResult.startOffset[0];
+            sal_Int32 nLength = rResult.endOffset[0] - rResult.startOffset[0];
+            sBuff.append(std::u16string_view(rStr).substr(nStart, nLength));
+        }
+        else if((i < rReplaceStr.getLength() - 1) && rReplaceStr[i] == '$')
+        {
+            sFndChar = rReplaceStr[ i + 1 ];
+            switch(sFndChar)
+            {   // placeholder for a backward reference?
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+                {
+                    int j = sFndChar - '0'; // index
+                    if(j < rResult.subRegExpressions)
                     {
-                        int j = sFndChar - '0'; // index
-                        if(j < rResult.subRegExpressions)
+                        sal_Int32 nSttReg = rResult.startOffset[j];
+                        sal_Int32 nRegLen = rResult.endOffset[j];
+                        if (nSttReg < 0 || nRegLen < 0) // A "not found" 
optional capture
+                        {
+                            nSttReg = nRegLen = 0; // Copy empty string
+                        }
+                        else if (nRegLen >= nSttReg)
+                        {
+                            nRegLen = nRegLen - nSttReg;
+                        }
+                        else
                         {
-                            sal_Int32 nSttReg = rResult.startOffset[j];
-                            sal_Int32 nRegLen = rResult.endOffset[j];
-                            if (nSttReg < 0 || nRegLen < 0) // A "not found" 
optional capture
-                            {
-                                nSttReg = nRegLen = 0; // Copy empty string
-                            }
-                            else if (nRegLen >= nSttReg)
-                            {
-                                nRegLen = nRegLen - nSttReg;
-                            }
-                            else
-                            {
-                                nRegLen = nSttReg - nRegLen;
-                                nSttReg = rResult.endOffset[j];
-                            }
-                            // Copy reference from found string
-                            
sBuff.append(std::u16string_view(rStr).substr(nSttReg, nRegLen));
+                            nRegLen = nSttReg - nRegLen;
+                            nSttReg = rResult.endOffset[j];
                         }
-                        i += 1;
+                        // Copy reference from found string
+                        sBuff.append(std::u16string_view(rStr).substr(nSttReg, 
nRegLen));
                     }
-                    break;
-                default:
-                    sBuff.append(rReplaceStr[i]);
-                    sBuff.append(rReplaceStr[i+1]);
                     i += 1;
-                    break;
-                }
-            }
-            else if((i < rReplaceStr.getLength() - 1) && rReplaceStr[i] == 
'\\')
-            {
-                sFndChar = rReplaceStr[ i+1 ];
-                switch(sFndChar)
-                {
-                case '\\':
-                case '&':
-                case '$':
-                    sBuff.append(sFndChar);
-                    i+=1;
-                    break;
-                case 't':
-                    sBuff.append('\t');
-                    i += 1;
-                    break;
-                default:
-                    sBuff.append(rReplaceStr[i]);
-                    sBuff.append(rReplaceStr[i+1]);
-                    i += 1;
-                    break;
                 }
+                break;
+            default:
+                sBuff.append(rReplaceStr[i]);
+                sBuff.append(rReplaceStr[i+1]);
+                i += 1;
+                break;
             }
-            else
+        }
+        else if((i < rReplaceStr.getLength() - 1) && rReplaceStr[i] == '\\')
+        {
+            sFndChar = rReplaceStr[ i+1 ];
+            switch(sFndChar)
             {
+            case '\\':
+            case '&':
+            case '$':
+                sBuff.append(sFndChar);
+                i+=1;
+                break;
+            case 't':
+                sBuff.append('\t');
+                i += 1;
+                break;
+            default:
                 sBuff.append(rReplaceStr[i]);
+                sBuff.append(rReplaceStr[i+1]);
+                i += 1;
+                break;
             }
         }
-        rReplaceStr = sBuff.makeStringAndClear();
+        else
+        {
+            sBuff.append(rReplaceStr[i]);
+        }
     }
+    rReplaceStr = sBuff.makeStringAndClear();
 }
 
 }   // namespace utl
diff --git a/unotools/source/misc/mediadescriptor.cxx 
b/unotools/source/misc/mediadescriptor.cxx
index e522b54ee83f..d73f3c5dd2eb 100644
--- a/unotools/source/misc/mediadescriptor.cxx
+++ b/unotools/source/misc/mediadescriptor.cxx
@@ -432,23 +432,23 @@ void MediaDescriptor::setComponentDataEntry( const 
OUString& rName, const css::u
 void MediaDescriptor::clearComponentDataEntry( const OUString& rName )
 {
     comphelper::SequenceAsHashMap::iterator aPropertyIter = find( 
PROP_COMPONENTDATA() );
-    if( aPropertyIter != end() )
+    if( aPropertyIter == end() )
+        return;
+
+    css::uno::Any& rCompDataAny = aPropertyIter->second;
+    bool bHasNamedValues = rCompDataAny.has< css::uno::Sequence< 
css::beans::NamedValue > >();
+    bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< 
css::beans::PropertyValue > >();
+    OSL_ENSURE( bHasNamedValues || bHasPropValues, 
"MediaDescriptor::clearComponentDataEntry - incompatible 'ComponentData' 
property in media descriptor" );
+    if( bHasNamedValues || bHasPropValues )
     {
-        css::uno::Any& rCompDataAny = aPropertyIter->second;
-        bool bHasNamedValues = rCompDataAny.has< css::uno::Sequence< 
css::beans::NamedValue > >();
-        bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< 
css::beans::PropertyValue > >();
-        OSL_ENSURE( bHasNamedValues || bHasPropValues, 
"MediaDescriptor::clearComponentDataEntry - incompatible 'ComponentData' 
property in media descriptor" );
-        if( bHasNamedValues || bHasPropValues )
-        {
-            // remove the value with the passed name
-            comphelper::SequenceAsHashMap aCompDataMap( rCompDataAny );
-            aCompDataMap.erase( rName );
-            // write back the sequence, or remove it completely if it is empty
-            if( aCompDataMap.empty() )
-                erase( aPropertyIter );
-            else
-                rCompDataAny = aCompDataMap.getAsConstAny( bHasPropValues );
-        }
+        // remove the value with the passed name
+        comphelper::SequenceAsHashMap aCompDataMap( rCompDataAny );
+        aCompDataMap.erase( rName );
+        // write back the sequence, or remove it completely if it is empty
+        if( aCompDataMap.empty() )
+            erase( aPropertyIter );
+        else
+            rCompDataAny = aCompDataMap.getAsConstAny( bHasPropValues );
     }
 }
 
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx 
b/unotools/source/ucbhelper/ucblockbytes.cxx
index b410352bfe93..5074989d6083 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -961,18 +961,18 @@ UcbLockBytes::~UcbLockBytes()
         }
     }
 
-    if ( !m_xInputStream.is() && m_xOutputStream.is() )
+    if ( m_xInputStream.is() || !m_xOutputStream.is() )
+        return;
+
+    try
+    {
+        m_xOutputStream->closeOutput();
+    }
+    catch (const RuntimeException&)
+    {
+    }
+    catch (const IOException&)
     {
-        try
-        {
-            m_xOutputStream->closeOutput();
-        }
-        catch (const RuntimeException&)
-        {
-        }
-        catch (const IOException&)
-        {
-        }
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to