loplugin:flatten in comphelper

Change-Id: I1a8db4dbd744b87406d1db5609585495f01f4403
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92478
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-04-18 11:35:04 +02:00
parent ed0097845a
commit 8d4fd34183
16 changed files with 537 additions and 536 deletions

View File

@@ -98,8 +98,9 @@ namespace comphelper
void OContainerListenerAdapter::dispose()
{
if (m_xContainer.is())
{
if (!m_xContainer.is())
return;
try
{
Reference< XContainerListener > xPreventDelete(this);
@@ -113,7 +114,6 @@ namespace comphelper
m_xContainer = nullptr;
m_pListener = nullptr;
}
}
void SAL_CALL OContainerListenerAdapter::disposing( const EventObject& _rSource)

View File

@@ -423,13 +423,15 @@ void EmbeddedObjectContainer::AddEmbeddedObject( const css::uno::Reference < css
xChild->setParent( pImpl->m_xModel.get() );
// look for object in temporary container
if ( pImpl->mpTempObjectContainer )
{
if ( !pImpl->mpTempObjectContainer )
return;
auto& rObjectContainer = pImpl->mpTempObjectContainer->pImpl->maNameToObjectMap;
auto aIter = std::find_if(rObjectContainer.begin(), rObjectContainer.end(),
[&xObj](const EmbeddedObjectContainerNameMap::value_type& rEntry) { return rEntry.second == xObj; });
if (aIter != rObjectContainer.end())
{
if (aIter == rObjectContainer.end())
return;
// copy replacement image from temporary container (if there is any)
OUString aTempName = aIter->first;
OUString aMediaType;
@@ -457,8 +459,6 @@ void EmbeddedObjectContainer::AddEmbeddedObject( const css::uno::Reference < css
// temp. container needs to forget the object
pImpl->mpTempObjectContainer->pImpl->maObjectToNameMap.erase( aIter->second );
pImpl->mpTempObjectContainer->pImpl->maNameToObjectMap.erase( aIter );
}
}
}
bool EmbeddedObjectContainer::StoreEmbeddedObject(
@@ -993,8 +993,9 @@ void EmbeddedObjectContainer::CloseEmbeddedObject( const uno::Reference < embed:
auto aIter = std::find_if(pImpl->maNameToObjectMap.begin(), pImpl->maNameToObjectMap.end(),
[&xObj](const EmbeddedObjectContainerNameMap::value_type& rEntry) { return rEntry.second == xObj; });
if (aIter != pImpl->maNameToObjectMap.end())
{
if (aIter == pImpl->maNameToObjectMap.end())
return;
pImpl->maObjectToNameMap.erase( aIter->second );
pImpl->maNameToObjectMap.erase( aIter );
@@ -1007,7 +1008,6 @@ void EmbeddedObjectContainer::CloseEmbeddedObject( const uno::Reference < embed:
// it is no problem if the object is already closed
// TODO/LATER: what if the object can not be closed?
}
}
}
uno::Reference < io::XInputStream > EmbeddedObjectContainer::GetGraphicStream( const OUString& aName, OUString* pMediaType )

View File

@@ -594,8 +594,9 @@ void SAL_CALL ImplEventAttacherManager::detach(sal_Int32 nIndex, const Reference
std::deque< AttacherIndex_Impl >::iterator aCurrentPosition = aIndex.begin() + nIndex;
auto aObjIt = std::find_if(aCurrentPosition->aObjList.begin(), aCurrentPosition->aObjList.end(),
[&xObject](const AttachedObject_Impl& rObj) { return rObj.xTarget == xObject; });
if (aObjIt != aCurrentPosition->aObjList.end())
{
if (aObjIt == aCurrentPosition->aObjList.end())
return;
sal_Int32 i = 0;
for( const auto& rEvt : aCurrentPosition->aEventList )
{
@@ -613,7 +614,6 @@ void SAL_CALL ImplEventAttacherManager::detach(sal_Int32 nIndex, const Reference
++i;
}
aCurrentPosition->aObjList.erase( aObjIt );
}
}
void SAL_CALL ImplEventAttacherManager::addScriptListener(const Reference< XScriptListener >& aListener)

View File

@@ -69,12 +69,14 @@ bool DirectoryHelper::dirExists(const OUString& rDirURL)
void DirectoryHelper::scanDirsAndFiles(const OUString& rDirURL, std::set<OUString>& rDirs,
std::set<std::pair<OUString, OUString>>& rFiles)
{
if (!rDirURL.isEmpty())
{
if (rDirURL.isEmpty())
return;
osl::Directory aDirectory(rDirURL);
if (osl::FileBase::E_None == aDirectory.open())
{
if (osl::FileBase::E_None != aDirectory.open())
return;
osl::DirectoryItem aDirectoryItem;
while (osl::FileBase::E_None == aDirectory.getNextItem(aDirectoryItem))
@@ -106,8 +108,6 @@ void DirectoryHelper::scanDirsAndFiles(const OUString& rDirURL, std::set<OUStrin
}
}
}
}
}
}
bool DirectoryHelper::deleteDirRecursively(const OUString& rDirURL)

View File

@@ -124,8 +124,9 @@ namespace comphelper
if ( !isAlive() )
return;
if ( _rxListener.is() && m_pImpl->getClientId() )
{
if ( !(_rxListener.is() && m_pImpl->getClientId()) )
return;
sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( m_pImpl->getClientId( ), _rxListener );
if ( !nListenerCount )
{
@@ -137,7 +138,6 @@ namespace comphelper
m_pImpl->setClientId( 0 );
}
}
}
void OAccessibleContextHelper::NotifyAccessibleEvent( const sal_Int16 _nEventId,

View File

@@ -436,8 +436,9 @@ namespace
private:
void visitNodesXMLRead(const uno::Reference< xml::dom::XElement >& rElement)
{
if (rElement.is())
{
if (!rElement.is())
return;
const OUString aTagName(rElement->getTagName());
if (aTagName == "extension")
@@ -480,7 +481,6 @@ namespace
}
}
}
}
public:
void createUserExtensionRegistryEntriesFromXML(const OUString& rUserConfigWorkURL)
@@ -605,25 +605,29 @@ namespace
const ExtensionInfoEntryVector& rToBeEnabled,
const ExtensionInfoEntryVector& rToBeDisabled)
{
if (DirectoryHelper::fileExists(rUnoPackagReg))
{
if (!DirectoryHelper::fileExists(rUnoPackagReg))
return;
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
uno::Reference< xml::dom::XDocumentBuilder > xBuilder = xml::dom::DocumentBuilder::create(xContext);
uno::Reference< xml::dom::XDocument > aDocument = xBuilder->parseURI(rUnoPackagReg);
if (aDocument.is())
{
if (visitNodesXMLChange(
if (!aDocument.is())
return;
if (!visitNodesXMLChange(
rTagToSearch,
aDocument->getDocumentElement(),
rToBeEnabled,
rToBeDisabled))
{
return;
// did change - write back
uno::Reference< xml::sax::XSAXSerializable > xSerializer(aDocument, uno::UNO_QUERY);
if (xSerializer.is())
{
if (!xSerializer.is())
return;
// create a SAXWriter
uno::Reference< xml::sax::XWriter > const xSaxWriter = xml::sax::Writer::create(xContext);
uno::Reference< io::XStream > xTempFile = io::TempFile::create(xContext);
@@ -640,8 +644,9 @@ namespace
aUrl >>= aTempURL;
// copy back file
if (!aTempURL.isEmpty() && DirectoryHelper::fileExists(aTempURL))
{
if (!(!aTempURL.isEmpty() && DirectoryHelper::fileExists(aTempURL)))
return;
if (DirectoryHelper::fileExists(rUnoPackagReg))
{
osl::File::remove(rUnoPackagReg);
@@ -653,11 +658,6 @@ namespace
osl::File::move(aTempURL, rUnoPackagReg);
#endif
}
}
}
}
}
}
public:
static void changeEnableDisableStateInXML(
@@ -1602,8 +1602,9 @@ namespace comphelper
// ensure existence of needed paths
getInitialBaseURL();
if (!maUserConfigBaseURL.isEmpty())
{
if (maUserConfigBaseURL.isEmpty())
return;
if (bSafeMode)
{
if (!mbSafeModeDirExists)
@@ -1643,15 +1644,15 @@ namespace comphelper
}
}
}
}
void BackupFileHelper::tryPush()
{
// no push when SafeModeDir exists, it may be Office's exit after SafeMode
// where SafeMode flag is already deleted, but SafeModeDir cleanup is not
// done yet (is done at next startup)
if (mbActive && !mbSafeModeDirExists)
{
if (!(mbActive && !mbSafeModeDirExists))
return;
const OUString aPackURL(getPackURL());
// ensure dir and file vectors
@@ -1667,7 +1668,6 @@ namespace comphelper
aPackURL);
}
}
}
void BackupFileHelper::tryPushExtensionInfo()
{
@@ -1709,8 +1709,9 @@ namespace comphelper
void BackupFileHelper::tryPop()
{
if (mbActive)
{
if (!mbActive)
return;
bool bDidPop(false);
const OUString aPackURL(getPackURL());
@@ -1733,7 +1734,6 @@ namespace comphelper
osl::Directory::remove(aPackURL);
}
}
}
bool BackupFileHelper::isPopPossibleExtensionInfo() const
{
@@ -1751,8 +1751,9 @@ namespace comphelper
void BackupFileHelper::tryPopExtensionInfo()
{
if (mbActive && mbExtensions)
{
if (!(mbActive && mbExtensions))
return;
bool bDidPop(false);
const OUString aPackURL(getPackURL());
@@ -1764,7 +1765,6 @@ namespace comphelper
osl::Directory::remove(aPackURL);
}
}
}
bool BackupFileHelper::isTryDisableAllExtensionsPossible()
{

View File

@@ -256,8 +256,9 @@ void SAL_CALL OLockListener::disposing( const lang::EventObject& aEvent )
osl::ClearableMutexGuard aGuard( m_aMutex );
// object is disposed
if ( aEvent.Source == m_xInstance )
{
if ( aEvent.Source != m_xInstance )
return;
// the object does not listen for anything any more
m_nMode = 0;
@@ -269,7 +270,6 @@ void SAL_CALL OLockListener::disposing( const lang::EventObject& aEvent )
try { xComponent->dispose(); }
catch( uno::Exception& ){}
}
}
}
@@ -279,8 +279,9 @@ void SAL_CALL OLockListener::queryClosing( const lang::EventObject& aEvent, sal_
{
// GetsOwnership parameter is always ignored, the user of the service must close the object always
osl::ClearableMutexGuard aGuard( m_aMutex );
if ( !m_bDisposed && aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_CLOSE ) )
{
if ( !(!m_bDisposed && aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_CLOSE )) )
return;
try
{
uno::Reference< embed::XActionsApproval > xApprove = m_xApproval;
@@ -300,7 +301,6 @@ void SAL_CALL OLockListener::queryClosing( const lang::EventObject& aEvent, sal_
{
// no action should be done
}
}
}
@@ -309,11 +309,13 @@ void SAL_CALL OLockListener::notifyClosing( const lang::EventObject& aEvent )
osl::ClearableMutexGuard aGuard( m_aMutex );
// object is closed, no reason to listen
if ( aEvent.Source == m_xInstance )
{
if ( aEvent.Source != m_xInstance )
return;
uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( aEvent.Source, uno::UNO_QUERY );
if ( xCloseBroadcaster.is() )
{
if ( !xCloseBroadcaster.is() )
return;
xCloseBroadcaster->removeCloseListener( static_cast< util::XCloseListener* >( this ) );
m_nMode &= ~embed::Actions::PREVENT_CLOSE;
if ( !m_nMode )
@@ -327,8 +329,6 @@ void SAL_CALL OLockListener::notifyClosing( const lang::EventObject& aEvent )
catch( uno::Exception& ){}
}
}
}
}
}
@@ -337,8 +337,9 @@ void SAL_CALL OLockListener::notifyClosing( const lang::EventObject& aEvent )
void SAL_CALL OLockListener::queryTermination( const lang::EventObject& aEvent )
{
osl::ClearableMutexGuard aGuard( m_aMutex );
if ( aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_TERMINATION ) )
{
if ( !(aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_TERMINATION )) )
return;
try
{
uno::Reference< embed::XActionsApproval > xApprove = m_xApproval;
@@ -358,7 +359,6 @@ void SAL_CALL OLockListener::queryTermination( const lang::EventObject& aEvent )
{
// no action should be done
}
}
}
@@ -367,11 +367,13 @@ void SAL_CALL OLockListener::notifyTermination( const lang::EventObject& aEvent
osl::ClearableMutexGuard aGuard( m_aMutex );
// object is terminated, no reason to listen
if ( aEvent.Source == m_xInstance )
{
if ( aEvent.Source != m_xInstance )
return;
uno::Reference< frame::XDesktop > xDesktop( aEvent.Source, uno::UNO_QUERY );
if ( xDesktop.is() )
{
if ( !xDesktop.is() )
return;
try
{
xDesktop->removeTerminateListener( static_cast< frame::XTerminateListener* >( this ) );
@@ -390,8 +392,6 @@ void SAL_CALL OLockListener::notifyTermination( const lang::EventObject& aEvent
}
catch( uno::Exception& )
{}
}
}
}

View File

@@ -208,11 +208,13 @@ OfficeInstallationDirectories::getSupportedServiceNames()
void OfficeInstallationDirectories::initDirs()
{
if ( !m_xOfficeBrandDir)
{
if ( m_xOfficeBrandDir)
return;
osl::MutexGuard aGuard( m_aMutex );
if ( !m_xOfficeBrandDir )
{
if ( m_xOfficeBrandDir )
return;
uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(m_xCtx);
m_xOfficeBrandDir = xExpander->expandMacros( "$BRAND_BASE_DIR" );
@@ -230,8 +232,6 @@ void OfficeInstallationDirectories::initDirs()
"Unable to obtain office user data directory!" );
makeCanonicalFileURL( *m_xUserDir );
}
}
}
}

View File

@@ -118,8 +118,9 @@ void SAL_CALL ChainablePropertySet::setPropertyValues(const Sequence< OUString >
if( nCount != rValues.getLength() )
throw IllegalArgumentException();
if( nCount )
{
if( !nCount )
return;
_preSetValues();
const Any * pAny = rValues.getConstArray();
@@ -136,7 +137,6 @@ void SAL_CALL ChainablePropertySet::setPropertyValues(const Sequence< OUString >
}
_postSetValues();
}
}
Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues(const Sequence< OUString >& rPropertyNames)

View File

@@ -189,8 +189,9 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >&
if( nCount != aValues.getLength() )
throw IllegalArgumentException();
if( nCount )
{
if( !nCount )
return;
_preSetValues();
const Any * pAny = aValues.getConstArray();
@@ -237,7 +238,6 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >&
rSlave.second->SetInit( false );
}
}
}
}
Sequence< Any > SAL_CALL MasterPropertySet::getPropertyValues( const Sequence< OUString >& aPropertyNames )

View File

@@ -99,8 +99,9 @@ GenericPropertySet::GenericPropertySet( PropertySetInfo* pInfo ) throw()
void SAL_CALL GenericPropertySet::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
{
Reference < XPropertySetInfo > xInfo = getPropertySetInfo( );
if ( xInfo.is() )
{
if ( !xInfo.is() )
return;
if ( aPropertyName.isEmpty() )
{
Sequence< Property> aSeq = xInfo->getProperties();
@@ -115,7 +116,6 @@ void SAL_CALL GenericPropertySet::addPropertyChangeListener( const OUString& aPr
m_aListener.addInterface(aPropertyName,xListener);
else
throw UnknownPropertyException( aPropertyName, *this );
}
}
void SAL_CALL GenericPropertySet::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
@@ -123,8 +123,9 @@ void SAL_CALL GenericPropertySet::removePropertyChangeListener( const OUString&
ClearableMutexGuard aGuard( maMutex );
Reference < XPropertySetInfo > xInfo = getPropertySetInfo( );
aGuard.clear();
if ( xInfo.is() )
{
if ( !xInfo.is() )
return;
if ( aPropertyName.isEmpty() )
{
Sequence< Property> aSeq = xInfo->getProperties();
@@ -139,7 +140,6 @@ void SAL_CALL GenericPropertySet::removePropertyChangeListener( const OUString&
m_aListener.removeInterface(aPropertyName,xListener);
else
throw UnknownPropertyException( aPropertyName, *this );
}
}
void GenericPropertySet::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues )

View File

@@ -144,7 +144,9 @@ namespace comphelper
::osl::MutexGuard aGuard( m_aMutex );
m_isModified = bModified;
}
if (bModified) {
if (!bModified)
return;
try {
Reference<XInterface> xThis(*this);
EventObject event(xThis);
@@ -158,7 +160,6 @@ namespace comphelper
// ignore
}
}
}
sal_Bool SAL_CALL OPropertyBag::isModified()

View File

@@ -298,8 +298,9 @@ namespace internal
void PropertyForwarder::doForward( sal_Int32 _nHandle, const Any& _rValue )
{
OSL_ENSURE( m_rAggregationHelper.m_xAggregateSet.is(), "PropertyForwarder::doForward: no property set!" );
if ( m_rAggregationHelper.m_xAggregateSet.is() )
{
if ( !m_rAggregationHelper.m_xAggregateSet.is() )
return;
m_rAggregationHelper.forwardingPropertyValue( _nHandle );
OSL_ENSURE( m_nCurrentlyForwarding == -1, "PropertyForwarder::doForward: reentrance?" );
@@ -320,7 +321,6 @@ namespace internal
m_rAggregationHelper.forwardedPropertyValue( _nHandle );
}
}
}
OPropertySetAggregationHelper::OPropertySetAggregationHelper( ::cppu::OBroadcastHelper& rBHlp )

View File

@@ -129,8 +129,9 @@ void SAL_CALL PropertySetHelper::setPropertyValues( const Sequence< OUString >&
if( nCount != rValues.getLength() )
throw IllegalArgumentException();
if( nCount )
{
if( !nCount )
return;
std::unique_ptr<PropertyMapEntry const *[]> pEntries(new PropertyMapEntry const *[nCount+1]);
pEntries[nCount] = nullptr;
const OUString* pNames = rPropertyNames.getConstArray();
@@ -148,7 +149,6 @@ void SAL_CALL PropertySetHelper::setPropertyValues( const Sequence< OUString >&
if( bUnknown )
throw RuntimeException( *pNames, static_cast< XPropertySet* >( this ) );
}
}
Sequence< Any > SAL_CALL PropertySetHelper::getPropertyValues(const Sequence< OUString >& rPropertyNames)

View File

@@ -89,8 +89,9 @@ void OPropertyChangeMultiplexer::unlock()
void OPropertyChangeMultiplexer::dispose()
{
if (m_bListening)
{
if (!m_bListening)
return;
Reference< XPropertyChangeListener> xPreventDelete(this);
for (const OUString& rProp : m_aProperties)
@@ -103,7 +104,6 @@ void OPropertyChangeMultiplexer::dispose()
if (m_bAutoSetRelease)
m_xSet = nullptr;
}
}
// XEventListener

View File

@@ -191,8 +191,9 @@ sal_Int64 SAL_CALL UNOMemoryStream::getLength()
void SAL_CALL UNOMemoryStream::writeBytes( const Sequence< sal_Int8 >& aData )
{
const sal_Int32 nBytesToWrite( aData.getLength() );
if( nBytesToWrite )
{
if( !nBytesToWrite )
return;
sal_Int64 nNewSize = static_cast<sal_Int64>(mnCursor) + nBytesToWrite;
if( nNewSize > SAL_MAX_INT32 )
{
@@ -208,7 +209,6 @@ void SAL_CALL UNOMemoryStream::writeBytes( const Sequence< sal_Int8 >& aData )
memcpy( pCursor, aData.getConstArray(), nBytesToWrite );
mnCursor += nBytesToWrite;
}
}
void SAL_CALL UNOMemoryStream::flush()